summaryrefslogtreecommitdiff
path: root/core/java/android/app/ProgressDialog.java
diff options
context:
space:
mode:
authorDaisuke Miyakawa <>2009-04-02 10:44:31 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-02 10:44:31 -0700
commiteb3e3e368a5093768b44b415a85a3d0bcce92583 (patch)
treec0226eab28a3ad36cb86898fe3a019f8892c747e /core/java/android/app/ProgressDialog.java
parent43ca00b0e82711f67246030e70bfb1f423e4a67f (diff)
AI 144210: am: CL 144182 am: CL 144181 Modify ProgressDialog class and its xml so that it follows the
Android's UI guide line. This modification is based on leland's mock. See http://b/issue?id=1748136 for more information. Put ProgressNumber left side, next to ProgressPercentage. Make ProgressPercentage Bold. Put ProgressNumber and ProgressPercentage near to the ProgressBar above. This is same as the design of Market application. Enable ProgressDialog change the ProgressNumber format. This is hidden since the interface is premature. Original author: dmiyakawa Merged from: //branches/cupcake/... Original author: android-build Merged from: //branches/donutburger/... Automated import of CL 144210
Diffstat (limited to 'core/java/android/app/ProgressDialog.java')
-rw-r--r--core/java/android/app/ProgressDialog.java24
1 files changed, 22 insertions, 2 deletions
diff --git a/core/java/android/app/ProgressDialog.java b/core/java/android/app/ProgressDialog.java
index c87e3982b7ba..bdea0698cf59 100644
--- a/core/java/android/app/ProgressDialog.java
+++ b/core/java/android/app/ProgressDialog.java
@@ -21,6 +21,9 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
@@ -52,6 +55,7 @@ public class ProgressDialog extends AlertDialog {
private int mProgressStyle = STYLE_SPINNER;
private TextView mProgressNumber;
+ private String mProgressNumberFormat;
private TextView mProgressPercent;
private NumberFormat mProgressPercentFormat;
@@ -121,13 +125,18 @@ public class ProgressDialog extends AlertDialog {
int progress = mProgress.getProgress();
int max = mProgress.getMax();
double percent = (double) progress / (double) max;
- mProgressNumber.setText(progress + "/" + max);
- mProgressPercent.setText(mProgressPercentFormat.format(percent));
+ String format = mProgressNumberFormat;
+ mProgressNumber.setText(String.format(format, progress, max));
+ SpannableString tmp = new SpannableString(mProgressPercentFormat.format(percent));
+ tmp.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
+ 0, tmp.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ mProgressPercent.setText(tmp);
}
};
View view = inflater.inflate(R.layout.alert_dialog_progress, null);
mProgress = (ProgressBar) view.findViewById(R.id.progress);
mProgressNumber = (TextView) view.findViewById(R.id.progress_number);
+ mProgressNumberFormat = "%d/%d";
mProgressPercent = (TextView) view.findViewById(R.id.progress_percent);
mProgressPercentFormat = NumberFormat.getPercentInstance();
mProgressPercentFormat.setMaximumFractionDigits(0);
@@ -293,6 +302,17 @@ public class ProgressDialog extends AlertDialog {
mProgressStyle = style;
}
+ /**
+ * Change the format of Progress Number. The default is "current/max".
+ * Should not be called during the number is progressing.
+ * @param format Should contain two "%d". The first is used for current number
+ * and the second is used for the maximum.
+ * @hide
+ */
+ public void setProgressNumberFormat(String format) {
+ mProgressNumberFormat = format;
+ }
+
private void onProgressChanged() {
if (mProgressStyle == STYLE_HORIZONTAL) {
mViewUpdateHandler.sendEmptyMessage(0);