Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0851e72 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make auth fill UI size sane size" into oc-dev

parents 8658d433 640a135e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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. -->
+4 −0
Original line number Diff line number Diff line
@@ -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>
+4 −1
Original line number Diff line number Diff line
@@ -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>
+4 −0
Original line number Diff line number Diff line
@@ -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 -->
+38 −8
Original line number Diff line number Diff line
@@ -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;