Skip to content

Commit

Permalink
Application-wide in-app browser for all urls (#1674)
Browse files Browse the repository at this point in the history
* Application-wide in-app browser for all urls

* Changelog entries fixed

---------

Co-authored-by: Honza <[email protected]>
  • Loading branch information
Milan-Cerovsky and HonzaR authored Nov 13, 2024
1 parent d4be4a5 commit af5ed30
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 57 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ and this application adheres to [Semantic Versioning](https://semver.org/spec/v2
- New Sending, Success, Failure, and GrpcFailure subscreens of the Send Confirmation screen have been added
- New Copy Transaction IDs feature has been added to the MultipleTransactionFailure screen

### Changelog
### Changed
- Shielded transactions are properly indicated in transaction history
- The in-app update logic has been fixed and is now correctly requested with every app launch
- The Not enough space and In-app udpate screens have been redesigned
- External links now open in in-app browser

### Fixed
- Address book toast now correctly shows on send screen when adding both new and known addresses to text field
Expand Down
3 changes: 2 additions & 1 deletion docs/whatsNew/WHATS_NEW_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ directly impact users rather than highlighting other key architectural updates.*
- New Sending, Success, Failure, and GrpcFailure subscreens of the Send Confirmation screen have been added
- New Copy Transaction IDs feature has been added to the MultipleTransactionFailure screen

### Changelog
### Changed
- Shielded transactions are properly indicated in transaction history
- The in-app update logic has been fixed and is now correctly requested with every app launch
- The Not enough space and In-app udpate screens have been redesigned
- External links now open in in-app browser

### Fixed
- Address book toast now correctly shows on send screen when adding both new and known addresses to text field
Expand Down
3 changes: 2 additions & 1 deletion docs/whatsNew/WHATS_NEW_ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ directly impact users rather than highlighting other key architectural updates.*
- New Sending, Success, Failure, and GrpcFailure subscreens of the Send Confirmation screen have been added
- New Copy Transaction IDs feature has been added to the MultipleTransactionFailure screen

### Changelog
### Changed
- Shielded transactions are properly indicated in transaction history
- The in-app update logic has been fixed and is now correctly requested with every app launch
- The Not enough space and In-app udpate screens have been redesigned
- External links now open in in-app browser

### Fixed
- Address book toast now correctly shows on send screen when adding both new and known addresses to text field
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

package co.electriccoin.zcash.ui.screen.about

import android.content.Context
import android.app.Activity
import androidx.activity.compose.BackHandler
import androidx.compose.material3.SnackbarHostState
import androidx.compose.runtime.Composable
Expand Down Expand Up @@ -57,7 +57,7 @@ internal fun WrapAbout(
configInfo = configInfo,
onPrivacyPolicy = {
openPrivacyPolicyInWebBrowser(
activity.applicationContext,
activity,
snackbarHostState,
scope
)
Expand All @@ -69,17 +69,16 @@ internal fun WrapAbout(
}

fun openPrivacyPolicyInWebBrowser(
context: Context,
activity: Activity,
snackbarHostState: SnackbarHostState,
scope: CoroutineScope
) {
val storeIntent = WebBrowserUtil.newActivityIntent(WebBrowserUtil.ZCASH_PRIVACY_POLICY_URI)
runCatching {
context.startActivity(storeIntent)
WebBrowserUtil.startActivity(activity, WebBrowserUtil.ZCASH_PRIVACY_POLICY_URI)
}.onFailure {
scope.launch {
snackbarHostState.showSnackbar(
message = context.getString(R.string.about_unable_to_web_browser)
message = activity.getString(R.string.about_unable_to_web_browser)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
package co.electriccoin.zcash.ui.screen.about.util

import android.content.Intent
import android.app.Activity
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent

object WebBrowserUtil {
const val FLAGS =
Intent.FLAG_ACTIVITY_NO_HISTORY or
Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_MULTIPLE_TASK

const val ZCASH_PRIVACY_POLICY_URI = "https://electriccoin.co/zashi-privacy-policy/" // NON-NLS

/**
* Returns new action view app intent. We assume the a web browser app is installed.
*
* @param url The webpage url to open
*
* @return Intent for launching in a browser app.
*/
internal fun newActivityIntent(url: String): Intent {
val storeUri = Uri.parse(url)
val storeIntent = Intent(Intent.ACTION_VIEW, storeUri)

// To properly handle the browser backstack while navigate back to our app
storeIntent.addFlags(FLAGS)

return storeIntent
internal fun startActivity(
activity: Activity,
url: String
) {
val intent =
CustomTabsIntent.Builder()
.setUrlBarHidingEnabled(true)
.setShowTitle(true)
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)
.build()
intent.launchUrl(activity, Uri.parse(url))
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package co.electriccoin.zcash.ui.screen.integrations

import android.net.Uri
import androidx.activity.compose.BackHandler
import androidx.browser.customtabs.CustomTabsIntent
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand All @@ -11,6 +9,7 @@ import co.electriccoin.zcash.di.koinActivityViewModel
import co.electriccoin.zcash.ui.common.compose.LocalActivity
import co.electriccoin.zcash.ui.common.compose.LocalNavController
import co.electriccoin.zcash.ui.common.viewmodel.WalletViewModel
import co.electriccoin.zcash.ui.screen.about.util.WebBrowserUtil
import co.electriccoin.zcash.ui.screen.integrations.view.Integrations
import co.electriccoin.zcash.ui.screen.integrations.viewmodel.IntegrationsViewModel
import com.flexa.core.Flexa
Expand All @@ -34,13 +33,7 @@ internal fun WrapIntegrations() {

LaunchedEffect(Unit) {
viewModel.coinbaseNavigationCommand.collect { uri ->
val intent =
CustomTabsIntent.Builder()
.setUrlBarHidingEnabled(true)
.setShowTitle(true)
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)
.build()
intent.launchUrl(activity, Uri.parse(uri))
WebBrowserUtil.startActivity(activity, uri)
}
}

Expand Down

0 comments on commit af5ed30

Please sign in to comment.