From 1ec5701a091744631fca06ca5bb67a0d99011bd7 Mon Sep 17 00:00:00 2001 From: skxu Date: Fri, 5 May 2023 06:35:52 +0000 Subject: [PATCH 1/2] Modify icon size for fill and save dialogs Bug: 274942082 Test: Tested on phone, foldable, tablet Change-Id: I40da6b0b67dae523b6afb903f65bc4842630c308 --- core/res/res/layout/autofill_fill_dialog.xml | 6 +++--- core/res/res/layout/autofill_save.xml | 7 +++---- core/res/res/values/dimens.xml | 13 +++++------- core/res/res/values/symbols.xml | 3 +-- .../android/server/autofill/ui/SaveUi.java | 20 +------------------ 5 files changed, 13 insertions(+), 36 deletions(-) diff --git a/core/res/res/layout/autofill_fill_dialog.xml b/core/res/res/layout/autofill_fill_dialog.xml index 2e65800d5abbc..d1a4935633cbb 100644 --- a/core/res/res/layout/autofill_fill_dialog.xml +++ b/core/res/res/layout/autofill_fill_dialog.xml @@ -35,10 +35,10 @@ + android:layout_height="@dimen/autofill_dialog_icon_max_height" + android:layout_width="fill_parent"/> + android:layout_height="@dimen/autofill_save_icon_max_height" + android:layout_width="fill_parent"/> diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index bc0af12e95690..5240b57a952e6 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -874,6 +874,7 @@ 32dp 16dp 32dp + 56dp 8dp 16dp 16dp @@ -882,19 +883,15 @@ 20% - - 300dp - 3 - + 32dp + + 56dp + 56dp diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 73e3b417f67ae..c5af6b1ab07e0 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3654,7 +3654,6 @@ - @@ -5011,7 +5010,7 @@ - + diff --git a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java index 12042594fefbd..a2b08405ab366 100644 --- a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java @@ -563,25 +563,7 @@ final class SaveUi { private void setServiceIcon(Context context, View view, Drawable serviceIcon) { final ImageView iconView = view.findViewById(R.id.autofill_save_icon); final Resources res = context.getResources(); - - final int maxWidth = res.getDimensionPixelSize(R.dimen.autofill_save_icon_max_size); - final int maxHeight = maxWidth; - final int actualWidth = serviceIcon.getMinimumWidth(); - final int actualHeight = serviceIcon.getMinimumHeight(); - - if (actualWidth <= maxWidth && actualHeight <= maxHeight) { - if (sDebug) { - Slog.d(TAG, "Adding service icon " - + "(" + actualWidth + "x" + actualHeight + ") as it's less than maximum " - + "(" + maxWidth + "x" + maxHeight + ")."); - } - iconView.setImageDrawable(serviceIcon); - } else { - Slog.w(TAG, "Not adding service icon of size " - + "(" + actualWidth + "x" + actualHeight + ") because maximum is " - + "(" + maxWidth + "x" + maxHeight + ")."); - ((ViewGroup)iconView.getParent()).removeView(iconView); - } + iconView.setImageDrawable(serviceIcon); } private static boolean isValidLink(PendingIntent pendingIntent, Intent intent) { From 9ff02b9245b62193f7df0073d769e16b1aef2fe2 Mon Sep 17 00:00:00 2001 From: skxu Date: Mon, 8 May 2023 21:58:52 +0000 Subject: [PATCH 2/2] Set max dialog width on landscape and foldables Both fill and save dialogs should have max width=640dp Bug: 258077031 Test: Tested locally on phone, foldable, and tablet devices; also ran atest CtsAutoFillServiceTestCases on tablet and passed Change-Id: Icab9c5437fb5b717f800dfc659ba54c0b50132d8 --- core/res/res/values/dimens.xml | 3 +++ core/res/res/values/symbols.xml | 1 + .../com/android/server/autofill/ui/DialogFillUi.java | 10 +++++++++- .../java/com/android/server/autofill/ui/SaveUi.java | 10 +++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml index 5240b57a952e6..24da59a378f81 100644 --- a/core/res/res/values/dimens.xml +++ b/core/res/res/values/dimens.xml @@ -892,6 +892,9 @@ 56dp + + 640dp + 56dp diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index c5af6b1ab07e0..3f2a989587913 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -3655,6 +3655,7 @@ + diff --git a/services/autofill/java/com/android/server/autofill/ui/DialogFillUi.java b/services/autofill/java/com/android/server/autofill/ui/DialogFillUi.java index dec0e7666b1b8..dbeb624bd202c 100644 --- a/services/autofill/java/com/android/server/autofill/ui/DialogFillUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/DialogFillUi.java @@ -29,6 +29,7 @@ import android.graphics.drawable.Drawable; import android.service.autofill.Dataset; import android.service.autofill.FillResponse; import android.text.TextUtils; +import android.util.DisplayMetrics; import android.util.PluralsMessageFormatter; import android.util.Slog; import android.view.ContextThemeWrapper; @@ -177,7 +178,14 @@ final class DialogFillUi { window.setGravity(Gravity.BOTTOM | Gravity.CENTER); window.setCloseOnTouchOutside(true); final WindowManager.LayoutParams params = window.getAttributes(); - params.width = WindowManager.LayoutParams.MATCH_PARENT; + + DisplayMetrics displayMetrics = new DisplayMetrics(); + window.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); + final int screenWidth = displayMetrics.widthPixels; + final int maxWidth = + mContext.getResources().getDimensionPixelSize(R.dimen.autofill_dialog_max_width); + params.width = Math.min(screenWidth, maxWidth); + params.accessibilityTitle = mContext.getString(R.string.autofill_picker_accessibility_title); params.windowAnimations = R.style.AutofillSaveAnimation; diff --git a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java index a2b08405ab366..f035d07642790 100644 --- a/services/autofill/java/com/android/server/autofill/ui/SaveUi.java +++ b/services/autofill/java/com/android/server/autofill/ui/SaveUi.java @@ -48,6 +48,7 @@ import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.util.ArraySet; +import android.util.DisplayMetrics; import android.util.Pair; import android.util.Slog; import android.util.SparseArray; @@ -361,7 +362,14 @@ final class SaveUi { window.setGravity(Gravity.BOTTOM | Gravity.CENTER); window.setCloseOnTouchOutside(true); final WindowManager.LayoutParams params = window.getAttributes(); - params.width = WindowManager.LayoutParams.MATCH_PARENT; + + DisplayMetrics displayMetrics = new DisplayMetrics(); + window.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); + final int screenWidth = displayMetrics.widthPixels; + final int maxWidth = + context.getResources().getDimensionPixelSize(R.dimen.autofill_dialog_max_width); + params.width = Math.min(screenWidth, maxWidth); + params.accessibilityTitle = context.getString(R.string.autofill_save_accessibility_title); params.windowAnimations = R.style.AutofillSaveAnimation; params.setTrustedOverlay();