diff options
| author | 2017-05-02 01:41:58 +0000 | |
|---|---|---|
| committer | 2017-05-02 01:41:58 +0000 | |
| commit | f9ec22d29a3d487868d18383af4aa91c4379a27c (patch) | |
| tree | 6e6a67ead4109a2b5be0f86d3aac65ddf2356510 | |
| parent | bdd5e56e778020a6a39c57c0c688389f1259e7aa (diff) | |
| parent | c0851e72a5864fde0af699b85d19419ed7bc5e67 (diff) | |
Merge "Make auth fill UI size sane size" into oc-dev
am: c0851e72a5
Change-Id: Ie7ce1a2a92e2fa3e653df3f95be8ff6a8f4d2a47
| -rw-r--r-- | core/res/res/values/attrs.xml | 6 | ||||
| -rw-r--r-- | core/res/res/values/dimens.xml | 4 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 5 | ||||
| -rw-r--r-- | core/res/res/values/themes.xml | 4 | ||||
| -rw-r--r-- | services/autofill/java/com/android/server/autofill/ui/FillUi.java | 46 |
5 files changed, 56 insertions, 9 deletions
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index c4215141448d..cfe25b33a4c3 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -63,6 +63,12 @@ <!-- Drawable to be drawn over the view to mark it as autofilled--> <attr name="autofilledHighlight" format="reference" /> + <!-- Max width of the autofill data set picker as a fraction of the screen width --> + <attr name="autofillDatasetPickerMaxWidth" format="reference" /> + + <!-- Max height of the autofill data set picker as a fraction of the screen height --> + <attr name="autofillDatasetPickerMaxHeight" format="reference" /> + <!-- Default disabled alpha for widgets that set enabled/disabled alpha programmatically. --> <attr name="disabledAlpha" format="float" /> <!-- The alpha applied to the foreground color to create the primary text color. --> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index ef6c21fd90c0..ece0e821060c 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -536,4 +536,8 @@ <dimen name="item_touch_helper_max_drag_scroll_per_frame">20dp</dimen> <dimen name="item_touch_helper_swipe_escape_velocity">120dp</dimen> <dimen name="item_touch_helper_swipe_escape_max_velocity">800dp</dimen> + + <!-- Max width/height of the autofill data set picker as a fraction of the screen width/height --> + <dimen name="autofill_dataset_picker_max_size">90%</dimen> + </resources> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 1d2bc1953fd2..1966f6a89412 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -239,7 +239,8 @@ <java-symbol type="attr" name="accessibilityFocusedDrawable"/> <java-symbol type="attr" name="isLightTheme"/> <java-symbol type="attr" name="autofilledHighlight"/> - + <java-symbol type="attr" name="autofillDatasetPickerMaxWidth"/> + <java-symbol type="attr" name="autofillDatasetPickerMaxHeight"/> <java-symbol type="bool" name="action_bar_embed_tabs" /> <java-symbol type="bool" name="action_bar_expanded_action_views_exclusive" /> <java-symbol type="bool" name="config_avoidGfxAccel" /> @@ -2906,6 +2907,7 @@ <java-symbol type="string" name="autofill_save_type_email_address" /> <java-symbol type="drawable" name="autofill_dataset_picker_background" /> <java-symbol type="style" name="AutofillDatasetPicker" /> + <java-symbol type="dimen" name="autofill_dataset_picker_max_size"/> <!-- Accessibility fingerprint gestures --> <java-symbol type="string" name="capability_title_canCaptureFingerprintGestures" /> @@ -3007,4 +3009,5 @@ <java-symbol type="array" name="config_allowedGlobalInstantAppSettings" /> <java-symbol type="array" name="config_allowedSystemInstantAppSettings" /> <java-symbol type="array" name="config_allowedSecureInstantAppSettings" /> + </resources> diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml index e8fbf348c371..383ae5d577ce 100644 --- a/core/res/res/values/themes.xml +++ b/core/res/res/values/themes.xml @@ -449,6 +449,10 @@ please see themes_device_defaults.xml. <item name="tooltipFrameBackground">@drawable/tooltip_frame</item> <item name="tooltipForegroundColor">@color/bright_foreground_light</item> <item name="tooltipBackgroundColor">@color/tooltip_background_light</item> + + <!-- Autofill: max width/height of the dataset picker as a fraction of screen size --> + <item name="autofillDatasetPickerMaxWidth">@dimen/autofill_dataset_picker_max_size</item> + <item name="autofillDatasetPickerMaxHeight">@dimen/autofill_dataset_picker_max_size</item> </style> <!-- Variant of {@link #Theme} with no title bar --> diff --git a/services/autofill/java/com/android/server/autofill/ui/FillUi.java b/services/autofill/java/com/android/server/autofill/ui/FillUi.java index fa95e036eae5..dd297a645436 100644 --- a/services/autofill/java/com/android/server/autofill/ui/FillUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/FillUi.java @@ -23,10 +23,12 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.IntentSender; +import android.graphics.Point; import android.graphics.Rect; import android.service.autofill.Dataset; import android.service.autofill.FillResponse; import android.util.Slog; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -52,6 +54,8 @@ final class FillUi { private static final int VISIBLE_OPTIONS_MAX_COUNT = 3; + private static final TypedValue sTempTypedValue = new TypedValue(); + interface Callback { void onResponsePicked(@NonNull FillResponse response); void onDatasetPicked(@NonNull Dataset dataset); @@ -63,9 +67,13 @@ final class FillUi { void startIntentSender(IntentSender intentSender); } + private final @NonNull Point mTempPoint = new Point(); + private final @NonNull AutofillWindowPresenter mWindowPresenter = new AutofillWindowPresenter(); + private final @NonNull Context mContext; + private final @NonNull AnchoredWindow mWindow; private final @NonNull Callback mCallback; @@ -84,6 +92,7 @@ final class FillUi { FillUi(@NonNull Context context, @NonNull FillResponse response, @NonNull AutofillId focusedViewId, @NonNull @Nullable String filterText, @NonNull Callback callback) { + mContext = context; mCallback = callback; final LayoutInflater inflater = LayoutInflater.from(context); @@ -115,13 +124,18 @@ final class FillUi { mWindow = null; return; } - final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED); - content.measure(widthMeasureSpec, heightMeasureSpec); + + Point maxSize = mTempPoint; + resolveMaxWindowSize(context, maxSize); + final int widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxSize.x, + MeasureSpec.AT_MOST); + final int heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxSize.y, + MeasureSpec.AT_MOST); + + decor.measure(widthMeasureSpec, heightMeasureSpec); decor.setOnClickListener(v -> mCallback.onResponsePicked(response)); - // TODO(b/37567439): temporary limiting maximum height and minimum width - mContentWidth = Math.max(content.getMeasuredWidth(), 1000); - mContentHeight = Math.min(content.getMeasuredHeight(), 500); + mContentWidth = content.getMeasuredWidth(); + mContentHeight = content.getMeasuredHeight(); mWindow = new AnchoredWindow(decor); mCallback.requestShowFillUi(mContentWidth, mContentHeight, mWindowPresenter); @@ -245,6 +259,9 @@ final class FillUi { return changed; } + Point maxSize = mTempPoint; + resolveMaxWindowSize(mContext, maxSize); + mContentWidth = 0; mContentHeight = 0; @@ -254,12 +271,14 @@ final class FillUi { for (int i = 0; i < itemCount; i++) { View view = mAdapter.getItem(i).getView(); view.measure(widthMeasureSpec, heightMeasureSpec); - final int newContentWidth = Math.max(mContentWidth, view.getMeasuredWidth()); + final int clampedMeasuredWidth = Math.min(view.getMeasuredWidth(), maxSize.x); + final int newContentWidth = Math.max(mContentWidth, clampedMeasuredWidth); if (newContentWidth != mContentWidth) { mContentWidth = newContentWidth; changed = true; } - final int newContentHeight = mContentHeight + view.getMeasuredHeight(); + final int clampedMeasuredHeight = Math.min(view.getMeasuredHeight(), maxSize.y); + final int newContentHeight = mContentHeight + clampedMeasuredHeight; if (newContentHeight != mContentHeight) { mContentHeight = newContentHeight; changed = true; @@ -274,6 +293,17 @@ final class FillUi { } } + private static void resolveMaxWindowSize(Context context, Point outPoint) { + context.getDisplay().getSize(outPoint); + TypedValue typedValue = sTempTypedValue; + context.getTheme().resolveAttribute(R.attr.autofillDatasetPickerMaxWidth, + typedValue, true); + outPoint.x = (int) typedValue.getFraction(outPoint.x, outPoint.x); + context.getTheme().resolveAttribute(R.attr.autofillDatasetPickerMaxHeight, + typedValue, true); + outPoint.y = (int) typedValue.getFraction(outPoint.y, outPoint.y); + } + private static class ViewItem { private final String mValue; private final Dataset mDataset; |