summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
authorsaber safavi <saber.safavi@codic.se>2023-07-18 16:49:31 +0200
committersaber safavi <saber.safavi@codic.se>2023-07-19 15:52:15 +0200
commit38d912fb6f7522c1e2356dac1aa23e1917b59bce (patch)
tree7240585e55295c373f13fbdc70804dd9ab95b3a2 /android/app/src
parent1ec1b9347c9f9703cc6a27f2f56722fdc2ab27d0 (diff)
downloadmullvadvpn-38d912fb6f7522c1e2356dac1aa23e1917b59bce.tar.xz
mullvadvpn-38d912fb6f7522c1e2356dac1aa23e1917b59bce.zip
Cleanup left over layouts after compose migration
Diffstat (limited to 'android/app/src')
-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
3 files changed, 0 insertions, 186 deletions
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)
- }
- }
-}