Loading core/java/com/android/internal/app/AlertController.java +20 −10 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.os.Handler; import android.os.Message; import android.text.TextUtils; import android.util.AttributeSet; import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; Loading Loading @@ -165,6 +166,13 @@ public class AlertController { } } private static boolean shouldCenterSingleButton(Context context) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogCenterButtons, outValue, true); return outValue.data != 0; } public AlertController(Context context, DialogInterface di, Window window) { mContext = context; mDialogInterface = di; Loading Loading @@ -508,6 +516,7 @@ public class AlertController { whichButtons = whichButtons | BIT_BUTTON_NEUTRAL; } if (shouldCenterSingleButton(mContext)) { /* * If we only have 1 button it should be centered on the layout and * expand to fill 50% of the available space. Loading @@ -519,6 +528,7 @@ public class AlertController { } else if (whichButtons == BIT_BUTTON_NEUTRAL) { centerButton(mButtonNeutral); } } return whichButtons != 0; } Loading core/res/res/values/attrs.xml +1 −0 Original line number Diff line number Diff line Loading @@ -351,6 +351,7 @@ <eat-comment /> <attr name="alertDialogStyle" format="reference" /> <attr name="alertDialogButtonGroupStyle" format="reference" /> <attr name="alertDialogCenterButtons" format="boolean" /> <!-- ============ --> <!-- Panel styles --> Loading core/res/res/values/themes.xml +3 −1 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ <item name="dialogTheme">@android:style/Theme.Dialog</item> <item name="alertDialogTheme">@android:style/Theme.Dialog.Alert</item> <item name="alertDialogButtonGroupStyle">?android:attr/buttonGroupStyle</item> <item name="alertDialogCenterButtons">true</item> <!-- Panel attributes --> <item name="panelBackground">@android:drawable/menu_background</item> Loading Loading @@ -590,7 +591,7 @@ </style> <!-- @hide --> <style name="Theme.Dialog.AppError"> <style name="Theme.Dialog.AppError" parent="Theme.Holo.Dialog"> <item name="windowFrame">@null</item> <item name="windowTitleStyle">@android:style/DialogWindowTitle</item> <item name="windowBackground">@android:color/transparent</item> Loading Loading @@ -754,6 +755,7 @@ <item name="dialogTheme">@android:style/Theme.Holo.Dialog</item> <item name="alertDialogTheme">@android:style/Theme.Holo.Dialog.Alert</item> <item name="alertDialogButtonGroupStyle">@android:style/Widget.Holo.ButtonGroup.AlertDialog</item> <item name="alertDialogCenterButtons">false</item> <!-- Panel attributes --> <item name="panelBackground">@android:drawable/menu_background</item> Loading Loading
core/java/com/android/internal/app/AlertController.java +20 −10 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.os.Handler; import android.os.Message; import android.text.TextUtils; import android.util.AttributeSet; import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; Loading Loading @@ -165,6 +166,13 @@ public class AlertController { } } private static boolean shouldCenterSingleButton(Context context) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(com.android.internal.R.attr.alertDialogCenterButtons, outValue, true); return outValue.data != 0; } public AlertController(Context context, DialogInterface di, Window window) { mContext = context; mDialogInterface = di; Loading Loading @@ -508,6 +516,7 @@ public class AlertController { whichButtons = whichButtons | BIT_BUTTON_NEUTRAL; } if (shouldCenterSingleButton(mContext)) { /* * If we only have 1 button it should be centered on the layout and * expand to fill 50% of the available space. Loading @@ -519,6 +528,7 @@ public class AlertController { } else if (whichButtons == BIT_BUTTON_NEUTRAL) { centerButton(mButtonNeutral); } } return whichButtons != 0; } Loading
core/res/res/values/attrs.xml +1 −0 Original line number Diff line number Diff line Loading @@ -351,6 +351,7 @@ <eat-comment /> <attr name="alertDialogStyle" format="reference" /> <attr name="alertDialogButtonGroupStyle" format="reference" /> <attr name="alertDialogCenterButtons" format="boolean" /> <!-- ============ --> <!-- Panel styles --> Loading
core/res/res/values/themes.xml +3 −1 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ <item name="dialogTheme">@android:style/Theme.Dialog</item> <item name="alertDialogTheme">@android:style/Theme.Dialog.Alert</item> <item name="alertDialogButtonGroupStyle">?android:attr/buttonGroupStyle</item> <item name="alertDialogCenterButtons">true</item> <!-- Panel attributes --> <item name="panelBackground">@android:drawable/menu_background</item> Loading Loading @@ -590,7 +591,7 @@ </style> <!-- @hide --> <style name="Theme.Dialog.AppError"> <style name="Theme.Dialog.AppError" parent="Theme.Holo.Dialog"> <item name="windowFrame">@null</item> <item name="windowTitleStyle">@android:style/DialogWindowTitle</item> <item name="windowBackground">@android:color/transparent</item> Loading Loading @@ -754,6 +755,7 @@ <item name="dialogTheme">@android:style/Theme.Holo.Dialog</item> <item name="alertDialogTheme">@android:style/Theme.Holo.Dialog.Alert</item> <item name="alertDialogButtonGroupStyle">@android:style/Widget.Holo.ButtonGroup.AlertDialog</item> <item name="alertDialogCenterButtons">false</item> <!-- Panel attributes --> <item name="panelBackground">@android:drawable/menu_background</item> Loading