From 601b95c3a24d1620f85abcb6bd5c37fde97d521b Mon Sep 17 00:00:00 2001 From: Oli Lan Date: Mon, 8 Mar 2021 17:59:58 +0000 Subject: [PATCH] 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 --- core/res/res/values/strings.xml | 6 ++++++ core/res/res/values/symbols.xml | 2 ++ .../java/com/android/server/clipboard/ClipboardService.java | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 2b1168f14f210..2ffa29b533310 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -2778,6 +2778,12 @@ Copied + + %1$s pasted from %2$s + + + %1$s pasted from clipboard + More diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 00cc81639608c..07938fd3a3248 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -558,6 +558,8 @@ + + diff --git a/services/core/java/com/android/server/clipboard/ClipboardService.java b/services/core/java/com/android/server/clipboard/ClipboardService.java index 7dfecd56eaf50..5020917f8eb18 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(() ->