diff --git a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt index b7a43fbd3..658d7ba14 100644 --- a/app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/settings/viewmodel/SettingsViewModel.kt @@ -1235,4 +1235,34 @@ class SettingsViewModel showGreenToast(R.string.settings_developer_cleared_native_friends_in_database_toast, R.drawable.trash_simple) } } + + @UiThread + fun clearOrphanAuthInfo() { + coreContext.postOnCoreThread { core -> + var count = 0 + for (authInfo in core.authInfoList) { + val username = authInfo.username + if (username == null) { + Log.i("$TAG Removing auth info [$authInfo] without username") + core.removeAuthInfo(authInfo) + count += 1 + } else { + val account = core.accountList.find { + it.params.identityAddress?.username == username + } + if (account == null) { + Log.i("$TAG Removing auth info [$authInfo] with username [$username] for which no account was found") + core.removeAuthInfo(authInfo) + count += 1 + } + } + } + if (count == 0) { + showGreenToast(R.string.settings_developer_no_auth_info_removed_toast, R.drawable.trash_simple) + } else { + val message = AppUtils.getStringWithPlural(R.plurals.settings_developer_cleared_auth_info_toast, count, "$count") + showFormattedGreenToast(message, R.drawable.warning_circle) + } + } + } } diff --git a/app/src/main/res/layout/settings_developer_fragment.xml b/app/src/main/res/layout/settings_developer_fragment.xml index 694b1ecd6..6ce1ae0cf 100644 --- a/app/src/main/res/layout/settings_developer_fragment.xml +++ b/app/src/main/res/layout/settings_developer_fragment.xml @@ -315,21 +315,25 @@ app:layout_constraintEnd_toEndOf="parent"/> + + diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 527a72232..622737479 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -332,6 +332,12 @@ Supprimer les contacts natifs importés Ils seront synchronisés à nouveau au prochain démarrage de l\'application sauf si vous retirez la permission de lire les contacts Contacts importés supprimés + Supprimer les informations d\'authentification orphelines + Aucune information d\'authentification orpheline trouvée + + %s information d\'authentification supprimée + %s informations d\'authentification supprimées + Mon compte diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 205559593..748021857 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -374,6 +374,12 @@ Clear imported contacts from native address book They will be imported again the next time the app starts unless you remove the contacts permission Imported contacts have been deleted + Clear authentication info no longer associated to any account + No orphan authentication info found + + %s orphan authentication info removed + %s orphans authentication info removed + Manage account