Merge changes from topics "dialog-width", "icon-size" into udc-dev

* changes:
  Set max dialog width on landscape and foldables
  Modify icon size for fill and save dialogs
This commit is contained in:
TreeHugger Robot
2023-05-12 17:54:27 +00:00
committed by Android (Google) Code Review
6 changed files with 35 additions and 38 deletions

View File

@@ -35,10 +35,10 @@
<ImageView
android:id="@+id/autofill_service_icon"
android:scaleType="fitStart"
android:scaleType="fitCenter"
android:visibility="gone"
android:layout_width="@dimen/autofill_dialog_icon_size"
android:layout_height="@dimen/autofill_dialog_icon_size"/>
android:layout_height="@dimen/autofill_dialog_icon_max_height"
android:layout_width="fill_parent"/>
<LinearLayout
android:id="@+id/autofill_dialog_header"

View File

@@ -40,10 +40,10 @@
<ImageView
android:id="@+id/autofill_save_icon"
android:scaleType="fitStart"
android:scaleType="fitCenter"
android:layout_gravity="center"
android:layout_width="@dimen/autofill_save_icon_size"
android:layout_height="@dimen/autofill_save_icon_size"/>
android:layout_height="@dimen/autofill_save_icon_max_height"
android:layout_width="fill_parent"/>
<TextView
android:id="@+id/autofill_save_title"
@@ -60,7 +60,6 @@
android:id="@+id/autofill_save_custom_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/autofill_save_scroll_view_top_margin"
android:visibility="gone"/>
</LinearLayout>

View File

@@ -874,6 +874,7 @@
<dimen name="autofill_elevation">32dp</dimen>
<dimen name="autofill_save_inner_padding">16dp</dimen>
<dimen name="autofill_save_icon_size">32dp</dimen>
<dimen name="autofill_save_icon_max_height">56dp</dimen>
<dimen name="autofill_save_title_start_padding">8dp</dimen>
<dimen name="autofill_save_scroll_view_top_margin">16dp</dimen>
<dimen name="autofill_save_button_bar_padding">16dp</dimen>
@@ -882,19 +883,18 @@
<!-- Max height of the the autofill save custom subtitle as a fraction of the screen width/height -->
<dimen name="autofill_save_custom_subtitle_max_height">20%</dimen>
<!-- Max (absolute) dimensions (both width and height) of autofill service icon on autofill save affordance.
NOTE: the actual displayed size might is actually smaller than this and is hardcoded in the
autofill_save.xml layout; this dimension is just used to avoid a crash in the UI (if the icon provided
by the autofill service metadata is bigger than these dimentionsit will not be displayed).
-->
<dimen name="autofill_save_icon_max_size">300dp</dimen>
<!-- Maximum number of datasets that are visible in the UX picker without scrolling -->
<integer name="autofill_max_visible_datasets">3</integer>
<!-- Size of an icon in the Autolfill fill dialog -->
<!-- Size of an icon in the Autofill fill dialog -->
<dimen name="autofill_dialog_icon_size">32dp</dimen>
<!-- The max height of an icon in the Autofill fill dialog. -->
<dimen name="autofill_dialog_icon_max_height">56dp</dimen>
<!-- The max width of the Autofill fill dialog. -->
<dimen name="autofill_dialog_max_width">640dp</dimen>
<!-- Size of a slice shortcut view -->
<dimen name="slice_shortcut_size">56dp</dimen>
<!-- Size of action icons in a slice -->

View File

@@ -3660,8 +3660,8 @@
<java-symbol type="dimen" name="autofill_dataset_picker_max_width"/>
<java-symbol type="dimen" name="autofill_dataset_picker_max_height"/>
<java-symbol type="dimen" name="autofill_save_custom_subtitle_max_height"/>
<java-symbol type="dimen" name="autofill_save_icon_max_size"/>
<java-symbol type="integer" name="autofill_max_visible_datasets" />
<java-symbol type="dimen" name="autofill_dialog_max_width" />
<java-symbol type="style" name="Theme.DeviceDefault.Autofill" />
<java-symbol type="style" name="Theme.DeviceDefault.Light.Autofill" />
@@ -5018,7 +5018,7 @@
<java-symbol type="bool" name="config_batteryStatsResetOnUnplugHighBatteryLevel" />
<java-symbol type="bool" name="config_batteryStatsResetOnUnplugAfterSignificantCharge" />
<java-symbol name="materialColorOnSecondaryFixedVariant" type="attr"/>
<java-symbol name="materialColorOnTertiaryFixedVariant" type="attr"/>
<java-symbol name="materialColorSurfaceContainerLowest" type="attr"/>

View File

@@ -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;

View File

@@ -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();
@@ -563,25 +571,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) {