diff options
| author | Albin <albin@mullvad.net> | 2023-06-12 13:39:38 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2023-06-12 16:01:59 +0200 |
| commit | 07dd9e22c56ca090b557c0d193c929ac6cea4458 (patch) | |
| tree | 91dfe997521a4210e5189ca03f8cf054eb29ddd4 /android/app/src | |
| parent | 9b484ae51a8953022894eaab7aa493e5cde167b0 (diff) | |
| download | mullvadvpn-07dd9e22c56ca090b557c0d193c929ac6cea4458.tar.xz mullvadvpn-07dd9e22c56ca090b557c0d193c929ac6cea4458.zip | |
Remove account cell from settings
Diffstat (limited to 'android/app/src')
5 files changed, 7 insertions, 98 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/SettingsFragment.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/SettingsFragment.kt index 8db85de50d..4ebd2eff38 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/SettingsFragment.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/fragment/SettingsFragment.kt @@ -13,12 +13,10 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flatMapLatest -import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import net.mullvad.mullvadvpn.BuildConfig import net.mullvad.mullvadvpn.R import net.mullvad.mullvadvpn.model.DeviceState -import net.mullvad.mullvadvpn.repository.AccountRepository import net.mullvad.mullvadvpn.repository.DeviceRepository import net.mullvad.mullvadvpn.ui.CollapsibleTitleController import net.mullvad.mullvadvpn.ui.NavigationBarPainter @@ -29,7 +27,6 @@ import net.mullvad.mullvadvpn.ui.paintStatusBar import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionManager import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionState import net.mullvad.mullvadvpn.ui.serviceconnection.appVersionInfoCache -import net.mullvad.mullvadvpn.ui.widget.AccountCell import net.mullvad.mullvadvpn.ui.widget.AppVersionCell import net.mullvad.mullvadvpn.ui.widget.NavigateCell import net.mullvad.mullvadvpn.util.JobTracker @@ -41,11 +38,9 @@ import org.koin.android.ext.android.inject class SettingsFragment : BaseFragment(), StatusBarPainter, NavigationBarPainter { // Injected dependencies - private val accountRepository: AccountRepository by inject() private val deviceRepository: DeviceRepository by inject() private val serviceConnectionManager: ServiceConnectionManager by inject() - private lateinit var accountMenu: AccountCell private lateinit var appVersionMenu: AppVersionCell private lateinit var vpnSettingsMenu: View private lateinit var splitTunnelingMenu: View @@ -67,11 +62,6 @@ class SettingsFragment : BaseFragment(), StatusBarPainter, NavigationBarPainter view.findViewById<ImageButton>(R.id.close).setOnClickListener { activity?.onBackPressed() } - accountMenu = - view.findViewById<AccountCell>(R.id.account).apply { - targetFragment = AccountFragment::class - } - vpnSettingsMenu = view.findViewById<NavigateCell>(R.id.vpn_settings).apply { targetFragment = VpnSettingsFragment::class @@ -114,7 +104,6 @@ class SettingsFragment : BaseFragment(), StatusBarPainter, NavigationBarPainter private fun initializeUiState() { updateLoggedInStatus(deviceRepository.deviceState.value is DeviceState.LoggedIn) - accountMenu.accountExpiry = accountRepository.accountExpiryState.value.date() appVersionMenu.version = BuildConfig.VERSION_NAME serviceConnectionManager.appVersionInfoCache().let { cache -> updateVersionInfo( @@ -141,7 +130,6 @@ class SettingsFragment : BaseFragment(), StatusBarPainter, NavigationBarPainter repeatOnLifecycle(Lifecycle.State.RESUMED) { launchPaintStatusBarAfterTransition() luanchConfigureMenuOnDeviceChanges() - launchUpdateExpiryTextOnExpiryChanges() launchVersionInfoSubscription() } } @@ -158,12 +146,6 @@ class SettingsFragment : BaseFragment(), StatusBarPainter, NavigationBarPainter .collect { device -> updateLoggedInStatus(device is DeviceState.LoggedIn) } } - private fun CoroutineScope.launchUpdateExpiryTextOnExpiryChanges() = launch { - accountRepository.accountExpiryState - .map { state -> state.date() } - .collect { expiryDate -> accountMenu.accountExpiry = expiryDate } - } - private fun CoroutineScope.launchVersionInfoSubscription() = launch { serviceConnectionManager.connectionState .flatMapLatest { state -> @@ -184,7 +166,6 @@ class SettingsFragment : BaseFragment(), StatusBarPainter, NavigationBarPainter View.GONE } - accountMenu.visibility = visibility vpnSettingsMenu.visibility = visibility splitTunnelingMenu.visibility = visibility } diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountCell.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountCell.kt deleted file mode 100644 index 4a4acf737a..0000000000 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/AccountCell.kt +++ /dev/null @@ -1,70 +0,0 @@ -package net.mullvad.mullvadvpn.ui.widget - -import android.content.Context -import android.graphics.Typeface -import android.util.AttributeSet -import android.util.TypedValue -import android.view.Gravity -import android.widget.TextView -import kotlin.properties.Delegates.observable -import net.mullvad.mullvadvpn.R -import net.mullvad.mullvadvpn.util.TimeLeftFormatter -import org.joda.time.DateTime -import org.joda.time.Duration - -class AccountCell : NavigateCell { - private val formatter = TimeLeftFormatter(resources) - - private val expiredColor = context.getColor(R.color.red) - private val normalColor = context.getColor(R.color.white60) - - private val remainingTimeLabel = - 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) - } - - setAllCaps(true) - setTextColor(normalColor) - setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.text_small)) - setTypeface(null, Typeface.BOLD) - - text = "" - } - - var accountExpiry by - observable<DateTime?>(null) { _, _, expiry -> - remainingTimeLabel.apply { - if (expiry != null) { - val remainingTime = Duration(DateTime.now(), expiry) - - if (remainingTime.isShorterThan(Duration.ZERO)) { - setText(R.string.out_of_time) - setTextColor(expiredColor) - } else { - setText(formatter.format(expiry, remainingTime)) - setTextColor(normalColor) - } - } else { - text = "" - } - } - } - - 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(remainingTimeLabel, cell.childCount - 1) - } -} diff --git a/android/app/src/main/res/layout/account.xml b/android/app/src/main/res/layout/account.xml index 25c912d131..86af11c504 100644 --- a/android/app/src/main/res/layout/account.xml +++ b/android/app/src/main/res/layout/account.xml @@ -19,7 +19,8 @@ android:layout_height="wrap_content" android:padding="12dp" android:background="?android:attr/selectableItemBackground" - android:src="@drawable/icon_close" /> + android:src="@drawable/icon_close" + android:contentDescription="@string/back" /> <TextView android:id="@+id/collapsed_title" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/android/app/src/main/res/layout/header_bar.xml b/android/app/src/main/res/layout/header_bar.xml index 784d0a85ec..f040afd9cb 100644 --- a/android/app/src/main/res/layout/header_bar.xml +++ b/android/app/src/main/res/layout/header_bar.xml @@ -30,7 +30,8 @@ android:src="@drawable/icon_account" app:layout_constraintEnd_toStartOf="@id/settings" app:layout_constraintTop_toTopOf="parent" - app:layout_constraintBottom_toBottomOf="parent" /> + app:layout_constraintBottom_toBottomOf="parent" + android:contentDescription="@string/settings_account" /> <ImageButton android:id="@+id/settings" android:layout_width="wrap_content" android:layout_height="match_parent" @@ -39,6 +40,7 @@ android:src="@drawable/icon_settings" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" - app:layout_constraintBottom_toBottomOf="parent" /> + app:layout_constraintBottom_toBottomOf="parent" + android:contentDescription="@string/settings" /> </androidx.constraintlayout.widget.ConstraintLayout> </merge> diff --git a/android/app/src/main/res/layout/settings.xml b/android/app/src/main/res/layout/settings.xml index 0bd735a887..fe4d75ba99 100644 --- a/android/app/src/main/res/layout/settings.xml +++ b/android/app/src/main/res/layout/settings.xml @@ -43,15 +43,10 @@ android:lines="1" android:text="@string/settings" style="@style/SettingsExpandedHeader" /> - <net.mullvad.mullvadvpn.ui.widget.AccountCell android:id="@+id/account" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="@dimen/vertical_space" - mullvad:text="@string/settings_account" /> <net.mullvad.mullvadvpn.ui.widget.NavigateCell android:id="@+id/vpn_settings" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="1dp" + android:layout_marginTop="@dimen/vertical_space" mullvad:text="@string/settings_vpn" /> <net.mullvad.mullvadvpn.ui.widget.NavigateCell android:id="@+id/split_tunneling" android:layout_width="match_parent" |
