summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOli Lan <olilan@google.com>2021-03-08 17:59:58 +0000
committerOli Lan <olilan@google.com>2021-03-09 16:53:32 +0000
commit601b95c3a24d1620f85abcb6bd5c37fde97d521b (patch)
treebf23e6e91a785bfd4f615209ab89d457fcbb0919
parenta644b688927fd5cd27b5e983a21a15c1356bbd4c (diff)
Use string resources for clipboard access notifications.
This replaces the hardcoded strings used for the clipboard access notification toasts with string resources. Bug: 179469804 Test: Manual, copy and paste and check notification text is correct Change-Id: If912455d544da053b52433dc153b1f9483eeb613
-rw-r--r--core/res/res/values/strings.xml6
-rw-r--r--core/res/res/values/symbols.xml2
-rw-r--r--services/core/java/com/android/server/clipboard/ClipboardService.java6
3 files changed, 12 insertions, 2 deletions
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 2b1168f14f21..2ffa29b53331 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2778,6 +2778,12 @@
<!-- Displayed to the user to confirm that they have copied text/images to the clipboard [CHAR LIMIT=NONE] -->
<string name="copied">Copied</string>
+ <!-- Displayed to the user to inform them that an app has accessed clipboard data (pasted as in "copy and paste") that was copied from another app [CHAR LIMIT=50] -->
+ <string name="pasted_from_app"><xliff:g id="pasting_app_name" example="Gmail">%1$s</xliff:g> pasted from <xliff:g id="source_app_name" example="Chrome">%2$s</xliff:g></string>
+
+ <!-- Displayed to the user to inform them that an app has accessed clipboard data (pasted as in "copy and paste") [CHAR LIMIT=50] -->
+ <string name="pasted_from_clipboard"><xliff:g id="pasting_app_name" example="Gmail">%1$s</xliff:g> pasted from clipboard</string>
+
<!-- Menu item displayed at the end of a menu to allow users to see another page worth of menu items. This is shown on any app's menu as long as the app has too many items in the menu.-->
<string name="more_item_label">More</string>
<!-- Prepended to the shortcut for a menu item to indicate that the user should hold the MENU button together with the shortcut to invoke the item. For example, if the shortcut to open a new tab in browser is MENU and B together, then this would be prepended to the letter "B" -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 00cc81639608..07938fd3a324 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -558,6 +558,8 @@
<java-symbol type="string" name="prepend_shortcut_label" />
<java-symbol type="string" name="private_dns_broken_detailed" />
<java-symbol type="string" name="paste_as_plain_text" />
+ <java-symbol type="string" name="pasted_from_app" />
+ <java-symbol type="string" name="pasted_from_clipboard" />
<java-symbol type="string" name="replace" />
<java-symbol type="string" name="undo" />
<java-symbol type="string" name="redo" />
diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java
index 7dfecd56eaf5..5020917f8eb1 100644
--- a/services/core/java/com/android/server/clipboard/ClipboardService.java
+++ b/services/core/java/com/android/server/clipboard/ClipboardService.java
@@ -60,6 +60,7 @@ import android.util.SparseArray;
import android.view.autofill.AutofillManagerInternal;
import android.widget.Toast;
+import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.server.LocalServices;
import com.android.server.SystemService;
@@ -955,9 +956,10 @@ public class ClipboardService extends SystemService {
mPm.getApplicationInfoAsUser(callingPackage, 0, userId));
String message;
if (sourceAppLabel != null) {
- message = callingAppLabel + " pasted from " + sourceAppLabel;
+ message = getContext().getString(
+ R.string.pasted_from_app, callingAppLabel, sourceAppLabel);
} else {
- message = callingAppLabel + " pasted from clipboard";
+ message = getContext().getString(R.string.pasted_from_clipboard, callingAppLabel);
}
Slog.i(TAG, message);
Binder.withCleanCallingIdentity(() ->