use smt_private for the private account name

This commit is contained in:
tibbi 2019-01-24 19:55:12 +01:00
parent e5862e700a
commit 37b6619e51
3 changed files with 7 additions and 8 deletions

View File

@ -10,8 +10,8 @@ import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.extensions.value
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.extensions.getPrivateContactSource
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
import com.simplemobiletools.contacts.pro.helpers.SMT_PRIVATE
import com.simplemobiletools.contacts.pro.models.ContactSource
import com.simplemobiletools.contacts.pro.models.Group
import kotlinx.android.synthetic.main.dialog_create_new_group.view.*
@ -36,8 +36,7 @@ class CreateNewGroupDialog(val activity: BaseSimpleActivity, val callback: (newG
val contactSources = ArrayList<ContactSource>()
ContactsHelper(activity).getContactSources {
it.filter { it.type.contains("google", true) }.mapTo(contactSources) { ContactSource(it.name, it.type, it.name) }
val phoneSecret = activity.getString(R.string.phone_storage_hidden)
contactSources.add(ContactSource(phoneSecret, SMT_PRIVATE, phoneSecret))
contactSources.add(activity.getPrivateContactSource())
val items = ArrayList<RadioItem>()
contactSources.forEachIndexed { index, contactSource ->

View File

@ -307,13 +307,12 @@ fun Context.getVisibleContactSources(): ArrayList<String> {
val sources = getAllContactSources()
val ignoredContactSources = config.ignoredContactSources
return ArrayList(sources).filter { !ignoredContactSources.contains(it.getFullIdentifier()) }
.map { if (it.type == SMT_PRIVATE) SMT_PRIVATE else it.name }.toMutableList() as ArrayList<String>
.map { it.name }.toMutableList() as ArrayList<String>
}
fun Context.getAllContactSources(): List<ContactSource> {
val sources = ContactsHelper(this).getDeviceContactSources()
val phoneSecret = getString(R.string.phone_storage_hidden)
sources.add(ContactSource(phoneSecret, SMT_PRIVATE, phoneSecret))
sources.add(getPrivateContactSource())
return sources.toMutableList()
}
@ -372,3 +371,5 @@ fun Context.deleteBlockedNumber(number: String) {
@TargetApi(Build.VERSION_CODES.M)
fun Context.isDefaultDialer() = isMarshmallowPlus() && telecomManager.defaultDialerPackage == packageName
fun Context.getPrivateContactSource() = ContactSource(SMT_PRIVATE, SMT_PRIVATE, getString(R.string.phone_storage_hidden))

View File

@ -845,8 +845,7 @@ class ContactsHelper(val context: Context) {
private fun getContactSourcesSync(): ArrayList<ContactSource> {
val sources = getDeviceContactSources()
val phoneSecret = context.getString(R.string.phone_storage_hidden)
sources.add(ContactSource(phoneSecret, SMT_PRIVATE, phoneSecret))
sources.add(context.getPrivateContactSource())
return ArrayList(sources)
}