summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-06-25 14:41:01 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-06-25 14:41:01 -0300
commita54e05de9c40537dd2f8b67d8edd0baebc83df6b (patch)
tree8ff6ff5f57a5017c8f5c7f32d0c4ab8a6a63e71c
parent1f9a0ccd4f79af3231efa5493a8aebfd0700876b (diff)
parent45d4c173091d018d8fd413e1ac9532354e59b231 (diff)
downloadmullvadvpn-a54e05de9c40537dd2f8b67d8edd0baebc83df6b.tar.xz
mullvadvpn-a54e05de9c40537dd2f8b67d8edd0baebc83df6b.zip
Merge branch 'fix-notification-banner-height-calculation'
-rw-r--r--CHANGELOG.md4
-rw-r--r--android/build.gradle1
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt12
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/NotificationBanner.kt24
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/UnderNotificationBannerBehavior.kt34
-rw-r--r--android/src/main/res/layout/connect.xml340
6 files changed, 210 insertions, 205 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 07807bb68b..cd6518c8e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -37,6 +37,10 @@ Line wrap the file at 100 chars. Th
#### Windows
- Fix window flickering by disabling window animations.
+#### Android
+- Fix Connect screen sometimes becoming unusually tall. This ended up causing the screen to be
+ scrolled up and made the UI elements unable to be seen until the user scrolled down.
+
## [2020.5] - 2020-06-25
### Added
diff --git a/android/build.gradle b/android/build.gradle
index 60ad2af53b..3ec109fbeb 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -81,6 +81,7 @@ repositories {
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
+ implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.21'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
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 1ef0b3ac62..550edd7e26 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/ConnectFragment.kt
@@ -16,7 +16,6 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
private lateinit var actionButton: ConnectActionButton
private lateinit var switchLocationButton: SwitchLocationButton
private lateinit var headerBar: HeaderBar
- private lateinit var body: View
private lateinit var notificationBanner: NotificationBanner
private lateinit var status: ConnectionStatus
private lateinit var locationInfo: LocationInfo
@@ -44,10 +43,7 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
headerBar = HeaderBar(view, resources)
- body = view.findViewById(R.id.body)
-
notificationBanner = NotificationBanner(view, parentActivity, appVersionInfoCache, daemon)
- notificationBanner.onHeightChange = { newHeight -> updateBodyPaddingTop(newHeight) }
status = ConnectionStatus(view, resources)
@@ -131,14 +127,6 @@ class ConnectFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
state.putBoolean(KEY_IS_TUNNEL_INFO_EXPANDED, isTunnelInfoExpanded)
}
- private fun updateBodyPaddingTop(newPaddingTop: Int) {
- body.apply {
- if (paddingTop != newPaddingTop) {
- setPadding(paddingLeft, newPaddingTop, paddingRight, paddingBottom)
- }
- }
- }
-
private fun updateTunnelState(uiState: TunnelState, realState: TunnelState) {
notificationBanner.tunnelState = realState
locationInfo.state = realState
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/NotificationBanner.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/NotificationBanner.kt
index 1aeed5e5ca..efb27bc4d7 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/NotificationBanner.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/NotificationBanner.kt
@@ -5,7 +5,6 @@ import android.content.Intent
import android.graphics.drawable.Drawable
import android.net.Uri
import android.view.View
-import android.view.View.MeasureSpec
import android.widget.ImageView
import android.widget.TextView
import kotlin.properties.Delegates.observable
@@ -53,12 +52,6 @@ class NotificationBanner(
private val message: TextView = parentView.findViewById(R.id.notification_message)
private val icon: View = parentView.findViewById(R.id.notification_icon)
- private var height: Int by observable(0) { _, oldValue, newValue ->
- if (oldValue != newValue) {
- onHeightChange?.invoke(newValue)
- }
- }
-
private var updateJob: Job? = null
private var externalLink: ExternalLink? = null
@@ -93,10 +86,6 @@ class NotificationBanner(
}
)
- var onHeightChange by observable<((Int) -> Unit)?>(null) { _, _, newListener ->
- newListener?.invoke(height)
- }
-
var accountExpiry by observable<DateTime?>(null) { _, _, _ -> update() }
var keyState by observable<KeygenEvent?>(null) { _, _, _ -> update() }
var tunnelState by observable<TunnelState>(TunnelState.Disconnected()) { _, _, _ -> update() }
@@ -282,8 +271,6 @@ class NotificationBanner(
banner.setClickable(true)
icon.visibility = View.VISIBLE
}
-
- height = recalculateHeight()
}
private fun hide() {
@@ -294,15 +281,4 @@ class NotificationBanner(
}
}
}
-
- private fun recalculateHeight(): Int {
- banner.apply {
- val widthSpec = MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.AT_MOST)
- val heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
-
- measure(widthSpec, heightSpec)
-
- return measuredHeight
- }
- }
}
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/UnderNotificationBannerBehavior.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/UnderNotificationBannerBehavior.kt
new file mode 100644
index 0000000000..a0759ed9fa
--- /dev/null
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/UnderNotificationBannerBehavior.kt
@@ -0,0 +1,34 @@
+package net.mullvad.mullvadvpn.ui
+
+import android.content.Context
+import android.support.design.widget.CoordinatorLayout
+import android.support.design.widget.CoordinatorLayout.Behavior
+import android.util.AttributeSet
+import android.view.View
+import android.widget.ScrollView
+import net.mullvad.mullvadvpn.R
+
+class UnderNotificationBannerBehavior(
+ context: Context,
+ attributes: AttributeSet
+) : Behavior<ScrollView>(context, attributes) {
+ override fun layoutDependsOn(parent: CoordinatorLayout, body: ScrollView, dependency: View) =
+ dependency.id == R.id.notification_banner
+
+ override fun onDependentViewChanged(
+ parent: CoordinatorLayout,
+ body: ScrollView,
+ dependency: View
+ ): Boolean {
+ val newPaddingTop = dependency.height
+
+ body.getChildAt(0).apply {
+ if (paddingTop != newPaddingTop) {
+ setPadding(paddingLeft, newPaddingTop, paddingRight, paddingBottom)
+ return true
+ } else {
+ return false
+ }
+ }
+ }
+}
diff --git a/android/src/main/res/layout/connect.xml b/android/src/main/res/layout/connect.xml
index c1daa9f950..9e33f21f1e 100644
--- a/android/src/main/res/layout/connect.xml
+++ b/android/src/main/res/layout/connect.xml
@@ -1,10 +1,11 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ 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:layout_alignParentTop="true"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="@color/red"
@@ -33,193 +34,194 @@
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/icon_settings" />
</LinearLayout>
- <FrameLayout android:id="@+id/notification_banner"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/header_bar"
- 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.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: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>
- <ScrollView android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/header_bar"
- android:layout_alignParentBottom="true"
- android:fillViewport="true">
- <LinearLayout android:id="@+id/body"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- android:gravity="bottom">
- <ProgressBar android:id="@+id/connecting_spinner"
- android:layout_width="60dp"
- android:layout_height="60dp"
- android:layout_gravity="center"
- android:layout_marginBottom="7dp"
- android:indeterminate="true"
- android:indeterminateOnly="true"
- android:indeterminateDuration="600"
- android:indeterminateDrawable="@drawable/icon_spinner"
- android:visibility="invisible" />
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="0"
- android:layout_marginTop="7dp"
- android:orientation="vertical"
- android:gravity="start">
- <TextView android:id="@+id/connection_status"
+ 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_marginBottom="4dp"
- android:layout_marginHorizontal="24dp"
- android:textColor="@color/red"
- android:textSize="16sp"
+ 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/unsecured_connection"
+ android:text="@string/blocking_internet"
android:textAllCaps="true" />
- <TextView android:id="@+id/city"
+ <TextView android:id="@+id/notification_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginHorizontal="24dp"
- android:textColor="@color/white"
- android:textSize="34sp"
- android:textStyle="bold"
- android:text="" />
- <TextView android:id="@+id/country"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginHorizontal="24dp"
- android:textColor="@color/white"
- android:textSize="34sp"
- android:textStyle="bold"
- android:text="" />
- <LinearLayout android:id="@+id/tunnel_info"
- android:layout_width="match_parent"
+ 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>
+ <ScrollView android:id="@+id/body"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="net.mullvad.mullvadvpn.ui.UnderNotificationBannerBehavior"
+ android:fillViewport="true">
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:gravity="bottom">
+ <ProgressBar android:id="@+id/connecting_spinner"
+ android:layout_width="60dp"
+ android:layout_height="60dp"
+ android:layout_gravity="center"
+ android:layout_marginBottom="7dp"
+ android:indeterminate="true"
+ android:indeterminateOnly="true"
+ android:indeterminateDuration="600"
+ android:indeterminateDrawable="@drawable/icon_spinner"
+ android:visibility="invisible" />
+ <LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
+ android:layout_marginTop="7dp"
android:orientation="vertical"
- android:paddingHorizontal="24dp"
- android:gravity="start"
- android:clickable="true"
- android:background="?android:attr/selectableItemBackground">
- <LinearLayout android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
- <TextView android:id="@+id/hostname"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="@color/white"
- android:textSize="16sp"
- android:textStyle="bold"
- android:text="" />
- <ImageView android:id="@+id/chevron"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginHorizontal="5dp"
- android:alpha="0.4"
- android:src="@drawable/icon_chevron_expand" />
- </LinearLayout>
- <TextView android:id="@+id/tunnel_protocol"
+ android:gravity="start">
+ <TextView android:id="@+id/connection_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginTop="4dp"
- android:textColor="@color/white"
- android:textSize="13sp"
- android:text="" />
- <TextView android:id="@+id/in_address"
+ android:layout_marginBottom="4dp"
+ android:layout_marginHorizontal="24dp"
+ android:textColor="@color/red"
+ android:textSize="16sp"
+ android:textStyle="bold"
+ android:text="@string/unsecured_connection"
+ android:textAllCaps="true" />
+ <TextView android:id="@+id/city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginHorizontal="24dp"
android:textColor="@color/white"
- android:textSize="13sp"
+ android:textSize="34sp"
+ android:textStyle="bold"
android:text="" />
- <TextView android:id="@+id/out_address"
+ <TextView android:id="@+id/country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginHorizontal="24dp"
android:textColor="@color/white"
- android:textSize="13sp"
+ android:textSize="34sp"
+ android:textStyle="bold"
android:text="" />
+ <LinearLayout android:id="@+id/tunnel_info"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:orientation="vertical"
+ android:paddingHorizontal="24dp"
+ android:gravity="start"
+ android:clickable="true"
+ android:background="?android:attr/selectableItemBackground">
+ <LinearLayout android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <TextView android:id="@+id/hostname"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/white"
+ android:textSize="16sp"
+ android:textStyle="bold"
+ android:text="" />
+ <ImageView android:id="@+id/chevron"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginHorizontal="5dp"
+ android:alpha="0.4"
+ android:src="@drawable/icon_chevron_expand" />
+ </LinearLayout>
+ <TextView android:id="@+id/tunnel_protocol"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="4dp"
+ android:textColor="@color/white"
+ android:textSize="13sp"
+ android:text="" />
+ <TextView android:id="@+id/in_address"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/white"
+ android:textSize="13sp"
+ android:text="" />
+ <TextView android:id="@+id/out_address"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="@color/white"
+ android:textSize="13sp"
+ android:text="" />
+ </LinearLayout>
</LinearLayout>
- </LinearLayout>
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="0"
- android:orientation="vertical"
- android:padding="24dp">
- <Button android:id="@+id/switch_location"
- android:layout_marginTop="20dp"
- android:layout_marginBottom="16dp"
- android:paddingHorizontal="8dp"
- android:text="@string/switch_location"
- android:drawableRight="@drawable/icon_chevron"
- style="@style/White20Button" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="horizontal">
- <Button android:id="@+id/action_button"
- android:layout_weight="1"
- android:text="@string/connect"
- style="@style/GreenButton" />
- <ImageButton android:id="@+id/reconnect_button"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_weight="0"
- android:layout_marginLeft="1dp"
- android:paddingHorizontal="10dp"
- android:background="@drawable/transparent_red_right_half_button_background"
- android:visibility="gone"
- android:src="@drawable/icon_reload" />
+ android:layout_weight="0"
+ android:orientation="vertical"
+ android:padding="24dp">
+ <Button android:id="@+id/switch_location"
+ android:layout_marginTop="20dp"
+ android:layout_marginBottom="16dp"
+ android:paddingHorizontal="8dp"
+ android:text="@string/switch_location"
+ android:drawableRight="@drawable/icon_chevron"
+ style="@style/White20Button" />
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <Button android:id="@+id/action_button"
+ android:layout_weight="1"
+ android:text="@string/connect"
+ style="@style/GreenButton" />
+ <ImageButton android:id="@+id/reconnect_button"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="0"
+ android:layout_marginLeft="1dp"
+ android:paddingHorizontal="10dp"
+ android:background="@drawable/transparent_red_right_half_button_background"
+ android:visibility="gone"
+ android:src="@drawable/icon_reload" />
+ </LinearLayout>
</LinearLayout>
</LinearLayout>
- </LinearLayout>
- </ScrollView>
-</RelativeLayout>
+ </ScrollView>
+ </android.support.design.widget.CoordinatorLayout>
+</LinearLayout>