File tree Expand file tree Collapse file tree 2 files changed +28
-11
lines changed
app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions Expand file tree Collapse file tree 2 files changed +28
-11
lines changed Original file line number Diff line number Diff line change @@ -65,25 +65,26 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
6565 )
6666
6767 val items = ArrayList <RadioItem >()
68- val sources = it.filter { ! ignoredTypes.contains(it.type) }.map { it.name }
69- var currentSourceIndex = - 1
68+ val filteredSources = it.filter { ! ignoredTypes.contains(it.type) }
69+ var sources = filteredSources.map { it.name }
70+ var currentSourceIndex = sources.indexOfFirst { it == currentSource }
71+ sources = filteredSources.map { it.publicName }
72+
7073 sources.forEachIndexed { index, account ->
7174 var publicAccount = account
7275 if (account == config.localAccountName) {
7376 publicAccount = getString(R .string.phone_storage)
7477 }
7578
7679 items.add(RadioItem (index, publicAccount))
77- if (account == currentSource) {
78- currentSourceIndex = index
79- } else if (currentSource == SMT_PRIVATE && account == getString(R .string.phone_storage_hidden)) {
80+ if (currentSource == SMT_PRIVATE && account == getString(R .string.phone_storage_hidden)) {
8081 currentSourceIndex = index
8182 }
8283 }
8384
8485 runOnUiThread {
8586 RadioGroupDialog (this , items, currentSourceIndex) {
86- callback(sources [it as Int ])
87+ callback(filteredSources [it as Int ].name )
8788 }
8889 }
8990 }
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import android.content.Intent
77import android.database.Cursor
88import android.net.Uri
99import android.os.Build
10+ import android.os.Handler
11+ import android.os.Looper
1012import android.provider.BlockedNumberContract
1113import android.provider.BlockedNumberContract.BlockedNumbers
1214import android.provider.ContactsContract
@@ -194,12 +196,26 @@ fun Context.getPhotoThumbnailSize(): Int {
194196fun Context.hasContactPermissions () = hasPermission(PERMISSION_READ_CONTACTS ) && hasPermission(PERMISSION_WRITE_CONTACTS )
195197
196198fun Context.getPublicContactSource (source : String , callback : (String ) -> Unit ) {
197- val newSource = when (source) {
198- config.localAccountName -> getString(R .string.phone_storage)
199- SMT_PRIVATE -> getString(R .string.phone_storage_hidden)
200- else -> source
199+ when (source) {
200+ config.localAccountName -> callback(getString(R .string.phone_storage))
201+ SMT_PRIVATE -> callback(getString(R .string.phone_storage_hidden))
202+ else -> {
203+ Thread {
204+ ContactsHelper (this ).getContactSources {
205+ var newSource = source
206+ for (contactSource in it) {
207+ if (contactSource.name == source && contactSource.type == TELEGRAM_PACKAGE ) {
208+ newSource + = " (${getString(R .string.telegram)} )"
209+ break
210+ }
211+ }
212+ Handler (Looper .getMainLooper()).post {
213+ callback(newSource)
214+ }
215+ }
216+ }.start()
217+ }
201218 }
202- callback(newSource)
203219}
204220
205221fun Context.sendSMSToContacts (contacts : ArrayList <Contact >) {
You can’t perform that action at this time.
0 commit comments