summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2023-07-19 15:59:09 +0200
committerAlbin <albin@mullvad.net>2023-07-19 15:59:09 +0200
commita9d3ab4ad5a639fb85b46f1705f8477a18e88b91 (patch)
treebb41e9ec20bb1c0218d323b9a677f4ad8b283a83 /android
parent1ec1b9347c9f9703cc6a27f2f56722fdc2ab27d0 (diff)
parentd6abf963242ae7f0864720e29a1dbbfd5bda1936 (diff)
downloadmullvadvpn-a9d3ab4ad5a639fb85b46f1705f8477a18e88b91.tar.xz
mullvadvpn-a9d3ab4ad5a639fb85b46f1705f8477a18e88b91.zip
Merge branch 'port-download-link-removal-to-main-droid-209'
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt4
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt20
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrl.kt5
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/VersionInfoNotification.kt5
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AppVersionCell.kt74
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NavigateCell.kt57
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlCell.kt55
7 files changed, 28 insertions, 192 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt
index 3edab0bb77..3bb06a35b3 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/cell/NavigationComposeCell.kt
@@ -60,6 +60,7 @@ fun NavigationComposeCell(
modifier: Modifier = Modifier,
showWarning: Boolean = false,
bodyView: @Composable () -> Unit = { DefaultNavigationView(chevronContentDescription = title) },
+ isRowEnabled: Boolean = true,
onClick: () -> Unit
) {
BaseCell(
@@ -67,7 +68,8 @@ fun NavigationComposeCell(
title = {
NavigationTitleView(title = title, modifier = modifier, showWarning = showWarning)
},
- bodyView = { bodyView() }
+ bodyView = { bodyView() },
+ isRowEnabled = isRowEnabled
)
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt
index 54f3223360..d0b460633b 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt
@@ -127,13 +127,23 @@ fun SettingsScreen(
},
bodyView =
@Composable {
- NavigationCellBody(
- content = uiState.appVersion,
- contentBodyDescription = stringResource(id = R.string.app_version),
- isExternalLink = true,
- )
+ if (BuildConfig.BUILD_TYPE != BuildTypes.RELEASE) {
+ NavigationCellBody(
+ content = uiState.appVersion,
+ contentBodyDescription =
+ stringResource(id = R.string.app_version),
+ isExternalLink = true,
+ )
+ } else {
+ Text(
+ text = uiState.appVersion,
+ style = MaterialTheme.typography.labelMedium,
+ color = MaterialTheme.colorScheme.onSecondary
+ )
+ }
},
showWarning = uiState.isUpdateAvailable,
+ isRowEnabled = BuildConfig.BUILD_TYPE != BuildTypes.RELEASE
)
}
if (uiState.isUpdateAvailable) {
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrl.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrl.kt
index cd0b0564ec..ea36973660 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrl.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/NotificationWithUrl.kt
@@ -18,4 +18,9 @@ abstract class NotificationWithUrl(protected val context: Context, urlString: St
onClick = openUrl
showIcon = true
}
+
+ internal fun disableExternalLink() {
+ showIcon = false
+ onClick = null
+ }
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/VersionInfoNotification.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/VersionInfoNotification.kt
index 862c59400d..c37b5e5220 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/VersionInfoNotification.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/notification/VersionInfoNotification.kt
@@ -1,7 +1,9 @@
package net.mullvad.mullvadvpn.ui.notification
import android.content.Context
+import net.mullvad.mullvadvpn.BuildConfig
import net.mullvad.mullvadvpn.R
+import net.mullvad.mullvadvpn.constant.BuildTypes
import net.mullvad.mullvadvpn.ui.VersionInfo
import net.mullvad.mullvadvpn.util.appendHideNavOnReleaseBuild
@@ -39,6 +41,9 @@ class VersionInfoNotification(val isEnabled: Boolean, context: Context) :
}
shouldShow = true
+ if (BuildConfig.BUILD_TYPE == BuildTypes.RELEASE) {
+ disableExternalLink()
+ }
} else {
shouldShow = false
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AppVersionCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AppVersionCell.kt
deleted file mode 100644
index 9c656f2471..0000000000
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AppVersionCell.kt
+++ /dev/null
@@ -1,74 +0,0 @@
-package net.mullvad.mullvadvpn.ui.widget
-
-import android.content.Context
-import android.graphics.Typeface
-import android.net.Uri
-import android.util.AttributeSet
-import android.util.TypedValue
-import android.view.Gravity
-import android.widget.ImageView
-import android.widget.TextView
-import kotlin.properties.Delegates.observable
-import net.mullvad.mullvadvpn.R
-import net.mullvad.mullvadvpn.util.appendHideNavOnReleaseBuild
-
-class AppVersionCell : UrlCell {
- private val warningIcon =
- ImageView(context).apply {
- val iconSize = resources.getDimensionPixelSize(R.dimen.app_version_warning_icon_size)
-
- layoutParams = LayoutParams(iconSize, iconSize, 0.0f)
-
- resources.getDimensionPixelSize(R.dimen.cell_inner_spacing).let { padding ->
- setPadding(0, 0, padding, 0)
- }
-
- setImageResource(R.drawable.icon_alert)
- }
-
- private val versionLabel =
- TextView(context).apply {
- layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0.0f)
- gravity = Gravity.RIGHT
-
- resources.getDimensionPixelSize(R.dimen.cell_inner_spacing).let { padding ->
- setPadding(padding, 0, padding, 0)
- }
-
- setTextColor(context.getColor(R.color.white60))
- setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.text_small))
- setTypeface(null, Typeface.BOLD)
-
- text = ""
- }
-
- var updateAvailable by
- observable(false) { _, _, updateAvailable ->
- if (updateAvailable) {
- warningIcon.visibility = VISIBLE
- footer?.visibility = VISIBLE
- } else {
- warningIcon.visibility = GONE
- footer?.visibility = GONE
- }
- }
-
- var version by observable("") { _, _, version -> versionLabel.text = version }
-
- @JvmOverloads
- constructor(
- context: Context,
- attributes: AttributeSet? = null,
- defaultStyleAttribute: Int = 0,
- defaultStyleResource: Int = 0
- ) : super(context, attributes, defaultStyleAttribute, defaultStyleResource)
-
- init {
- cell.addView(warningIcon, 0)
- cell.addView(versionLabel, cell.getChildCount() - 1)
-
- if (url == null) {
- url = Uri.parse(context.getString(R.string.download_url).appendHideNavOnReleaseBuild())
- }
- }
-}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NavigateCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NavigateCell.kt
deleted file mode 100644
index ee1901774a..0000000000
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/NavigateCell.kt
+++ /dev/null
@@ -1,57 +0,0 @@
-package net.mullvad.mullvadvpn.ui.widget
-
-import android.content.Context
-import android.util.AttributeSet
-import android.widget.ImageView
-import androidx.fragment.app.Fragment
-import androidx.fragment.app.FragmentActivity
-import kotlin.reflect.KClass
-import net.mullvad.mullvadvpn.R
-
-open class NavigateCell : Cell {
- private val chevron =
- ImageView(context).apply {
- val width = resources.getDimensionPixelSize(R.dimen.chevron_width)
- val height = resources.getDimensionPixelSize(R.dimen.chevron_height)
-
- layoutParams = LayoutParams(width, height, 0.0f)
- alpha = 0.6f
-
- setImageResource(R.drawable.icon_chevron)
- }
-
- var targetFragment: KClass<out Fragment>? = null
-
- constructor(context: Context) : super(context)
-
- constructor(context: Context, attributes: AttributeSet) : super(context, attributes)
-
- constructor(
- context: Context,
- attributes: AttributeSet,
- defaultStyleAttribute: Int
- ) : super(context, attributes, defaultStyleAttribute)
-
- init {
- cell.addView(chevron)
- onClickListener = { openSubFragment() }
- }
-
- private fun openSubFragment() {
- targetFragment?.let { fragmentClass ->
- val fragment = fragmentClass.java.getConstructor().newInstance()
-
- (context as? FragmentActivity)?.supportFragmentManager?.beginTransaction()?.apply {
- setCustomAnimations(
- R.anim.fragment_enter_from_right,
- R.anim.fragment_exit_to_left,
- R.anim.fragment_half_enter_from_left,
- R.anim.fragment_exit_to_right
- )
- replace(R.id.main_fragment, fragment)
- addToBackStack(null)
- commitAllowingStateLoss()
- }
- }
- }
-}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlCell.kt
deleted file mode 100644
index d562e1dc79..0000000000
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/UrlCell.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-package net.mullvad.mullvadvpn.ui.widget
-
-import android.content.Context
-import android.content.Intent
-import android.net.Uri
-import android.util.AttributeSet
-import android.widget.ImageView
-import net.mullvad.mullvadvpn.R
-import net.mullvad.mullvadvpn.util.appendHideNavOnReleaseBuild
-
-open class UrlCell : Cell {
- private val externalLinkIcon =
- ImageView(context).apply {
- layoutParams = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0.0f)
- alpha = 0.6f
-
- setImageResource(R.drawable.icon_extlink)
- }
-
- var url: Uri? = null
-
- @JvmOverloads
- constructor(
- context: Context,
- attributes: AttributeSet? = null,
- defaultStyleAttribute: Int = 0,
- defaultStyleResource: Int = 0
- ) : super(context, attributes, defaultStyleAttribute, defaultStyleResource) {
- loadAttributes(attributes)
-
- cell.addView(externalLinkIcon)
-
- onClickListener = { openLink() }
- }
-
- private fun loadAttributes(attributes: AttributeSet?) {
- context.theme.obtainStyledAttributes(attributes, R.styleable.Url, 0, 0).apply {
- try {
- getString(R.styleable.Url_url)?.let { urlString ->
- url = Uri.parse(urlString.appendHideNavOnReleaseBuild())
- }
- } finally {
- recycle()
- }
- }
- }
-
- private fun openLink() {
- url?.let { url ->
- val intent = Intent(Intent.ACTION_VIEW, url)
-
- context.startActivity(intent)
- }
- }
-}