From 66ff093a66412f90a5a7eb80ce8fcd792e03f7c7 Mon Sep 17 00:00:00 2001 From: ismailnurudeen Date: Tue, 21 Feb 2023 13:15:48 +0100 Subject: [PATCH] fix: use baseConfig instead of ContactsConfig --- .../pro/activities/EditContactActivity.kt | 6 +- .../activities/InsertOrEditContactActivity.kt | 6 +- .../contacts/pro/activities/MainActivity.kt | 52 ++++++++--------- .../pro/activities/SettingsActivity.kt | 56 +++++++++--------- .../pro/activities/ViewContactActivity.kt | 8 +-- .../contacts/pro/adapters/ContactsAdapter.kt | 4 +- .../contacts/pro/adapters/GroupsAdapter.kt | 2 +- .../pro/adapters/SelectContactsAdapter.kt | 4 +- .../MyContactsContentProvider.kt | 4 +- .../pro/dialogs/ChangeSortingDialog.kt | 4 +- .../pro/dialogs/ExportContactsDialog.kt | 4 +- .../pro/dialogs/FilterContactSourcesDialog.kt | 4 +- .../pro/dialogs/ImportContactsDialog.kt | 2 +- .../pro/dialogs/ManageVisibleFieldsDialog.kt | 8 +-- .../pro/dialogs/ManageVisibleTabsDialog.kt | 6 +- .../pro/dialogs/MyDatePickerDialog.kt | 4 +- .../contacts/pro/extensions/Activity.kt | 4 +- .../pro/fragments/MyViewPagerFragment.kt | 18 +++--- .../contacts/pro/helpers/VcfExporter.kt | 57 ++++++++++--------- 19 files changed, 129 insertions(+), 124 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt index ad53706b..d4007a7e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt @@ -388,7 +388,7 @@ class EditContactActivity : ContactActivity() { } private fun setupFieldVisibility() { - val showFields = contactsConfig.showContactFields + val showFields = this.baseConfig.showContactFields if (showFields and (SHOW_PREFIX_FIELD or SHOW_FIRST_NAME_FIELD or SHOW_MIDDLE_NAME_FIELD or SHOW_SURNAME_FIELD or SHOW_SUFFIX_FIELD) == 0) { contact_name_image.beInvisible() } @@ -744,7 +744,7 @@ class EditContactActivity : ContactActivity() { } private fun setupNewContact() { - originalContactSource = if (hasContactPermissions()) contactsConfig.lastUsedContactSource else SMT_PRIVATE + originalContactSource = if (hasContactPermissions()) this.baseConfig.lastUsedContactSource else SMT_PRIVATE contact = getEmptyContact() getPublicContactSource(contact!!.source) { contact_source.text = if (it == "") getString(R.string.phone_storage) else it @@ -1049,7 +1049,7 @@ class EditContactActivity : ContactActivity() { contact = contactValues ensureBackgroundThread { - contactsConfig.lastUsedContactSource = contact!!.source + this.baseConfig.lastUsedContactSource = contact!!.source when { contact!!.id == 0 -> insertNewContact(false) originalContactSource != contact!!.source -> insertNewContact(true) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt index 90b1f1c9..6a7f51d7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt @@ -17,7 +17,7 @@ import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.adapters.ViewPagerAdapter import com.simplemobiletools.contacts.pro.dialogs.ChangeSortingDialog import com.simplemobiletools.contacts.pro.dialogs.FilterContactSourcesDialog -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.contacts.pro.fragments.MyViewPagerFragment import com.simplemobiletools.contacts.pro.helpers.ADD_NEW_CONTACT_NUMBER import com.simplemobiletools.contacts.pro.helpers.KEY_EMAIL @@ -159,7 +159,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { private fun setupTabs() { insert_edit_tabs_holder.removeAllTabs() contactsFavoritesList.forEachIndexed { index, value -> - if (contactsConfig.showTabs and value != 0) { + if (this.baseConfig.showTabs and value != 0) { insert_edit_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply { customView?.findViewById(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index)) customView?.findViewById(R.id.tab_item_label)?.text = getTabLabel(index) @@ -349,7 +349,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener { private fun getTabsMask(): Int { var mask = TAB_CONTACTS - if (contactsConfig.showTabs and TAB_FAVORITES != 0) { + if (this.baseConfig.showTabs and TAB_FAVORITES != 0) { mask += TAB_FAVORITES } return mask diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt index 18f1024f..fccc2537 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt @@ -18,7 +18,7 @@ import com.simplemobiletools.commons.databases.ContactsDatabase import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.commons.models.Release @@ -90,19 +90,19 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { override fun onResume() { super.onResume() - if (storedShowPhoneNumbers != contactsConfig.showPhoneNumbers) { + if (storedShowPhoneNumbers != this.baseConfig.showPhoneNumbers) { System.exit(0) return } - if (storedShowTabs != contactsConfig.showTabs) { - contactsConfig.lastUsedViewPagerPage = 0 + if (storedShowTabs != this.baseConfig.showTabs) { + this.baseConfig.lastUsedViewPagerPage = 0 finish() startActivity(intent) return } - val configShowContactThumbnails = contactsConfig.showContactThumbnails + val configShowContactThumbnails = this.baseConfig.showContactThumbnails if (storedShowContactThumbnails != configShowContactThumbnails) { getAllFragments().forEach { it?.showContactThumbnailsChanged(configShowContactThumbnails) @@ -119,13 +119,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { updateMenuColors() setupTabColors() - val configStartNameWithSurname = contactsConfig.startNameWithSurname + val configStartNameWithSurname = this.baseConfig.startNameWithSurname if (storedStartNameWithSurname != configStartNameWithSurname) { contacts_fragment?.startNameWithSurnameChanged(configStartNameWithSurname) favorites_fragment?.startNameWithSurnameChanged(configStartNameWithSurname) } - val configFontSize = contactsConfig.fontSize + val configFontSize = this.baseConfig.fontSize if (storedFontSize != configFontSize) { getAllFragments().forEach { it?.fontSizeChanged() @@ -144,23 +144,23 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { main_dialpad_button.apply { setImageDrawable(dialpadIcon) background.applyColorFilter(properPrimaryColor) - beVisibleIf(contactsConfig.showDialpadButton) + beVisibleIf(this@MainActivity.baseConfig.showDialpadButton) } isFirstResume = false checkShortcuts() - if (!contactsConfig.wasUpgradedFromFreeShown && isPackageInstalled("com.simplemobiletools.contacts")) { + if (!this.baseConfig.wasUpgradedFromFreeShown && isPackageInstalled("com.simplemobiletools.contacts")) { val dialogText = getString(R.string.upgraded_to_pro_contacts, getString(R.string.phone_storage_hidden)) ConfirmationDialog(this, dialogText, 0, R.string.ok, 0, false) {} - contactsConfig.wasUpgradedFromFreeShown = true + this.baseConfig.wasUpgradedFromFreeShown = true } } override fun onPause() { super.onPause() storeStateVariables() - contactsConfig.lastUsedViewPagerPage = view_pager.currentItem + this.baseConfig.lastUsedViewPagerPage = view_pager.currentItem } override fun onDestroy() { @@ -197,7 +197,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { main_menu.getToolbar().menu.apply { findItem(R.id.sort).isVisible = currentFragment != groups_fragment findItem(R.id.filter).isVisible = currentFragment != groups_fragment - findItem(R.id.dialpad).isVisible = !contactsConfig.showDialpadButton + findItem(R.id.dialpad).isVisible = !this@MainActivity.baseConfig.showDialpadButton findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations) } } @@ -239,7 +239,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { } private fun storeStateVariables() { - contactsConfig.apply { + this.baseConfig.apply { storedShowContactThumbnails = showContactThumbnails storedShowPhoneNumbers = showPhoneNumbers storedStartNameWithSurname = startNameWithSurname @@ -250,13 +250,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { @SuppressLint("NewApi") private fun checkShortcuts() { - val appIconColor = contactsConfig.appIconColor - if (isNougatMR1Plus() && contactsConfig.lastHandledShortcutColor != appIconColor) { + val appIconColor = this.baseConfig.appIconColor + if (isNougatMR1Plus() && this.baseConfig.lastHandledShortcutColor != appIconColor) { val createNewContact = getCreateNewContactShortcut(appIconColor) try { shortcutManager.dynamicShortcuts = Arrays.asList(createNewContact) - contactsConfig.lastHandledShortcutColor = appIconColor + this.baseConfig.lastHandledShortcutColor = appIconColor } catch (ignored: Exception) { } } @@ -280,7 +280,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { } private fun getCurrentFragment(): MyViewPagerFragment? { - val showTabs = contactsConfig.showTabs + val showTabs = this.baseConfig.showTabs val fragments = arrayListOf() if (showTabs and TAB_CONTACTS != 0) { fragments.add(contacts_fragment) @@ -314,7 +314,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { private fun getInactiveTabIndexes(activeIndex: Int) = (0 until main_tabs_holder.tabCount).filter { it != activeIndex } private fun getSelectedTabDrawableIds(): ArrayList { - val showTabs = contactsConfig.showTabs + val showTabs = this.baseConfig.showTabs val icons = ArrayList() if (showTabs and TAB_CONTACTS != 0) { @@ -333,7 +333,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { } private fun getDeselectedTabDrawableIds(): ArrayList { - val showTabs = contactsConfig.showTabs + val showTabs = this.baseConfig.showTabs val icons = ArrayList() if (showTabs and TAB_CONTACTS != 0) { @@ -385,7 +385,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { private fun setupTabs() { main_tabs_holder.removeAllTabs() tabsList.forEachIndexed { index, value -> - if (contactsConfig.showTabs and value != 0) { + if (this.baseConfig.showTabs and value != 0) { main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply { customView?.findViewById(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index)) customView?.findViewById(R.id.tab_item_label)?.text = getTabLabel(index) @@ -499,7 +499,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { private fun tryExportContacts() { if (isQPlus()) { - ExportContactsDialog(this, contactsConfig.lastExportPath, true) { file, ignoredContactSources -> + ExportContactsDialog(this, this.baseConfig.lastExportPath, true) { file, ignoredContactSources -> ignoredExportContactSources = ignoredContactSources Intent(Intent.ACTION_CREATE_DOCUMENT).apply { @@ -519,7 +519,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { } else { handlePermission(PERMISSION_WRITE_STORAGE) { if (it) { - ExportContactsDialog(this, contactsConfig.lastExportPath, false) { file, ignoredContactSources -> + ExportContactsDialog(this, this.baseConfig.lastExportPath, false) { file, ignoredContactSources -> getFileOutputStream(file.toFileDirItem(this), true) { exportContactsTo(ignoredContactSources, it) } @@ -577,7 +577,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { isGettingContacts = true if (view_pager.adapter == null) { - view_pager.adapter = ViewPagerAdapter(this, tabsList, contactsConfig.showTabs) + view_pager.adapter = ViewPagerAdapter(this, tabsList, this.baseConfig.showTabs) view_pager.currentItem = getDefaultTab() } @@ -617,9 +617,9 @@ class MainActivity : SimpleActivity(), RefreshContactsListener { private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment) private fun getDefaultTab(): Int { - val showTabsMask = contactsConfig.showTabs - return when (contactsConfig.defaultTab) { - TAB_LAST_USED -> contactsConfig.lastUsedViewPagerPage + val showTabsMask = this.baseConfig.showTabs + return when (this.baseConfig.defaultTab) { + TAB_LAST_USED -> this.baseConfig.lastUsedViewPagerPage TAB_CONTACTS -> 0 TAB_FAVORITES -> if (showTabsMask and TAB_CONTACTS > 0) 1 else 0 else -> { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt index 29109732..feb3e2cd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt @@ -8,7 +8,7 @@ import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleTabsDialog -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import kotlinx.android.synthetic.main.activity_settings.* import java.util.* @@ -77,15 +77,15 @@ class SettingsActivity : SimpleActivity() { RadioItem(TAB_LAST_USED, getString(R.string.last_used_tab)) ) - RadioGroupDialog(this@SettingsActivity, items, contactsConfig.defaultTab) { - contactsConfig.defaultTab = it as Int + RadioGroupDialog(this@SettingsActivity, items, this.baseConfig.defaultTab) { + this.baseConfig.defaultTab = it as Int settings_default_tab.text = getDefaultTabText() } } } private fun getDefaultTabText() = getString( - when (baseConfig.defaultTab) { + when (this.baseConfig.defaultTab) { TAB_CONTACTS -> R.string.contacts_tab TAB_FAVORITES -> R.string.favorites_tab TAB_GROUPS -> R.string.groups_tab @@ -103,19 +103,19 @@ class SettingsActivity : SimpleActivity() { RadioItem(FONT_SIZE_EXTRA_LARGE, getString(R.string.extra_large)) ) - RadioGroupDialog(this@SettingsActivity, items, contactsConfig.fontSize) { - contactsConfig.fontSize = it as Int + RadioGroupDialog(this@SettingsActivity, items, this.baseConfig.fontSize) { + this.baseConfig.fontSize = it as Int settings_font_size.text = getFontSizeText() } } } private fun setupUseEnglish() { - settings_use_english_holder.beVisibleIf((contactsConfig.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) - settings_use_english.isChecked = contactsConfig.useEnglish + settings_use_english_holder.beVisibleIf((this.baseConfig.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) + settings_use_english.isChecked = this.baseConfig.useEnglish settings_use_english_holder.setOnClickListener { settings_use_english.toggle() - contactsConfig.useEnglish = settings_use_english.isChecked + this.baseConfig.useEnglish = settings_use_english.isChecked System.exit(0) } } @@ -129,50 +129,50 @@ class SettingsActivity : SimpleActivity() { } private fun setupShowContactThumbnails() { - settings_show_contact_thumbnails.isChecked = contactsConfig.showContactThumbnails + settings_show_contact_thumbnails.isChecked = this.baseConfig.showContactThumbnails settings_show_contact_thumbnails_holder.setOnClickListener { settings_show_contact_thumbnails.toggle() - contactsConfig.showContactThumbnails = settings_show_contact_thumbnails.isChecked + this.baseConfig.showContactThumbnails = settings_show_contact_thumbnails.isChecked } } private fun setupShowPhoneNumbers() { - settings_show_phone_numbers.isChecked = contactsConfig.showPhoneNumbers + settings_show_phone_numbers.isChecked = this.baseConfig.showPhoneNumbers settings_show_phone_numbers_holder.setOnClickListener { settings_show_phone_numbers.toggle() - contactsConfig.showPhoneNumbers = settings_show_phone_numbers.isChecked + this.baseConfig.showPhoneNumbers = settings_show_phone_numbers.isChecked } } private fun setupShowContactsWithNumbers() { - settings_show_only_contacts_with_numbers.isChecked = contactsConfig.showOnlyContactsWithNumbers + settings_show_only_contacts_with_numbers.isChecked = this.baseConfig.showOnlyContactsWithNumbers settings_show_only_contacts_with_numbers_holder.setOnClickListener { settings_show_only_contacts_with_numbers.toggle() - contactsConfig.showOnlyContactsWithNumbers = settings_show_only_contacts_with_numbers.isChecked + this.baseConfig.showOnlyContactsWithNumbers = settings_show_only_contacts_with_numbers.isChecked } } private fun setupStartNameWithSurname() { - settings_start_name_with_surname.isChecked = contactsConfig.startNameWithSurname + settings_start_name_with_surname.isChecked = this.baseConfig.startNameWithSurname settings_start_name_with_surname_holder.setOnClickListener { settings_start_name_with_surname.toggle() - contactsConfig.startNameWithSurname = settings_start_name_with_surname.isChecked + this.baseConfig.startNameWithSurname = settings_start_name_with_surname.isChecked } } private fun setupShowDialpadButton() { - settings_show_dialpad_button.isChecked = contactsConfig.showDialpadButton + settings_show_dialpad_button.isChecked = this.baseConfig.showDialpadButton settings_show_dialpad_button_holder.setOnClickListener { settings_show_dialpad_button.toggle() - contactsConfig.showDialpadButton = settings_show_dialpad_button.isChecked + this.baseConfig.showDialpadButton = settings_show_dialpad_button.isChecked } } private fun setupShowPrivateContacts() { - settings_show_private_contacts.isChecked = contactsConfig.showPrivateContacts + settings_show_private_contacts.isChecked = this.baseConfig.showPrivateContacts settings_show_private_contacts_holder.setOnClickListener { settings_show_private_contacts.toggle() - contactsConfig.showPrivateContacts = settings_show_private_contacts.isChecked + this.baseConfig.showPrivateContacts = settings_show_private_contacts.isChecked } } @@ -185,15 +185,15 @@ class SettingsActivity : SimpleActivity() { RadioItem(ON_CLICK_EDIT_CONTACT, getString(R.string.edit_contact)) ) - RadioGroupDialog(this@SettingsActivity, items, contactsConfig.onContactClick) { - contactsConfig.onContactClick = it as Int + RadioGroupDialog(this@SettingsActivity, items, this.baseConfig.onContactClick) { + this.baseConfig.onContactClick = it as Int settings_on_contact_click.text = getOnContactClickText() } } } private fun getOnContactClickText() = getString( - when (contactsConfig.onContactClick) { + when (this.baseConfig.onContactClick) { ON_CLICK_CALL_CONTACT -> R.string.call_contact ON_CLICK_VIEW_CONTACT -> R.string.view_contact else -> R.string.edit_contact @@ -201,18 +201,18 @@ class SettingsActivity : SimpleActivity() { ) private fun setupShowCallConfirmation() { - settings_show_call_confirmation.isChecked = contactsConfig.showCallConfirmation + settings_show_call_confirmation.isChecked = this.baseConfig.showCallConfirmation settings_show_call_confirmation_holder.setOnClickListener { settings_show_call_confirmation.toggle() - contactsConfig.showCallConfirmation = settings_show_call_confirmation.isChecked + this.baseConfig.showCallConfirmation = settings_show_call_confirmation.isChecked } } private fun setupMergeDuplicateContacts() { - settings_merge_duplicate_contacts.isChecked = contactsConfig.mergeDuplicateContacts + settings_merge_duplicate_contacts.isChecked = this.baseConfig.mergeDuplicateContacts settings_merge_duplicate_contacts_holder.setOnClickListener { settings_merge_duplicate_contacts.toggle() - contactsConfig.mergeDuplicateContacts = settings_merge_duplicate_contacts.isChecked + this.baseConfig.mergeDuplicateContacts = settings_merge_duplicate_contacts.isChecked } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt index dc133bee..d9b9df5c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt @@ -46,7 +46,7 @@ class ViewContactActivity : ContactActivity() { private var showFields = 0 private var fullContact: Contact? = null // contact with all fields filled from duplicates private var duplicateInitialized = false - private val mergeDuplicate: Boolean get() = contactsConfig.mergeDuplicateContacts + private val mergeDuplicate: Boolean get() = this.baseConfig.mergeDuplicateContacts private val COMPARABLE_PHONE_NUMBER_LENGTH = 9 @@ -59,7 +59,7 @@ class ViewContactActivity : ContactActivity() { return } - showFields = contactsConfig.showContactFields + showFields = this.baseConfig.showContactFields contact_wrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN setupMenu() } @@ -122,7 +122,7 @@ class ViewContactActivity : ContactActivity() { findItem(R.id.manage_visible_fields).setOnMenuItemClickListener { ManageVisibleFieldsDialog(this@ViewContactActivity) { - showFields = contactsConfig.showContactFields + showFields = this@ViewContactActivity.baseConfig.showContactFields ensureBackgroundThread { initContact() } @@ -388,7 +388,7 @@ class ViewContactActivity : ContactActivity() { copyOnLongClick(phoneNumber.value) setOnClickListener { - if (contactsConfig.showCallConfirmation) { + if (this@ViewContactActivity.baseConfig.showCallConfirmation) { CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) { startCallIntent(phoneNumber.value) } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/ContactsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/ContactsAdapter.kt index cb539c6c..586c7a74 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/ContactsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/ContactsAdapter.kt @@ -60,7 +60,7 @@ class ContactsAdapter( private val NEW_GROUP_ID = -1 - private var config = activity.contactsConfig + private var config = activity.baseConfig private var textToHighlight = highlightText var startNameWithSurname = config.startNameWithSurname @@ -452,7 +452,7 @@ class ContactsAdapter( override fun onChange(position: Int) = contactItems.getOrNull(position)?.getBubbleText() ?: "" override fun onRowMoved(fromPosition: Int, toPosition: Int) { - activity.contactsConfig.isCustomOrderSelected = true + activity.baseConfig.isCustomOrderSelected = true if (fromPosition < toPosition) { for (i in fromPosition until toPosition) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/GroupsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/GroupsAdapter.kt index e9540145..a4f74cce 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/GroupsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/GroupsAdapter.kt @@ -27,7 +27,7 @@ class GroupsAdapter( ) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate { private var textToHighlight = "" - var showContactThumbnails = activity.contactsConfig.showContactThumbnails + var showContactThumbnails = activity.baseConfig.showContactThumbnails var fontSize = activity.getTextSize() init { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/SelectContactsAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/SelectContactsAdapter.kt index 4e1c552d..ecbbf492 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/SelectContactsAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/adapters/SelectContactsAdapter.kt @@ -11,7 +11,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.signature.ObjectKey import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.helpers.SimpleContactsHelper import com.simplemobiletools.commons.models.contacts.* import com.simplemobiletools.commons.views.MyRecyclerView @@ -30,7 +30,7 @@ class SelectContactsAdapter( RecyclerView.Adapter() { private val itemViews = SparseArray() private val selectedPositions = HashSet() - private val config = activity.contactsConfig + private val config = activity.baseConfig private val adjustedPrimaryColor = activity.getProperPrimaryColor() private val fontSize = activity.getTextSize() diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/contentproviders/MyContactsContentProvider.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/contentproviders/MyContactsContentProvider.kt index 900cb881..a89cd45f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/contentproviders/MyContactsContentProvider.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/contentproviders/MyContactsContentProvider.kt @@ -6,15 +6,15 @@ import android.database.Cursor import android.database.MatrixCursor import android.net.Uri import com.google.gson.Gson +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.helpers.MyContactsContentProvider -import com.simplemobiletools.commons.extensions.contactsConfig import com.simplemobiletools.commons.helpers.LocalContactsHelper class MyContactsContentProvider : ContentProvider() { override fun insert(uri: Uri, contentValues: ContentValues?) = null override fun query(uri: Uri, projection: Array?, selection: String?, selectionArgs: Array?, sortOrder: String?): Cursor? { - if (context == null || !context!!.contactsConfig.showPrivateContacts) { + if (context == null || !context!!.baseConfig.showPrivateContacts) { return null } else { val matrixCursor = MatrixCursor( diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ChangeSortingDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ChangeSortingDialog.kt index 44c18836..5ca84879 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ChangeSortingDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ChangeSortingDialog.kt @@ -2,7 +2,7 @@ package com.simplemobiletools.contacts.pro.dialogs import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.beGoneIf -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.helpers.* @@ -11,7 +11,7 @@ import kotlinx.android.synthetic.main.dialog_change_sorting.view.* class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCustomSorting: Boolean = false, private val callback: () -> Unit) { private var currSorting = 0 - private var config = activity.contactsConfig + private var config = activity.baseConfig private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null) init { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ExportContactsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ExportContactsDialog.kt index 0a4dc314..3c2d3361 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ExportContactsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ExportContactsDialog.kt @@ -5,7 +5,7 @@ import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.helpers.ContactsHelper import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.models.contacts.* @@ -80,7 +80,7 @@ class ExportContactsDialog( ignoreClicks = true ensureBackgroundThread { - activity.contactsConfig.lastExportPath = file.absolutePath.getParentPath() + activity.baseConfig.lastExportPath = file.absolutePath.getParentPath() val selectedSources = (view.export_contacts_list.adapter as FilterContactSourcesAdapter).getSelectedContactSources() val ignoredSources = contactSources .filter { !selectedSources.contains(it) } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/FilterContactSourcesDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/FilterContactSourcesDialog.kt index 97a607d8..e52e8d26 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/FilterContactSourcesDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/FilterContactSourcesDialog.kt @@ -7,7 +7,7 @@ import com.simplemobiletools.commons.helpers.SMT_PRIVATE import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.adapters.FilterContactSourcesAdapter -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.extensions.getVisibleContactSources import com.simplemobiletools.commons.helpers.ContactsHelper import com.simplemobiletools.commons.models.contacts.* @@ -77,7 +77,7 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb }.toHashSet() if (activity.getVisibleContactSources() != ignoredContactSources) { - activity.contactsConfig.ignoredContactSources = ignoredContactSources + activity.baseConfig.ignoredContactSources = ignoredContactSources callback() } dialog?.dismiss() diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ImportContactsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ImportContactsDialog.kt index 149e287d..436118b3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ImportContactsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ImportContactsDialog.kt @@ -19,7 +19,7 @@ class ImportContactsDialog(val activity: SimpleActivity, val path: String, priva init { val view = (activity.layoutInflater.inflate(R.layout.dialog_import_contacts, null) as ViewGroup).apply { - targetContactSource = activity.contactsConfig.lastUsedContactSource + targetContactSource = activity.baseConfig.lastUsedContactSource activity.getPublicContactSource(targetContactSource) { import_contacts_title.setText(it) if (it.isEmpty()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageVisibleFieldsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageVisibleFieldsDialog.kt index d70d6cef..6d9147b2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageVisibleFieldsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageVisibleFieldsDialog.kt @@ -5,7 +5,7 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.views.MyAppCompatCheckbox import com.simplemobiletools.contacts.pro.R -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.helpers.* class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback: (hasSomethingChanged: Boolean) -> Unit) { @@ -33,7 +33,7 @@ class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback: put(SHOW_RINGTONE_FIELD, R.id.manage_ringtone) } - val showContactFields = activity.contactsConfig.showContactFields + val showContactFields = activity.baseConfig.showContactFields for ((key, value) in fields) { view.findViewById(value).isChecked = showContactFields and key != 0 } @@ -54,8 +54,8 @@ class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback: } } - val hasSomethingChanged = activity.contactsConfig.showContactFields != result - activity.contactsConfig.showContactFields = result + val hasSomethingChanged = activity.baseConfig.showContactFields != result + activity.baseConfig.showContactFields = result if (hasSomethingChanged) { callback(true) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageVisibleTabsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageVisibleTabsDialog.kt index 68e95f18..9adf617b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageVisibleTabsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/ManageVisibleTabsDialog.kt @@ -8,7 +8,7 @@ import com.simplemobiletools.commons.helpers.TAB_FAVORITES import com.simplemobiletools.commons.helpers.TAB_GROUPS import com.simplemobiletools.commons.views.MyAppCompatCheckbox import com.simplemobiletools.contacts.pro.R -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.helpers.ALL_TABS_MASK class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) { @@ -22,7 +22,7 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) { put(TAB_GROUPS, R.id.manage_visible_tabs_groups) } - val showTabs = activity.contactsConfig.showTabs + val showTabs = activity.baseConfig.showTabs for ((key, value) in tabs) { view.findViewById(value).isChecked = showTabs and key != 0 } @@ -47,6 +47,6 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) { result = ALL_TABS_MASK } - activity.contactsConfig.showTabs = result + activity.baseConfig.showTabs = result } } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/MyDatePickerDialog.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/MyDatePickerDialog.kt index 90b94058..3fcb7b7c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/MyDatePickerDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/dialogs/MyDatePickerDialog.kt @@ -5,7 +5,7 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.helpers.isSPlus import com.simplemobiletools.contacts.pro.R -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import kotlinx.android.synthetic.main.dialog_date_picker.view.* import org.joda.time.DateTime import java.util.* @@ -38,7 +38,7 @@ class MyDatePickerDialog(val activity: BaseSimpleActivity, val defaultDate: Stri } } - if (activity.contactsConfig.isUsingSystemTheme && isSPlus()) { + if (activity.baseConfig.isUsingSystemTheme && isSPlus()) { val dialogBackgroundColor = activity.getColor(R.color.you_dialog_background_color) view.dialog_holder.setBackgroundColor(dialogBackgroundColor) view.date_picker.setBackgroundColor(dialogBackgroundColor) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt index 11f8cc58..db7eac9b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/extensions/Activity.kt @@ -30,7 +30,7 @@ fun SimpleActivity.startCallIntent(recipient: String) { } fun SimpleActivity.tryStartCall(contact: Contact) { - if (contactsConfig.showCallConfirmation) { + if (this.baseConfig.showCallConfirmation) { CallConfirmationDialog(this, contact.getNameToDisplay()) { startCall(contact) } @@ -107,7 +107,7 @@ fun BaseSimpleActivity.shareContacts(contacts: ArrayList) { } fun SimpleActivity.handleGenericContactClick(contact: Contact) { - when (contactsConfig.onContactClick) { + when (this.baseConfig.onContactClick) { ON_CLICK_CALL_CONTACT -> callContact(contact) ON_CLICK_VIEW_CONTACT -> viewContact(contact) ON_CLICK_EDIT_CONTACT -> editContact(contact) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt index 429b60a2..2faa833c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/MyViewPagerFragment.kt @@ -17,7 +17,7 @@ import com.simplemobiletools.contacts.pro.activities.MainActivity import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter import com.simplemobiletools.contacts.pro.adapters.GroupsAdapter -import com.simplemobiletools.commons.extensions.contactsConfig +import com.simplemobiletools.commons.extensions.baseConfig import com.simplemobiletools.commons.helpers.Converters import com.simplemobiletools.contacts.pro.helpers.* import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener @@ -38,13 +38,13 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) private var lastHashCode = 0 private var contactsIgnoringSearch = ArrayList() private var groupsIgnoringSearch = ArrayList() - private lateinit var config: ContactsConfig + private lateinit var config: BaseConfig var skipHashComparing = false var forceListRedraw = false fun setupFragment(activity: SimpleActivity) { - config = activity.contactsConfig + config = activity.baseConfig if (this.activity == null) { this.activity = activity fragment_fab?.beGoneIf(activity is InsertOrEditContactActivity) @@ -124,7 +124,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) this is FavoritesFragment -> { val favorites = contacts.filter { it.starred == 1 } as ArrayList - if (activity!!.contactsConfig.isCustomOrderSelected) { + if (activity!!.baseConfig.isCustomOrderSelected) { sortByCustomOrder(favorites) } else { favorites @@ -158,7 +158,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) } private fun sortByCustomOrder(starred: List): ArrayList { - val favoritesOrder = activity!!.contactsConfig.favoritesContactsOrder + val favoritesOrder = activity!!.baseConfig.favoritesContactsOrder if (favoritesOrder.isEmpty()) { return ArrayList(starred) @@ -218,7 +218,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) } } else { (currAdapter as GroupsAdapter).apply { - showContactThumbnails = activity.contactsConfig.showContactThumbnails + showContactThumbnails = activity.baseConfig.showContactThumbnails updateItems(storedGroups) } } @@ -280,7 +280,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) activity?.apply { val orderIds = items.map { it.id } val orderGsonString = Gson().toJson(orderIds) - contactsConfig.favoritesContactsOrder = orderGsonString + this.baseConfig.favoritesContactsOrder = orderGsonString } } @@ -299,7 +299,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) } private fun setupLetterFastscroller(contacts: ArrayList) { - val sorting = context.contactsConfig.sorting + val sorting = context.baseConfig.sorting letter_fastscroller.setupWithRecyclerView(fragment_list, { position -> try { val contact = contacts[position] @@ -308,7 +308,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) sorting and SORT_BY_SURNAME != 0 && contact.surname.isNotEmpty() -> contact.surname sorting and SORT_BY_MIDDLE_NAME != 0 && contact.middleName.isNotEmpty() -> contact.middleName sorting and SORT_BY_FIRST_NAME != 0 && contact.firstName.isNotEmpty() -> contact.firstName - context.contactsConfig.startNameWithSurname -> contact.surname + context.baseConfig.startNameWithSurname -> contact.surname else -> contact.firstName } diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt index e02462cc..87a9b3fd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/helpers/VcfExporter.kt @@ -1,7 +1,11 @@ package com.simplemobiletools.contacts.pro.helpers import android.net.Uri -import android.provider.ContactsContract +import android.provider.ContactsContract.CommonDataKinds.Email +import android.provider.ContactsContract.CommonDataKinds.Event +import android.provider.ContactsContract.CommonDataKinds.Im +import android.provider.ContactsContract.CommonDataKinds.Phone +import android.provider.ContactsContract.CommonDataKinds.StructuredPostal import android.provider.MediaStore import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.getByteArray @@ -79,7 +83,7 @@ class VcfExporter { } contact.events.forEach { event -> - if (event.type == ContactsContract.CommonDataKinds.Event.TYPE_ANNIVERSARY || event.type == ContactsContract.CommonDataKinds.Event.TYPE_BIRTHDAY) { + if (event.type == Event.TYPE_ANNIVERSARY || event.type == Event.TYPE_BIRTHDAY) { val dateTime = event.value.getDateTimeFromDateString(false) Calendar.getInstance().apply { clear() @@ -87,10 +91,11 @@ class VcfExporter { set(Calendar.YEAR, 1900) } else { set(Calendar.YEAR, dateTime.year) + } set(Calendar.MONTH, dateTime.monthOfYear - 1) set(Calendar.DAY_OF_MONTH, dateTime.dayOfMonth) - if (event.type == ContactsContract.CommonDataKinds.Event.TYPE_BIRTHDAY) { + if (event.type == Event.TYPE_BIRTHDAY) { card.birthdays.add(Birthday(time)) } else { card.anniversaries.add(Anniversary(time)) @@ -108,14 +113,14 @@ class VcfExporter { contact.IMs.forEach { val impp = when (it.type) { - ContactsContract.CommonDataKinds.Im.PROTOCOL_AIM -> Impp.aim(it.value) - ContactsContract.CommonDataKinds.Im.PROTOCOL_YAHOO -> Impp.yahoo(it.value) - ContactsContract.CommonDataKinds.Im.PROTOCOL_MSN -> Impp.msn(it.value) - ContactsContract.CommonDataKinds.Im.PROTOCOL_ICQ -> Impp.icq(it.value) - ContactsContract.CommonDataKinds.Im.PROTOCOL_SKYPE -> Impp.skype(it.value) - ContactsContract.CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK -> Impp(HANGOUTS, it.value) - ContactsContract.CommonDataKinds.Im.PROTOCOL_QQ -> Impp(QQ, it.value) - ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER -> Impp(JABBER, it.value) + Im.PROTOCOL_AIM -> Impp.aim(it.value) + Im.PROTOCOL_YAHOO -> Impp.yahoo(it.value) + Im.PROTOCOL_MSN -> Impp.msn(it.value) + Im.PROTOCOL_ICQ -> Impp.icq(it.value) + Im.PROTOCOL_SKYPE -> Impp.skype(it.value) + Im.PROTOCOL_GOOGLE_TALK -> Impp(HANGOUTS, it.value) + Im.PROTOCOL_QQ -> Impp(QQ, it.value) + Im.PROTOCOL_JABBER -> Impp(JABBER, it.value) else -> Impp(it.label, it.value) } @@ -171,29 +176,29 @@ class VcfExporter { } private fun getPhoneNumberTypeLabel(type: Int, label: String) = when (type) { - ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE -> CELL - ContactsContract.CommonDataKinds.Phone.TYPE_HOME -> HOME - ContactsContract.CommonDataKinds.Phone.TYPE_WORK -> WORK - ContactsContract.CommonDataKinds.Phone.TYPE_MAIN -> PREF - ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK -> WORK_FAX - ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME -> HOME_FAX - ContactsContract.CommonDataKinds.Phone.TYPE_PAGER -> PAGER - ContactsContract.CommonDataKinds.Phone.TYPE_OTHER -> OTHER + Phone.TYPE_MOBILE -> CELL + Phone.TYPE_HOME -> HOME + Phone.TYPE_WORK -> WORK + Phone.TYPE_MAIN -> PREF + Phone.TYPE_FAX_WORK -> WORK_FAX + Phone.TYPE_FAX_HOME -> HOME_FAX + Phone.TYPE_PAGER -> PAGER + Phone.TYPE_OTHER -> OTHER else -> label } private fun getEmailTypeLabel(type: Int, label: String) = when (type) { - ContactsContract.CommonDataKinds.Email.TYPE_HOME -> HOME - ContactsContract.CommonDataKinds.Email.TYPE_WORK -> WORK - ContactsContract.CommonDataKinds.Email.TYPE_MOBILE -> MOBILE - ContactsContract.CommonDataKinds.Email.TYPE_OTHER -> OTHER + Email.TYPE_HOME -> HOME + Email.TYPE_WORK -> WORK + Email.TYPE_MOBILE -> MOBILE + Email.TYPE_OTHER -> OTHER else -> label } private fun getAddressTypeLabel(type: Int, label: String) = when (type) { - ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME -> HOME - ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK -> WORK - ContactsContract.CommonDataKinds.StructuredPostal.TYPE_OTHER -> OTHER + StructuredPostal.TYPE_HOME -> HOME + StructuredPostal.TYPE_WORK -> WORK + StructuredPostal.TYPE_OTHER -> OTHER else -> label } }