Skip to content

Commit

Permalink
PWN-897 - Fix webview paste button (#2187)
Browse files Browse the repository at this point in the history
  • Loading branch information
gslevinkov authored Feb 8, 2024
1 parent 6c30c14 commit 7b673c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/main/assets/referral_bridge_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ window.ReferralBridge = {
AndroidReferralBridge.showShareDialog(link);
},
getClipboardContent: function() {
return AndroidReferralBridge.getClipboardValue();
return JSON.parse(AndroidReferralBridge.getClipboardValue());
},
signMessageAsync: async function(message) {
const result = AndroidReferralBridge.signMessageAsync(message);
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/org/p2p/wallet/referral/ReferralBridge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import org.p2p.wallet.utils.getClipboardText

private typealias JsResultWrapper = String

/**
* @see [assets/referral_bridge_provider.js]
*/
class ReferralWebViewBridge(
webView: WebView,
private val tokenKeyProvider: TokenKeyProvider,
Expand Down Expand Up @@ -131,7 +134,7 @@ class ReferralWebViewBridge(

@JavascriptInterface
fun getClipboardValue(): JsResultWrapper {
val context = referralWebView?.context ?: return wrapInJsResult("No Android context found")
val context = referralWebView?.context ?: return wrapInJsResult(Exception("No Android context found"))
return wrapInJsResult(context.getClipboardText(trimmed = true).orEmpty())
}

Expand Down

0 comments on commit 7b673c5

Please sign in to comment.