From 8631cf1471f024750ebb5f56b6d916c20b6ab739 Mon Sep 17 00:00:00 2001
From: JRoberts <8711996+jr-simplex@users.noreply.github.com>
Date: Thu, 10 Nov 2022 16:58:31 +0400
Subject: [PATCH] android: remove local authentication error toasts, rename
Retry -> Unlock (#1339)
---
.../java/chat/simplex/app/MainActivity.kt | 37 +++++--------------
.../java/chat/simplex/app/model/SimpleXAPI.kt | 8 +---
.../app/views/helpers/LocalAuthentication.kt | 12 ------
.../app/src/main/res/values-de/strings.xml | 4 --
.../app/src/main/res/values-ru/strings.xml | 4 --
.../app/src/main/res/values/strings.xml | 4 --
6 files changed, 10 insertions(+), 59 deletions(-)
diff --git a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt
index 78d964b0d8..f612354bf2 100644
--- a/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt
+++ b/apps/android/app/src/main/java/chat/simplex/app/MainActivity.kt
@@ -14,7 +14,7 @@ import androidx.compose.foundation.layout.*
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.outlined.Replay
+import androidx.compose.material.icons.outlined.Lock
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
@@ -144,17 +144,10 @@ class MainActivity: FragmentActivity() {
this@MainActivity,
completed = { laResult ->
when (laResult) {
- LAResult.Success -> {
+ LAResult.Success ->
userAuthorized.value = true
- }
- is LAResult.Error -> {
+ is LAResult.Error, LAResult.Failed ->
laFailed.value = true
- laErrorToast(applicationContext, laResult.errString)
- }
- LAResult.Failed -> {
- laFailed.value = true
- laFailedToast(applicationContext)
- }
LAResult.Unavailable -> {
userAuthorized.value = true
m.performLA.value = false
@@ -190,15 +183,9 @@ class MainActivity: FragmentActivity() {
prefPerformLA.set(true)
laTurnedOnAlert()
}
- is LAResult.Error -> {
+ is LAResult.Error, LAResult.Failed -> {
m.performLA.value = false
prefPerformLA.set(false)
- laErrorToast(applicationContext, laResult.errString)
- }
- LAResult.Failed -> {
- m.performLA.value = false
- prefPerformLA.set(false)
- laFailedToast(applicationContext)
}
LAResult.Unavailable -> {
m.performLA.value = false
@@ -223,15 +210,9 @@ class MainActivity: FragmentActivity() {
m.performLA.value = false
prefPerformLA.set(false)
}
- is LAResult.Error -> {
+ is LAResult.Error, LAResult.Failed -> {
m.performLA.value = true
prefPerformLA.set(true)
- laErrorToast(applicationContext, laResult.errString)
- }
- LAResult.Failed -> {
- m.performLA.value = true
- prefPerformLA.set(true)
- laFailedToast(applicationContext)
}
LAResult.Unavailable -> {
m.performLA.value = false
@@ -298,14 +279,14 @@ fun MainPage(
}
@Composable
- fun retryAuthView() {
+ fun authView() {
Box(
Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
SimpleButton(
- stringResource(R.string.auth_retry),
- icon = Icons.Outlined.Replay,
+ stringResource(R.string.auth_unlock),
+ icon = Icons.Outlined.Lock,
click = {
laFailed.value = false
runAuthenticate()
@@ -326,7 +307,7 @@ fun MainPage(
onboarding == null || userCreated == null -> SplashView()
!chatsAccessAuthorized -> {
if (chatModel.controller.appPrefs.performLA.get() && laFailed.value) {
- retryAuthView()
+ authView()
} else {
SplashView()
}
diff --git a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt
index c4bf1b6009..ccc08306c4 100644
--- a/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt
+++ b/apps/android/app/src/main/java/chat/simplex/app/model/SimpleXAPI.kt
@@ -1347,15 +1347,9 @@ open class ChatController(var ctrl: ChatCtrl?, val ntfManager: NtfManager, val a
appPrefs.performLA.set(true)
laTurnedOnAlert()
}
- is LAResult.Error -> {
+ is LAResult.Error, LAResult.Failed -> {
chatModel.performLA.value = false
appPrefs.performLA.set(false)
- laErrorToast(appContext, laResult.errString)
- }
- LAResult.Failed -> {
- chatModel.performLA.value = false
- appPrefs.performLA.set(false)
- laFailedToast(appContext)
}
LAResult.Unavailable -> {
chatModel.performLA.value = false
diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/helpers/LocalAuthentication.kt b/apps/android/app/src/main/java/chat/simplex/app/views/helpers/LocalAuthentication.kt
index 75f97be140..eb52ed137a 100644
--- a/apps/android/app/src/main/java/chat/simplex/app/views/helpers/LocalAuthentication.kt
+++ b/apps/android/app/src/main/java/chat/simplex/app/views/helpers/LocalAuthentication.kt
@@ -89,18 +89,6 @@ fun laTurnedOnAlert() = AlertManager.shared.showAlertMsg(
generalGetString(R.string.auth_you_will_be_required_to_authenticate_when_you_start_or_resume)
)
-fun laErrorToast(context: Context, errString: CharSequence) = Toast.makeText(
- context,
- if (errString.isNotEmpty()) String.format(generalGetString(R.string.auth_error_w_desc), errString) else generalGetString(R.string.auth_error),
- Toast.LENGTH_SHORT
-).show()
-
-fun laFailedToast(context: Context) = Toast.makeText(
- context,
- generalGetString(R.string.auth_failed),
- Toast.LENGTH_SHORT
-).show()
-
fun laUnavailableInstructionAlert() = AlertManager.shared.showAlertMsg(
generalGetString(R.string.auth_unavailable),
generalGetString(R.string.auth_device_authentication_is_not_enabled_you_can_turn_on_in_settings_once_enabled)
diff --git a/apps/android/app/src/main/res/values-de/strings.xml b/apps/android/app/src/main/res/values-de/strings.xml
index 5c2011f2bb..c543f6c38c 100644
--- a/apps/android/app/src/main/res/values-de/strings.xml
+++ b/apps/android/app/src/main/res/values-de/strings.xml
@@ -131,13 +131,9 @@
SimpleX Sperre aktivieren
SimpleX Sperre deaktivieren
Bestätigen Sie Ihre Zugangsdaten
- Authentifizierungsfehler
- Authentifizierungsfehler: %1$s
- Authentifizierung fehlgeschlagen
Authentifizierung nicht verfügbar
Geräteauthentifizierung ist nicht aktiviert. Sie können die SimpleX Sperre über die Einstellungen aktivieren, sobald Sie die Geräteauthentifizierung aktiviert haben.
Geräteauthentifizierung ist deaktiviert. SimpleX Sperre ist abgeschaltet.
- Wiederholen
Chat beenden
Chat-Konsole öffnen
diff --git a/apps/android/app/src/main/res/values-ru/strings.xml b/apps/android/app/src/main/res/values-ru/strings.xml
index da0397cc9b..ca1f0db918 100644
--- a/apps/android/app/src/main/res/values-ru/strings.xml
+++ b/apps/android/app/src/main/res/values-ru/strings.xml
@@ -131,13 +131,9 @@
Включить блокировку SimpleX
Отключить блокировку SimpleX
Пройдите аутентификацию
- Ошибка аутентификации
- Ошибка аутентификации: %1$s
- Ошибка аутентификации
Аутентификация недоступна
Аутентификация устройства не включена. Вы можете включить блокировку SimpleX в Настройках после включения аутентификации.
Аутентификация устройства выключена. Отключение блокировки SimpleX Chat.
- Повторить
Остановить чат
Открыть консоль
diff --git a/apps/android/app/src/main/res/values/strings.xml b/apps/android/app/src/main/res/values/strings.xml
index b1e492ea7d..5efcc80432 100644
--- a/apps/android/app/src/main/res/values/strings.xml
+++ b/apps/android/app/src/main/res/values/strings.xml
@@ -131,13 +131,9 @@
Enable SimpleX Lock
Disable SimpleX Lock
Confirm your credential
- Authentication error
- Authentication error: %1$s
- Authentication failed
Authentication unavailable
Device authentication is not enabled. You can turn on SimpleX Lock via Settings, once you enable device authentication.
Device authentication is disabled. Turning off SimpleX Lock.
- Retry
Stop chat
Open chat console