diff --git a/vector/src/main/java/im/vector/app/core/pushers/UPHelper.kt b/vector/src/main/java/im/vector/app/core/pushers/UPHelper.kt index 0d7e69d382..e8c06ef1cc 100644 --- a/vector/src/main/java/im/vector/app/core/pushers/UPHelper.kt +++ b/vector/src/main/java/im/vector/app/core/pushers/UPHelper.kt @@ -16,6 +16,7 @@ package im.vector.app.core.pushers import android.content.Context +import android.content.pm.PackageManager import androidx.appcompat.app.AlertDialog import androidx.core.content.edit import im.vector.app.R @@ -95,7 +96,7 @@ object UPHelper { when (distributors.size) { 0 -> { /** - * TODO: fallback with sync service : automatic ? + * Fallback with sync service */ } 1 -> { @@ -104,10 +105,22 @@ object UPHelper { } else -> { val builder: AlertDialog.Builder = AlertDialog.Builder(context) - builder.setTitle("Choose a distributor") + builder.setTitle(context.getString(R.string.unifiedpush_getdistributors_dialog_title)) val distributorsArray = distributors.toTypedArray() - builder.setItems(distributorsArray) { _, which -> + val distributorsNameArray = distributorsArray.map { + if (it == context.packageName) { + context.getString(R.string.unifiedpush_getdistributors_dialog_fcm_fallback) + } else { + try { + val ai = context.packageManager.getApplicationInfo(it, 0) + context.packageManager.getApplicationLabel(ai) + } catch (e: PackageManager.NameNotFoundException) { + it + } as String + } + }.toTypedArray() + builder.setItems(distributorsNameArray) { _, which -> val distributor = distributorsArray[which] up.saveDistributor(context, distributor) Timber.i("Saving distributor: $distributor") diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index d82c8bead2..a3d5b3a0e4 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1115,6 +1115,10 @@ <string name="settings_troubleshoot_test_endpoint_success">Endpoint successfully retrieved:\n%1$s</string> <string name="settings_troubleshoot_test_endpoint_failed">Failed to retrieved Endpoint.</string> + <!-- UnifiedPush Distributor Picker Dialog --> + <string name="unifiedpush_getdistributors_dialog_title">Choose a distributor</string> + <string name="unifiedpush_getdistributors_dialog_fcm_fallback">FCM Fallback</string> + <!-- FCM Token, not used anymore --> <string name="settings_troubleshoot_test_fcm_title">Firebase Token</string> <string name="settings_troubleshoot_test_fcm_success">FCM token successfully retrieved:\n%1$s</string>