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"?>
<!-- Copyright 2015 The Chromium Authors. All rights reserved.
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"
android:layout_width="wrap_content"
android:layout_width="match_parent"
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_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="22dp">
<RadioButton
android:id="@+id/radiobutton"
android:layout_width="27sp"
android:layout_height="23sp"
android:layout_marginStart="21dp"
android:layout_marginEnd="21dp" />
android:layout_marginStart="21dp"
android:layout_marginEnd="16dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:textSize="17sp" />
<TextView
android:id="@+id/link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="21dp" />
</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>
\ No newline at end of file
......@@ -89,7 +89,7 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
}
void setValueForTesting(String value) {
radioButtonClicked(Integer.parseInt(value));
searchEngineSelected(Integer.parseInt(value));
}
/**
......@@ -164,22 +164,19 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
view = mLayoutInflater.inflate(R.layout.search_engine, null);
}
RadioButton radioButton = (RadioButton) view.findViewById(R.id.radiobutton);
TextView description = (TextView) view.findViewById(R.id.description);
TextView link = (TextView) view.findViewById(R.id.link);
TemplateUrl templateUrl = mSearchEngines.get(position);
Resources resources = mContext.getResources();
view.setOnClickListener(this);
view.setTag(position);
RadioButton radioButton = (RadioButton) view.findViewById(R.id.radiobutton);
boolean selected = position == mSelectedSearchEnginePosition;
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.setOnClickListener(this);
description.setTag(position);
TextView link = (TextView) view.findViewById(R.id.link);
link.setVisibility(selected ? View.VISIBLE : View.GONE);
if (selected) {
ForegroundColorSpan linkSpan = new ForegroundColorSpan(
......@@ -219,19 +216,17 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
if (view.getTag() == null) {
onLocationLinkClicked();
} 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
// search engine.
SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(mContext);
if (sharedPreferences.getBoolean(PrefServiceBridge.LOCATION_AUTO_ALLOWED, false)) {
if (locationEnabled(mSelectedSearchEnginePosition)) {
TemplateUrl templateUrl = mSearchEngines.get(mSelectedSearchEnginePosition);
String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl(
toIndex(mSelectedSearchEnginePosition));
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