UP dialog: app name

This commit is contained in:
S1m 2021-06-30 08:36:29 +02:00
parent 5f5b873414
commit 09b290e579
2 changed files with 20 additions and 3 deletions

View File

@ -16,6 +16,7 @@
package im.vector.app.core.pushers package im.vector.app.core.pushers
import android.content.Context import android.content.Context
import android.content.pm.PackageManager
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.content.edit import androidx.core.content.edit
import im.vector.app.R import im.vector.app.R
@ -95,7 +96,7 @@ object UPHelper {
when (distributors.size) { when (distributors.size) {
0 -> { 0 -> {
/** /**
* TODO: fallback with sync service : automatic ? * Fallback with sync service
*/ */
} }
1 -> { 1 -> {
@ -104,10 +105,22 @@ object UPHelper {
} }
else -> { else -> {
val builder: AlertDialog.Builder = AlertDialog.Builder(context) 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() 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] val distributor = distributorsArray[which]
up.saveDistributor(context, distributor) up.saveDistributor(context, distributor)
Timber.i("Saving distributor: $distributor") Timber.i("Saving distributor: $distributor")

View File

@ -1115,6 +1115,10 @@
<string name="settings_troubleshoot_test_endpoint_success">Endpoint successfully retrieved:\n%1$s</string> <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> <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 --> <!-- FCM Token, not used anymore -->
<string name="settings_troubleshoot_test_fcm_title">Firebase Token</string> <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> <string name="settings_troubleshoot_test_fcm_success">FCM token successfully retrieved:\n%1$s</string>