diff options
author | rouslan <rouslan@chromium.org> | 2015-08-17 11:47:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-17 18:48:41 +0000 |
commit | 70bff3c5ec16fa2d6d396cc2e652331b9c9cf127 (patch) | |
tree | 7adef8ff591ba2ed762d77da8a29199e4a78c942 /ui | |
parent | da2dc7a92b0b7ec999633bb746d87714d5901931 (diff) | |
download | chromium_src-70bff3c5ec16fa2d6d396cc2e652331b9c9cf127.zip chromium_src-70bff3c5ec16fa2d6d396cc2e652331b9c9cf127.tar.gz chromium_src-70bff3c5ec16fa2d6d396cc2e652331b9c9cf127.tar.bz2 |
Keyboard accessory icons for card scan and settings.
BUG=428087
Review URL: https://codereview.chromium.org/1291703006
Cr-Commit-Position: refs/heads/master@{#343725}
Diffstat (limited to 'ui')
-rw-r--r-- | ui/android/java/res/layout/autofill_keyboard_accessory_icon.xml | 13 | ||||
-rw-r--r-- | ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java | 37 |
2 files changed, 37 insertions, 13 deletions
diff --git a/ui/android/java/res/layout/autofill_keyboard_accessory_icon.xml b/ui/android/java/res/layout/autofill_keyboard_accessory_icon.xml new file mode 100644 index 0000000..d06e90d --- /dev/null +++ b/ui/android/java/res/layout/autofill_keyboard_accessory_icon.xml @@ -0,0 +1,13 @@ +<?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. --> + +<ImageView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:layout_height="@dimen/keyboard_accessory_height" + android:layout_width="40dp" + android:background="@drawable/autofill_chip_inset" + android:padding="12dp" + tools:ignore="contentDescription" /> + diff --git a/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java b/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java index 1968592..153691f 100644 --- a/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java +++ b/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java @@ -12,6 +12,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -82,24 +83,33 @@ public class AutofillKeyboardAccessory extends LinearLayout public void showWithSuggestions(AutofillSuggestion[] suggestions, boolean isRtl) { removeAllViews(); for (AutofillSuggestion suggestion : suggestions) { - View touchTarget = LayoutInflater.from(getContext()).inflate( - R.layout.autofill_keyboard_accessory_item, this, false); - touchTarget.setOnClickListener(this); - TextView label = (TextView) touchTarget.findViewById( - R.id.autofill_keyboard_accessory_item_label); - label.setMaxWidth(mMaximumLabelWidthPx); - - if (suggestion.getIconId() != 0) { - ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( - label, suggestion.getIconId(), 0, 0, 0); - } - - if (!TextUtils.isEmpty(suggestion.getLabel())) { + assert !TextUtils.isEmpty(suggestion.getLabel()); + + View touchTarget; + if (suggestion.getSuggestionId() < 0 && suggestion.getIconId() != 0) { + touchTarget = LayoutInflater.from(getContext()).inflate( + R.layout.autofill_keyboard_accessory_icon, this, false); + + ImageView icon = (ImageView) touchTarget; + icon.setImageResource(suggestion.getIconId()); + icon.setContentDescription(suggestion.getLabel()); + } else { + touchTarget = LayoutInflater.from(getContext()).inflate( + R.layout.autofill_keyboard_accessory_item, this, false); + + TextView label = (TextView) touchTarget.findViewById( + R.id.autofill_keyboard_accessory_item_label); + label.setMaxWidth(mMaximumLabelWidthPx); label.setText(suggestion.getLabel()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { label.setTypeface(Typeface.DEFAULT_BOLD); } + if (suggestion.getIconId() != 0) { + ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( + label, suggestion.getIconId(), 0, 0, 0); + } + if (!TextUtils.isEmpty(suggestion.getSublabel())) { TextView sublabel = (TextView) touchTarget.findViewById( R.id.autofill_keyboard_accessory_item_sublabel); @@ -109,6 +119,7 @@ public class AutofillKeyboardAccessory extends LinearLayout } } + touchTarget.setOnClickListener(this); addView(touchTarget); } |