Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CBW-1440] added support for concordiumwallet://wc deeplink #308

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<uses-permission android:name="android.permission.USE_BIOMETRIC" /> <!-- Protection level: normal -->
<uses-permission android:name="android.permission.CAMERA" /> <!-- Protection level: dangerous -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<uses-feature
android:name="android.hardware.camera.any"
Expand Down Expand Up @@ -53,6 +53,16 @@

<data android:scheme="wc" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
TouHouNo marked this conversation as resolved.
Show resolved Hide resolved
android:host="wc"
android:scheme="concordiumwallet" />
</intent-filter>
</activity>
<service
android:name=".ui.walletconnect.WalletConnectService"
Expand Down
45 changes: 23 additions & 22 deletions app/src/main/java/com/concordium/wallet/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ class MainActivity : BaseActivity(), IdentityStatusDelegate by IdentityStatusDel

initializeViews()

intent?.data?.let { if (it.toString().startsWith("wc")) wcUri = it.toString() }
intent?.data?.let {
if (it.toString().startsWith("wc") || it.toString()
orhoj marked this conversation as resolved.
Show resolved Hide resolved
.startsWith("concordiumwallet")
) wcUri = it.toString()
}

// If we're being restored from a previous state,
// then we don't want to add fragments and should return or else
Expand All @@ -70,7 +74,9 @@ class MainActivity : BaseActivity(), IdentityStatusDelegate by IdentityStatusDel
return
} else {
intent?.data?.let {
if (it.toString().startsWith("wc")) {
if (it.toString().startsWith("wc") || it.toString()
.startsWith("concordiumwallet")
) {
wcUri = it.toString()
if (App.appCore.session.isLoggedIn.value == true && AuthPreferences(this).hasSeedPhrase()) {
gotoWalletConnect()
Expand All @@ -88,9 +94,7 @@ class MainActivity : BaseActivity(), IdentityStatusDelegate by IdentityStatusDel

private fun setupToolbar() {
setupActionBar(
binding.toolbarLayout.toolbar,
binding.toolbarLayout.toolbarTitle,
R.string.main_title
binding.toolbarLayout.toolbar, binding.toolbarLayout.toolbarTitle, R.string.main_title
)
supportActionBar?.setCustomView(R.layout.app_toolbar_main)
binding.toolbarLayout.settingsContainer.setOnClickListener {
Expand Down Expand Up @@ -171,7 +175,7 @@ class MainActivity : BaseActivity(), IdentityStatusDelegate by IdentityStatusDel
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
intent?.data?.let {
if (it.toString().startsWith("wc")) {
if (it.toString().startsWith("wc") || it.toString().startsWith("concordiumwallet")) {
wcUri = it.toString()
if (App.appCore.session.isLoggedIn.value == true && AuthPreferences(this).hasSeedPhrase()) {
gotoWalletConnect()
Expand All @@ -194,8 +198,7 @@ class MainActivity : BaseActivity(), IdentityStatusDelegate by IdentityStatusDel

private fun initializeViewModel() {
viewModel = ViewModelProvider(
this,
ViewModelProvider.AndroidViewModelFactory.getInstance(application)
this, ViewModelProvider.AndroidViewModelFactory.getInstance(application)
)[MainViewModel::class.java]

viewModel.titleLiveData.observe(this) { title ->
Expand All @@ -209,8 +212,7 @@ class MainActivity : BaseActivity(), IdentityStatusDelegate by IdentityStatusDel
}
}
viewModel.newFinalizedAccountLiveData.observe(this) { newAccount ->
newAccount?.let {
}
newAccount?.let {}
}
viewModel.showTermsAndConditions.observe(this) { shouldShowTermsAndConditions ->
if (shouldShowTermsAndConditions) {
Expand Down Expand Up @@ -253,39 +255,38 @@ class MainActivity : BaseActivity(), IdentityStatusDelegate by IdentityStatusDel
wcUri = ""
getResultWalletNotSetupIntroTerms.launch(
Intent(
this,
WalletNotSetupActivity::class.java
this, WalletNotSetupActivity::class.java
)
)
} else {
startActivity(Intent(this, IntroTermsActivity::class.java))
}
} else if (App.appCore.session.hasSetupPassword) {
if (wcUri.isNotBlank()) {
if (AuthPreferences(this).hasSeedPhrase())
getResultAuthLogin.launch(Intent(this, AuthLoginActivity::class.java))
if (AuthPreferences(this).hasSeedPhrase()) getResultAuthLogin.launch(
Intent(
this,
AuthLoginActivity::class.java
)
)
else {
wcUri = ""
getResultWalletNotSetupPassPhrase.launch(
Intent(
this,
WalletNotSetupActivity::class.java
this, WalletNotSetupActivity::class.java
)
)
}
} else
startActivity(Intent(this, AuthLoginActivity::class.java))
} else startActivity(Intent(this, AuthLoginActivity::class.java))
} else {
if (wcUri.isNotBlank()) {
wcUri = ""
getResultWalletNotSetupAuthSetup.launch(
Intent(
this,
WalletNotSetupActivity::class.java
this, WalletNotSetupActivity::class.java
)
)
} else
startActivity(Intent(this, AuthSetupActivity::class.java))
} else startActivity(Intent(this, AuthSetupActivity::class.java))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ScanQRViewModel(application: Application) : AndroidViewModel(application)
}

fun checkQrWalletConnect(qrInfo: String): Boolean {
return qrInfo.isNotBlank() && qrInfo.lowercase().startsWith("wc:")
return qrInfo.isNotBlank() && (qrInfo.lowercase().startsWith("wc:") || qrInfo.lowercase()
orhoj marked this conversation as resolved.
Show resolved Hide resolved
.startsWith("concordiumwallet:"))
}
}
Loading