Skip to content

Commit

Permalink
UP dialog: app name
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g committed Jun 30, 2021
1 parent 5f5b873 commit 09b290e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
19 changes: 16 additions & 3 deletions vector/src/main/java/im/vector/app/core/pushers/UPHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -95,7 +96,7 @@ object UPHelper {
when (distributors.size) {
0 -> {
/**
* TODO: fallback with sync service : automatic ?
* Fallback with sync service
*/
}
1 -> {
Expand All @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 09b290e

Please sign in to comment.