Loading core/java/com/android/internal/app/AlertController.java +35 −1 Original line number Diff line number Diff line Loading @@ -20,9 +20,13 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import android.annotation.Nullable; import android.app.AlertDialog; import android.app.compat.CompatChanges; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.content.res.TypedArray; import android.database.Cursor; import android.graphics.drawable.Drawable; Loading Loading @@ -58,6 +62,7 @@ import android.widget.ListView; import android.widget.ScrollView; import android.widget.SimpleCursorAdapter; import android.widget.TextView; import android.widget.flags.Flags; import com.android.internal.R; Loading @@ -66,6 +71,12 @@ import java.lang.ref.WeakReference; public class AlertController { public static final int MICRO = 1; private static boolean sUseWearMaterial3Style; @ChangeId @EnabledSince(targetSdkVersion = 36) private static final long WEAR_MATERIAL3_ALERTDIALOG = 379365266L; private final Context mContext; private final DialogInterface mDialogInterface; protected final Window mWindow; Loading Loading @@ -210,7 +221,8 @@ public class AlertController { mHandler = new ButtonHandler(di); final TypedArray a = context.obtainStyledAttributes(null, R.styleable.AlertDialog, R.attr.alertDialogStyle, 0); R.styleable.AlertDialog, getAlertDialogDefStyleAttr(context), getAlertDialogDefStyleRes()); mAlertDialogLayout = a.getResourceId( R.styleable.AlertDialog_layout, R.layout.alert_dialog); Loading @@ -236,6 +248,28 @@ public class AlertController { window.requestFeature(Window.FEATURE_NO_TITLE); } private int getAlertDialogDefStyleAttr(Context context) { sUseWearMaterial3Style = useWearMaterial3Style(context); if (sUseWearMaterial3Style) { return 0; } return R.attr.alertDialogStyle; } private int getAlertDialogDefStyleRes() { if (sUseWearMaterial3Style) { return com.android.internal.R.style.AlertDialog_DeviceDefault_WearMaterial3; } return 0; } private static boolean useWearMaterial3Style(Context context) { return Flags.useWearMaterial3Ui() && CompatChanges.isChangeEnabled(WEAR_MATERIAL3_ALERTDIALOG) && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH) && context.getThemeResId() == com.android.internal.R.style.Theme_DeviceDefault; } static boolean canTextInput(View v) { if (v.onCheckIsTextEditor()) { return true; Loading core/res/res/layout-watch-v36/alert_dialog_material.xml→core/res/res/layout-watch-v36/alert_dialog_wear_material3.xml +0 −0 File moved. View file core/res/res/values-watch-v36/styles_material.xml +4 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,10 @@ </style> <!-- AlertDialog Styles --> <style name="AlertDialog.DeviceDefault.WearMaterial3"> <item name="layout">@layout/alert_dialog_wear_material3</item> </style> <style name="Widget.DeviceDefault.Button.ButtonBar.AlertDialog.WearMaterial3" parent="Widget.DeviceDefault.Button"> <item name="android:textSize">0sp</item> <item name="android:gravity">center</item> Loading core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -5824,5 +5824,8 @@ <!-- Style for Wear Material3 Button. Will only be used for sdk 36 or above. --> <java-symbol type="style" name="Widget.DeviceDefault.Button.WearMaterial3" /> <!-- Style for Wear Material3 AlertDialog. Will only be used for sdk 36 or above. --> <java-symbol type="style" name="AlertDialog.DeviceDefault.WearMaterial3" /> <java-symbol type="bool" name="config_allowNormalBrightnessForDozePolicy" /> </resources> Loading
core/java/com/android/internal/app/AlertController.java +35 −1 Original line number Diff line number Diff line Loading @@ -20,9 +20,13 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import android.annotation.Nullable; import android.app.AlertDialog; import android.app.compat.CompatChanges; import android.compat.annotation.ChangeId; import android.compat.annotation.EnabledSince; import android.compat.annotation.UnsupportedAppUsage; import android.content.Context; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.content.res.TypedArray; import android.database.Cursor; import android.graphics.drawable.Drawable; Loading Loading @@ -58,6 +62,7 @@ import android.widget.ListView; import android.widget.ScrollView; import android.widget.SimpleCursorAdapter; import android.widget.TextView; import android.widget.flags.Flags; import com.android.internal.R; Loading @@ -66,6 +71,12 @@ import java.lang.ref.WeakReference; public class AlertController { public static final int MICRO = 1; private static boolean sUseWearMaterial3Style; @ChangeId @EnabledSince(targetSdkVersion = 36) private static final long WEAR_MATERIAL3_ALERTDIALOG = 379365266L; private final Context mContext; private final DialogInterface mDialogInterface; protected final Window mWindow; Loading Loading @@ -210,7 +221,8 @@ public class AlertController { mHandler = new ButtonHandler(di); final TypedArray a = context.obtainStyledAttributes(null, R.styleable.AlertDialog, R.attr.alertDialogStyle, 0); R.styleable.AlertDialog, getAlertDialogDefStyleAttr(context), getAlertDialogDefStyleRes()); mAlertDialogLayout = a.getResourceId( R.styleable.AlertDialog_layout, R.layout.alert_dialog); Loading @@ -236,6 +248,28 @@ public class AlertController { window.requestFeature(Window.FEATURE_NO_TITLE); } private int getAlertDialogDefStyleAttr(Context context) { sUseWearMaterial3Style = useWearMaterial3Style(context); if (sUseWearMaterial3Style) { return 0; } return R.attr.alertDialogStyle; } private int getAlertDialogDefStyleRes() { if (sUseWearMaterial3Style) { return com.android.internal.R.style.AlertDialog_DeviceDefault_WearMaterial3; } return 0; } private static boolean useWearMaterial3Style(Context context) { return Flags.useWearMaterial3Ui() && CompatChanges.isChangeEnabled(WEAR_MATERIAL3_ALERTDIALOG) && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH) && context.getThemeResId() == com.android.internal.R.style.Theme_DeviceDefault; } static boolean canTextInput(View v) { if (v.onCheckIsTextEditor()) { return true; Loading
core/res/res/layout-watch-v36/alert_dialog_material.xml→core/res/res/layout-watch-v36/alert_dialog_wear_material3.xml +0 −0 File moved. View file
core/res/res/values-watch-v36/styles_material.xml +4 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,10 @@ </style> <!-- AlertDialog Styles --> <style name="AlertDialog.DeviceDefault.WearMaterial3"> <item name="layout">@layout/alert_dialog_wear_material3</item> </style> <style name="Widget.DeviceDefault.Button.ButtonBar.AlertDialog.WearMaterial3" parent="Widget.DeviceDefault.Button"> <item name="android:textSize">0sp</item> <item name="android:gravity">center</item> Loading
core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -5824,5 +5824,8 @@ <!-- Style for Wear Material3 Button. Will only be used for sdk 36 or above. --> <java-symbol type="style" name="Widget.DeviceDefault.Button.WearMaterial3" /> <!-- Style for Wear Material3 AlertDialog. Will only be used for sdk 36 or above. --> <java-symbol type="style" name="AlertDialog.DeviceDefault.WearMaterial3" /> <java-symbol type="bool" name="config_allowNormalBrightnessForDozePolicy" /> </resources>