1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 04:19:08 -05:00

Change style of privacy policy link (#321)

This commit is contained in:
Rafał Borcz 2019-04-09 23:33:53 +02:00 committed by Mikołaj Pich
parent cbf3215dd1
commit 74e98e4430
7 changed files with 53 additions and 31 deletions

View File

@ -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<Student>) {
(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()

View File

@ -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()

View File

@ -37,5 +37,9 @@ interface LoginFormView : BaseView {
fun showVersion()
fun showPrivacyPolicy()
fun notifyParentAccountLogged(students: List<Student>)
fun openPrivacyPolicyPage()
}

View File

@ -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" />
<TextView
android:id="@+id/loginFormPrivacyPolicyLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="@string/login_privacy_policy"
app:layout_constraintStart_toStartOf="@+id/loginFormHostLayout"
app:layout_constraintTop_toBottomOf="@+id/loginFormHostLayout" />
<com.google.android.material.button.MaterialButton
android:id="@+id/loginFormSignIn"
style="@style/Widget.MaterialComponents.Button"
@ -171,14 +158,12 @@
app:backgroundTint="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/loginFormHostLayout"
app:layout_constraintVertical_bias="1.0" />
app:layout_constraintTop_toBottomOf="@+id/loginFormHostLayout" />
<TextView
android:id="@+id/loginFormVersion"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginEnd="16dp"
@ -186,11 +171,31 @@
android:maxLines="2"
android:textColor="?android:textColorSecondary"
android:textSize="12sp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@id/loginFormSignIn"
app:layout_constraintEnd_toStartOf="@+id/loginFormSignIn"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/loginFormSignIn"
tools:text="Version 1.0.0" />
<com.google.android.material.button.MaterialButton
android:id="@+id/loginFormPrivacyLink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:text="@string/login_privacy_policy"
android:textAppearance="?android:textAppearance"
android:textColor="@color/colorPrimary"
android:visibility="invisible"
app:backgroundTint="?android:windowBackground"
app:fontFamily="sans-serif-medium"
app:layout_constraintBottom_toBottomOf="@id/loginFormSignIn"
app:layout_constraintEnd_toStartOf="@+id/loginFormSignIn"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@id/loginFormHostLayout"
app:layout_constraintTop_toTopOf="@+id/loginFormSignIn"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
</FrameLayout>

View File

@ -26,7 +26,6 @@
<string name="login_password_hint">Hasło</string>
<string name="login_host_hint">Dziennik</string>
<string name="login_symbol_hint">Symbol</string>
<string name="login_privacy_policy"><a href="https://wulkanowy.github.io/polityka-prywatnosci.html">Polityka prywatności</a></string>
<string name="login_sign_in">Zaloguj</string>
<string name="login_invalid_password">To hasło jest za krótkie</string>
<string name="login_incorrect_password">Dane logowania są niepoprawne</string>
@ -34,6 +33,7 @@
<string name="login_field_required">To pole jest wymagane</string>
<string name="login_duplicate_student">Ten student jest już zalogowany</string>
<string name="login_symbol_helper">Symbol znajduje się na stronie dziennika w zakładce Dostęp Mobilny</string>
<string name="login_privacy_policy">Polityka prywatności</string>
<!--Main-->

View File

@ -26,7 +26,6 @@
<string name="login_password_hint">Password</string>
<string name="login_host_hint">Register</string>
<string name="login_symbol_hint">Symbol</string>
<string name="login_privacy_policy"><a href="https://wulkanowy.github.io/polityka-prywatnosci.html">Privacy policy</a></string>
<string name="login_sign_in">Sign in</string>
<string name="login_invalid_password">This password is too short</string>
<string name="login_incorrect_password">Login details are incorrect</string>
@ -34,6 +33,7 @@
<string name="login_field_required">This field is required</string>
<string name="login_duplicate_student">This student has already been logged in</string>
<string name="login_symbol_helper">The symbol is located on the register page in the Mobile Access tab</string>
<string name="login_privacy_policy">Privacy policy</string>
<!--Main-->

View File

@ -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)