diff options
| author | Adam Soltys <[email protected]> | 2025-02-28 12:21:23 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-28 12:21:23 -0800 |
| commit | 50dff116c6b6cdb8ee01720e8efacce9628e571f (patch) | |
| tree | 5e8474a64eebfa8251139c0f38a5da477e26bc6d /android/app/src/main/java/io/coinos/MainActivity.java | |
| parent | 43185349b3d15de20bc798a3a4c18be94be13a84 (diff) | |
| download | coinos-ui-50dff116c6b6cdb8ee01720e8efacce9628e571f.tar.gz coinos-ui-50dff116c6b6cdb8ee01720e8efacce9628e571f.zip | |
capacitor android
Diffstat (limited to 'android/app/src/main/java/io/coinos/MainActivity.java')
| -rw-r--r-- | android/app/src/main/java/io/coinos/MainActivity.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/android/app/src/main/java/io/coinos/MainActivity.java b/android/app/src/main/java/io/coinos/MainActivity.java new file mode 100644 index 00000000..66bb81bf --- /dev/null +++ b/android/app/src/main/java/io/coinos/MainActivity.java @@ -0,0 +1,64 @@ +package io.coinos; + +import com.getcapacitor.BridgeActivity; +import com.getcapacitor.Bridge; +import com.getcapacitor.PluginCall; +import com.getcapacitor.PluginHandle; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.webkit.CookieManager; + +public class MainActivity extends BridgeActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = getIntent(); + if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) { + Uri data = intent.getData(); + if (data != null) { + String url = data.toString(); + Bridge bridge = getBridge(); + + if (bridge != null) { + String encodedUrl = Uri.encode(url); + String destinationUrl = "https://coinos.io/send/" + encodedUrl; + + bridge.getWebView().post(() -> { + bridge.getWebView().loadUrl(destinationUrl); + }); + } + } + } + } + + @Override + public void onNewIntent(Intent intent) { + super.onNewIntent(intent); + setIntent(intent); + if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) { + Uri data = intent.getData(); + if (data != null) { + String url = data.toString(); + + // Dispatch deep link when app is already open + Bridge bridge = getBridge(); + if (bridge != null) { + String encodedUrl = Uri.encode(url); + String destinationUrl = "https://dev.coinos.io/send/" + encodedUrl; + + bridge.getWebView().post(() -> { + bridge.getWebView().loadUrl(destinationUrl); + }); + } + } + } + } + + @Override + public void onPause() { + super.onPause(); + CookieManager.getInstance().flush(); + } +} |
