Skip to content

Commit 81cca03

Browse files
adampAndroid (Google) Code Review
authored andcommitted
Merge "Fix metrics on Holo progress dialogs"
2 parents 3593fc4 + ba3c377 commit 81cca03

File tree

5 files changed

+110
-4
lines changed

5 files changed

+110
-4
lines changed

core/java/android/app/ProgressDialog.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
package android.app;
1818

19+
import com.android.internal.R;
20+
1921
import android.content.Context;
22+
import android.content.res.TypedArray;
2023
import android.graphics.drawable.Drawable;
2124
import android.os.Bundle;
2225
import android.os.Handler;
@@ -29,8 +32,6 @@
2932
import android.widget.ProgressBar;
3033
import android.widget.TextView;
3134

32-
import com.android.internal.R;
33-
3435
import java.text.NumberFormat;
3536

3637
/**
@@ -119,6 +120,9 @@ public static ProgressDialog show(Context context, CharSequence title,
119120
@Override
120121
protected void onCreate(Bundle savedInstanceState) {
121122
LayoutInflater inflater = LayoutInflater.from(mContext);
123+
TypedArray a = mContext.obtainStyledAttributes(null,
124+
com.android.internal.R.styleable.AlertDialog,
125+
com.android.internal.R.attr.alertDialogStyle, 0);
122126
if (mProgressStyle == STYLE_HORIZONTAL) {
123127

124128
/* Use a separate handler to update the text views as they
@@ -149,17 +153,22 @@ public void handleMessage(Message msg) {
149153
}
150154
}
151155
};
152-
View view = inflater.inflate(R.layout.alert_dialog_progress, null);
156+
View view = inflater.inflate(a.getResourceId(
157+
com.android.internal.R.styleable.AlertDialog_horizontalProgressLayout,
158+
R.layout.alert_dialog_progress), null);
153159
mProgress = (ProgressBar) view.findViewById(R.id.progress);
154160
mProgressNumber = (TextView) view.findViewById(R.id.progress_number);
155161
mProgressPercent = (TextView) view.findViewById(R.id.progress_percent);
156162
setView(view);
157163
} else {
158-
View view = inflater.inflate(R.layout.progress_dialog, null);
164+
View view = inflater.inflate(a.getResourceId(
165+
com.android.internal.R.styleable.AlertDialog_progressLayout,
166+
R.layout.progress_dialog), null);
159167
mProgress = (ProgressBar) view.findViewById(R.id.progress);
160168
mMessageView = (TextView) view.findViewById(R.id.message);
161169
setView(view);
162170
}
171+
a.recycle();
163172
if (mMax > 0) {
164173
setMax(mMax);
165174
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2011 The Android Open Source Project
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:layout_width="wrap_content" android:layout_height="match_parent">
19+
<ProgressBar android:id="@+id/progress"
20+
style="?android:attr/progressBarStyleHorizontal"
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
android:layout_marginTop="16dip"
24+
android:layout_marginBottom="1dip"
25+
android:layout_marginLeft="16dip"
26+
android:layout_marginRight="16dip"
27+
android:layout_centerHorizontal="true" />
28+
<TextView
29+
android:id="@+id/progress_percent"
30+
android:layout_width="wrap_content"
31+
android:layout_height="wrap_content"
32+
android:paddingBottom="16dip"
33+
android:layout_marginLeft="16dip"
34+
android:layout_marginRight="16dip"
35+
android:layout_alignParentLeft="true"
36+
android:layout_below="@id/progress"
37+
/>
38+
<TextView
39+
android:id="@+id/progress_number"
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:paddingBottom="16dip"
43+
android:layout_marginLeft="16dip"
44+
android:layout_marginRight="16dip"
45+
android:layout_alignParentRight="true"
46+
android:layout_below="@id/progress"
47+
/>
48+
</RelativeLayout>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/*
4+
** Copyright 2011, The Android Open Source Project
5+
**
6+
** Licensed under the Apache License, Version 2.0 (the "License");
7+
** you may not use this file except in compliance with the License.
8+
** You may obtain a copy of the License at
9+
**
10+
** http://www.apache.org/licenses/LICENSE-2.0
11+
**
12+
** Unless required by applicable law or agreed to in writing, software
13+
** distributed under the License is distributed on an "AS IS" BASIS,
14+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
** See the License for the specific language governing permissions and
16+
** limitations under the License.
17+
*/
18+
-->
19+
20+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content">
23+
24+
<LinearLayout android:id="@+id/body"
25+
android:orientation="horizontal"
26+
android:layout_width="match_parent"
27+
android:layout_height="match_parent"
28+
android:baselineAligned="false"
29+
android:padding="16dip">
30+
31+
<ProgressBar android:id="@android:id/progress"
32+
style="?android:attr/progressBarStyle"
33+
android:layout_width="wrap_content"
34+
android:layout_height="wrap_content"
35+
android:max="10000"
36+
android:layout_marginRight="16dip" />
37+
38+
<TextView android:id="@+id/message"
39+
android:layout_width="match_parent"
40+
android:layout_height="wrap_content"
41+
android:layout_gravity="center_vertical" />
42+
</LinearLayout>
43+
</FrameLayout>

core/res/res/values/attrs.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,8 @@
15511551
<attr name="multiChoiceItemLayout" format="reference" />
15521552
<attr name="singleChoiceItemLayout" format="reference" />
15531553
<attr name="listItemLayout" format="reference" />
1554+
<attr name="progressLayout" format="reference" />
1555+
<attr name="horizontalProgressLayout" format="reference" />
15541556
</declare-styleable>
15551557

15561558
<!-- Fragment animation class attributes. -->

core/res/res/values/styles.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ please see styles_device_defaults.xml.
6161
<item name="bottomBright">@android:drawable/popup_bottom_bright</item>
6262
<item name="bottomMedium">@android:drawable/popup_bottom_medium</item>
6363
<item name="centerMedium">@android:drawable/popup_center_medium</item>
64+
<item name="progressLayout">@android:layout/progress_dialog</item>
65+
<item name="horizontalProgressLayout">@android:layout/alert_dialog_progress</item>
6466
</style>
6567

6668
<style name="Widget.PreferenceFrameLayout">
@@ -2350,6 +2352,8 @@ please see styles_device_defaults.xml.
23502352
<item name="centerMedium">@android:drawable/dialog_middle_holo_dark</item>
23512353
<item name="layout">@android:layout/alert_dialog_holo</item>
23522354
<item name="listLayout">@android:layout/select_dialog_holo</item>
2355+
<item name="progressLayout">@android:layout/progress_dialog_holo</item>
2356+
<item name="horizontalProgressLayout">@android:layout/alert_dialog_progress_holo</item>
23532357
<item name="listItemLayout">@android:layout/select_dialog_item_holo</item>
23542358
<item name="multiChoiceItemLayout">@android:layout/select_dialog_multichoice_holo</item>
23552359
<item name="singleChoiceItemLayout">@android:layout/select_dialog_singlechoice_holo</item>

0 commit comments

Comments
 (0)