diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-02-08 21:52:27 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2021-02-11 17:51:24 +0000 |
| commit | 09262822872a5100902cefcdd5dc16d745d58310 (patch) | |
| tree | 9bb295b898db500507276c7da72fbdc9a148be55 /android | |
| parent | 13263d0857321c5106190435a67eb32155d5a870 (diff) | |
| download | mullvadvpn-09262822872a5100902cefcdd5dc16d745d58310.tar.xz mullvadvpn-09262822872a5100902cefcdd5dc16d745d58310.zip | |
Refactor `AppVersionCell` to sub-class `UrlCell`
Diffstat (limited to 'android')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AppVersionCell.kt | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AppVersionCell.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AppVersionCell.kt index f3508847d1..978a8b1505 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AppVersionCell.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AppVersionCell.kt @@ -1,7 +1,6 @@ package net.mullvad.mullvadvpn.ui.widget import android.content.Context -import android.content.Intent import android.graphics.Typeface import android.net.Uri import android.util.AttributeSet @@ -12,7 +11,7 @@ import android.widget.TextView import kotlin.properties.Delegates.observable import net.mullvad.mullvadvpn.R -class AppVersionCell : Cell { +class AppVersionCell : UrlCell { private val warningIcon = ImageView(context).apply { val iconSize = resources.getDimensionPixelSize(R.dimen.app_version_warning_icon_size) @@ -40,13 +39,6 @@ class AppVersionCell : Cell { text = "" } - 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 updateAvailable by observable(false) { _, _, updateAvailable -> if (updateAvailable) { warningIcon.visibility = VISIBLE @@ -61,32 +53,20 @@ class AppVersionCell : Cell { versionLabel.text = version } - constructor(context: Context) : super(context) {} - - constructor(context: Context, attributes: AttributeSet) : super(context, attributes) {} - - constructor(context: Context, attributes: AttributeSet, defaultStyleAttribute: Int) : - super(context, attributes, defaultStyleAttribute) {} - + @JvmOverloads constructor( context: Context, - attributes: AttributeSet, - defaultStyleAttribute: Int, - defaultStyleResource: Int + attributes: AttributeSet? = null, + defaultStyleAttribute: Int = 0, + defaultStyleResource: Int = 0 ) : super(context, attributes, defaultStyleAttribute, defaultStyleResource) {} init { cell.addView(warningIcon, 0) - cell.addView(versionLabel) - cell.addView(externalLinkIcon) - - onClickListener = { openLink() } - } + cell.addView(versionLabel, cell.getChildCount() - 1) - private fun openLink() { - val url = context.getString(R.string.download_url) - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) - - context.startActivity(intent) + if (url == null) { + url = Uri.parse(context.getString(R.string.download_url)) + } } } |
