Skip to content

Commit

Permalink
Allow to login with keyboard action done
Browse files Browse the repository at this point in the history
  • Loading branch information
borja authored and flaquir4 committed Jul 27, 2020
1 parent 535980f commit 0be17ad
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.inputmethod.EditorInfo
import androidx.core.widget.addTextChangedListener
import com.flaquir4.codetest.R
import com.flaquir4.codetest.presentation.base.BaseActivity
Expand Down Expand Up @@ -34,13 +35,23 @@ class LoginActivity : BaseActivity(), LoginView {

private fun hookListeners() {
loginButton?.setOnClickListener {
val username = usernameInputLayout?.editText?.text.toString()
val password = passwordInputLayout?.editText?.text.toString()
onLoginTap()
}

presenter.onLogInButtonTap(username, password)
passwordEditText.setOnEditorActionListener { v, actionId, event ->
if (actionId == EditorInfo.IME_ACTION_DONE) {
onLoginTap()
}
false
}
}

private fun onLoginTap() {
val username = usernameInputLayout?.editText?.text.toString()
val password = passwordInputLayout?.editText?.text.toString()
presenter.onLogInButtonTap(username, password)
}

override fun navigateToMainScreen() {
startActivity(MainActivity.getIntent(this))
finish()
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/layout-land/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/usernameEditText"
android:nextFocusDown="@id/passwordEditText"
android:maxLines="1"
android:imeOptions="actionNext"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.android.material.textfield.TextInputLayout>
Expand Down Expand Up @@ -57,6 +61,7 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:layout_height="match_parent" />
</com.google.android.material.textfield.TextInputLayout>
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/usernameEditText"
android:nextFocusForward="@id/passwordEditText"
android:imeOptions="actionNext"
android:maxLines="1"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.android.material.textfield.TextInputLayout>
Expand Down Expand Up @@ -64,6 +68,7 @@
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:layout_height="match_parent" />
</com.google.android.material.textfield.TextInputLayout>
Expand Down
2 changes: 1 addition & 1 deletion config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ complexity:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
thresholdInFiles: 11
thresholdInClasses: 11
thresholdInClasses: 20
thresholdInInterfaces: 11
thresholdInObjects: 11
thresholdInEnums: 11
Expand Down

0 comments on commit 0be17ad

Please sign in to comment.