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 | |
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}
18 files changed, 77 insertions, 22 deletions
diff --git a/chrome/android/java/res/drawable-hdpi/ic_photo_camera.png b/chrome/android/java/res/drawable-hdpi/ic_photo_camera.png Binary files differnew file mode 100644 index 0000000..e9ed26d --- /dev/null +++ b/chrome/android/java/res/drawable-hdpi/ic_photo_camera.png diff --git a/chrome/android/java/res/drawable-hdpi/ic_settings.png b/chrome/android/java/res/drawable-hdpi/ic_settings.png Binary files differnew file mode 100644 index 0000000..acf1ddf --- /dev/null +++ b/chrome/android/java/res/drawable-hdpi/ic_settings.png diff --git a/chrome/android/java/res/drawable-mdpi/ic_photo_camera.png b/chrome/android/java/res/drawable-mdpi/ic_photo_camera.png Binary files differnew file mode 100644 index 0000000..2ce3c5b --- /dev/null +++ b/chrome/android/java/res/drawable-mdpi/ic_photo_camera.png diff --git a/chrome/android/java/res/drawable-mdpi/ic_settings.png b/chrome/android/java/res/drawable-mdpi/ic_settings.png Binary files differnew file mode 100644 index 0000000..c59419c --- /dev/null +++ b/chrome/android/java/res/drawable-mdpi/ic_settings.png diff --git a/chrome/android/java/res/drawable-xhdpi/ic_photo_camera.png b/chrome/android/java/res/drawable-xhdpi/ic_photo_camera.png Binary files differnew file mode 100644 index 0000000..d83d658 --- /dev/null +++ b/chrome/android/java/res/drawable-xhdpi/ic_photo_camera.png diff --git a/chrome/android/java/res/drawable-xhdpi/ic_settings.png b/chrome/android/java/res/drawable-xhdpi/ic_settings.png Binary files differnew file mode 100644 index 0000000..e84e188 --- /dev/null +++ b/chrome/android/java/res/drawable-xhdpi/ic_settings.png diff --git a/chrome/android/java/res/drawable-xxhdpi/ic_photo_camera.png b/chrome/android/java/res/drawable-xxhdpi/ic_photo_camera.png Binary files differnew file mode 100644 index 0000000..6125fa2 --- /dev/null +++ b/chrome/android/java/res/drawable-xxhdpi/ic_photo_camera.png diff --git a/chrome/android/java/res/drawable-xxhdpi/ic_settings.png b/chrome/android/java/res/drawable-xxhdpi/ic_settings.png Binary files differnew file mode 100644 index 0000000..3023ff8 --- /dev/null +++ b/chrome/android/java/res/drawable-xxhdpi/ic_settings.png diff --git a/chrome/android/java/res/drawable-xxxhdpi/ic_photo_camera.png b/chrome/android/java/res/drawable-xxxhdpi/ic_photo_camera.png Binary files differnew file mode 100644 index 0000000..6df33ed --- /dev/null +++ b/chrome/android/java/res/drawable-xxxhdpi/ic_photo_camera.png diff --git a/chrome/android/java/res/drawable-xxxhdpi/ic_settings.png b/chrome/android/java/res/drawable-xxxhdpi/ic_settings.png Binary files differnew file mode 100644 index 0000000..476d5c9 --- /dev/null +++ b/chrome/android/java/res/drawable-xxxhdpi/ic_settings.png diff --git a/chrome/browser/android/resource_id.h b/chrome/browser/android/resource_id.h index 9658a69..b46ad95 100644 --- a/chrome/browser/android/resource_id.h +++ b/chrome/browser/android/resource_id.h @@ -54,14 +54,18 @@ DEFINE_RESOURCE_ID(IDR_PAGEINFO_INFO, R.drawable.pageinfo_warning) DEFINE_RESOURCE_ID(IDR_PAGEINFO_WARNING_MAJOR,\ R.drawable.pageinfo_warning) -// Autofill popup images. +// Autofill popup and keyboard accessory images. DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_AMEX, R.drawable.amex_card) DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_DISCOVER, R.drawable.discover_card) DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_GENERIC, R.drawable.generic_card) DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_MASTERCARD, R.drawable.mc_card) DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_VISA, R.drawable.visa_card) DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_SCAN_NEW, android.R.drawable.ic_menu_camera) +DEFINE_RESOURCE_ID(IDR_AUTOFILL_CC_SCAN_NEW_KEYBOARD_ACCESSORY, + org.chromium.chrome.R.drawable.ic_photo_camera) DEFINE_RESOURCE_ID(IDR_CREDIT_CARD_CVC_HINT, R.drawable.cvc_icon) DEFINE_RESOURCE_ID(IDR_CREDIT_CARD_CVC_HINT_AMEX, R.drawable.cvc_icon_amex) +DEFINE_RESOURCE_ID(IDR_AUTOFILL_SETTINGS, + org.chromium.chrome.R.drawable.ic_settings) #endif // CHROME_BROWSER_ANDROID_RESOURCE_ID_H_ diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc index d9d2907..e9679da 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.cc @@ -7,6 +7,7 @@ #include <algorithm> #include <utility> +#include "base/command_line.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/autofill/autofill_popup_view.h" @@ -14,6 +15,7 @@ #include "components/autofill/core/browser/autofill_popup_delegate.h" #include "components/autofill/core/browser/popup_item_ids.h" #include "components/autofill/core/browser/suggestion.h" +#include "components/autofill/core/common/autofill_switches.h" #include "content/public/browser/native_web_keyboard_event.h" #include "grit/components_scaled_resources.h" #include "ui/base/resource/resource_bundle.h" @@ -60,10 +62,12 @@ const DataResource kDataResources[] = { { "jcbCC", IDR_AUTOFILL_CC_GENERIC }, { "masterCardCC", IDR_AUTOFILL_CC_MASTERCARD }, { "visaCC", IDR_AUTOFILL_CC_VISA }, +#if defined(OS_ANDROID) { "scanCreditCardIcon", IDR_AUTOFILL_CC_SCAN_NEW }, -#if defined(OS_MACOSX) && !defined(OS_IOS) + { "settings", IDR_AUTOFILL_SETTINGS }, +#elif defined(OS_MACOSX) && !defined(OS_IOS) { "macContactsIcon", IDR_AUTOFILL_MAC_CONTACTS_ICON }, -#endif // defined(OS_MACOSX) && !defined(OS_IOS) +#endif }; } // namespace @@ -349,12 +353,23 @@ void AutofillPopupControllerImpl::AcceptSuggestion(size_t index) { int AutofillPopupControllerImpl::GetIconResourceID( const base::string16& resource_name) const { + int result = -1; for (size_t i = 0; i < arraysize(kDataResources); ++i) { - if (resource_name == base::ASCIIToUTF16(kDataResources[i].name)) - return kDataResources[i].id; + if (resource_name == base::ASCIIToUTF16(kDataResources[i].name)) { + result = kDataResources[i].id; + break; + } + } + +#if defined(OS_ANDROID) + if (result == IDR_AUTOFILL_CC_SCAN_NEW && + base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableAccessorySuggestionView)) { + result = IDR_AUTOFILL_CC_SCAN_NEW_KEYBOARD_ACCESSORY; } +#endif // OS_ANDROID - return -1; + return result; } bool AutofillPopupControllerImpl::IsWarning(size_t index) const { diff --git a/components/OWNERS b/components/OWNERS index 65dd810..8ad2031 100644 --- a/components/OWNERS +++ b/components/OWNERS @@ -12,7 +12,6 @@ per-file audio_modem.gypi=xiyuan@chromium.org # Can not match autofill* due to crbug.com/397984 per-file autofill.gypi=estade@chromium.org per-file autofill.gypi=isherman@chromium.org -per-file autofill_scaled_resources.grdp=estade@chromium.org per-file autofill_strings.grdp=estade@chromium.org per-file autofill_strings.grdp=isherman@chromium.org diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc index 7a220f3..8e9d059 100644 --- a/components/autofill/core/browser/autofill_external_delegate.cc +++ b/components/autofill/core/browser/autofill_external_delegate.cc @@ -377,6 +377,10 @@ void AutofillExternalDelegate::ApplyAutofillOptions( suggestions->push_back(Suggestion( l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS_POPUP))); suggestions->back().frontend_id = POPUP_ITEM_ID_AUTOFILL_OPTIONS; + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableAccessorySuggestionView)) { + suggestions->back().icon = base::ASCIIToUTF16("settings"); + } } void AutofillExternalDelegate::InsertDataListValues( diff --git a/components/resources/OWNERS b/components/resources/OWNERS index 38ecb2c..a26b1a0 100644 --- a/components/resources/OWNERS +++ b/components/resources/OWNERS @@ -1,3 +1,4 @@ +per-file autofill_scaled_resources.grdp=estade@chromium.org per-file data_reduction_proxy*=bengr@chromium.org per-file data_reduction_proxy*=sclittle@chromium.org per-file dom_distiller*=cjhopman@chromium.org diff --git a/components/resources/autofill_scaled_resources.grdp b/components/resources/autofill_scaled_resources.grdp index b419e82..d40d1d0 100644 --- a/components/resources/autofill_scaled_resources.grdp +++ b/components/resources/autofill_scaled_resources.grdp @@ -5,8 +5,16 @@ <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_GENERIC" file="autofill/cc-generic.png" /> <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_MASTERCARD" file="autofill/mastercard.png" /> <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_VISA" file="autofill/visa.png" /> - <!-- This is not used on desktop, only Android, so use a placeholder file. --> - <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_SCAN_NEW" file="autofill/cc-generic.png" /> + + <if expr="is_android"> + <!-- These are not used on desktop, only Android, so use a placeholder file. + TODO(rouslan): Remove non-keyboard-accessory icon when keyboard + accessory becomes default on Android. --> + <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_SCAN_NEW" file="autofill/cc-generic.png" /> + <structure type="chrome_scaled_image" name="IDR_AUTOFILL_CC_SCAN_NEW_KEYBOARD_ACCESSORY" file="autofill/cc-generic.png" /> + <structure type="chrome_scaled_image" name="IDR_AUTOFILL_SETTINGS" file="autofill/cc-generic.png" /> + </if> + <structure type="chrome_scaled_image" name="IDR_AUTOFILL_MAC_CONTACTS_ICON" file="autofill/mac_contacts_icon.png" /> <structure type="chrome_scaled_image" name="IDR_CREDIT_CARD_CVC_HINT" file="autofill/credit_card_cvc_hint.png" /> <structure type="chrome_scaled_image" name="IDR_CREDIT_CARD_CVC_HINT_AMEX" file="autofill/credit_card_cvc_hint_amex.png" /> 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); } |