mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-27 12:00:03 +03:00
Kotlinification
This commit is contained in:
parent
f0afd5ceea
commit
1058bfecf4
1 changed files with 18 additions and 14 deletions
|
@ -39,26 +39,30 @@ class TestFirebaseToken @Inject constructor(private val context: AppCompatActivi
|
|||
FirebaseMessaging.getInstance().token
|
||||
.addOnCompleteListener(context) { task ->
|
||||
if (!task.isSuccessful) {
|
||||
val errorMsg = if (task.exception == null) "Unknown" else task.exception!!.localizedMessage
|
||||
// Can't find where this constant is (not documented -or deprecated in docs- and all obfuscated)
|
||||
if ("SERVICE_NOT_AVAILABLE".equals(errorMsg)) {
|
||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed_service_not_available, errorMsg)
|
||||
} else if ("TOO_MANY_REGISTRATIONS".equals(errorMsg)) {
|
||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed_too_many_registration, errorMsg)
|
||||
} else if ("ACCOUNT_MISSING".equals(errorMsg)) {
|
||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed_account_missing, errorMsg)
|
||||
description = when (val errorMsg = task.exception?.localizedMessage ?: "Unknown") {
|
||||
"SERVICE_NOT_AVAILABLE" -> {
|
||||
stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed_service_not_available, errorMsg)
|
||||
}
|
||||
"TOO_MANY_REGISTRATIONS" -> {
|
||||
stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed_too_many_registration, errorMsg)
|
||||
}
|
||||
"ACCOUNT_MISSING" -> {
|
||||
quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_fcm_failed_account_missing_quick_fix) {
|
||||
override fun doFix() {
|
||||
startAddGoogleAccountIntent(context, activityResultLauncher)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed, errorMsg)
|
||||
stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed_account_missing, errorMsg)
|
||||
}
|
||||
else -> {
|
||||
stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed, errorMsg)
|
||||
}
|
||||
}
|
||||
status = TestStatus.FAILED
|
||||
} else {
|
||||
task.result?.let { token ->
|
||||
val tok = token.substring(0, Math.min(8, token.length)) + "********************"
|
||||
val tok = token.take(8) + "********************"
|
||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_fcm_success, tok)
|
||||
Timber.e("Retrieved FCM token success [$tok].")
|
||||
// Ensure it is well store in our local storage
|
||||
|
|
Loading…
Reference in a new issue