Merge "Don't be clever with strings" into pi-dev

This commit is contained in:
android-build-team Robot
2018-05-07 16:10:34 +00:00
committed by Android (Google) Code Review
2 changed files with 35 additions and 47 deletions

View File

@@ -1567,21 +1567,20 @@
<!-- Notification: Control panel: Label that displays when the app's notifications cannot be blocked. -->
<string name="notification_unblockable_desc">These notifications can\'t be turned off</string>
<string name="notification_appops_camera_active">camera</string>
<string name="notification_appops_microphone_active">microphone</string>
<string name="notification_appops_overlay_active">displaying over other apps on your screen</string>
<plurals name="notification_appops">
<item quantity="one">This app is <xliff:g id="performing activity" example="using the camera">%1$s</xliff:g>.</item>
<item quantity="other">This app is <xliff:g id="performing activity" example="using the camera">%1$s</xliff:g> and <xliff:g id="performing activity" example="using the microphone">%2$s</xliff:g>.</item>
</plurals>
<plurals name="notification_using">
<item quantity="one">using the <xliff:g id="performing activity" example="camera">%1$s</xliff:g></item>
<item quantity="other">using the <xliff:g id="performing activity" example="camera">%1$s</xliff:g> and <xliff:g id="performing activity" example="microphone">%2$s</xliff:g></item>
</plurals>
<!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
<string name="appops_camera">This app is using the camera.</string>
<!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
<string name="appops_microphone">This app is using the microphone.</string>
<!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
<string name="appops_overlay">This app is displaying over other apps on your screen.</string>
<!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
<string name="appops_camera_mic">This app is using the microphone and camera.</string>
<!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
<string name="appops_camera_overlay">This app is displaying over other apps on your screen and using the camera.</string>
<!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
<string name="appops_mic_overlay">This app is displaying over other apps on your screen and using the microphone.</string>
<!-- Notification Inline controls: describes what the app is doing in the background [CHAR_LIMIT=NONE] -->
<string name="appops_camera_mic_overlay">This app is displaying over other apps on your screen and using the microphone and camera.</string>
<string name="notification_appops_settings">Settings</string>
<string name="notification_appops_ok">OK</string>

View File

@@ -109,7 +109,7 @@ public class AppOpsInfo extends LinearLayout implements NotificationGuts.GutsCon
private void bindPrompt() {
final TextView prompt = findViewById(R.id.prompt);
prompt.setText(getPromptString());
prompt.setText(getPrompt());
}
private void bindButtons() {
@@ -121,41 +121,30 @@ public class AppOpsInfo extends LinearLayout implements NotificationGuts.GutsCon
ok.setOnClickListener(mOnOk);
}
private String getPromptString() {
String cameraString =
mContext.getResources().getString(R.string.notification_appops_camera_active);
String micString =
mContext.getResources().getString(R.string.notification_appops_microphone_active);
String overlayString =
mContext.getResources().getString(R.string.notification_appops_overlay_active);
String using = null;
String promptString;
if (mAppOps.contains(AppOpsManager.OP_CAMERA)
&& mAppOps.contains(AppOpsManager.OP_RECORD_AUDIO)) {
using = mContext.getResources().getQuantityString(
R.plurals.notification_using, 2, micString, cameraString);
} else if (mAppOps.contains(AppOpsManager.OP_CAMERA)) {
using = mContext.getResources().getQuantityString(
R.plurals.notification_using, 1, cameraString);
} else if (mAppOps.contains(AppOpsManager.OP_RECORD_AUDIO)){
using = mContext.getResources().getQuantityString(
R.plurals.notification_using, 1, micString);
}
if (mAppOps.contains(AppOpsManager.OP_SYSTEM_ALERT_WINDOW)) {
if (using != null) {
promptString = mContext.getResources().getQuantityString(
R.plurals.notification_appops, 2, overlayString, using);
private String getPrompt() {
if (mAppOps == null || mAppOps.size() == 0) {
return "";
} else if (mAppOps.size() == 1) {
if (mAppOps.contains(AppOpsManager.OP_CAMERA)) {
return mContext.getString(R.string.appops_camera);
} else if (mAppOps.contains(AppOpsManager.OP_RECORD_AUDIO)) {
return mContext.getString(R.string.appops_microphone);
} else {
promptString = mContext.getResources().getQuantityString(
R.plurals.notification_appops, 1, overlayString);
return mContext.getString(R.string.appops_overlay);
}
} else if (mAppOps.size() == 2) {
if (mAppOps.contains(AppOpsManager.OP_CAMERA)) {
if (mAppOps.contains(AppOpsManager.OP_RECORD_AUDIO)) {
return mContext.getString(R.string.appops_camera_mic);
} else {
return mContext.getString(R.string.appops_camera_overlay);
}
} else {
return mContext.getString(R.string.appops_mic_overlay);
}
} else {
promptString = mContext.getResources().getQuantityString(
R.plurals.notification_appops, 1, using);
return mContext.getString(R.string.appops_camera_mic_overlay);
}
return promptString;
}
@Override