Skip to content

Commit

Permalink
fix: deleted hideSoftKeyboard function and refactor the setOnKeyListe…
Browse files Browse the repository at this point in the history
…ner method
  • Loading branch information
Aitorbp committed Sep 19, 2024
1 parent cfb5229 commit 2f3c193
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import android.net.Uri
import android.text.method.LinkMovementMethod
import android.util.TypedValue
import android.view.ContextThemeWrapper
import android.view.inputmethod.InputMethodManager
import android.webkit.MimeTypeMap
import android.widget.Button
import android.widget.LinearLayout
Expand Down Expand Up @@ -274,17 +273,6 @@ private fun makeIntent(file: File?, context: Context): Intent {
return sendIntent
}

fun Activity.hideSoftKeyboard() {
val focusedView = currentFocus
focusedView?.let {
val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(
focusedView.windowToken,
0
)
}
}

fun Activity.checkPasscodeEnforced(securityEnforced: SecurityEnforced) {
val sharedPreferencesProvider = OCSharedPreferencesProvider(this)
val mdmProvider by inject<MdmProvider>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import com.owncloud.android.BuildConfig
import com.owncloud.android.R
import com.owncloud.android.databinding.PasscodelockBinding
import com.owncloud.android.domain.utils.Event
import com.owncloud.android.extensions.hideSoftKeyboard
import com.owncloud.android.extensions.showBiometricDialog
import com.owncloud.android.presentation.documentsprovider.DocumentsProviderUtils.Companion.notifyDocumentsProviderRoots
import com.owncloud.android.presentation.security.biometric.BiometricStatus
Expand Down Expand Up @@ -195,23 +194,20 @@ class PassCodeActivity : AppCompatActivity(), NumberKeyboardListener, EnableBiom
val numberOfPasscodeDigits = (passCodeViewModel.getPassCode()?.length ?: passCodeViewModel.getNumberOfPassCodeDigits())
for (i in 0 until numberOfPasscodeDigits) {

passCodeEditTexts[i]?.apply {
hideSoftKeyboard()

setOnKeyListener { v, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_TAB && event.action == KeyEvent.ACTION_DOWN) {
val focusDirection = if (passCodeEditTexts.indexOf(v) == 0) {
View.FOCUS_DOWN
} else {
View.FOCUS_LEFT
}
v.focusSearch(focusDirection)?.requestFocus()
true
passCodeEditTexts[i]?.setOnKeyListener { v, keyCode, event ->
if (keyCode == KeyEvent.KEYCODE_TAB && event.action == KeyEvent.ACTION_DOWN) {
val focusDirection = if (passCodeEditTexts.indexOf(v) == 0) {
View.FOCUS_DOWN
} else {
false
View.FOCUS_RIGHT
}
v.focusSearch(focusDirection)?.requestFocus()
true
} else {
false
}
}

passCodeEditTexts[i]?.onFocusChangeListener = OnFocusChangeListener { _: View, _: Boolean ->
// Return the focus to the first EditText without number
for (j in 0 until i) {
Expand Down

0 comments on commit 2f3c193

Please sign in to comment.