summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-24 02:11:55 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-24 02:11:55 -0500
commitdcc7ddcd3b34de4fb9d50742fd0679f8237e386c (patch)
treeda2723ce093902dd87d1f6e8b3899bdad481e550 /app/src/main/java/com
parent4fdb3458ec7c5c58f500f64d8efcffd99e0e9dde (diff)
ConfigEditFragment: Copy public key on click
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com')
-rw-r--r--app/src/main/java/com/wireguard/android/ConfigEditFragment.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/src/main/java/com/wireguard/android/ConfigEditFragment.java b/app/src/main/java/com/wireguard/android/ConfigEditFragment.java
index 48d32d39..ebebef42 100644
--- a/app/src/main/java/com/wireguard/android/ConfigEditFragment.java
+++ b/app/src/main/java/com/wireguard/android/ConfigEditFragment.java
@@ -1,6 +1,8 @@
package com.wireguard.android;
import android.app.Activity;
+import android.content.ClipData;
+import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -23,6 +25,18 @@ public class ConfigEditFragment extends BaseConfigFragment {
private static final String KEY_MODIFIED_CONFIG = "modifiedConfig";
private static final String KEY_ORIGINAL_NAME = "originalName";
+ public static void copyPublicKey(final Context context, final String publicKey) {
+ if (publicKey == null || publicKey.isEmpty())
+ return;
+ final ClipboardManager clipboard =
+ (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
+ final String description =
+ context.getResources().getString(R.string.public_key_description);
+ clipboard.setPrimaryClip(ClipData.newPlainText(description, publicKey));
+ final String message = context.getResources().getString(R.string.public_key_copied_message);
+ Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
+ }
+
private Config localConfig;
private String originalName;