summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ivan Chiang <chiangi@google.com> 2021-02-22 10:12:15 +0800
committer Ivan Chiang <chiangi@google.com> 2021-02-24 13:03:38 +0800
commit9911b9e917cd9ddbe9bbcbd5a975335b46b4c1c0 (patch)
treedceea69d122c3119115da7f510b6615c8c95897a
parent8f4e416217095c198885fb3cf8323be7d5369b3d (diff)
Add the title string on progress dialog in PermissionActivity
Add the string and remove unused codes. Fix: 160189362 Test: manual. Add the screenshots on b/160189362 Change-Id: I5b3a783da920c94942209304b1dc282361fa3836
-rwxr-xr-xgen_strings.py31
-rw-r--r--res/layout/permission_body.xml6
-rw-r--r--res/values/strings.xml80
-rw-r--r--src/com/android/providers/media/PermissionActivity.java64
4 files changed, 130 insertions, 51 deletions
diff --git a/gen_strings.py b/gen_strings.py
index 99bba8a34..a3d98be50 100755
--- a/gen_strings.py
+++ b/gen_strings.py
@@ -31,12 +31,6 @@ for verb in verbs:
if verb == "write":
verblabel = "modify"
- verblabelcaps = verblabel[0].upper() + verblabel[1:]
- if verb == "trash":
- verblabelcaps = "Move to trash"
- if verb == "untrash":
- verblabelcaps = "Move out of trash"
-
print '''
<!-- ========================= %s STRINGS ========================= -->
''' % (verb.upper())
@@ -49,6 +43,13 @@ for verb in verbs:
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> ${datalabel}s to trash?</item>
</plurals>
''').substitute(vars()).strip("\n")
+ print Template('''
+<!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] -->
+<plurals name="permission_progress_${verb}_${data}">
+ <item quantity="one">Moving $datalabel to trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s to trash&#8230;</item>
+</plurals>
+''').substitute(vars()).strip("\n")
elif verb == "untrash":
print Template('''
@@ -58,6 +59,13 @@ for verb in verbs:
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> ${datalabel}s out of trash?</item>
</plurals>
''').substitute(vars()).strip("\n")
+ print Template('''
+<!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] -->
+<plurals name="permission_progress_${verb}_${data}">
+ <item quantity="one">Moving $datalabel out of trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s out of trash&#8230;</item>
+</plurals>
+''').substitute(vars()).strip("\n")
else:
print Template('''
@@ -67,6 +75,17 @@ for verb in verbs:
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to $verblabel <xliff:g id="count" example="42">^2</xliff:g> ${datalabel}s?</item>
</plurals>
''').substitute(vars()).strip("\n")
+ if verb == "write":
+ actionLabel = "Modifying"
+ else:
+ actionLabel = "Deleting"
+ print Template('''
+<!-- Progress dialog message after user allows $verb permission to the $data item [CHAR LIMIT=128] -->
+<plurals name="permission_progress_${verb}_${data}">
+ <item quantity="one">$actionLabel $datalabel&#8230;</item>
+ <item quantity="other">$actionLabel <xliff:g id="count" example="42">^1</xliff:g> ${datalabel}s&#8230;</item>
+</plurals>
+''').substitute(vars()).strip("\n")
print '''
<!-- ========================= END AUTO-GENERATED BY gen_strings.py ========================= -->
diff --git a/res/layout/permission_body.xml b/res/layout/permission_body.xml
index 0fb4ece49..7c7406566 100644
--- a/res/layout/permission_body.xml
+++ b/res/layout/permission_body.xml
@@ -97,11 +97,5 @@
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:visibility="gone" />
- <TextView
- android:id="@+id/message"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginTop="12dp"
- android:visibility="gone" />
</LinearLayout>
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d6171ca78..ead6337c0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -88,21 +88,41 @@
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to modify this audio file?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to modify <xliff:g id="count" example="42">^2</xliff:g> audio files?</item>
</plurals>
+ <!-- Progress dialog message after user allows write permission to the audio item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_write_audio">
+ <item quantity="one">Modifying audio file&#8230;</item>
+ <item quantity="other">Modifying <xliff:g id="count" example="42">^1</xliff:g> audio files&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow write permission to the video item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_write_video">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to modify this video?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to modify <xliff:g id="count" example="42">^2</xliff:g> videos?</item>
</plurals>
+ <!-- Progress dialog message after user allows write permission to the video item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_write_video">
+ <item quantity="one">Modifying video&#8230;</item>
+ <item quantity="other">Modifying <xliff:g id="count" example="42">^1</xliff:g> videos&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow write permission to the image item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_write_image">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to modify this photo?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to modify <xliff:g id="count" example="42">^2</xliff:g> photos?</item>
</plurals>
+ <!-- Progress dialog message after user allows write permission to the image item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_write_image">
+ <item quantity="one">Modifying photo&#8230;</item>
+ <item quantity="other">Modifying <xliff:g id="count" example="42">^1</xliff:g> photos&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow write permission to the generic item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_write_generic">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to modify this item?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to modify <xliff:g id="count" example="42">^2</xliff:g> items?</item>
</plurals>
+ <!-- Progress dialog message after user allows write permission to the generic item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_write_generic">
+ <item quantity="one">Modifying item&#8230;</item>
+ <item quantity="other">Modifying <xliff:g id="count" example="42">^1</xliff:g> items&#8230;</item>
+ </plurals>
<!-- ========================= TRASH STRINGS ========================= -->
@@ -111,21 +131,41 @@
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this audio file to trash?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> audio files to trash?</item>
</plurals>
+ <!-- Progress dialog message after user allows trash permission to the audio item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_trash_audio">
+ <item quantity="one">Moving audio file to trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> audio files to trash&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow trash permission to the video item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_trash_video">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this video to trash?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> videos to trash?</item>
</plurals>
+ <!-- Progress dialog message after user allows trash permission to the video item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_trash_video">
+ <item quantity="one">Moving video to trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> videos to trash&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow trash permission to the image item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_trash_image">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this photo to trash?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> photos to trash?</item>
</plurals>
+ <!-- Progress dialog message after user allows trash permission to the image item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_trash_image">
+ <item quantity="one">Moving photo to trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> photos to trash&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow trash permission to the generic item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_trash_generic">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this item to trash?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> items to trash?</item>
</plurals>
+ <!-- Progress dialog message after user allows trash permission to the generic item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_trash_generic">
+ <item quantity="one">Moving item to trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> items to trash&#8230;</item>
+ </plurals>
<!-- ========================= UNTRASH STRINGS ========================= -->
@@ -134,21 +174,41 @@
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this audio file out of trash?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> audio files out of trash?</item>
</plurals>
+ <!-- Progress dialog message after user allows untrash permission to the audio item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_untrash_audio">
+ <item quantity="one">Moving audio file out of trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> audio files out of trash&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow untrash permission to the video item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_untrash_video">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this video out of trash?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> videos out of trash?</item>
</plurals>
+ <!-- Progress dialog message after user allows untrash permission to the video item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_untrash_video">
+ <item quantity="one">Moving video out of trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> videos out of trash&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow untrash permission to the image item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_untrash_image">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this photo out of trash?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> photos out of trash?</item>
</plurals>
+ <!-- Progress dialog message after user allows untrash permission to the image item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_untrash_image">
+ <item quantity="one">Moving photo out of trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> photos out of trash&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow untrash permission to the generic item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_untrash_generic">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move this item out of trash?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to move <xliff:g id="count" example="42">^2</xliff:g> items out of trash?</item>
</plurals>
+ <!-- Progress dialog message after user allows untrash permission to the generic item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_untrash_generic">
+ <item quantity="one">Moving item out of trash&#8230;</item>
+ <item quantity="other">Moving <xliff:g id="count" example="42">^1</xliff:g> items out of trash&#8230;</item>
+ </plurals>
<!-- ========================= DELETE STRINGS ========================= -->
@@ -157,21 +217,41 @@
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to delete this audio file?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to delete <xliff:g id="count" example="42">^2</xliff:g> audio files?</item>
</plurals>
+ <!-- Progress dialog message after user allows delete permission to the audio item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_delete_audio">
+ <item quantity="one">Deleting audio file&#8230;</item>
+ <item quantity="other">Deleting <xliff:g id="count" example="42">^1</xliff:g> audio files&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow delete permission to the video item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_delete_video">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to delete this video?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to delete <xliff:g id="count" example="42">^2</xliff:g> videos?</item>
</plurals>
+ <!-- Progress dialog message after user allows delete permission to the video item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_delete_video">
+ <item quantity="one">Deleting video&#8230;</item>
+ <item quantity="other">Deleting <xliff:g id="count" example="42">^1</xliff:g> videos&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow delete permission to the image item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_delete_image">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to delete this photo?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to delete <xliff:g id="count" example="42">^2</xliff:g> photos?</item>
</plurals>
+ <!-- Progress dialog message after user allows delete permission to the image item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_delete_image">
+ <item quantity="one">Deleting photo&#8230;</item>
+ <item quantity="other">Deleting <xliff:g id="count" example="42">^1</xliff:g> photos&#8230;</item>
+ </plurals>
<!-- Dialog title asking if user will allow delete permission to the generic item displayed below this string. [CHAR LIMIT=128] -->
<plurals name="permission_delete_generic">
<item quantity="one">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to delete this item?</item>
<item quantity="other">Allow <xliff:g id="app_name" example="Gmail">^1</xliff:g> to delete <xliff:g id="count" example="42">^2</xliff:g> items?</item>
</plurals>
+ <!-- Progress dialog message after user allows delete permission to the generic item [CHAR LIMIT=128] -->
+ <plurals name="permission_progress_delete_generic">
+ <item quantity="one">Deleting item&#8230;</item>
+ <item quantity="other">Deleting <xliff:g id="count" example="42">^1</xliff:g> items&#8230;</item>
+ </plurals>
<!-- ========================= END AUTO-GENERATED BY gen_strings.py ========================= -->
diff --git a/src/com/android/providers/media/PermissionActivity.java b/src/com/android/providers/media/PermissionActivity.java
index 0183690f8..e2a35d2e5 100644
--- a/src/com/android/providers/media/PermissionActivity.java
+++ b/src/com/android/providers/media/PermissionActivity.java
@@ -25,7 +25,7 @@ import static com.android.providers.media.util.Logging.TAG;
import android.app.Activity;
import android.app.AlertDialog;
-import android.app.ProgressDialog;
+import android.app.Dialog;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -50,7 +50,6 @@ import android.os.Handler;
import android.provider.MediaStore;
import android.provider.MediaStore.MediaColumns;
import android.text.TextUtils;
-import android.text.format.DateUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Size;
@@ -60,6 +59,7 @@ import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.widget.ImageView;
+import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -103,7 +103,7 @@ public class PermissionActivity extends Activity {
private AlertDialog actionDialog;
private AsyncTask<Void, Void, Void> positiveActionTask;
- private ProgressDialog progressDialog;
+ private Dialog progressDialog;
private TextView titleView;
private static final Long LEAST_SHOW_PROGRESS_TIME_MS = 300L;
@@ -154,8 +154,8 @@ public class PermissionActivity extends Activity {
return;
}
- progressDialog = new ProgressDialog(this);
- progressDialog.setCancelable(false);
+ // Create Progress dialog
+ createProgressDialog();
// Favorite-related requests are automatically granted for now; we still
// make developers go through this no-op dialog flow to preserve our
@@ -172,13 +172,6 @@ public class PermissionActivity extends Activity {
handleImageViewVisibility(bodyView, uris);
new DescriptionTask(bodyView).execute(uris);
- final CharSequence message = resolveMessageText();
- if (!TextUtils.isEmpty(message)) {
- final TextView messageView = bodyView.requireViewById(R.id.message);
- messageView.setVisibility(View.VISIBLE);
- messageView.setText(message);
- }
-
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
// We set the title in message so that the text doesn't get truncated
builder.setMessage(resolveTitleText());
@@ -212,6 +205,19 @@ public class PermissionActivity extends Activity {
});
}
+ private void createProgressDialog() {
+ final ProgressBar progressBar = new ProgressBar(this);
+ final int padding = getResources().getDimensionPixelOffset(R.dimen.dialog_space);
+
+ progressBar.setIndeterminate(true);
+ progressBar.setPadding(0, padding / 2, 0, padding);
+ progressDialog = new AlertDialog.Builder(this)
+ .setTitle(resolveProgressMessageText())
+ .setView(progressBar)
+ .setCancelable(false)
+ .create();
+ }
+
@Override
public void onDestroy() {
super.onDestroy();
@@ -452,43 +458,23 @@ public class PermissionActivity extends Activity {
}
/**
- * Resolve the dialog message string to be displayed to the user, if any.
- * All arguments have been bound and this string is ready to be displayed.
+ * Resolve the progress message string to be displayed to the user. All
+ * arguments have been bound and this string is ready to be displayed.
*/
- private @Nullable CharSequence resolveMessageText() {
- final String resName = "permission_" + verb + "_" + data + "_info";
+ private @Nullable CharSequence resolveProgressMessageText() {
+ final String resName = "permission_progress_" + verb + "_" + data;
final int resId = getResources().getIdentifier(resName, "plurals",
getResources().getResourcePackageName(R.string.app_label));
if (resId != 0) {
final int count = uris.size();
- final long durationMillis = (values.getAsLong(MediaColumns.DATE_EXPIRES) * 1000)
- - System.currentTimeMillis();
- final long durationDays = (durationMillis + DateUtils.DAY_IN_MILLIS)
- / DateUtils.DAY_IN_MILLIS;
final CharSequence text = getResources().getQuantityText(resId, count);
- return TextUtils.expandTemplate(text, label, String.valueOf(count),
- String.valueOf(durationDays));
+ return TextUtils.expandTemplate(text, String.valueOf(count));
} else {
- // Only some actions have a secondary message string; it's okay if
- // there isn't one defined
- return null;
+ // We always need a string to prompt the user with
+ throw new IllegalStateException("Invalid resource: " + resName);
}
}
- private @NonNull CharSequence resolvePositiveText() {
- final String resName = "permission_" + verb + "_grant";
- final int resId = getResources().getIdentifier(resName, "string",
- getResources().getResourcePackageName(R.string.app_label));
- return getResources().getText(resId);
- }
-
- private @NonNull CharSequence resolveNegativeText() {
- final String resName = "permission_" + verb + "_deny";
- final int resId = getResources().getIdentifier(resName, "string",
- getResources().getResourcePackageName(R.string.app_label));
- return getResources().getText(resId);
- }
-
/**
* Recursively walk the given view hierarchy looking for the first
* {@link View} which matches the given predicate.