diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2023-09-04 13:05:02 +0200 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2023-09-06 14:44:43 +0200 |
| commit | 2f4dff85ed1af96ba8c307f0f6a4d35a31391b29 (patch) | |
| tree | 0465407c636d9145ea6c3d539501ef72e3734c06 /android/app/src | |
| parent | 9786122e86daed287c6e9f9f233301e8d4524789 (diff) | |
| download | mullvadvpn-2f4dff85ed1af96ba8c307f0f6a4d35a31391b29.tar.xz mullvadvpn-2f4dff85ed1af96ba8c307f0f6a4d35a31391b29.zip | |
Remove unused code related to list item view
Diffstat (limited to 'android/app/src')
15 files changed, 0 insertions, 484 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/ActionListItemView.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/ActionListItemView.kt deleted file mode 100644 index e80807427b..0000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/ActionListItemView.kt +++ /dev/null @@ -1,120 +0,0 @@ -package net.mullvad.mullvadvpn.ui.listitemview - -import android.content.Context -import android.content.res.Resources -import android.util.AttributeSet -import android.view.View.OnClickListener -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.TextView -import androidx.core.view.isVisible -import net.mullvad.mullvadvpn.R -import net.mullvad.mullvadvpn.ui.widget.WidgetState - -open class ActionListItemView -@JvmOverloads -constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = R.attr.actionListItemViewStyle, - defStyleRes: Int = 0 -) : ListItemView(context, attrs, defStyleAttr, defStyleRes) { - - protected var widgetController: WidgetViewController<*>? = null - protected val itemText: TextView = findViewById(R.id.itemText) - protected val itemIcon: ImageView = findViewById(R.id.itemIcon) - protected val widgetContainer: ViewGroup = findViewById(R.id.widgetContainer) - - protected val clickListener = OnClickListener { - itemData.action?.let { _ -> listItemListener?.onItemAction(itemData) } - } - - override val layoutRes: Int - get() = R.layout.list_item_action - - override val heightRes: Int - get() = R.dimen.cell_height - - override fun onUpdate() { - updateImage() - updateText() - updateWidget() - updateAction() - } - - protected open fun updateImage() { - try { - itemData.iconRes?.let { - itemIcon.isVisible = true - itemIcon.setImageResource(it) - return - } - } catch (ignore: Resources.NotFoundException) { - itemIcon.isVisible = true - itemIcon.setImageResource(R.drawable.ic_icons_missing) - return - } - - itemIcon.isVisible = false - itemIcon.setImageDrawable(null) - } - - protected open fun updateText() { - itemData.textRes?.let { - itemText.setText(it) - return - } - itemData.text?.let { - itemText.setText(it) - return - } - itemText.text = "" - } - - protected open fun updateAction() { - if (itemData.action == null) { - setOnClickListener(null) - isClickable = false - isFocusable = false - } else { - setOnClickListener(clickListener) - isClickable = true - isFocusable = true - } - } - - protected open fun updateWidget() { - itemData.widget.let { state -> - when (state) { - is WidgetState.ImageState -> { - if (widgetController !is WidgetViewController.StandardController) { - widgetContainer.removeAllViews() - widgetContainer.isVisible = true - widgetController = WidgetViewController.StandardController(widgetContainer) - } - (widgetController as WidgetViewController.StandardController).updateState(state) - } - is WidgetState.SwitchState -> { - if (widgetController !is WidgetViewController.SwitchController) { - widgetContainer.removeAllViews() - widgetContainer.isVisible = true - widgetController = WidgetViewController.SwitchController(widgetContainer) - } - (widgetController as WidgetViewController.SwitchController).updateState(state) - } - null -> { - if (widgetController != null) { - widgetController = null - widgetContainer.removeAllViews() - widgetContainer.isVisible = false - } - } - } - } - } - - override fun onAttachedToWindow() { - super.onAttachedToWindow() - widgetContainer.requestLayout() - } -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/DividerGroupListItemView.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/DividerGroupListItemView.kt deleted file mode 100644 index 61bb5bf400..0000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/DividerGroupListItemView.kt +++ /dev/null @@ -1,15 +0,0 @@ -package net.mullvad.mullvadvpn.ui.listitemview - -import android.content.Context -import androidx.appcompat.view.ContextThemeWrapper -import net.mullvad.mullvadvpn.R - -class DividerGroupListItemView(context: Context) : - ListItemView(ContextThemeWrapper(context, R.style.ListItem_DividerGroup)) { - - override val layoutRes: Int - get() = R.layout.list_item_group_divider - - override val heightRes: Int - get() = R.dimen.vertical_space -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/ListItemView.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/ListItemView.kt deleted file mode 100644 index 981d6d0813..0000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/ListItemView.kt +++ /dev/null @@ -1,43 +0,0 @@ -package net.mullvad.mullvadvpn.ui.listitemview - -import android.content.Context -import android.util.AttributeSet -import android.view.LayoutInflater -import androidx.annotation.DimenRes -import androidx.annotation.LayoutRes -import androidx.constraintlayout.widget.ConstraintLayout -import net.mullvad.mullvadvpn.applist.ListItemData -import net.mullvad.mullvadvpn.ui.ListItemListener - -abstract class ListItemView -@JvmOverloads -constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0, - defStyleRes: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr, defStyleRes) { - @get:LayoutRes protected abstract val layoutRes: Int - - @get:DimenRes protected abstract val heightRes: Int? - protected lateinit var itemData: ListItemData - var listItemListener: ListItemListener? = null - - init { - val view = LayoutInflater.from(context).inflate(layoutRes, this, true) - val height = - if (heightRes != null) { - resources.getDimensionPixelSize(heightRes!!) - } else { - LayoutParams.WRAP_CONTENT - } - view.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, height) - } - - fun update(data: ListItemData) { - itemData = data - onUpdate() - } - - protected open fun onUpdate() {} -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/PlainListItemView.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/PlainListItemView.kt deleted file mode 100644 index b0553619f9..0000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/PlainListItemView.kt +++ /dev/null @@ -1,31 +0,0 @@ -package net.mullvad.mullvadvpn.ui.listitemview - -import android.content.Context -import android.widget.TextView -import androidx.appcompat.view.ContextThemeWrapper -import net.mullvad.mullvadvpn.R - -class PlainListItemView(context: Context) : - ListItemView(ContextThemeWrapper(context, R.style.ListItem_PlainText)) { - override val layoutRes: Int - get() = R.layout.list_item_plain_text - - override val heightRes: Int? = null - private val plainText: TextView = findViewById(R.id.plain_text) - - override fun onUpdate() { - updateText() - } - - private fun updateText() { - itemData.textRes?.let { - plainText.setText(it) - return - } - itemData.text?.let { - plainText.text = it - return - } - plainText.text = "" - } -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/ProgressListItemView.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/ProgressListItemView.kt deleted file mode 100644 index 724caf0c61..0000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/ProgressListItemView.kt +++ /dev/null @@ -1,15 +0,0 @@ -package net.mullvad.mullvadvpn.ui.listitemview - -import android.content.Context -import androidx.appcompat.view.ContextThemeWrapper -import net.mullvad.mullvadvpn.R - -class ProgressListItemView(context: Context) : - ListItemView(ContextThemeWrapper(context, R.style.ListItem_DividerGroup)) { - - override val layoutRes: Int - get() = R.layout.list_item_progress - - override val heightRes: Int - get() = R.dimen.progress_size -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/TwoActionListItemView.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/TwoActionListItemView.kt deleted file mode 100644 index ffe6d0ae89..0000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/TwoActionListItemView.kt +++ /dev/null @@ -1,34 +0,0 @@ -package net.mullvad.mullvadvpn.ui.listitemview - -import android.content.Context -import android.view.ViewGroup -import androidx.appcompat.view.ContextThemeWrapper -import net.mullvad.mullvadvpn.R - -class TwoActionListItemView(context: Context) : - ActionListItemView(ContextThemeWrapper(context, R.style.ListItem_Action_Double)) { - override val layoutRes: Int - get() = R.layout.list_item_two_action - - private val container: ViewGroup = findViewById(R.id.container_without_widget) - - init { - isClickable = false - isFocusable = false - } - - override fun updateAction() { - if (itemData.action == null) { - container.setOnClickListener(null) - container.isClickable = false - container.isFocusable = false - } else { - container.setOnClickListener(clickListener) - container.isClickable = true - container.isFocusable = true - } - widgetContainer.setOnClickListener(clickListener) - widgetContainer.isClickable = true - widgetContainer.isFocusable = true - } -} diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/WidgetViewController.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/WidgetViewController.kt deleted file mode 100644 index 62325b4e1d..0000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/listitemview/WidgetViewController.kt +++ /dev/null @@ -1,42 +0,0 @@ -package net.mullvad.mullvadvpn.ui.listitemview - -import android.view.LayoutInflater -import android.view.ViewGroup -import android.widget.ImageView -import androidx.annotation.LayoutRes -import androidx.appcompat.widget.SwitchCompat -import net.mullvad.mullvadvpn.R -import net.mullvad.mullvadvpn.ui.widget.WidgetState - -sealed class WidgetViewController<T : WidgetState>(val parent: ViewGroup) { - @get:LayoutRes protected abstract val layoutRes: Int - - init { - LayoutInflater.from(parent.context).inflate(layoutRes, parent) - } - - abstract fun updateState(state: T) - - class StandardController(parent: ViewGroup) : - WidgetViewController<WidgetState.ImageState>(parent) { - override val layoutRes: Int - get() = R.layout.list_item_widget_image - - private val imageView: ImageView = parent.findViewById(R.id.widgetImage) - - override fun updateState(state: WidgetState.ImageState) = - imageView.setImageResource(state.imageRes) - } - - class SwitchController(parent: ViewGroup) : - WidgetViewController<WidgetState.SwitchState>(parent) { - override val layoutRes: Int - get() = R.layout.list_item_widget_switch - - private val switch: SwitchCompat = parent.findViewById(R.id.widgetSwitch) - - override fun updateState(state: WidgetState.SwitchState) { - switch.isChecked = state.isChecked - } - } -} diff --git a/android/app/src/main/res/layout/list_item_action.xml b/android/app/src/main/res/layout/list_item_action.xml deleted file mode 100644 index 9b9fc806f0..0000000000 --- a/android/app/src/main/res/layout/list_item_action.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - style="@style/ListItem.Action" - tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> - <include layout="@layout/list_item_base" /> - <FrameLayout android:id="@+id/widgetContainer" - android:layout_width="wrap_content" - android:layout_height="0dp" - android:paddingStart="@dimen/widget_padding" - android:paddingEnd="@dimen/widget_padding" - android:visibility="invisible" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toEndOf="@id/itemText" - app:layout_constraintTop_toTopOf="parent" /> - <androidx.constraintlayout.widget.Guideline android:id="@+id/endGuideline" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_end="@dimen/cell_right_padding" /> - <androidx.constraintlayout.widget.Barrier android:id="@+id/widgetBarrier" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:barrierDirection="start" - app:constraint_referenced_ids="widgetContainer,endGuideline" /> -</merge> diff --git a/android/app/src/main/res/layout/list_item_base.xml b/android/app/src/main/res/layout/list_item_base.xml deleted file mode 100644 index 0c22feef21..0000000000 --- a/android/app/src/main/res/layout/list_item_base.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="@dimen/cell_height" - tools:background="@color/green" - tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> - <androidx.appcompat.widget.AppCompatImageView android:id="@+id/itemIcon" - android:layout_width="@dimen/icon_size" - android:layout_height="@dimen/icon_size" - android:layout_marginEnd="@dimen/cell_inner_spacing" - android:background="@null" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@id/itemText" - app:layout_constraintStart_toStartOf="@id/startGuideline" - app:layout_constraintTop_toTopOf="parent" - tools:visibility="gone" - tools:src="@drawable/launch_logo" /> - <androidx.appcompat.widget.AppCompatTextView android:id="@+id/itemText" - android:layout_width="0dp" - android:layout_height="match_parent" - android:gravity="center_vertical" - android:textAppearance="@style/TextAppearance.Mullvad.Title1" - android:textStyle="bold" - android:background="@null" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@id/widgetBarrier" - app:layout_constraintStart_toEndOf="@id/itemIcon" - app:layout_constraintTop_toTopOf="parent" - tools:background="@color/white20" - tools:text="WireGuard MTU" /> - <androidx.constraintlayout.widget.Guideline android:id="@+id/startGuideline" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_begin="@dimen/screen_vertical_margin" /> - <androidx.constraintlayout.widget.Barrier android:id="@+id/widgetBarrier" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:tag="base" - app:barrierDirection="start" - app:constraint_referenced_ids="parent" /> -</merge> diff --git a/android/app/src/main/res/layout/list_item_group_divider.xml b/android/app/src/main/res/layout/list_item_group_divider.xml deleted file mode 100644 index 9546d55c98..0000000000 --- a/android/app/src/main/res/layout/list_item_group_divider.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="@dimen/vertical_space" - tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout" /> diff --git a/android/app/src/main/res/layout/list_item_plain_text.xml b/android/app/src/main/res/layout/list_item_plain_text.xml deleted file mode 100644 index f17bc6ed5e..0000000000 --- a/android/app/src/main/res/layout/list_item_plain_text.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="wrap_content" - tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> - <androidx.appcompat.widget.AppCompatTextView android:id="@+id/plain_text" - android:layout_width="0dp" - android:layout_height="wrap_content" - android:paddingTop="0dp" - android:paddingBottom="0dp" - android:textAppearance="@style/TextAppearance.Mullvad.Small" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="@id/endGuideline" - app:layout_constraintStart_toStartOf="@id/startGuideline" - app:layout_constraintTop_toTopOf="parent" - tools:text="Choose the apps you want to exclude from the VPN tunnel." /> - <androidx.constraintlayout.widget.Guideline android:id="@+id/startGuideline" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_begin="@dimen/screen_vertical_margin" /> - <androidx.constraintlayout.widget.Guideline android:id="@+id/endGuideline" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_end="@dimen/screen_vertical_margin" /> -</merge> diff --git a/android/app/src/main/res/layout/list_item_progress.xml b/android/app/src/main/res/layout/list_item_progress.xml deleted file mode 100644 index 221947ea85..0000000000 --- a/android/app/src/main/res/layout/list_item_progress.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> - <ProgressBar android:id="@+id/loading_spinner" - android:layout_width="@dimen/progress_size" - android:layout_height="@dimen/progress_size" - android:indeterminate="true" - android:indeterminateDrawable="@drawable/icon_spinner" - android:indeterminateDuration="600" - android:indeterminateOnly="true" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> -</merge> diff --git a/android/app/src/main/res/layout/list_item_two_action.xml b/android/app/src/main/res/layout/list_item_two_action.xml deleted file mode 100644 index 81e6a5c652..0000000000 --- a/android/app/src/main/res/layout/list_item_two_action.xml +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<merge xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="@dimen/cell_height" - tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> - <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/container_without_widget" - android:layout_width="0dp" - android:layout_height="0dp" - android:background="?android:attr/selectableItemBackground" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@id/widgetBarrier" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent"> - <include layout="@layout/list_item_base" /> - </androidx.constraintlayout.widget.ConstraintLayout> - <FrameLayout android:id="@+id/widgetContainer" - android:layout_width="wrap_content" - android:layout_height="0dp" - android:background="?android:attr/selectableItemBackground" - android:paddingStart="@dimen/widget_padding" - android:paddingEnd="@dimen/widget_padding" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - android:visibility="visible" - app:layout_constraintStart_toEndOf="@id/container_without_widget" - app:layout_constraintTop_toTopOf="parent" /> - <androidx.constraintlayout.widget.Guideline android:id="@+id/endGuideline" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - app:layout_constraintGuide_end="@dimen/cell_right_padding" /> - <androidx.constraintlayout.widget.Barrier android:id="@+id/widgetBarrier" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:barrierDirection="start" - app:constraint_referenced_ids="widgetContainer,endGuideline" /> -</merge> diff --git a/android/app/src/main/res/layout/list_item_widget_image.xml b/android/app/src/main/res/layout/list_item_widget_image.xml deleted file mode 100644 index 95034e46e3..0000000000 --- a/android/app/src/main/res/layout/list_item_widget_image.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.appcompat.widget.AppCompatImageView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/widgetImage" - android:layout_width="@dimen/icon_size" - android:layout_height="@dimen/icon_size" - android:layout_gravity="center" - android:tint="@color/white40" - android:tintMode="multiply" - tools:src="@drawable/icon_extlink" /> diff --git a/android/app/src/main/res/layout/list_item_widget_switch.xml b/android/app/src/main/res/layout/list_item_widget_switch.xml deleted file mode 100644 index 9c4e342660..0000000000 --- a/android/app/src/main/res/layout/list_item_widget_switch.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<androidx.appcompat.widget.SwitchCompat xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/widgetSwitch" - style="@style/AppTheme.Switch" - android:layout_gravity="center" - android:clickable="false" - android:focusable="false" - android:background="@null" - android:focusableInTouchMode="false" - tools:checked="false" /> |
