summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2010-11-05 20:06:02 -0700
committerAdam Powell <adamp@google.com>2010-11-05 20:06:02 -0700
commit3320dcd049700481c744d499feeecd1454afd4d7 (patch)
tree95a7380b0c5f25668cb41b11b074efc2566985d8 /core
parenteb0699bacd1ad8053172ab146385b4f0600c8eee (diff)
downloadframeworks_base-3320dcd049700481c744d499feeecd1454afd4d7.zip
frameworks_base-3320dcd049700481c744d499feeecd1454afd4d7.tar.gz
frameworks_base-3320dcd049700481c744d499feeecd1454afd4d7.tar.bz2
Fixed several dialog theming issues
Change-Id: I8e83e5a35acaae63a70bef48f543e3fd82ced354
Diffstat (limited to 'core')
-rw-r--r--core/java/com/android/internal/app/AlertController.java30
-rwxr-xr-xcore/res/res/values/attrs.xml1
-rw-r--r--core/res/res/values/themes.xml4
3 files changed, 24 insertions, 11 deletions
diff --git a/core/java/com/android/internal/app/AlertController.java b/core/java/com/android/internal/app/AlertController.java
index fefdcea..b2810b1 100644
--- a/core/java/com/android/internal/app/AlertController.java
+++ b/core/java/com/android/internal/app/AlertController.java
@@ -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;
@@ -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;
@@ -508,16 +516,18 @@ public class AlertController {
whichButtons = whichButtons | BIT_BUTTON_NEUTRAL;
}
- /*
- * If we only have 1 button it should be centered on the layout and
- * expand to fill 50% of the available space.
- */
- if (whichButtons == BIT_BUTTON_POSITIVE) {
- centerButton(mButtonPositive);
- } else if (whichButtons == BIT_BUTTON_NEGATIVE) {
- centerButton(mButtonNeutral);
- } else if (whichButtons == BIT_BUTTON_NEUTRAL) {
- centerButton(mButtonNeutral);
+ 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.
+ */
+ if (whichButtons == BIT_BUTTON_POSITIVE) {
+ centerButton(mButtonPositive);
+ } else if (whichButtons == BIT_BUTTON_NEGATIVE) {
+ centerButton(mButtonNeutral);
+ } else if (whichButtons == BIT_BUTTON_NEUTRAL) {
+ centerButton(mButtonNeutral);
+ }
}
return whichButtons != 0;
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 1083452..b22d833 100755
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -351,6 +351,7 @@
<eat-comment />
<attr name="alertDialogStyle" format="reference" />
<attr name="alertDialogButtonGroupStyle" format="reference" />
+ <attr name="alertDialogCenterButtons" format="boolean" />
<!-- ============ -->
<!-- Panel styles -->
diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml
index e92ebba..cefc039 100644
--- a/core/res/res/values/themes.xml
+++ b/core/res/res/values/themes.xml
@@ -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>
@@ -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>
@@ -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>