From 74e98e4430053ed07148d8073f1d67ed87e26648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Tue, 9 Apr 2019 23:33:53 +0200 Subject: [PATCH] Change style of privacy policy link (#321) --- .../modules/login/form/LoginFormFragment.kt | 14 +++++-- .../modules/login/form/LoginFormPresenter.kt | 9 ++++- .../ui/modules/login/form/LoginFormView.kt | 4 ++ .../main/res/layout/fragment_login_form.xml | 37 +++++++++++-------- app/src/main/res/values-pl/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- .../login/form/LoginFormPresenterTest.kt | 16 ++++---- 7 files changed, 53 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt index 5c0a6ed8..2a0467d9 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormFragment.kt @@ -1,8 +1,8 @@ package io.github.wulkanowy.ui.modules.login.form import android.annotation.SuppressLint +import android.content.Intent import android.os.Bundle -import android.text.method.LinkMovementMethod import android.view.LayoutInflater import android.view.View import android.view.View.GONE @@ -54,8 +54,8 @@ class LoginFormFragment : BaseFragment(), LoginFormView { loginFormName.setOnTextChangedListener { presenter.onNameTextChanged() } loginFormPass.setOnTextChangedListener { presenter.onPassTextChanged() } loginFormHost.setOnItemSelectedListener { presenter.onHostSelected() } - loginFormPrivacyPolicyLink.movementMethod = LinkMovementMethod.getInstance() - loginFormSignIn.setOnClickListener { presenter.attemptLogin() } + loginFormSignIn.setOnClickListener { presenter.onSignInClick() } + loginFormPrivacyLink.setOnClickListener { presenter.onPrivacyLinkClick() } loginFormPass.setOnEditorActionListener { _, id, _ -> if (id == IME_ACTION_DONE || id == IME_NULL) loginFormSignIn.callOnClick() else false @@ -132,6 +132,10 @@ class LoginFormFragment : BaseFragment(), LoginFormView { } } + override fun showPrivacyPolicy() { + loginFormPrivacyLink.visibility = VISIBLE + } + override fun notifyParentAccountLogged(students: List) { (activity as? LoginActivity)?.onFormFragmentAccountLogged(students, Triple( loginFormName.text.toString(), @@ -140,6 +144,10 @@ class LoginFormFragment : BaseFragment(), LoginFormView { )) } + override fun openPrivacyPolicyPage() { + startActivity(Intent.parseUri("https://wulkanowy.github.io/polityka-prywatnosci.html", 0)) + } + override fun onDestroyView() { super.onDestroyView() presenter.onDetachView() diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt index a0717649..3ab47c29 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenter.kt @@ -22,7 +22,8 @@ class LoginFormPresenter @Inject constructor( super.onAttachView(view) view.run { initView() - if (isDebug) showVersion() + if (isDebug) showVersion() else showPrivacyPolicy() + errorHandler.onBadCredentials = { setErrorPassIncorrect() showSoftKeyboard() @@ -31,6 +32,10 @@ class LoginFormPresenter @Inject constructor( } } + fun onPrivacyLinkClick() { + view?.openPrivacyPolicyPage() + } + fun onHostSelected() { view?.apply { clearPassError() @@ -47,7 +52,7 @@ class LoginFormPresenter @Inject constructor( view?.clearNameError() } - fun attemptLogin() { + fun onSignInClick() { val email = view?.formNameValue.orEmpty() val password = view?.formPassValue.orEmpty() val endpoint = view?.formHostValue.orEmpty() diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormView.kt index 69672780..80a7b5e9 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormView.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/login/form/LoginFormView.kt @@ -37,5 +37,9 @@ interface LoginFormView : BaseView { fun showVersion() + fun showPrivacyPolicy() + fun notifyParentAccountLogged(students: List) + + fun openPrivacyPolicyPage() } diff --git a/app/src/main/res/layout/fragment_login_form.xml b/app/src/main/res/layout/fragment_login_form.xml index 7a82eaf7..197db570 100644 --- a/app/src/main/res/layout/fragment_login_form.xml +++ b/app/src/main/res/layout/fragment_login_form.xml @@ -39,7 +39,6 @@ app:fontFamily="sans-serif-light" app:layout_constraintBottom_toTopOf="@+id/loginFormNameLayout" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_chainStyle="packed" /> @@ -59,7 +58,6 @@ app:errorEnabled="true" app:layout_constraintBottom_toTopOf="@+id/loginFormPassLayout" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/loginFormHeader"> @@ -87,7 +85,6 @@ app:errorEnabled="true" app:layout_constraintBottom_toTopOf="@+id/loginFormHostLayout" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/loginFormNameLayout" app:passwordToggleEnabled="true"> @@ -117,7 +114,6 @@ android:orientation="vertical" app:layout_constraintBottom_toTopOf="@+id/loginFormSignIn" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/loginFormPassLayout"> @@ -145,15 +141,6 @@ app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="@+id/loginFormHostLayout" /> - - + app:layout_constraintTop_toBottomOf="@+id/loginFormHostLayout" /> + + diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index a5b8b66a..04a4a2ea 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -26,7 +26,6 @@ Hasło Dziennik Symbol - Polityka prywatności Zaloguj To hasło jest za krótkie Dane logowania są niepoprawne @@ -34,6 +33,7 @@ To pole jest wymagane Ten student jest już zalogowany Symbol znajduje się na stronie dziennika w zakładce Dostęp Mobilny + Polityka prywatności diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a4089a46..69481ecf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -26,7 +26,6 @@ Password Register Symbol - Privacy policy Sign in This password is too short Login details are incorrect @@ -34,6 +33,7 @@ This field is required This student has already been logged in The symbol is located on the register page in the Mobile Access tab + Privacy policy diff --git a/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt b/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt index 83047e02..b643a550 100644 --- a/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt +++ b/app/src/test/java/io/github/wulkanowy/ui/modules/login/form/LoginFormPresenterTest.kt @@ -53,7 +53,7 @@ class LoginFormPresenterTest { `when`(loginFormView.formNameValue).thenReturn("") `when`(loginFormView.formPassValue).thenReturn("test123") `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf") - presenter.attemptLogin() + presenter.onSignInClick() verify(loginFormView).setErrorNameRequired() verify(loginFormView, never()).setErrorPassRequired(false) @@ -65,7 +65,7 @@ class LoginFormPresenterTest { `when`(loginFormView.formNameValue).thenReturn("@") `when`(loginFormView.formPassValue).thenReturn("") `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf") - presenter.attemptLogin() + presenter.onSignInClick() verify(loginFormView, never()).setErrorNameRequired() verify(loginFormView).setErrorPassRequired(true) @@ -77,7 +77,7 @@ class LoginFormPresenterTest { `when`(loginFormView.formNameValue).thenReturn("@") `when`(loginFormView.formPassValue).thenReturn("123") `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf") - presenter.attemptLogin() + presenter.onSignInClick() verify(loginFormView, never()).setErrorNameRequired() verify(loginFormView, never()).setErrorPassRequired(true) @@ -93,7 +93,7 @@ class LoginFormPresenterTest { `when`(loginFormView.formNameValue).thenReturn("@") `when`(loginFormView.formPassValue).thenReturn("123456") `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf") - presenter.attemptLogin() + presenter.onSignInClick() verify(loginFormView).hideSoftKeyboard() verify(loginFormView).showProgress(true) @@ -109,7 +109,7 @@ class LoginFormPresenterTest { `when`(loginFormView.formNameValue).thenReturn("@") `when`(loginFormView.formPassValue).thenReturn("123456") `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf") - presenter.attemptLogin() + presenter.onSignInClick() verify(loginFormView).hideSoftKeyboard() verify(loginFormView).showProgress(true) @@ -125,8 +125,8 @@ class LoginFormPresenterTest { `when`(loginFormView.formNameValue).thenReturn("@") `when`(loginFormView.formPassValue).thenReturn("123456") `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf") - presenter.attemptLogin() - presenter.attemptLogin() + presenter.onSignInClick() + presenter.onSignInClick() verify(loginFormView, times(2)).hideSoftKeyboard() verify(loginFormView, times(2)).showProgress(true) @@ -143,7 +143,7 @@ class LoginFormPresenterTest { `when`(loginFormView.formNameValue).thenReturn("@") `when`(loginFormView.formPassValue).thenReturn("123456") `when`(loginFormView.formHostValue).thenReturn("https://fakelog.cf") - presenter.attemptLogin() + presenter.onSignInClick() verify(loginFormView).hideSoftKeyboard() verify(loginFormView).showProgress(true)