Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[a11y] Keyboard navigation in security passcode view #4455

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ownCloud admins and users.
* Enhancement - Changed the color of some elements to improve accessibility: [#4364](https://github.com/owncloud/android/issues/4364)
* Enhancement - Improved SearchView accessibility: [#4365](https://github.com/owncloud/android/issues/4365)
* Enhancement - Hardware keyboard support: [#4438](https://github.com/owncloud/android/pull/4438)
* Enhancement - Hardware keyboard support for passcode view: [#4447](https://github.com/owncloud/android/issues/4447)

## Details

Expand Down Expand Up @@ -99,6 +100,13 @@ ownCloud admins and users.
https://github.com/owncloud/android/issues/4368
https://github.com/owncloud/android/pull/4438

* Enhancement - Hardware keyboard support for passcode view: [#4447](https://github.com/owncloud/android/issues/4447)

Navigation via hardware keyboard has been added to the passcode view.

https://github.com/owncloud/android/issues/4447
https://github.com/owncloud/android/pull/4455

# Changelog for ownCloud Android Client [4.3.1] (2024-07-22)

The following sections list the changes in ownCloud Android Client 4.3.1 relevant to
Expand Down
6 changes: 6 additions & 0 deletions changelog/unreleased/4455
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Hardware keyboard support for passcode view

Navigation via hardware keyboard has been added to the passcode view.

https://github.com/owncloud/android/issues/4447
https://github.com/owncloud/android/pull/4455
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
* @author Abel García de Prada
* @author Juan Carlos Garrote Gascón
* @author David Crespo Ríos
* @author Aitor Ballesteros Pavón
*
* Copyright (C) 2011 Bartek Przybylski
* Copyright (C) 2021 ownCloud GmbH.
* Copyright (C) 2024 ownCloud GmbH.
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand Down Expand Up @@ -118,6 +120,7 @@ class PassCodeActivity : AppCompatActivity(), NumberKeyboardListener, EnableBiom
binding.explanation.visibility = View.INVISIBLE
supportActionBar?.setDisplayHomeAsUpEnabled(false) //Don´t show the back arrow
}

ACTION_CREATE -> { //Create a new password
if (confirmingPassCode) {
//the app was in the passcode confirmation
Expand All @@ -136,22 +139,26 @@ class PassCodeActivity : AppCompatActivity(), NumberKeyboardListener, EnableBiom
intent.extras?.getBoolean(EXTRAS_MIGRATION) == true -> {
supportActionBar?.setDisplayHomeAsUpEnabled(false)
}

intent.extras?.getBoolean(EXTRAS_LOCK_ENFORCED) == true -> {
supportActionBar?.setDisplayHomeAsUpEnabled(false)
}

else -> {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
}
}
}

ACTION_REMOVE -> { // Remove password
// pass code preference has just been disabled in Preferences;
// will confirm user knows pass code, then remove it
binding.header.text = getString(R.string.pass_code_remove_your_pass_code)
binding.explanation.visibility = View.INVISIBLE
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}

else -> {
throw IllegalArgumentException(R.string.illegal_argument_exception_message.toString() + " ")
}
Expand Down Expand Up @@ -231,12 +238,14 @@ class PassCodeActivity : AppCompatActivity(), NumberKeyboardListener, EnableBiom
else -> actionCheckError()
}
}

PasscodeAction.REMOVE -> {
when (status.type) {
PasscodeType.OK -> actionRemoveOk()
else -> actionRemoveError()
}
}

PasscodeAction.CREATE -> {
when (status.type) {
PasscodeType.NO_CONFIRM -> actionCreateNoConfirm()
Expand Down Expand Up @@ -421,6 +430,7 @@ class PassCodeActivity : AppCompatActivity(), NumberKeyboardListener, EnableBiom
BiometricStatus.ENABLED_BY_USER -> {
passCodeViewModel.setBiometricsState(enabled = true)
}

BiometricStatus.DISABLED_BY_USER -> {
passCodeViewModel.setBiometricsState(enabled = false)
}
Expand All @@ -434,15 +444,52 @@ class PassCodeActivity : AppCompatActivity(), NumberKeyboardListener, EnableBiom
ACTION_REMOVE -> {
return PasscodeAction.REMOVE
}

ACTION_CREATE -> {
return PasscodeAction.CREATE
}

else -> {
return PasscodeAction.CHECK
}
}
}

override fun onKeyUp(keyCode: Int, event: KeyEvent?): Boolean {
return when (keyCode) {
KeyEvent.KEYCODE_TAB -> {
findViewById<View>(R.id.lock_time).requestFocus()
true
}
jesmrec marked this conversation as resolved.
Show resolved Hide resolved

KeyEvent.KEYCODE_DPAD_DOWN -> {
if (!findViewById<View>(R.id.numberKeyboard).hasFocus()) {
findViewById<View>(R.id.numberKeyboard).requestFocus()
}
true
}
jesmrec marked this conversation as resolved.
Show resolved Hide resolved

in KeyEvent.KEYCODE_0..KeyEvent.KEYCODE_9 -> {
val number = keyCode - KeyEvent.KEYCODE_0
passCodeViewModel.onNumberClicked(number)
true
}

KeyEvent.KEYCODE_DEL -> {
passCodeViewModel.onBackspaceClicked()
true
}

KeyEvent.KEYCODE_ESCAPE -> {
PassCodeManager.onActivityStopped(this)
super.onBackPressed()
true
}

else -> super.onKeyUp(keyCode, event)
}
}

companion object {
const val ACTION_CREATE = "ACTION_REQUEST_WITH_RESULT"
const val ACTION_REMOVE = "ACTION_CHECK_WITH_RESULT"
Expand Down
Loading