summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-06-04 10:53:33 -0300
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-06-04 10:53:33 -0300
commit7c0b5a497a8075bd290612d6a4bb0a3d460ac7ab (patch)
tree623417047417bd4dfd39561ef889a32decea2e6a /android/src
parent84f15cf5cd04b466ffc86086d1f6dde3ac67f336 (diff)
parent1e2bdd028f92d6938fb70c5d0b446bd9c267685e (diff)
downloadmullvadvpn-7c0b5a497a8075bd290612d6a4bb0a3d460ac7ab.tar.xz
mullvadvpn-7c0b5a497a8075bd290612d6a4bb0a3d460ac7ab.zip
Merge branch 'login-screen-scroll-view'
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/LoginFragment.kt20
-rw-r--r--android/src/main/res/layout/login.xml290
2 files changed, 167 insertions, 143 deletions
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 fdec6efd12..de24fee6fc 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/LoginFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/LoginFragment.kt
@@ -1,10 +1,12 @@
package net.mullvad.mullvadvpn.ui
+import android.graphics.Rect
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.ScrollView
import android.widget.TextView
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.delay
@@ -27,6 +29,7 @@ class LoginFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
private lateinit var loggedInStatus: View
private lateinit var loginFailStatus: View
private lateinit var accountInput: AccountInput
+ private lateinit var scrollArea: ScrollView
private val loggedIn = CompletableDeferred<LoginResult>()
@@ -51,7 +54,10 @@ class LoginFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
view.findViewById<Button>(R.id.create_account)
.setOnClickAction("createAccount", jobTracker) { createAccount() }
+ scrollArea = view.findViewById(R.id.scroll_area)
+
fetchHistory()
+ scrollToShow(accountInput.input)
return view
}
@@ -72,6 +78,12 @@ class LoginFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
jobTracker.cancelJob("advanceToNextScreen")
}
+ private fun scrollToShow(view: View) {
+ val rectangle = Rect(0, 0, view.width, view.height)
+
+ scrollArea.requestChildRectangleOnScreen(view, rectangle, false)
+ }
+
private suspend fun createAccount() {
title.setText(R.string.logging_in_title)
subtitle.setText(R.string.creating_new_account)
@@ -82,6 +94,8 @@ class LoginFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
accountInput.state = LoginState.InProgress
+ scrollToShow(loggingInStatus)
+
val accountToken = jobTracker.runOnBackground {
daemon.createNewAccount()
}
@@ -103,6 +117,8 @@ class LoginFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
accountInput.state = LoginState.InProgress
+ scrollToShow(loggingInStatus)
+
performLogin(accountToken)
}
@@ -163,6 +179,8 @@ class LoginFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
loggedInStatus.visibility = View.VISIBLE
accountInput.state = LoginState.Success
+
+ scrollToShow(loggedInStatus)
}
private fun openNextScreen(fragment: Fragment) {
@@ -181,5 +199,7 @@ class LoginFragment : ServiceDependentFragment(OnNoService.GoToLaunchScreen) {
loggedInStatus.visibility = View.GONE
accountInput.state = LoginState.Failure
+
+ scrollToShow(accountInput.input)
}
}
diff --git a/android/src/main/res/layout/login.xml b/android/src/main/res/layout/login.xml
index df0e9be771..0c4cd93fdb 100644
--- a/android/src/main/res/layout/login.xml
+++ b/android/src/main/res/layout/login.xml
@@ -1,148 +1,152 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:mullvad="http://schemas.android.com/apk/res-auto"
- android:id="@+id/main_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:mullvad="http://schemas.android.com/apk/res-auto"
+ android:id="@+id/scroll_area"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fillViewport="true">
<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>
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:orientation="vertical"
- android:padding="24dp">
- <Space android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1" />
- <FrameLayout android:layout_width="60dp"
- android:layout_height="60dp"
- android:layout_gravity="center_horizontal"
- android:layout_marginBottom="30dp">
- <ProgressBar android:id="@+id/logging_in_status"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:indeterminate="true"
- android:indeterminateOnly="true"
- android:indeterminateDuration="600"
- android:indeterminateDrawable="@drawable/icon_spinner"
- android:visibility="gone" />
- <ImageView android:id="@+id/logged_in_status"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:src="@drawable/icon_success"
- android:visibility="gone" />
- <ImageView android:id="@+id/login_fail_status"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:src="@drawable/icon_fail"
- android:visibility="gone" />
- </FrameLayout>
- <TextView android:id="@+id/title"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="0"
- android:layout_marginBottom="4dp"
- android:gravity="start"
- android:textColor="@color/white"
- android:textSize="32sp"
- android:textStyle="bold"
- android:text="@string/login_title" />
- <TextView android:id="@+id/subtitle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="0"
- android:layout_marginBottom="10dp"
- android:gravity="start"
- android:textColor="@color/white80"
- android:textSize="13sp"
- android:text="@string/login_description" />
- <net.mullvad.mullvadvpn.ui.AccountInputContainer android:id="@+id/account_input_container"
- android:layout_width="match_parent"
- android:layout_height="48dp"
- android:orientation="horizontal">
- <EditText android:id="@+id/account_input"
- android:digits="0123456789"
- android:layout_width="match_parent"
- android:layout_height="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:paddingHorizontal="12dp"
- android:background="@drawable/account_input_background"
- android:inputType="number"
- android:singleLine="true"
- android:imeOptions="flagNoPersonalizedLearning"
- android:textCursorDrawable="@drawable/text_input_cursor"
- android:hint="@string/login_hint"
- android:textColorHint="@color/blue40"
- android:textColor="@color/blue"
- android:textSize="20sp"
- android:textStyle="bold" />
- <ImageButton android:id="@+id/login_button"
- android:layout_width="48dp"
+ 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:background="@drawable/login_button_background"
- android:src="@drawable/login_button_arrow" />
- </net.mullvad.mullvadvpn.ui.AccountInputContainer>
- <ListView android:id="@+id/account_history_list"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:divider="@drawable/account_history_list_divider"
- android:dividerHeight="1dp"
- android:visibility="invisible"
- android:background="@drawable/account_history_background" />
- <Space android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="3" />
- </LinearLayout>
- <LinearLayout android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="0"
- android:orientation="vertical"
- android:paddingHorizontal="24dp"
- android:paddingBottom="24dp"
- android:paddingTop="16dp"
- android:background="@color/darkBlue">
- <TextView android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="8dp"
- android:gravity="start"
- android:textColor="@color/white80"
- android:textSize="13sp"
- android:text="@string/dont_have_an_account" />
- <net.mullvad.mullvadvpn.ui.widget.Button android:id="@+id/create_account"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- mullvad:buttonColor="blue"
- mullvad:text="@string/create_account" />
+ android:paddingHorizontal="12dp"
+ android:background="?android:attr/selectableItemBackground"
+ android:src="@drawable/icon_settings" />
+ </LinearLayout>
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:orientation="vertical"
+ android:padding="24dp">
+ <Space android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1" />
+ <FrameLayout android:layout_width="60dp"
+ android:layout_height="60dp"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginBottom="30dp">
+ <ProgressBar android:id="@+id/logging_in_status"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:indeterminate="true"
+ android:indeterminateOnly="true"
+ android:indeterminateDuration="600"
+ android:indeterminateDrawable="@drawable/icon_spinner"
+ android:visibility="gone" />
+ <ImageView android:id="@+id/logged_in_status"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:src="@drawable/icon_success"
+ android:visibility="gone" />
+ <ImageView android:id="@+id/login_fail_status"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:src="@drawable/icon_fail"
+ android:visibility="gone" />
+ </FrameLayout>
+ <TextView android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:layout_marginBottom="4dp"
+ android:gravity="start"
+ android:textColor="@color/white"
+ android:textSize="32sp"
+ android:textStyle="bold"
+ android:text="@string/login_title" />
+ <TextView android:id="@+id/subtitle"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:layout_marginBottom="10dp"
+ android:gravity="start"
+ android:textColor="@color/white80"
+ android:textSize="13sp"
+ android:text="@string/login_description" />
+ <net.mullvad.mullvadvpn.ui.AccountInputContainer android:id="@+id/account_input_container"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"
+ android:orientation="horizontal">
+ <EditText android:id="@+id/account_input"
+ android:digits="0123456789"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:paddingHorizontal="12dp"
+ android:background="@drawable/account_input_background"
+ android:inputType="number"
+ android:singleLine="true"
+ android:imeOptions="flagNoPersonalizedLearning"
+ android:textCursorDrawable="@drawable/text_input_cursor"
+ android:hint="@string/login_hint"
+ android:textColorHint="@color/blue40"
+ android:textColor="@color/blue"
+ android:textSize="20sp"
+ android:textStyle="bold" />
+ <ImageButton android:id="@+id/login_button"
+ android:layout_width="48dp"
+ android:layout_height="match_parent"
+ android:layout_weight="0"
+ android:background="@drawable/login_button_background"
+ android:src="@drawable/login_button_arrow" />
+ </net.mullvad.mullvadvpn.ui.AccountInputContainer>
+ <ListView android:id="@+id/account_history_list"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:divider="@drawable/account_history_list_divider"
+ android:dividerHeight="1dp"
+ android:visibility="invisible"
+ android:background="@drawable/account_history_background" />
+ <Space android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="3" />
+ </LinearLayout>
+ <LinearLayout android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="0"
+ android:orientation="vertical"
+ android:paddingHorizontal="24dp"
+ android:paddingBottom="24dp"
+ android:paddingTop="16dp"
+ android:background="@color/darkBlue">
+ <TextView android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="8dp"
+ android:gravity="start"
+ android:textColor="@color/white80"
+ android:textSize="13sp"
+ android:text="@string/dont_have_an_account" />
+ <net.mullvad.mullvadvpn.ui.widget.Button android:id="@+id/create_account"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ mullvad:buttonColor="blue"
+ mullvad:text="@string/create_account" />
+ </LinearLayout>
</LinearLayout>
-</LinearLayout>
+</ScrollView>