diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-28 19:21:03 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-07-29 12:14:14 +0000 |
| commit | 713e05d8961881a1e3f7bd7680fe671f5e840902 (patch) | |
| tree | 897a954a9cddf8e3bd839418045c1f3e63faf23d /android | |
| parent | 6403534b1a16aacf0883a5e8c46812144c507b79 (diff) | |
| download | mullvadvpn-713e05d8961881a1e3f7bd7680fe671f5e840902.tar.xz mullvadvpn-713e05d8961881a1e3f7bd7680fe671f5e840902.zip | |
Use new `HeaderBar` widget
Diffstat (limited to 'android')
8 files changed, 25 insertions, 139 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt index 22ed6c3d39..30794f0eec 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt @@ -4,7 +4,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.ImageButton import kotlinx.coroutines.delay import net.mullvad.mullvadvpn.R import net.mullvad.mullvadvpn.model.TunnelState @@ -12,6 +11,7 @@ import net.mullvad.mullvadvpn.ui.notification.AccountExpiryNotification import net.mullvad.mullvadvpn.ui.notification.KeyStatusNotification import net.mullvad.mullvadvpn.ui.notification.TunnelStateNotification import net.mullvad.mullvadvpn.ui.notification.VersionInfoNotification +import net.mullvad.mullvadvpn.ui.widget.HeaderBar import net.mullvad.mullvadvpn.ui.widget.NotificationBanner import org.joda.time.DateTime @@ -42,12 +42,10 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) { val view = inflater.inflate(R.layout.connect, container, false) val resources = parentActivity.resources - view.findViewById<ImageButton>(R.id.settings).setOnClickListener { - parentActivity.openSettings() + headerBar = view.findViewById<HeaderBar>(R.id.header_bar).apply { + tunnelState = TunnelState.Disconnected() } - headerBar = HeaderBar(view, parentActivity) - notificationBanner = view.findViewById<NotificationBanner>(R.id.notification_banner).apply { notifications.apply { register(TunnelStateNotification(parentActivity, connectionProxy)) @@ -132,7 +130,7 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) { private fun updateTunnelState(uiState: TunnelState, realState: TunnelState) { locationInfo.state = realState - headerBar.setState(realState) + headerBar.tunnelState = realState status.setState(realState) actionButton.tunnelState = uiState diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/LoginFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/LoginFragment.kt index 8cc64918f5..5d103918d1 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/LoginFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/LoginFragment.kt @@ -40,8 +40,6 @@ class LoginFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) { ): View { val view = inflater.inflate(R.layout.login, container, false) - view.findViewById<View>(R.id.settings).setOnClickListener { parentActivity.openSettings() } - title = view.findViewById(R.id.title) subtitle = view.findViewById(R.id.subtitle) loggingInStatus = view.findViewById(R.id.logging_in_status) diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/OutOfTimeFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/OutOfTimeFragment.kt index 7835cd56a8..f0c2030645 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/OutOfTimeFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/OutOfTimeFragment.kt @@ -9,6 +9,7 @@ import kotlinx.coroutines.delay import net.mullvad.mullvadvpn.R import net.mullvad.mullvadvpn.model.TunnelState import net.mullvad.mullvadvpn.ui.widget.Button +import net.mullvad.mullvadvpn.ui.widget.HeaderBar import net.mullvad.mullvadvpn.ui.widget.UrlButton import net.mullvad.talpid.tunnel.ActionAfterDisconnect import org.joda.time.DateTime @@ -25,7 +26,7 @@ class OutOfTimeFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) field = value updateDisconnectButton() updateBuyButtons() - headerBar.setState(value) + headerBar.tunnelState = state } override fun onSafelyCreateView( @@ -35,12 +36,10 @@ class OutOfTimeFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) ): View { val view = inflater.inflate(R.layout.out_of_time, container, false) - view.findViewById<View>(R.id.settings).setOnClickListener { - parentActivity.openSettings() + headerBar = view.findViewById<HeaderBar>(R.id.header_bar).apply { + tunnelState = this@OutOfTimeFragment.tunnelState } - headerBar = HeaderBar(view, parentActivity) - view.findViewById<TextView>(R.id.no_more_vpn_time_left).text = parentActivity.getString(R.string.no_more_vpn_time_left) + " " + parentActivity.getString(R.string.add_time_to_account) diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WelcomeFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WelcomeFragment.kt index 261630e784..7c19f02098 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WelcomeFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/WelcomeFragment.kt @@ -11,7 +11,9 @@ import android.widget.TextView import android.widget.Toast import kotlinx.coroutines.delay import net.mullvad.mullvadvpn.R +import net.mullvad.mullvadvpn.model.TunnelState import net.mullvad.mullvadvpn.ui.widget.Button +import net.mullvad.mullvadvpn.ui.widget.HeaderBar import net.mullvad.mullvadvpn.ui.widget.UrlButton import org.joda.time.DateTime @@ -27,8 +29,8 @@ class WelcomeFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) { ): View { val view = inflater.inflate(R.layout.welcome, container, false) - view.findViewById<View>(R.id.settings).setOnClickListener { - parentActivity.openSettings() + view.findViewById<HeaderBar>(R.id.header_bar).apply { + tunnelState = TunnelState.Disconnected() } accountLabel = view.findViewById<TextView>(R.id.account_number).apply { diff --git a/android/src/main/res/layout/connect.xml b/android/src/main/res/layout/connect.xml index 2d7877cf2b..789f82e6da 100644 --- a/android/src/main/res/layout/connect.xml +++ b/android/src/main/res/layout/connect.xml @@ -3,37 +3,10 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> - <LinearLayout android:id="@+id/header_bar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal" - android:gravity="center_vertical" - android:background="@color/red" - android:elevation="0.5dp"> - <ImageView android:layout_width="50dp" - android:layout_height="50dp" - android:layout_marginLeft="12dp" - android:layout_marginVertical="12dp" - android:layout_weight="0" - android:src="@drawable/logo_icon" /> - <TextView android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginHorizontal="8dp" - android:layout_marginVertical="12dp" - android:layout_weight="1" - android:textColor="@color/white80" - android:textSize="24sp" - android:textStyle="bold" - android:text="@string/app_name" - android:textAllCaps="true" /> - <ImageButton android:id="@+id/settings" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_weight="0" - android:paddingHorizontal="12dp" - android:background="?android:attr/selectableItemBackground" - android:src="@drawable/icon_settings" /> - </LinearLayout> + <net.mullvad.mullvadvpn.ui.widget.HeaderBar android:id="@+id/header_bar" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:elevation="0.5dp" /> <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <net.mullvad.mullvadvpn.ui.widget.NotificationBanner android:id="@+id/notification_banner" diff --git a/android/src/main/res/layout/login.xml b/android/src/main/res/layout/login.xml index 0c4cd93fdb..fa96ddf91c 100644 --- a/android/src/main/res/layout/login.xml +++ b/android/src/main/res/layout/login.xml @@ -7,35 +7,9 @@ <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> - <LinearLayout android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="0" - android:orientation="horizontal" - android:gravity="center_vertical"> - <ImageView android:layout_width="50dp" - android:layout_height="50dp" - android:layout_weight="0" - android:layout_marginLeft="12dp" - android:layout_marginVertical="12dp" - android:src="@drawable/logo_icon" /> - <TextView android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_weight="1" - android:layout_marginHorizontal="8dp" - android:layout_marginVertical="12dp" - android:textColor="@color/white60" - android:textSize="24sp" - android:textStyle="bold" - android:text="@string/app_name" - android:textAllCaps="true" /> - <ImageButton android:id="@+id/settings" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_weight="0" - android:paddingHorizontal="12dp" - android:background="?android:attr/selectableItemBackground" - android:src="@drawable/icon_settings" /> - </LinearLayout> + <net.mullvad.mullvadvpn.ui.widget.HeaderBar android:id="@+id/header_bar" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" diff --git a/android/src/main/res/layout/out_of_time.xml b/android/src/main/res/layout/out_of_time.xml index 150a86787e..6fda6d9be0 100644 --- a/android/src/main/res/layout/out_of_time.xml +++ b/android/src/main/res/layout/out_of_time.xml @@ -2,38 +2,9 @@ xmlns:mullvad="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> - <LinearLayout android:id="@+id/header_bar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_weight="0" - android:orientation="horizontal" - android:gravity="center_vertical" - android:background="@color/red" - android:elevation="0.5dp"> - <ImageView android:layout_width="50dp" - android:layout_height="50dp" - android:layout_marginLeft="12dp" - android:layout_marginVertical="12dp" - android:layout_weight="0" - android:src="@drawable/logo_icon" /> - <TextView android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginHorizontal="8dp" - android:layout_marginVertical="12dp" - android:layout_weight="1" - android:textColor="@color/white80" - android:textSize="24sp" - android:textStyle="bold" - android:text="@string/app_name" - android:textAllCaps="true" /> - <ImageButton android:id="@+id/settings" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_weight="0" - android:paddingHorizontal="12dp" - android:background="?android:attr/selectableItemBackground" - android:src="@drawable/icon_settings" /> - </LinearLayout> + <net.mullvad.mullvadvpn.ui.widget.HeaderBar android:id="@+id/header_bar" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" diff --git a/android/src/main/res/layout/welcome.xml b/android/src/main/res/layout/welcome.xml index 147e0b3294..5ce39f65a9 100644 --- a/android/src/main/res/layout/welcome.xml +++ b/android/src/main/res/layout/welcome.xml @@ -2,38 +2,9 @@ xmlns:mullvad="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> - <LinearLayout android:id="@+id/header_bar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_alignParentTop="true" - android:orientation="horizontal" - android:gravity="center_vertical" - android:background="@color/red" - android:elevation="0.5dp"> - <ImageView android:layout_width="50dp" - android:layout_height="50dp" - android:layout_marginLeft="12dp" - android:layout_marginVertical="12dp" - android:layout_weight="0" - android:src="@drawable/logo_icon" /> - <TextView android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginHorizontal="8dp" - android:layout_marginVertical="12dp" - android:layout_weight="1" - android:textColor="@color/white80" - android:textSize="24sp" - android:textStyle="bold" - android:text="@string/app_name" - android:textAllCaps="true" /> - <ImageButton android:id="@+id/settings" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_weight="0" - android:paddingHorizontal="12dp" - android:background="?android:attr/selectableItemBackground" - android:src="@drawable/icon_settings" /> - </LinearLayout> + <net.mullvad.mullvadvpn.ui.widget.HeaderBar android:id="@+id/header_bar" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" |
