diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/CreateNewGroupDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/CreateNewGroupDialog.kt index a76f57f3..ddda65f7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/CreateNewGroupDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/CreateNewGroupDialog.kt @@ -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() 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() contactSources.forEachIndexed { index, contactSource -> diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt index d1ce1b7e..5a517b45 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Context.kt @@ -307,13 +307,12 @@ fun Context.getVisibleContactSources(): ArrayList { 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 + .map { it.name }.toMutableList() as ArrayList } fun Context.getAllContactSources(): List { 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)) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt index 508671a5..14cf3ddb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/ContactsHelper.kt @@ -845,8 +845,7 @@ class ContactsHelper(val context: Context) { private fun getContactSourcesSync(): ArrayList { 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) }