diff --git a/app/src/main/java/zapsolutions/zap/ScanActivity.java b/app/src/main/java/zapsolutions/zap/ScanActivity.java index b10b652e..2ec86a6a 100644 --- a/app/src/main/java/zapsolutions/zap/ScanActivity.java +++ b/app/src/main/java/zapsolutions/zap/ScanActivity.java @@ -46,7 +46,7 @@ public void onButtonPasteClick() { super.onButtonPasteClick(); try { - readData(ClipBoardUtil.getPrimaryContent(getApplicationContext())); + readData(ClipBoardUtil.getPrimaryContent(getApplicationContext(), true)); } catch (NullPointerException e) { showError(getResources().getString(R.string.error_emptyClipboardPayment), RefConstants.ERROR_DURATION_SHORT); } diff --git a/app/src/main/java/zapsolutions/zap/channelManagement/ScanNodePubKeyActivity.java b/app/src/main/java/zapsolutions/zap/channelManagement/ScanNodePubKeyActivity.java index 3a17b639..5bea9824 100644 --- a/app/src/main/java/zapsolutions/zap/channelManagement/ScanNodePubKeyActivity.java +++ b/app/src/main/java/zapsolutions/zap/channelManagement/ScanNodePubKeyActivity.java @@ -129,7 +129,7 @@ public void onButtonPasteClick() { super.onButtonPasteClick(); try { - String clipboardContent = ClipBoardUtil.getPrimaryContent(getApplicationContext()); + String clipboardContent = ClipBoardUtil.getPrimaryContent(getApplicationContext(),true); processUserData(clipboardContent); } catch (NullPointerException e) { showError(getResources().getString(R.string.error_emptyClipboardConnect), RefConstants.ERROR_DURATION_SHORT); diff --git a/app/src/main/java/zapsolutions/zap/setup/ConnectRemoteNodeActivity.java b/app/src/main/java/zapsolutions/zap/setup/ConnectRemoteNodeActivity.java index a294cc2a..3a7d6b4e 100644 --- a/app/src/main/java/zapsolutions/zap/setup/ConnectRemoteNodeActivity.java +++ b/app/src/main/java/zapsolutions/zap/setup/ConnectRemoteNodeActivity.java @@ -55,7 +55,7 @@ public void onButtonPasteClick() { String clipboardContent = ""; boolean isClipboardContentValid = false; try { - clipboardContent = ClipBoardUtil.getPrimaryContent(getApplicationContext()); + clipboardContent = ClipBoardUtil.getPrimaryContent(getApplicationContext(), true); isClipboardContentValid = true; } catch (NullPointerException e) { showError(getResources().getString(R.string.error_emptyClipboardConnect), RefConstants.ERROR_DURATION_SHORT); diff --git a/app/src/main/java/zapsolutions/zap/util/ClipBoardUtil.java b/app/src/main/java/zapsolutions/zap/util/ClipBoardUtil.java index 78f69cfa..083a0dde 100644 --- a/app/src/main/java/zapsolutions/zap/util/ClipBoardUtil.java +++ b/app/src/main/java/zapsolutions/zap/util/ClipBoardUtil.java @@ -39,9 +39,17 @@ public static void copyToClipboard(Context context, String label, CharSequence d } } - public static String getPrimaryContent(Context context) throws NullPointerException { + public static String getPrimaryContent(Context context, boolean addToScanHistory) throws NullPointerException { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(CLIPBOARD_SERVICE); - return clipboard.getPrimaryClip().getItemAt(0).getText().toString(); + String data = clipboard.getPrimaryClip().getItemAt(0).getText().toString(); + + if (addToScanHistory) { + // Make sure the data just pasted from the clipboard does not trigger a clipboard scan popup. + // This prevents a popup directly after a new wallet was setup using paste. + String clipboardContentHash = UtilFunctions.sha256Hash(data); + PrefsUtil.edit().putString(PrefsUtil.LAST_CLIPBOARD_SCAN, clipboardContentHash).apply(); + } + return data; } @@ -52,12 +60,12 @@ public static void performClipboardScan(Context context, CompositeDisposable com } try { - getPrimaryContent(context); + getPrimaryContent(context, false); } catch (NullPointerException e) { return; } - String clipboardContent = getPrimaryContent(context); + String clipboardContent = getPrimaryContent(context, false); String clipboardContentHash = UtilFunctions.sha256Hash(clipboardContent); if (PrefsUtil.getPrefs().getString(PrefsUtil.LAST_CLIPBOARD_SCAN, "").equals(clipboardContentHash)) { @@ -146,7 +154,7 @@ private static void showProceedQuestion(int question, Context context, OnClipboa AlertDialog.Builder adb = new AlertDialog.Builder(context) .setMessage(question) .setCancelable(true) - .setPositiveButton(R.string.continue_string, (dialog, whichButton) -> listener.onProceed(getPrimaryContent(context))) + .setPositiveButton(R.string.continue_string, (dialog, whichButton) -> listener.onProceed(getPrimaryContent(context, false))) .setNegativeButton(R.string.no, (dialog, which) -> { });