From ba3c377ba428bcf1c9b5a5cdf697fec0ed4fade7 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Fri, 9 Sep 2011 16:22:34 -0700 Subject: [PATCH] Fix metrics on Holo progress dialogs Change-Id: I8818d002dcee0ca6d6deead9e0403c07e8ef4460 --- core/java/android/app/ProgressDialog.java | 17 +++++-- .../res/layout/alert_dialog_progress_holo.xml | 48 +++++++++++++++++++ core/res/res/layout/progress_dialog_holo.xml | 43 +++++++++++++++++ core/res/res/values/attrs.xml | 2 + core/res/res/values/styles.xml | 4 ++ 5 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 core/res/res/layout/alert_dialog_progress_holo.xml create mode 100644 core/res/res/layout/progress_dialog_holo.xml diff --git a/core/java/android/app/ProgressDialog.java b/core/java/android/app/ProgressDialog.java index f1a04f85f2321..7f1f3850a3978 100644 --- a/core/java/android/app/ProgressDialog.java +++ b/core/java/android/app/ProgressDialog.java @@ -16,7 +16,10 @@ package android.app; +import com.android.internal.R; + import android.content.Context; +import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; @@ -29,8 +32,6 @@ import android.view.View; import android.widget.ProgressBar; import android.widget.TextView; -import com.android.internal.R; - import java.text.NumberFormat; /** @@ -119,6 +120,9 @@ public class ProgressDialog extends AlertDialog { @Override protected void onCreate(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(mContext); + TypedArray a = mContext.obtainStyledAttributes(null, + com.android.internal.R.styleable.AlertDialog, + com.android.internal.R.attr.alertDialogStyle, 0); if (mProgressStyle == STYLE_HORIZONTAL) { /* Use a separate handler to update the text views as they @@ -149,17 +153,22 @@ public class ProgressDialog extends AlertDialog { } } }; - View view = inflater.inflate(R.layout.alert_dialog_progress, null); + View view = inflater.inflate(a.getResourceId( + com.android.internal.R.styleable.AlertDialog_horizontalProgressLayout, + R.layout.alert_dialog_progress), null); mProgress = (ProgressBar) view.findViewById(R.id.progress); mProgressNumber = (TextView) view.findViewById(R.id.progress_number); mProgressPercent = (TextView) view.findViewById(R.id.progress_percent); setView(view); } else { - View view = inflater.inflate(R.layout.progress_dialog, null); + View view = inflater.inflate(a.getResourceId( + com.android.internal.R.styleable.AlertDialog_progressLayout, + R.layout.progress_dialog), null); mProgress = (ProgressBar) view.findViewById(R.id.progress); mMessageView = (TextView) view.findViewById(R.id.message); setView(view); } + a.recycle(); if (mMax > 0) { setMax(mMax); } diff --git a/core/res/res/layout/alert_dialog_progress_holo.xml b/core/res/res/layout/alert_dialog_progress_holo.xml new file mode 100644 index 0000000000000..94dbb2b1371fb --- /dev/null +++ b/core/res/res/layout/alert_dialog_progress_holo.xml @@ -0,0 +1,48 @@ + + + + + + + + diff --git a/core/res/res/layout/progress_dialog_holo.xml b/core/res/res/layout/progress_dialog_holo.xml new file mode 100644 index 0000000000000..9631efd870f50 --- /dev/null +++ b/core/res/res/layout/progress_dialog_holo.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 525b03ae9ac30..5b67fc7ce64f8 100755 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -1551,6 +1551,8 @@ + + diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 5033611ff219f..356a2ad9056e3 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -61,6 +61,8 @@ please see styles_device_defaults.xml. @android:drawable/popup_bottom_bright @android:drawable/popup_bottom_medium @android:drawable/popup_center_medium + @android:layout/progress_dialog + @android:layout/alert_dialog_progress