summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-06-26 17:13:18 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-07-01 20:22:03 +0000
commit61fcd8bec8f84e7c4278f28ffc6c5fafdb30c5e5 (patch)
tree37b0a3cd2f5700de0d41342219ec7c97336d2ede /android/src
parent13a6322b2de11c14ff54a0e5e71b3454eaffaee7 (diff)
downloadmullvadvpn-61fcd8bec8f84e7c4278f28ffc6c5fafdb30c5e5.tar.xz
mullvadvpn-61fcd8bec8f84e7c4278f28ffc6c5fafdb30c5e5.zip
Use new `NotificationBanner` widget
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt26
-rw-r--r--android/src/main/res/layout/connect.xml61
2 files changed, 18 insertions, 69 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 550edd7e26..55144b8529 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
@@ -8,6 +8,11 @@ import android.widget.ImageButton
import kotlinx.coroutines.delay
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.model.TunnelState
+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.NotificationBanner
import org.joda.time.DateTime
val KEY_IS_TUNNEL_INFO_EXPANDED = "is_tunnel_info_expanded"
@@ -43,7 +48,14 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
headerBar = HeaderBar(view, resources)
- notificationBanner = NotificationBanner(view, parentActivity, appVersionInfoCache, daemon)
+ notificationBanner = view.findViewById<NotificationBanner>(R.id.notification_banner).apply {
+ notifications.apply {
+ register(TunnelStateNotification(parentActivity, connectionProxy))
+ register(KeyStatusNotification(parentActivity, daemon, keyStatusListener))
+ register(VersionInfoNotification(parentActivity, appVersionInfoCache))
+ register(AccountExpiryNotification(parentActivity, daemon, accountCache))
+ }
+ }
status = ConnectionStatus(view, resources)
@@ -69,12 +81,6 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
notificationBanner.onResume()
- keyStatusListener.onKeyStatusChange.subscribe(this) { keyStatus ->
- jobTracker.newUiJob("updateKeyStatus") {
- notificationBanner.keyState = keyStatus
- }
- }
-
locationInfoCache.onNewLocation = { location ->
jobTracker.newUiJob("updateLocationInfo") {
locationInfo.location = location
@@ -98,10 +104,6 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
} else if (expiry != null) {
scheduleNextAccountExpiryCheck(expiry)
}
-
- jobTracker.newUiJob("updateAccountExpiry") {
- notificationBanner.accountExpiry = expiry
- }
}
}
@@ -119,6 +121,7 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
}
override fun onSafelyDestroyView() {
+ notificationBanner.onDestroy()
switchLocationButton.onDestroy()
}
@@ -128,7 +131,6 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
}
private fun updateTunnelState(uiState: TunnelState, realState: TunnelState) {
- notificationBanner.tunnelState = realState
locationInfo.state = realState
headerBar.setState(realState)
status.setState(realState)
diff --git a/android/src/main/res/layout/connect.xml b/android/src/main/res/layout/connect.xml
index 9e33f21f1e..2d7877cf2b 100644
--- a/android/src/main/res/layout/connect.xml
+++ b/android/src/main/res/layout/connect.xml
@@ -36,63 +36,10 @@
</LinearLayout>
<android.support.design.widget.CoordinatorLayout android:layout_width="match_parent"
android:layout_height="match_parent">
- <FrameLayout android:id="@+id/notification_banner"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="@color/darkBlue"
- android:visibility="invisible"
- android:clickable="false"
- android:elevation="0.25dp">
- <RelativeLayout android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingVertical="8dp"
- android:paddingLeft="20dp"
- android:paddingRight="10dp"
- android:background="?android:attr/selectableItemBackground">
- <RelativeLayout android:id="@+id/notification_status_container"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
- android:layout_alignBottom="@id/notification_title">
- <ImageView android:id="@+id/notification_status"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:src="@drawable/icon_notification_error" />
- </RelativeLayout>
- <TextView android:id="@+id/notification_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_toLeftOf="@id/notification_icon"
- android:layout_toRightOf="@id/notification_status_container"
- android:layout_marginLeft="7dp"
- android:textSize="13sp"
- android:textStyle="bold"
- android:text="@string/blocking_internet"
- android:textAllCaps="true" />
- <TextView android:id="@+id/notification_message"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignWithParentIfMissing="true"
- android:layout_toLeftOf="@id/notification_icon"
- android:layout_alignLeft="@id/notification_title"
- android:layout_below="@id/notification_title"
- android:textSize="13sp"
- android:textColor="@color/white60"
- android:text=""
- android:visibility="gone" />
- <ImageView android:id="@+id/notification_icon"
- android:layout_width="12dp"
- android:layout_height="12dp"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:alpha="0.6"
- android:src="@drawable/icon_extlink"
- android:visibility="gone" />
- </RelativeLayout>
- </FrameLayout>
+ <net.mullvad.mullvadvpn.ui.widget.NotificationBanner android:id="@+id/notification_banner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:elevation="0.25dp" />
<ScrollView android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="match_parent"