Commit 83d6dbf4 authored by newt's avatar newt Committed by Commit bot

Fix padding and touch effects in search engine dialog.

On pre-L devices, each item in the list of search engines had too much
top padding and no bottom padding. Also, on all devices, clicking a
search engine didn't show a ripple or highlight. Both of these bugs have
been fixed.

BUG=482193

Review URL: https://codereview.chromium.org/1109263004

Cr-Commit-Position: refs/heads/master@{#327522}
parent db5a56c7
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2015 The Chromium Authors. All rights reserved. <!-- Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. found in the LICENSE file. -->
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp">
<LinearLayout <RadioButton
android:id="@+id/radiobutton"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:layout_marginStart="21dp"
android:layout_marginTop="22dp"> android:layout_marginEnd="16dp" />
<RadioButton
android:id="@+id/radiobutton" <LinearLayout
android:layout_width="27sp" android:layout_width="0dp"
android:layout_height="23sp" android:layout_height="wrap_content"
android:layout_marginStart="21dp" android:layout_weight="1"
android:layout_marginEnd="21dp" /> android:orientation="vertical">
<TextView <TextView
android:id="@+id/description" android:id="@+id/description"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:textSize="17sp" /> android:textSize="17sp" />
<TextView
android:id="@+id/link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="21dp" />
</LinearLayout> </LinearLayout>
<TextView
android:id="@+id/link"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="70dp"
android:layout_marginEnd="21dp" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -89,7 +89,7 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On ...@@ -89,7 +89,7 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
} }
void setValueForTesting(String value) { void setValueForTesting(String value) {
radioButtonClicked(Integer.parseInt(value)); searchEngineSelected(Integer.parseInt(value));
} }
/** /**
...@@ -164,22 +164,19 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On ...@@ -164,22 +164,19 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
view = mLayoutInflater.inflate(R.layout.search_engine, null); view = mLayoutInflater.inflate(R.layout.search_engine, null);
} }
RadioButton radioButton = (RadioButton) view.findViewById(R.id.radiobutton); view.setOnClickListener(this);
TextView description = (TextView) view.findViewById(R.id.description); view.setTag(position);
TextView link = (TextView) view.findViewById(R.id.link);
TemplateUrl templateUrl = mSearchEngines.get(position);
Resources resources = mContext.getResources();
RadioButton radioButton = (RadioButton) view.findViewById(R.id.radiobutton);
boolean selected = position == mSelectedSearchEnginePosition; boolean selected = position == mSelectedSearchEnginePosition;
radioButton.setChecked(selected); radioButton.setChecked(selected);
radioButton.setOnClickListener(this);
radioButton.setTag(position);
TextView description = (TextView) view.findViewById(R.id.description);
TemplateUrl templateUrl = mSearchEngines.get(position);
Resources resources = mContext.getResources();
description.setText(getSearchEngineNameAndDomain(resources, templateUrl)); description.setText(getSearchEngineNameAndDomain(resources, templateUrl));
description.setOnClickListener(this);
description.setTag(position);
TextView link = (TextView) view.findViewById(R.id.link);
link.setVisibility(selected ? View.VISIBLE : View.GONE); link.setVisibility(selected ? View.VISIBLE : View.GONE);
if (selected) { if (selected) {
ForegroundColorSpan linkSpan = new ForegroundColorSpan( ForegroundColorSpan linkSpan = new ForegroundColorSpan(
...@@ -219,19 +216,17 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On ...@@ -219,19 +216,17 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
if (view.getTag() == null) { if (view.getTag() == null) {
onLocationLinkClicked(); onLocationLinkClicked();
} else { } else {
radioButtonClicked((int) view.getTag()); searchEngineSelected((int) view.getTag());
} }
} }
private void radioButtonClicked(int position) { private void searchEngineSelected(int position) {
// First clean up any automatically added permissions (if any) for the previously selected // First clean up any automatically added permissions (if any) for the previously selected
// search engine. // search engine.
SharedPreferences sharedPreferences = SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(mContext); PreferenceManager.getDefaultSharedPreferences(mContext);
if (sharedPreferences.getBoolean(PrefServiceBridge.LOCATION_AUTO_ALLOWED, false)) { if (sharedPreferences.getBoolean(PrefServiceBridge.LOCATION_AUTO_ALLOWED, false)) {
if (locationEnabled(mSelectedSearchEnginePosition)) { if (locationEnabled(mSelectedSearchEnginePosition)) {
TemplateUrl templateUrl = mSearchEngines.get(mSelectedSearchEnginePosition);
String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl( String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl(
toIndex(mSelectedSearchEnginePosition)); toIndex(mSelectedSearchEnginePosition));
WebsitePreferenceBridge.nativeSetGeolocationSettingForOrigin( WebsitePreferenceBridge.nativeSetGeolocationSettingForOrigin(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment