From 5076c11a214d34432e8055989ad6bdcd1fa0eded Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 21 Mar 2018 14:14:14 +0100 Subject: [PATCH] add secret phone storage account at group destination too --- .../contacts/dialogs/CreateNewGroupDialog.kt | 2 ++ .../com/simplemobiletools/contacts/helpers/ContactsHelper.kt | 4 ++++ .../kotlin/com/simplemobiletools/contacts/helpers/DBHelper.kt | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/CreateNewGroupDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/CreateNewGroupDialog.kt index 5f770ba1..33d9f348 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/CreateNewGroupDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/dialogs/CreateNewGroupDialog.kt @@ -12,6 +12,7 @@ import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.contacts.R import com.simplemobiletools.contacts.extensions.config import com.simplemobiletools.contacts.helpers.ContactsHelper +import com.simplemobiletools.contacts.helpers.SMT_PRIVATE import com.simplemobiletools.contacts.models.ContactSource import com.simplemobiletools.contacts.models.Group import kotlinx.android.synthetic.main.dialog_create_new_group.view.* @@ -40,6 +41,7 @@ class CreateNewGroupDialog(val activity: BaseSimpleActivity, val callback: (newG ContactsHelper(activity).getContactSources { it.filter { it.type.contains("google", true) }.mapTo(contactSources, { ContactSource(it.name, it.type) }) + contactSources.add(ContactSource(activity.getString(R.string.phone_storage_hidden), SMT_PRIVATE)) val items = ArrayList() contactSources.forEachIndexed { index, contactSource -> diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt index 56bbd854..61c1e2d0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt @@ -394,6 +394,10 @@ class ContactsHelper(val activity: BaseSimpleActivity) { } fun createNewGroup(title: String, accountName: String, accountType: String): Group? { + if (accountType == SMT_PRIVATE) { + return activity.dbHelper.createGroup(title) + } + val operations = ArrayList() ContentProviderOperation.newInsert(ContactsContract.Groups.CONTENT_URI).apply { withValue(ContactsContract.Groups.TITLE, title) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/DBHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/DBHelper.kt index 965c5256..45b448f3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/DBHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/DBHelper.kt @@ -126,6 +126,10 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont mDb.update(CONTACTS_TABLE_NAME, contactValues, selection, null) } + fun createGroup(name: String): Group? { + return null + } + fun getContacts(selection: String? = null, selectionArgs: Array? = null): ArrayList { val contacts = ArrayList() val projection = arrayOf(COL_ID, COL_FIRST_NAME, COL_MIDDLE_NAME, COL_SURNAME, COL_PHONE_NUMBERS, COL_EMAILS, COL_EVENTS, COL_STARRED,