Commit fafd3e1f authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

Move KeyboardAccessory to chrome directory for reuse in Manual UI

By moving the keyboard accessory to chrome/browser, the following work
for the new manual UI will be simplified by a large margin:
 - The entry point for the fallback sheet can be added directly
 - Buttons as needed for password generation can be added
 - styles can be unified by using default resources

This CL mainly moves the files and modifies BUILD files accordingly.
Only colors have changed to similar-looking colors that are already
defined in Chromium (which is unproblematic this component is not
user-facing yet and its final visuals are far from done).

Bug: 828832
Change-Id: I6e9b9c9902468c010f72b717fd24de0bd81953af
Reviewed-on: https://chromium-review.googlesource.com/995415Reviewed-by: default avatarTheresa <twellington@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Friedrich Horschig <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548747}
parent d4851402
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
android:insetRight="@dimen/keyboard_accessory_half_padding" android:insetRight="@dimen/keyboard_accessory_half_padding"
android:insetTop="@dimen/keyboard_accessory_padding"> android:insetTop="@dimen/keyboard_accessory_padding">
<shape> <shape>
<solid android:color="#ECEFF1" /> <solid android:color="@color/google_grey_200" />
<corners android:radius="2dp" /> <corners android:radius="2dp" />
</shape> </shape>
</inset> </inset>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
android:paddingEnd="@dimen/keyboard_accessory_half_padding" android:paddingEnd="@dimen/keyboard_accessory_half_padding"
android:paddingStart="@dimen/keyboard_accessory_half_padding" android:paddingStart="@dimen/keyboard_accessory_half_padding"
android:singleLine="true" android:singleLine="true"
android:textColor="#333" android:textColor="@color/google_grey_800"
android:textSize="@dimen/keyboard_accessory_text_size" /> android:textSize="@dimen/keyboard_accessory_text_size" />
<TextView <TextView
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingEnd="@dimen/keyboard_accessory_half_padding" android:paddingEnd="@dimen/keyboard_accessory_half_padding"
android:singleLine="true" android:singleLine="true"
android:textColor="#646464" android:textColor="@color/google_grey_600"
android:textSize="@dimen/keyboard_accessory_text_size" android:textSize="@dimen/keyboard_accessory_text_size"
android:visibility="gone" /> android:visibility="gone" />
......
...@@ -122,6 +122,14 @@ ...@@ -122,6 +122,14 @@
<!-- Overlay panel dimensions --> <!-- Overlay panel dimensions -->
<dimen name="overlay_panel_bar_height">56dp</dimen> <dimen name="overlay_panel_bar_height">56dp</dimen>
<!-- Autofill keyboard accessory dimensions -->
<dimen name="keyboard_accessory_chip_height">32dp</dimen>
<dimen name="keyboard_accessory_half_padding">4dp</dimen>
<dimen name="keyboard_accessory_height">48dp</dimen>
<dimen name="keyboard_accessory_padding">8dp</dimen>
<dimen name="keyboard_accessory_text_size">14sp</dimen>
<dimen name="keyboard_accessory_start_animation_translation">100dp</dimen>
<!-- Password generation popup dimensions --> <!-- Password generation popup dimensions -->
<dimen name="password_generation_divider_height">1dp</dimen> <dimen name="password_generation_divider_height">1dp</dimen>
<dimen name="password_generation_text_size">14sp</dimen> <dimen name="password_generation_text_size">14sp</dimen>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// 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.
package org.chromium.components.autofill; package org.chromium.chrome.browser.autofill;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
...@@ -25,6 +25,9 @@ import android.widget.LinearLayout; ...@@ -25,6 +25,9 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
import org.chromium.components.autofill.AutofillDelegate;
import org.chromium.components.autofill.AutofillSuggestion;
import org.chromium.ui.UiUtils; import org.chromium.ui.UiUtils;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
...@@ -34,9 +37,9 @@ import java.util.ArrayList; ...@@ -34,9 +37,9 @@ import java.util.ArrayList;
* The Autofill suggestion view that lists relevant suggestions. It sits above the keyboard and * The Autofill suggestion view that lists relevant suggestions. It sits above the keyboard and
* below the content area. * below the content area.
*/ */
public class AutofillKeyboardAccessory extends LinearLayout public class AutofillKeyboardAccessory
implements WindowAndroid.KeyboardVisibilityListener, View.OnClickListener, extends LinearLayout implements WindowAndroid.KeyboardVisibilityListener,
View.OnLongClickListener { View.OnClickListener, View.OnLongClickListener {
// Time to pause before reversing animation when the first suggestion is a hint. // Time to pause before reversing animation when the first suggestion is a hint.
private static final long PAUSE_ANIMATION_BEFORE_REVERSE_MILLIS = 1000; private static final long PAUSE_ANIMATION_BEFORE_REVERSE_MILLIS = 1000;
// Time to fade in views that we temporarily hide when we change container layout. // Time to fade in views that we temporarily hide when we change container layout.
...@@ -79,8 +82,8 @@ public class AutofillKeyboardAccessory extends LinearLayout ...@@ -79,8 +82,8 @@ public class AutofillKeyboardAccessory extends LinearLayout
mMaximumSublabelWidthPx = deviceWidthPx / 4; mMaximumSublabelWidthPx = deviceWidthPx / 4;
mWindowAndroid.addKeyboardVisibilityListener(this); mWindowAndroid.addKeyboardVisibilityListener(this);
int horizontalPaddingPx = getResources().getDimensionPixelSize( int horizontalPaddingPx =
R.dimen.keyboard_accessory_half_padding); getResources().getDimensionPixelSize(R.dimen.keyboard_accessory_half_padding);
setPadding(horizontalPaddingPx, 0, horizontalPaddingPx, 0); setPadding(horizontalPaddingPx, 0, horizontalPaddingPx, 0);
mAnimationDurationMillis = animationDurationMillis; mAnimationDurationMillis = animationDurationMillis;
...@@ -116,8 +119,9 @@ public class AutofillKeyboardAccessory extends LinearLayout ...@@ -116,8 +119,9 @@ public class AutofillKeyboardAccessory extends LinearLayout
View touchTarget; View touchTarget;
if (!suggestion.isFillable() && suggestion.getIconId() != 0) { if (!suggestion.isFillable() && suggestion.getIconId() != 0) {
touchTarget = LayoutInflater.from(getContext()).inflate( touchTarget =
R.layout.autofill_keyboard_accessory_icon, this, false); LayoutInflater.from(getContext())
.inflate(R.layout.autofill_keyboard_accessory_icon, this, false);
if (mSeparatorPosition == -1 && !isKeyboardAccessoryHint) mSeparatorPosition = i; if (mSeparatorPosition == -1 && !isKeyboardAccessoryHint) mSeparatorPosition = i;
...@@ -125,16 +129,17 @@ public class AutofillKeyboardAccessory extends LinearLayout ...@@ -125,16 +129,17 @@ public class AutofillKeyboardAccessory extends LinearLayout
Drawable drawable = Drawable drawable =
AppCompatResources.getDrawable(getContext(), suggestion.getIconId()); AppCompatResources.getDrawable(getContext(), suggestion.getIconId());
if (isKeyboardAccessoryHint) { if (isKeyboardAccessoryHint) {
drawable.setColorFilter(ApiCompatibilityUtils.getColor(getResources(), drawable.setColorFilter(
R.color.keyboard_accessory_hint_icon), ApiCompatibilityUtils.getColor(getResources(), R.color.google_blue_500),
PorterDuff.Mode.SRC_IN); PorterDuff.Mode.SRC_IN);
} else { } else {
icon.setContentDescription(suggestion.getLabel()); icon.setContentDescription(suggestion.getLabel());
} }
icon.setImageDrawable(drawable); icon.setImageDrawable(drawable);
} else { } else {
touchTarget = LayoutInflater.from(getContext()).inflate( touchTarget =
R.layout.autofill_keyboard_accessory_item, this, false); LayoutInflater.from(getContext())
.inflate(R.layout.autofill_keyboard_accessory_item, this, false);
TextView label = (TextView) touchTarget.findViewById( TextView label = (TextView) touchTarget.findViewById(
R.id.autofill_keyboard_accessory_item_label); R.id.autofill_keyboard_accessory_item_label);
...@@ -149,8 +154,7 @@ public class AutofillKeyboardAccessory extends LinearLayout ...@@ -149,8 +154,7 @@ public class AutofillKeyboardAccessory extends LinearLayout
} }
if (suggestion.getIconId() != 0) { if (suggestion.getIconId() != 0) {
ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds( ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(label,
label,
AppCompatResources.getDrawable(getContext(), suggestion.getIconId()), AppCompatResources.getDrawable(getContext(), suggestion.getIconId()),
null /* top */, null /* end */, null /* bottom */); null /* top */, null /* end */, null /* bottom */);
} }
......
...@@ -13,7 +13,6 @@ import org.chromium.base.annotations.JNINamespace; ...@@ -13,7 +13,6 @@ import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ResourceId; import org.chromium.chrome.browser.ResourceId;
import org.chromium.components.autofill.AutofillDelegate; import org.chromium.components.autofill.AutofillDelegate;
import org.chromium.components.autofill.AutofillKeyboardAccessory;
import org.chromium.components.autofill.AutofillSuggestion; import org.chromium.components.autofill.AutofillSuggestion;
import org.chromium.ui.DropdownItem; import org.chromium.ui.DropdownItem;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
......
...@@ -85,6 +85,7 @@ chrome_java_sources = [ ...@@ -85,6 +85,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/appmenu/AppMenuObserver.java", "java/src/org/chromium/chrome/browser/appmenu/AppMenuObserver.java",
"java/src/org/chromium/chrome/browser/appmenu/AppMenuPropertiesDelegate.java", "java/src/org/chromium/chrome/browser/appmenu/AppMenuPropertiesDelegate.java",
"java/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryBridge.java", "java/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryBridge.java",
"java/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessory.java",
"java/src/org/chromium/chrome/browser/autofill/AutofillLogger.java", "java/src/org/chromium/chrome/browser/autofill/AutofillLogger.java",
"java/src/org/chromium/chrome/browser/autofill/AutofillPopupBridge.java", "java/src/org/chromium/chrome/browser/autofill/AutofillPopupBridge.java",
"java/src/org/chromium/chrome/browser/autofill/CardUnmaskBridge.java", "java/src/org/chromium/chrome/browser/autofill/CardUnmaskBridge.java",
......
...@@ -72,7 +72,6 @@ android_library("autofill_java") { ...@@ -72,7 +72,6 @@ android_library("autofill_java") {
] ]
java_files = [ java_files = [
"java/src/org/chromium/components/autofill/AutofillDelegate.java", "java/src/org/chromium/components/autofill/AutofillDelegate.java",
"java/src/org/chromium/components/autofill/AutofillKeyboardAccessory.java",
"java/src/org/chromium/components/autofill/AutofillPopup.java", "java/src/org/chromium/components/autofill/AutofillPopup.java",
"java/src/org/chromium/components/autofill/AutofillSuggestion.java", "java/src/org/chromium/components/autofill/AutofillSuggestion.java",
] ]
......
...@@ -8,6 +8,4 @@ ...@@ -8,6 +8,4 @@
<!-- Text colors of warning messages for credit card and password forms. --> <!-- Text colors of warning messages for credit card and password forms. -->
<color name="http_bad_warning_message_text">#C53929</color> <color name="http_bad_warning_message_text">#C53929</color>
<color name="insecure_context_payment_disabled_message_text">#646464</color> <color name="insecure_context_payment_disabled_message_text">#646464</color>
<color name="keyboard_accessory_hint_icon">#4285F4</color>
</resources> </resources>
...@@ -5,18 +5,6 @@ ...@@ -5,18 +5,6 @@
found in the LICENSE file. found in the LICENSE file.
--> -->
<resources> <resources>
<!--
Fallback values if the corresponding com.android.internal.R dimensions
cannot be retrieved by name.
Note: Constants taken directly from Android's core/res/values/config.xml.
-->
<dimen name="keyboard_accessory_chip_height">32dp</dimen>
<dimen name="keyboard_accessory_half_padding">4dp</dimen>
<dimen name="keyboard_accessory_height">48dp</dimen>
<dimen name="keyboard_accessory_padding">8dp</dimen>
<dimen name="keyboard_accessory_text_size">14sp</dimen>
<dimen name="keyboard_accessory_start_animation_translation">100dp</dimen>
<!-- <!--
Larger label and icon sizes for Form-Not-Secure experiment Larger label and icon sizes for Form-Not-Secure experiment
(warning messages on credit card and password forms when users (warning messages on credit card and password forms when users
......
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