mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 13:15:35 +03:00
Fix
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
3ce4b8b1ac
commit
ec14e5e921
1 changed files with 9 additions and 12 deletions
|
@ -29,7 +29,6 @@ import com.owncloud.android.databinding.PasscodelockBinding
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC
|
import com.owncloud.android.lib.common.utils.Log_OC
|
||||||
import com.owncloud.android.ui.components.PassCodeEditText
|
import com.owncloud.android.ui.components.PassCodeEditText
|
||||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||||
import java.util.Arrays
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Suppress("TooManyFunctions", "MagicNumber")
|
@Suppress("TooManyFunctions", "MagicNumber")
|
||||||
|
@ -69,7 +68,7 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
|
||||||
private set
|
private set
|
||||||
|
|
||||||
private val passCodeEditTexts = arrayOfNulls<PassCodeEditText>(4)
|
private val passCodeEditTexts = arrayOfNulls<PassCodeEditText>(4)
|
||||||
private var passCodeDigits: Array<String?>? = arrayOf("", "", "", "")
|
private var passCodeDigits: Array<String> = arrayOf("", "", "", "")
|
||||||
private var confirmingPassCode = false
|
private var confirmingPassCode = false
|
||||||
private var changed = true // to control that only one blocks jump
|
private var changed = true // to control that only one blocks jump
|
||||||
|
|
||||||
|
@ -117,7 +116,7 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
|
||||||
} else if (ACTION_REQUEST_WITH_RESULT == intent.action) {
|
} else if (ACTION_REQUEST_WITH_RESULT == intent.action) {
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
confirmingPassCode = savedInstanceState.getBoolean(KEY_CONFIRMING_PASSCODE)
|
confirmingPassCode = savedInstanceState.getBoolean(KEY_CONFIRMING_PASSCODE)
|
||||||
passCodeDigits = savedInstanceState.getStringArray(KEY_PASSCODE_DIGITS)
|
passCodeDigits = savedInstanceState.getStringArray(KEY_PASSCODE_DIGITS) ?: arrayOf("", "", "", "")
|
||||||
}
|
}
|
||||||
if (confirmingPassCode) {
|
if (confirmingPassCode) {
|
||||||
// the app was in the passcode confirmation
|
// the app was in the passcode confirmation
|
||||||
|
@ -185,7 +184,7 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
|
||||||
passCodeEditTexts[passCodeIndex - 1]?.requestFocus()
|
passCodeEditTexts[passCodeIndex - 1]?.requestFocus()
|
||||||
|
|
||||||
if (!confirmingPassCode) {
|
if (!confirmingPassCode) {
|
||||||
passCodeDigits?.set(passCodeIndex - 1, "")
|
passCodeDigits[passCodeIndex - 1] = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
passCodeEditTexts[passCodeIndex - 1]?.setText(R.string.empty)
|
passCodeEditTexts[passCodeIndex - 1]?.setText(R.string.empty)
|
||||||
|
@ -258,8 +257,6 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showErrorAndRestart(errorMessage: Int, headerMessage: Int, explanationVisibility: Int) {
|
private fun showErrorAndRestart(errorMessage: Int, headerMessage: Int, explanationVisibility: Int) {
|
||||||
passCodeDigits?.let { Arrays.fill(it, null) }
|
|
||||||
|
|
||||||
Snackbar.make(findViewById(android.R.id.content), getString(errorMessage), Snackbar.LENGTH_LONG).show()
|
Snackbar.make(findViewById(android.R.id.content), getString(errorMessage), Snackbar.LENGTH_LONG).show()
|
||||||
binding.header.setText(headerMessage) // TODO check if really needed
|
binding.header.setText(headerMessage) // TODO check if really needed
|
||||||
binding.explanation.visibility = explanationVisibility // TODO check if really needed
|
binding.explanation.visibility = explanationVisibility // TODO check if really needed
|
||||||
|
@ -279,14 +276,14 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
|
||||||
|
|
||||||
private fun checkPassCode(): Boolean {
|
private fun checkPassCode(): Boolean {
|
||||||
val savedPassCodeDigits = preferences?.passCode
|
val savedPassCodeDigits = preferences?.passCode
|
||||||
return passCodeDigits?.zip(savedPassCodeDigits.orEmpty()) { input, saved ->
|
return passCodeDigits.zip(savedPassCodeDigits.orEmpty()) { input, saved ->
|
||||||
input != null && input == saved
|
input == saved
|
||||||
}?.all { it } ?: false
|
}.all { it }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun confirmPassCode(): Boolean {
|
private fun confirmPassCode(): Boolean {
|
||||||
return passCodeEditTexts.indices.all { i ->
|
return passCodeEditTexts.indices.all { i ->
|
||||||
passCodeEditTexts[i]?.text.toString() == passCodeDigits!![i]
|
passCodeEditTexts[i]?.text.toString() == passCodeDigits[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +317,7 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
|
||||||
val resultIntent = Intent()
|
val resultIntent = Intent()
|
||||||
resultIntent.putExtra(
|
resultIntent.putExtra(
|
||||||
KEY_PASSCODE,
|
KEY_PASSCODE,
|
||||||
passCodeDigits!![0] + passCodeDigits!![1] + passCodeDigits!![2] + passCodeDigits!![3]
|
passCodeDigits[0] + passCodeDigits[1] + passCodeDigits[2] + passCodeDigits[3]
|
||||||
)
|
)
|
||||||
setResult(RESULT_OK, resultIntent)
|
setResult(RESULT_OK, resultIntent)
|
||||||
passCodeManager?.updateLockTimestamp()
|
passCodeManager?.updateLockTimestamp()
|
||||||
|
@ -397,7 +394,7 @@ class PassCodeActivity : AppCompatActivity(), Injectable {
|
||||||
val passCodeText = passCodeEditTexts[mIndex]?.text
|
val passCodeText = passCodeEditTexts[mIndex]?.text
|
||||||
|
|
||||||
if (passCodeText != null) {
|
if (passCodeText != null) {
|
||||||
passCodeDigits!![mIndex] = passCodeText.toString()
|
passCodeDigits[mIndex] = passCodeText.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue