Commit be60e2f5 authored by Niklas Fix's avatar Niklas Fix 🎓

fix #56

parent fe2f62af
......@@ -15,6 +15,7 @@ import com.stepstone.stepper.VerificationError
import de.akamu.tudarmstadt.R
import de.akamu.tudarmstadt.features.signup.SignupActivity
import de.akamu.tudarmstadt.features.signup.SignupContract
import de.akamu.tudarmstadt.util.Constants
import de.akamu.tudarmstadt.util.Extensions.Companion.toast
import kotlinx.android.synthetic.main.fragment_password.*
......@@ -25,8 +26,8 @@ class PasswordFragment : Fragment(), PasswordContract.View, Step {
private var errorStringNotEqual: String = "error"
private var errorStringNotUpperLower: String = "error"
var ve1 : VerificationError? = null
var ve2 : VerificationError? = null
var ve1: VerificationError? = null
var ve2: VerificationError? = null
override lateinit var presenter: PasswordContract.Presenter
override var signupPresenter: SignupContract.Presenter? = null
......@@ -50,10 +51,21 @@ class PasswordFragment : Fragment(), PasswordContract.View, Step {
super.onActivityCreated(savedInstanceState)
signupPresenter = (activity as SignupActivity).presenter
textView_password_info.text = getString(
R.string.password_rules,
Constants.MIN_PASSWORD_LENGTH,
Constants.MAX_PASSWORD_LENGTH
)
val signUpFirstPasswordOnEditorActionListener = SignUpFirstPasswordOnEditorActionListener()
val signUpSecondPasswordOnEditorActionListener = SignUpSecondPasswordOnEditorActionListener()
textinputedittext_signup_password1.setOnEditorActionListener(signUpFirstPasswordOnEditorActionListener)
textinputedittext_signup_password2.setOnEditorActionListener(signUpSecondPasswordOnEditorActionListener)
val signUpSecondPasswordOnEditorActionListener =
SignUpSecondPasswordOnEditorActionListener()
textinputedittext_signup_password1.setOnEditorActionListener(
signUpFirstPasswordOnEditorActionListener
)
textinputedittext_signup_password2.setOnEditorActionListener(
signUpSecondPasswordOnEditorActionListener
)
}
override fun showFirstPasswordValid() {
......@@ -128,12 +140,14 @@ class PasswordFragment : Fragment(), PasswordContract.View, Step {
// activity?.toast(error.errorMessage)
}
private inner class SignUpFirstPasswordOnEditorActionListener : TextView.OnEditorActionListener {
private inner class SignUpFirstPasswordOnEditorActionListener :
TextView.OnEditorActionListener {
override fun onEditorAction(textView: TextView, id: Int, keyEvent: KeyEvent?): Boolean {
if (id == EditorInfo.IME_ACTION_NEXT || id == EditorInfo.IME_NULL) {
presenter.checkFirstPassword(textinputedittext_signup_password1.text.toString())
if(ve1 == null){
val imm = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
if (ve1 == null) {
val imm =
activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
imm!!.hideSoftInputFromWindow(
textinputlayout_signup_password1.windowToken,
InputMethodManager.RESULT_UNCHANGED_SHOWN
......@@ -145,15 +159,17 @@ class PasswordFragment : Fragment(), PasswordContract.View, Step {
}
}
private inner class SignUpSecondPasswordOnEditorActionListener : TextView.OnEditorActionListener {
private inner class SignUpSecondPasswordOnEditorActionListener :
TextView.OnEditorActionListener {
override fun onEditorAction(textView: TextView, id: Int, keyEvent: KeyEvent?): Boolean {
if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
presenter.checkSecondPassword(
textinputedittext_signup_password1.text.toString(),
textinputedittext_signup_password2.text.toString()
)
if(ve2 == null){
val imm = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
if (ve2 == null) {
val imm =
activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
imm!!.hideSoftInputFromWindow(
textinputlayout_signup_password2.windowToken,
InputMethodManager.RESULT_UNCHANGED_SHOWN
......
......@@ -62,7 +62,7 @@ class PasswordPresenter(var view: PasswordContract.View?)
checkSecondPassword(password1, password2)
}
fun containsUpperAndLowerChar(password: String) : Boolean {
private fun containsUpperAndLowerChar(password: String) : Boolean {
return password != password.toLowerCase(Locale.ROOT)
&& password != password.toUpperCase(Locale.ROOT)
}
......
......@@ -51,7 +51,7 @@
android:paddingEnd="16dp"
android:text="@string/signup_email_description_bottom"
android:textColor="@color/textWhite"
android:textSize="18sp"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textinputlayout_signup_email" />
......
......@@ -6,12 +6,61 @@
android:background="@color/akamu_blue"
tools:context="de.akamu.tudarmstadt.features.signup.password.PasswordFragment">
<TextView
android:id="@+id/textview_signup_password_description_head"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="128dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:paddingStart="64dp"
android:paddingEnd="64dp"
android:text="@string/signup_password_description_head"
android:textColor="@color/textWhite"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textview_signup_password_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:paddingStart="64dp"
android:paddingEnd="64dp"
android:text="@string/signup_password_description"
android:textColor="@color/textWhite"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textview_signup_password_description_head" />
<TextView
android:id="@+id/textView_password_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:text="@string/password_rules"
android:textColor="@color/textWhite"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textview_signup_password_description" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textinputlayout_signup_password1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="32dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="24dp"
android:hint="@string/hint_signup_enterpassword"
android:textColor="@color/textWhite"
......@@ -19,7 +68,7 @@
android:theme="@style/AkamuEditText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textview_signup_password_description"
app:layout_constraintTop_toBottomOf="@+id/textView_password_info"
app:passwordToggleEnabled="true"
app:passwordToggleTint="@color/white">
......@@ -65,39 +114,4 @@
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:id="@+id/textview_signup_password_description_head"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="128dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:paddingStart="64dp"
android:paddingEnd="64dp"
android:text="@string/signup_password_description_head"
android:textColor="@color/textWhite"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textview_signup_password_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:paddingStart="64dp"
android:paddingEnd="64dp"
android:text="@string/signup_password_description"
android:textColor="@color/textWhite"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textview_signup_password_description_head" />
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -228,4 +228,5 @@
<string name="load_user_failed">Nutzer konnte nicht geladen werden: %1$s</string>
<string name="no_common_questionpools">Keine gemeinsamen FragenPools</string>
<string name="no_common_questionpool_info">Um ein Duell spielen zu können, müssen du und dein Freund einen gemeinsamen FragenPool haben. Entweder hat dein Freund noch keine Pools ausgewählt, oder du kannst versuchen, andere Pools zu setzen.</string>
<string name="password_rules">Dein Passwort muss mindestens %1$d Zeichen, maximal %2$d Zeichen, mindestens einen Klein- und mindestens einen Großbuchstaben enthalten.</string>
</resources>
\ No newline at end of file
......@@ -280,4 +280,5 @@
<string name="load_user_failed">Failed to load user: %1$s</string>
<string name="no_common_questionpools">No common QuestionPools</string>
<string name="no_common_questionpool_info">In order to play a duel, you and your friend need to have common QuestionPools. Either your friend hasn\'t chosen any pools yet or you can try to select other pools.</string>
<string name="password_rules">Your password must contain at least %1$d characters, at most %2$d characters, at least one lower case and at leat one upper case letter.</string>
</resources>
......@@ -344,5 +344,6 @@
<string name="OK" translatable="false">OK</string>
<string name="no_common_questionpools" >No common QuestionPools</string>
<string name="no_common_questionpool_info" >In order to play a duel, you and your friend need to have a common QuestionPool. Either your friend hasn\'t chosen any pools yet or you can try to select other pools.</string>
<string name="password_rules">Your password must contain at least %1$d characters, at most %2$d characters, at least one lower case and at leat one upper case letter.</string>
</resources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment