Application-wide in-app browser for all urls (#1674)
* Application-wide in-app browser for all urls * Changelog entries fixed --------- Co-authored-by: Honza <rychnovsky.honza@gmail.com>
This commit is contained in:
parent
d4be4a5dda
commit
af5ed30e8a
|
@ -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 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
|
- New Copy Transaction IDs feature has been added to the MultipleTransactionFailure screen
|
||||||
|
|
||||||
### Changelog
|
### Changed
|
||||||
- Shielded transactions are properly indicated in transaction history
|
- 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 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
|
- The Not enough space and In-app udpate screens have been redesigned
|
||||||
|
- External links now open in in-app browser
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Address book toast now correctly shows on send screen when adding both new and known addresses to text field
|
- Address book toast now correctly shows on send screen when adding both new and known addresses to text field
|
||||||
|
|
|
@ -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 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
|
- New Copy Transaction IDs feature has been added to the MultipleTransactionFailure screen
|
||||||
|
|
||||||
### Changelog
|
### Changed
|
||||||
- Shielded transactions are properly indicated in transaction history
|
- 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 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
|
- The Not enough space and In-app udpate screens have been redesigned
|
||||||
|
- External links now open in in-app browser
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Address book toast now correctly shows on send screen when adding both new and known addresses to text field
|
- Address book toast now correctly shows on send screen when adding both new and known addresses to text field
|
||||||
|
|
|
@ -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 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
|
- New Copy Transaction IDs feature has been added to the MultipleTransactionFailure screen
|
||||||
|
|
||||||
### Changelog
|
### Changed
|
||||||
- Shielded transactions are properly indicated in transaction history
|
- 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 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
|
- The Not enough space and In-app udpate screens have been redesigned
|
||||||
|
- External links now open in in-app browser
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Address book toast now correctly shows on send screen when adding both new and known addresses to text field
|
- Address book toast now correctly shows on send screen when adding both new and known addresses to text field
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package co.electriccoin.zcash.ui.screen.about.util
|
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import androidx.test.filters.SmallTest
|
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Test
|
|
||||||
import kotlin.test.assertContains
|
|
||||||
|
|
||||||
class WebBrowserUtilTest {
|
|
||||||
@Test
|
|
||||||
@SmallTest
|
|
||||||
fun check_intent_for_web_browser() {
|
|
||||||
val intent = WebBrowserUtil.newActivityIntent(WebBrowserUtil.ZCASH_PRIVACY_POLICY_URI)
|
|
||||||
assertEquals(intent.action, Intent.ACTION_VIEW)
|
|
||||||
assertEquals(WebBrowserUtil.FLAGS, intent.flags)
|
|
||||||
assertContains(WebBrowserUtil.ZCASH_PRIVACY_POLICY_URI, intent.data.toString())
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package co.electriccoin.zcash.ui.screen.about
|
package co.electriccoin.zcash.ui.screen.about
|
||||||
|
|
||||||
import android.content.Context
|
import android.app.Activity
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.material3.SnackbarHostState
|
import androidx.compose.material3.SnackbarHostState
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
@ -57,7 +57,7 @@ internal fun WrapAbout(
|
||||||
configInfo = configInfo,
|
configInfo = configInfo,
|
||||||
onPrivacyPolicy = {
|
onPrivacyPolicy = {
|
||||||
openPrivacyPolicyInWebBrowser(
|
openPrivacyPolicyInWebBrowser(
|
||||||
activity.applicationContext,
|
activity,
|
||||||
snackbarHostState,
|
snackbarHostState,
|
||||||
scope
|
scope
|
||||||
)
|
)
|
||||||
|
@ -69,17 +69,16 @@ internal fun WrapAbout(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun openPrivacyPolicyInWebBrowser(
|
fun openPrivacyPolicyInWebBrowser(
|
||||||
context: Context,
|
activity: Activity,
|
||||||
snackbarHostState: SnackbarHostState,
|
snackbarHostState: SnackbarHostState,
|
||||||
scope: CoroutineScope
|
scope: CoroutineScope
|
||||||
) {
|
) {
|
||||||
val storeIntent = WebBrowserUtil.newActivityIntent(WebBrowserUtil.ZCASH_PRIVACY_POLICY_URI)
|
|
||||||
runCatching {
|
runCatching {
|
||||||
context.startActivity(storeIntent)
|
WebBrowserUtil.startActivity(activity, WebBrowserUtil.ZCASH_PRIVACY_POLICY_URI)
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
snackbarHostState.showSnackbar(
|
snackbarHostState.showSnackbar(
|
||||||
message = context.getString(R.string.about_unable_to_web_browser)
|
message = activity.getString(R.string.about_unable_to_web_browser)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,22 @@
|
||||||
package co.electriccoin.zcash.ui.screen.about.util
|
package co.electriccoin.zcash.ui.screen.about.util
|
||||||
|
|
||||||
import android.content.Intent
|
import android.app.Activity
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import androidx.browser.customtabs.CustomTabsIntent
|
||||||
|
|
||||||
object WebBrowserUtil {
|
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
|
const val ZCASH_PRIVACY_POLICY_URI = "https://electriccoin.co/zashi-privacy-policy/" // NON-NLS
|
||||||
|
|
||||||
/**
|
internal fun startActivity(
|
||||||
* Returns new action view app intent. We assume the a web browser app is installed.
|
activity: Activity,
|
||||||
*
|
url: String
|
||||||
* @param url The webpage url to open
|
) {
|
||||||
*
|
val intent =
|
||||||
* @return Intent for launching in a browser app.
|
CustomTabsIntent.Builder()
|
||||||
*/
|
.setUrlBarHidingEnabled(true)
|
||||||
internal fun newActivityIntent(url: String): Intent {
|
.setShowTitle(true)
|
||||||
val storeUri = Uri.parse(url)
|
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)
|
||||||
val storeIntent = Intent(Intent.ACTION_VIEW, storeUri)
|
.build()
|
||||||
|
intent.launchUrl(activity, Uri.parse(url))
|
||||||
// To properly handle the browser backstack while navigate back to our app
|
|
||||||
storeIntent.addFlags(FLAGS)
|
|
||||||
|
|
||||||
return storeIntent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package co.electriccoin.zcash.ui.screen.integrations
|
package co.electriccoin.zcash.ui.screen.integrations
|
||||||
|
|
||||||
import android.net.Uri
|
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.browser.customtabs.CustomTabsIntent
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
@ -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.LocalActivity
|
||||||
import co.electriccoin.zcash.ui.common.compose.LocalNavController
|
import co.electriccoin.zcash.ui.common.compose.LocalNavController
|
||||||
import co.electriccoin.zcash.ui.common.viewmodel.WalletViewModel
|
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.view.Integrations
|
||||||
import co.electriccoin.zcash.ui.screen.integrations.viewmodel.IntegrationsViewModel
|
import co.electriccoin.zcash.ui.screen.integrations.viewmodel.IntegrationsViewModel
|
||||||
import com.flexa.core.Flexa
|
import com.flexa.core.Flexa
|
||||||
|
@ -34,13 +33,7 @@ internal fun WrapIntegrations() {
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
viewModel.coinbaseNavigationCommand.collect { uri ->
|
viewModel.coinbaseNavigationCommand.collect { uri ->
|
||||||
val intent =
|
WebBrowserUtil.startActivity(activity, uri)
|
||||||
CustomTabsIntent.Builder()
|
|
||||||
.setUrlBarHidingEnabled(true)
|
|
||||||
.setShowTitle(true)
|
|
||||||
.setShareState(CustomTabsIntent.SHARE_STATE_OFF)
|
|
||||||
.build()
|
|
||||||
intent.launchUrl(activity, Uri.parse(uri))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue