diff --git a/app/src/main/java/org/fdroid/fdroid/Utils.java b/app/src/main/java/org/fdroid/fdroid/Utils.java
index 838c2aa52..5442b8bac 100644
--- a/app/src/main/java/org/fdroid/fdroid/Utils.java
+++ b/app/src/main/java/org/fdroid/fdroid/Utils.java
@@ -49,6 +49,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.annotation.StringRes;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.util.Consumer;
import androidx.core.util.Supplier;
@@ -889,12 +890,25 @@ public final class Utils {
}
/**
- * Copy text to the clipboard and show a toast informing the user that the text has been copied.
+ * Copy text to the clipboard and show a toast informing the user that something has been copied.
* @param context the context to use
* @param label the label used in the clipboard
* @param text the text to copy
*/
- public static void copyToClipboard(@NonNull Context context, @Nullable String label, @NonNull String text) {
+ public static void copyToClipboard(@NonNull Context context, @Nullable String label,
+ @NonNull String text) {
+ copyToClipboard(context, label, text, R.string.copied_to_clipboard);
+ }
+
+ /**
+ * Copy text to the clipboard and show a toast informing the user that the text has been copied.
+ * @param context the context to use
+ * @param label the label used in the clipboard
+ * @param text the text to copy
+ * @param message the message to show in the toast
+ */
+ public static void copyToClipboard(@NonNull Context context, @Nullable String label,
+ @NonNull String text, @StringRes int message) {
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard == null) {
// permission denied
@@ -905,7 +919,7 @@ public final class Utils {
if (Build.VERSION.SDK_INT < 33) {
// Starting with Android 13 (SDK 33) there is a system dialog with more clipboard actions
// shown automatically so there is no need to inform the user about the copy action.
- Toast.makeText(context, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show();
+ Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
// should not happen, something went wrong internally
diff --git a/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java b/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java
index 3d7ba3c30..5aa3b1ffe 100644
--- a/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java
+++ b/app/src/main/java/org/fdroid/fdroid/privileged/views/AppSecurityPermissions.java
@@ -231,7 +231,8 @@ public class AppSecurityPermissions {
@Override
public boolean onLongClick(View v) {
- Utils.copyToClipboard(getContext(), String.valueOf(perm.label), perm.name);
+ Utils.copyToClipboard(getContext(), String.valueOf(perm.label),
+ perm.name, R.string.copied_permission_to_clipboard);
return true;
}
diff --git a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java
index 57935f348..04959c11a 100644
--- a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java
+++ b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java
@@ -1308,7 +1308,7 @@ public class AppDetailsRecyclerViewAdapter
parent.addView(view);
view.setOnClickListener(v -> onLinkClicked(url));
view.setOnLongClickListener(v -> {
- Utils.copyToClipboard(context, text, url);
+ Utils.copyToClipboard(context, text, url, R.string.copied_url_to_clipboard);
return true;
});
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a95804b05..9dfaecc7c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -741,4 +741,6 @@ This often occurs with apps installed via Google Play or other sources, if they
- Updated %1$d years ago
Copied to clipboard
+ Copied URL to clipboard
+ Copied permission name to clipboard