fix: use baseConfig instead of ContactsConfig

This commit is contained in:
ismailnurudeen 2023-02-21 13:15:48 +01:00
parent c47604bd6e
commit 66ff093a66
19 changed files with 129 additions and 124 deletions

View File

@ -388,7 +388,7 @@ class EditContactActivity : ContactActivity() {
} }
private fun setupFieldVisibility() { 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) { 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() contact_name_image.beInvisible()
} }
@ -744,7 +744,7 @@ class EditContactActivity : ContactActivity() {
} }
private fun setupNewContact() { private fun setupNewContact() {
originalContactSource = if (hasContactPermissions()) contactsConfig.lastUsedContactSource else SMT_PRIVATE originalContactSource = if (hasContactPermissions()) this.baseConfig.lastUsedContactSource else SMT_PRIVATE
contact = getEmptyContact() contact = getEmptyContact()
getPublicContactSource(contact!!.source) { getPublicContactSource(contact!!.source) {
contact_source.text = if (it == "") getString(R.string.phone_storage) else it contact_source.text = if (it == "") getString(R.string.phone_storage) else it
@ -1049,7 +1049,7 @@ class EditContactActivity : ContactActivity() {
contact = contactValues contact = contactValues
ensureBackgroundThread { ensureBackgroundThread {
contactsConfig.lastUsedContactSource = contact!!.source this.baseConfig.lastUsedContactSource = contact!!.source
when { when {
contact!!.id == 0 -> insertNewContact(false) contact!!.id == 0 -> insertNewContact(false)
originalContactSource != contact!!.source -> insertNewContact(true) originalContactSource != contact!!.source -> insertNewContact(true)

View File

@ -17,7 +17,7 @@ import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.adapters.ViewPagerAdapter import com.simplemobiletools.contacts.pro.adapters.ViewPagerAdapter
import com.simplemobiletools.contacts.pro.dialogs.ChangeSortingDialog import com.simplemobiletools.contacts.pro.dialogs.ChangeSortingDialog
import com.simplemobiletools.contacts.pro.dialogs.FilterContactSourcesDialog 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.fragments.MyViewPagerFragment
import com.simplemobiletools.contacts.pro.helpers.ADD_NEW_CONTACT_NUMBER import com.simplemobiletools.contacts.pro.helpers.ADD_NEW_CONTACT_NUMBER
import com.simplemobiletools.contacts.pro.helpers.KEY_EMAIL import com.simplemobiletools.contacts.pro.helpers.KEY_EMAIL
@ -159,7 +159,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
private fun setupTabs() { private fun setupTabs() {
insert_edit_tabs_holder.removeAllTabs() insert_edit_tabs_holder.removeAllTabs()
contactsFavoritesList.forEachIndexed { index, value -> 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 { insert_edit_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index)) customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index))
customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index) customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index)
@ -349,7 +349,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
private fun getTabsMask(): Int { private fun getTabsMask(): Int {
var mask = TAB_CONTACTS var mask = TAB_CONTACTS
if (contactsConfig.showTabs and TAB_FAVORITES != 0) { if (this.baseConfig.showTabs and TAB_FAVORITES != 0) {
mask += TAB_FAVORITES mask += TAB_FAVORITES
} }
return mask return mask

View File

@ -18,7 +18,7 @@ import com.simplemobiletools.commons.databases.ContactsDatabase
import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.* 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.helpers.*
import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.commons.models.FAQItem
import com.simplemobiletools.commons.models.Release import com.simplemobiletools.commons.models.Release
@ -90,19 +90,19 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (storedShowPhoneNumbers != contactsConfig.showPhoneNumbers) { if (storedShowPhoneNumbers != this.baseConfig.showPhoneNumbers) {
System.exit(0) System.exit(0)
return return
} }
if (storedShowTabs != contactsConfig.showTabs) { if (storedShowTabs != this.baseConfig.showTabs) {
contactsConfig.lastUsedViewPagerPage = 0 this.baseConfig.lastUsedViewPagerPage = 0
finish() finish()
startActivity(intent) startActivity(intent)
return return
} }
val configShowContactThumbnails = contactsConfig.showContactThumbnails val configShowContactThumbnails = this.baseConfig.showContactThumbnails
if (storedShowContactThumbnails != configShowContactThumbnails) { if (storedShowContactThumbnails != configShowContactThumbnails) {
getAllFragments().forEach { getAllFragments().forEach {
it?.showContactThumbnailsChanged(configShowContactThumbnails) it?.showContactThumbnailsChanged(configShowContactThumbnails)
@ -119,13 +119,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
updateMenuColors() updateMenuColors()
setupTabColors() setupTabColors()
val configStartNameWithSurname = contactsConfig.startNameWithSurname val configStartNameWithSurname = this.baseConfig.startNameWithSurname
if (storedStartNameWithSurname != configStartNameWithSurname) { if (storedStartNameWithSurname != configStartNameWithSurname) {
contacts_fragment?.startNameWithSurnameChanged(configStartNameWithSurname) contacts_fragment?.startNameWithSurnameChanged(configStartNameWithSurname)
favorites_fragment?.startNameWithSurnameChanged(configStartNameWithSurname) favorites_fragment?.startNameWithSurnameChanged(configStartNameWithSurname)
} }
val configFontSize = contactsConfig.fontSize val configFontSize = this.baseConfig.fontSize
if (storedFontSize != configFontSize) { if (storedFontSize != configFontSize) {
getAllFragments().forEach { getAllFragments().forEach {
it?.fontSizeChanged() it?.fontSizeChanged()
@ -144,23 +144,23 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
main_dialpad_button.apply { main_dialpad_button.apply {
setImageDrawable(dialpadIcon) setImageDrawable(dialpadIcon)
background.applyColorFilter(properPrimaryColor) background.applyColorFilter(properPrimaryColor)
beVisibleIf(contactsConfig.showDialpadButton) beVisibleIf(this@MainActivity.baseConfig.showDialpadButton)
} }
isFirstResume = false isFirstResume = false
checkShortcuts() 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)) val dialogText = getString(R.string.upgraded_to_pro_contacts, getString(R.string.phone_storage_hidden))
ConfirmationDialog(this, dialogText, 0, R.string.ok, 0, false) {} ConfirmationDialog(this, dialogText, 0, R.string.ok, 0, false) {}
contactsConfig.wasUpgradedFromFreeShown = true this.baseConfig.wasUpgradedFromFreeShown = true
} }
} }
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
storeStateVariables() storeStateVariables()
contactsConfig.lastUsedViewPagerPage = view_pager.currentItem this.baseConfig.lastUsedViewPagerPage = view_pager.currentItem
} }
override fun onDestroy() { override fun onDestroy() {
@ -197,7 +197,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
main_menu.getToolbar().menu.apply { main_menu.getToolbar().menu.apply {
findItem(R.id.sort).isVisible = currentFragment != groups_fragment findItem(R.id.sort).isVisible = currentFragment != groups_fragment
findItem(R.id.filter).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) 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() { private fun storeStateVariables() {
contactsConfig.apply { this.baseConfig.apply {
storedShowContactThumbnails = showContactThumbnails storedShowContactThumbnails = showContactThumbnails
storedShowPhoneNumbers = showPhoneNumbers storedShowPhoneNumbers = showPhoneNumbers
storedStartNameWithSurname = startNameWithSurname storedStartNameWithSurname = startNameWithSurname
@ -250,13 +250,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
@SuppressLint("NewApi") @SuppressLint("NewApi")
private fun checkShortcuts() { private fun checkShortcuts() {
val appIconColor = contactsConfig.appIconColor val appIconColor = this.baseConfig.appIconColor
if (isNougatMR1Plus() && contactsConfig.lastHandledShortcutColor != appIconColor) { if (isNougatMR1Plus() && this.baseConfig.lastHandledShortcutColor != appIconColor) {
val createNewContact = getCreateNewContactShortcut(appIconColor) val createNewContact = getCreateNewContactShortcut(appIconColor)
try { try {
shortcutManager.dynamicShortcuts = Arrays.asList(createNewContact) shortcutManager.dynamicShortcuts = Arrays.asList(createNewContact)
contactsConfig.lastHandledShortcutColor = appIconColor this.baseConfig.lastHandledShortcutColor = appIconColor
} catch (ignored: Exception) { } catch (ignored: Exception) {
} }
} }
@ -280,7 +280,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
} }
private fun getCurrentFragment(): MyViewPagerFragment? { private fun getCurrentFragment(): MyViewPagerFragment? {
val showTabs = contactsConfig.showTabs val showTabs = this.baseConfig.showTabs
val fragments = arrayListOf<MyViewPagerFragment>() val fragments = arrayListOf<MyViewPagerFragment>()
if (showTabs and TAB_CONTACTS != 0) { if (showTabs and TAB_CONTACTS != 0) {
fragments.add(contacts_fragment) 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 getInactiveTabIndexes(activeIndex: Int) = (0 until main_tabs_holder.tabCount).filter { it != activeIndex }
private fun getSelectedTabDrawableIds(): ArrayList<Int> { private fun getSelectedTabDrawableIds(): ArrayList<Int> {
val showTabs = contactsConfig.showTabs val showTabs = this.baseConfig.showTabs
val icons = ArrayList<Int>() val icons = ArrayList<Int>()
if (showTabs and TAB_CONTACTS != 0) { if (showTabs and TAB_CONTACTS != 0) {
@ -333,7 +333,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
} }
private fun getDeselectedTabDrawableIds(): ArrayList<Int> { private fun getDeselectedTabDrawableIds(): ArrayList<Int> {
val showTabs = contactsConfig.showTabs val showTabs = this.baseConfig.showTabs
val icons = ArrayList<Int>() val icons = ArrayList<Int>()
if (showTabs and TAB_CONTACTS != 0) { if (showTabs and TAB_CONTACTS != 0) {
@ -385,7 +385,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
private fun setupTabs() { private fun setupTabs() {
main_tabs_holder.removeAllTabs() main_tabs_holder.removeAllTabs()
tabsList.forEachIndexed { index, value -> 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 { main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index)) customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index))
customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index) customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index)
@ -499,7 +499,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
private fun tryExportContacts() { private fun tryExportContacts() {
if (isQPlus()) { if (isQPlus()) {
ExportContactsDialog(this, contactsConfig.lastExportPath, true) { file, ignoredContactSources -> ExportContactsDialog(this, this.baseConfig.lastExportPath, true) { file, ignoredContactSources ->
ignoredExportContactSources = ignoredContactSources ignoredExportContactSources = ignoredContactSources
Intent(Intent.ACTION_CREATE_DOCUMENT).apply { Intent(Intent.ACTION_CREATE_DOCUMENT).apply {
@ -519,7 +519,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
} else { } else {
handlePermission(PERMISSION_WRITE_STORAGE) { handlePermission(PERMISSION_WRITE_STORAGE) {
if (it) { if (it) {
ExportContactsDialog(this, contactsConfig.lastExportPath, false) { file, ignoredContactSources -> ExportContactsDialog(this, this.baseConfig.lastExportPath, false) { file, ignoredContactSources ->
getFileOutputStream(file.toFileDirItem(this), true) { getFileOutputStream(file.toFileDirItem(this), true) {
exportContactsTo(ignoredContactSources, it) exportContactsTo(ignoredContactSources, it)
} }
@ -577,7 +577,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
isGettingContacts = true isGettingContacts = true
if (view_pager.adapter == null) { 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() view_pager.currentItem = getDefaultTab()
} }
@ -617,9 +617,9 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment) private fun getAllFragments() = arrayListOf(contacts_fragment, favorites_fragment, groups_fragment)
private fun getDefaultTab(): Int { private fun getDefaultTab(): Int {
val showTabsMask = contactsConfig.showTabs val showTabsMask = this.baseConfig.showTabs
return when (contactsConfig.defaultTab) { return when (this.baseConfig.defaultTab) {
TAB_LAST_USED -> contactsConfig.lastUsedViewPagerPage TAB_LAST_USED -> this.baseConfig.lastUsedViewPagerPage
TAB_CONTACTS -> 0 TAB_CONTACTS -> 0
TAB_FAVORITES -> if (showTabsMask and TAB_CONTACTS > 0) 1 else 0 TAB_FAVORITES -> if (showTabsMask and TAB_CONTACTS > 0) 1 else 0
else -> { else -> {

View File

@ -8,7 +8,7 @@ import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleFieldsDialog
import com.simplemobiletools.contacts.pro.dialogs.ManageVisibleTabsDialog 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 kotlinx.android.synthetic.main.activity_settings.*
import java.util.* import java.util.*
@ -77,15 +77,15 @@ class SettingsActivity : SimpleActivity() {
RadioItem(TAB_LAST_USED, getString(R.string.last_used_tab)) RadioItem(TAB_LAST_USED, getString(R.string.last_used_tab))
) )
RadioGroupDialog(this@SettingsActivity, items, contactsConfig.defaultTab) { RadioGroupDialog(this@SettingsActivity, items, this.baseConfig.defaultTab) {
contactsConfig.defaultTab = it as Int this.baseConfig.defaultTab = it as Int
settings_default_tab.text = getDefaultTabText() settings_default_tab.text = getDefaultTabText()
} }
} }
} }
private fun getDefaultTabText() = getString( private fun getDefaultTabText() = getString(
when (baseConfig.defaultTab) { when (this.baseConfig.defaultTab) {
TAB_CONTACTS -> R.string.contacts_tab TAB_CONTACTS -> R.string.contacts_tab
TAB_FAVORITES -> R.string.favorites_tab TAB_FAVORITES -> R.string.favorites_tab
TAB_GROUPS -> R.string.groups_tab TAB_GROUPS -> R.string.groups_tab
@ -103,19 +103,19 @@ class SettingsActivity : SimpleActivity() {
RadioItem(FONT_SIZE_EXTRA_LARGE, getString(R.string.extra_large)) RadioItem(FONT_SIZE_EXTRA_LARGE, getString(R.string.extra_large))
) )
RadioGroupDialog(this@SettingsActivity, items, contactsConfig.fontSize) { RadioGroupDialog(this@SettingsActivity, items, this.baseConfig.fontSize) {
contactsConfig.fontSize = it as Int this.baseConfig.fontSize = it as Int
settings_font_size.text = getFontSizeText() settings_font_size.text = getFontSizeText()
} }
} }
} }
private fun setupUseEnglish() { private fun setupUseEnglish() {
settings_use_english_holder.beVisibleIf((contactsConfig.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) settings_use_english_holder.beVisibleIf((this.baseConfig.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
settings_use_english.isChecked = contactsConfig.useEnglish settings_use_english.isChecked = this.baseConfig.useEnglish
settings_use_english_holder.setOnClickListener { settings_use_english_holder.setOnClickListener {
settings_use_english.toggle() settings_use_english.toggle()
contactsConfig.useEnglish = settings_use_english.isChecked this.baseConfig.useEnglish = settings_use_english.isChecked
System.exit(0) System.exit(0)
} }
} }
@ -129,50 +129,50 @@ class SettingsActivity : SimpleActivity() {
} }
private fun setupShowContactThumbnails() { 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_holder.setOnClickListener {
settings_show_contact_thumbnails.toggle() settings_show_contact_thumbnails.toggle()
contactsConfig.showContactThumbnails = settings_show_contact_thumbnails.isChecked this.baseConfig.showContactThumbnails = settings_show_contact_thumbnails.isChecked
} }
} }
private fun setupShowPhoneNumbers() { 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_holder.setOnClickListener {
settings_show_phone_numbers.toggle() settings_show_phone_numbers.toggle()
contactsConfig.showPhoneNumbers = settings_show_phone_numbers.isChecked this.baseConfig.showPhoneNumbers = settings_show_phone_numbers.isChecked
} }
} }
private fun setupShowContactsWithNumbers() { 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_holder.setOnClickListener {
settings_show_only_contacts_with_numbers.toggle() 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() { 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_holder.setOnClickListener {
settings_start_name_with_surname.toggle() 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() { 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_holder.setOnClickListener {
settings_show_dialpad_button.toggle() settings_show_dialpad_button.toggle()
contactsConfig.showDialpadButton = settings_show_dialpad_button.isChecked this.baseConfig.showDialpadButton = settings_show_dialpad_button.isChecked
} }
} }
private fun setupShowPrivateContacts() { 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_holder.setOnClickListener {
settings_show_private_contacts.toggle() 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)) RadioItem(ON_CLICK_EDIT_CONTACT, getString(R.string.edit_contact))
) )
RadioGroupDialog(this@SettingsActivity, items, contactsConfig.onContactClick) { RadioGroupDialog(this@SettingsActivity, items, this.baseConfig.onContactClick) {
contactsConfig.onContactClick = it as Int this.baseConfig.onContactClick = it as Int
settings_on_contact_click.text = getOnContactClickText() settings_on_contact_click.text = getOnContactClickText()
} }
} }
} }
private fun getOnContactClickText() = getString( private fun getOnContactClickText() = getString(
when (contactsConfig.onContactClick) { when (this.baseConfig.onContactClick) {
ON_CLICK_CALL_CONTACT -> R.string.call_contact ON_CLICK_CALL_CONTACT -> R.string.call_contact
ON_CLICK_VIEW_CONTACT -> R.string.view_contact ON_CLICK_VIEW_CONTACT -> R.string.view_contact
else -> R.string.edit_contact else -> R.string.edit_contact
@ -201,18 +201,18 @@ class SettingsActivity : SimpleActivity() {
) )
private fun setupShowCallConfirmation() { 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_holder.setOnClickListener {
settings_show_call_confirmation.toggle() settings_show_call_confirmation.toggle()
contactsConfig.showCallConfirmation = settings_show_call_confirmation.isChecked this.baseConfig.showCallConfirmation = settings_show_call_confirmation.isChecked
} }
} }
private fun setupMergeDuplicateContacts() { 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_holder.setOnClickListener {
settings_merge_duplicate_contacts.toggle() settings_merge_duplicate_contacts.toggle()
contactsConfig.mergeDuplicateContacts = settings_merge_duplicate_contacts.isChecked this.baseConfig.mergeDuplicateContacts = settings_merge_duplicate_contacts.isChecked
} }
} }
} }

View File

@ -46,7 +46,7 @@ class ViewContactActivity : ContactActivity() {
private var showFields = 0 private var showFields = 0
private var fullContact: Contact? = null // contact with all fields filled from duplicates private var fullContact: Contact? = null // contact with all fields filled from duplicates
private var duplicateInitialized = false 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 private val COMPARABLE_PHONE_NUMBER_LENGTH = 9
@ -59,7 +59,7 @@ class ViewContactActivity : ContactActivity() {
return return
} }
showFields = contactsConfig.showContactFields showFields = this.baseConfig.showContactFields
contact_wrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN contact_wrapper.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
setupMenu() setupMenu()
} }
@ -122,7 +122,7 @@ class ViewContactActivity : ContactActivity() {
findItem(R.id.manage_visible_fields).setOnMenuItemClickListener { findItem(R.id.manage_visible_fields).setOnMenuItemClickListener {
ManageVisibleFieldsDialog(this@ViewContactActivity) { ManageVisibleFieldsDialog(this@ViewContactActivity) {
showFields = contactsConfig.showContactFields showFields = this@ViewContactActivity.baseConfig.showContactFields
ensureBackgroundThread { ensureBackgroundThread {
initContact() initContact()
} }
@ -388,7 +388,7 @@ class ViewContactActivity : ContactActivity() {
copyOnLongClick(phoneNumber.value) copyOnLongClick(phoneNumber.value)
setOnClickListener { setOnClickListener {
if (contactsConfig.showCallConfirmation) { if (this@ViewContactActivity.baseConfig.showCallConfirmation) {
CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) { CallConfirmationDialog(this@ViewContactActivity, phoneNumber.value) {
startCallIntent(phoneNumber.value) startCallIntent(phoneNumber.value)
} }

View File

@ -60,7 +60,7 @@ class ContactsAdapter(
private val NEW_GROUP_ID = -1 private val NEW_GROUP_ID = -1
private var config = activity.contactsConfig private var config = activity.baseConfig
private var textToHighlight = highlightText private var textToHighlight = highlightText
var startNameWithSurname = config.startNameWithSurname var startNameWithSurname = config.startNameWithSurname
@ -452,7 +452,7 @@ class ContactsAdapter(
override fun onChange(position: Int) = contactItems.getOrNull(position)?.getBubbleText() ?: "" override fun onChange(position: Int) = contactItems.getOrNull(position)?.getBubbleText() ?: ""
override fun onRowMoved(fromPosition: Int, toPosition: Int) { override fun onRowMoved(fromPosition: Int, toPosition: Int) {
activity.contactsConfig.isCustomOrderSelected = true activity.baseConfig.isCustomOrderSelected = true
if (fromPosition < toPosition) { if (fromPosition < toPosition) {
for (i in fromPosition until toPosition) { for (i in fromPosition until toPosition) {

View File

@ -27,7 +27,7 @@ class GroupsAdapter(
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate { ) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
private var textToHighlight = "" private var textToHighlight = ""
var showContactThumbnails = activity.contactsConfig.showContactThumbnails var showContactThumbnails = activity.baseConfig.showContactThumbnails
var fontSize = activity.getTextSize() var fontSize = activity.getTextSize()
init { init {

View File

@ -11,7 +11,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.signature.ObjectKey import com.bumptech.glide.signature.ObjectKey
import com.simplemobiletools.commons.extensions.* 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.helpers.SimpleContactsHelper
import com.simplemobiletools.commons.models.contacts.* import com.simplemobiletools.commons.models.contacts.*
import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.commons.views.MyRecyclerView
@ -30,7 +30,7 @@ class SelectContactsAdapter(
RecyclerView.Adapter<SelectContactsAdapter.ViewHolder>() { RecyclerView.Adapter<SelectContactsAdapter.ViewHolder>() {
private val itemViews = SparseArray<View>() private val itemViews = SparseArray<View>()
private val selectedPositions = HashSet<Int>() private val selectedPositions = HashSet<Int>()
private val config = activity.contactsConfig private val config = activity.baseConfig
private val adjustedPrimaryColor = activity.getProperPrimaryColor() private val adjustedPrimaryColor = activity.getProperPrimaryColor()
private val fontSize = activity.getTextSize() private val fontSize = activity.getTextSize()

View File

@ -6,15 +6,15 @@ import android.database.Cursor
import android.database.MatrixCursor import android.database.MatrixCursor
import android.net.Uri import android.net.Uri
import com.google.gson.Gson import com.google.gson.Gson
import com.simplemobiletools.commons.extensions.baseConfig
import com.simplemobiletools.commons.helpers.MyContactsContentProvider import com.simplemobiletools.commons.helpers.MyContactsContentProvider
import com.simplemobiletools.commons.extensions.contactsConfig
import com.simplemobiletools.commons.helpers.LocalContactsHelper import com.simplemobiletools.commons.helpers.LocalContactsHelper
class MyContactsContentProvider : ContentProvider() { class MyContactsContentProvider : ContentProvider() {
override fun insert(uri: Uri, contentValues: ContentValues?) = null override fun insert(uri: Uri, contentValues: ContentValues?) = null
override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? { override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? {
if (context == null || !context!!.contactsConfig.showPrivateContacts) { if (context == null || !context!!.baseConfig.showPrivateContacts) {
return null return null
} else { } else {
val matrixCursor = MatrixCursor( val matrixCursor = MatrixCursor(

View File

@ -2,7 +2,7 @@ package com.simplemobiletools.contacts.pro.dialogs
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.beGoneIf 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.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.* 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) { class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCustomSorting: Boolean = false, private val callback: () -> Unit) {
private var currSorting = 0 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) private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
init { init {

View File

@ -5,7 +5,7 @@ import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog
import com.simplemobiletools.commons.extensions.* 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.ContactsHelper
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.models.contacts.* import com.simplemobiletools.commons.models.contacts.*
@ -80,7 +80,7 @@ class ExportContactsDialog(
ignoreClicks = true ignoreClicks = true
ensureBackgroundThread { ensureBackgroundThread {
activity.contactsConfig.lastExportPath = file.absolutePath.getParentPath() activity.baseConfig.lastExportPath = file.absolutePath.getParentPath()
val selectedSources = (view.export_contacts_list.adapter as FilterContactSourcesAdapter).getSelectedContactSources() val selectedSources = (view.export_contacts_list.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
val ignoredSources = contactSources val ignoredSources = contactSources
.filter { !selectedSources.contains(it) } .filter { !selectedSources.contains(it) }

View File

@ -7,7 +7,7 @@ import com.simplemobiletools.commons.helpers.SMT_PRIVATE
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.activities.SimpleActivity
import com.simplemobiletools.contacts.pro.adapters.FilterContactSourcesAdapter 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.extensions.getVisibleContactSources
import com.simplemobiletools.commons.helpers.ContactsHelper import com.simplemobiletools.commons.helpers.ContactsHelper
import com.simplemobiletools.commons.models.contacts.* import com.simplemobiletools.commons.models.contacts.*
@ -77,7 +77,7 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
}.toHashSet() }.toHashSet()
if (activity.getVisibleContactSources() != ignoredContactSources) { if (activity.getVisibleContactSources() != ignoredContactSources) {
activity.contactsConfig.ignoredContactSources = ignoredContactSources activity.baseConfig.ignoredContactSources = ignoredContactSources
callback() callback()
} }
dialog?.dismiss() dialog?.dismiss()

View File

@ -19,7 +19,7 @@ class ImportContactsDialog(val activity: SimpleActivity, val path: String, priva
init { init {
val view = (activity.layoutInflater.inflate(R.layout.dialog_import_contacts, null) as ViewGroup).apply { 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) { activity.getPublicContactSource(targetContactSource) {
import_contacts_title.setText(it) import_contacts_title.setText(it)
if (it.isEmpty()) { if (it.isEmpty()) {

View File

@ -5,7 +5,7 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.views.MyAppCompatCheckbox import com.simplemobiletools.commons.views.MyAppCompatCheckbox
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.commons.extensions.contactsConfig import com.simplemobiletools.commons.extensions.baseConfig
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback: (hasSomethingChanged: Boolean) -> Unit) { 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) put(SHOW_RINGTONE_FIELD, R.id.manage_ringtone)
} }
val showContactFields = activity.contactsConfig.showContactFields val showContactFields = activity.baseConfig.showContactFields
for ((key, value) in fields) { for ((key, value) in fields) {
view.findViewById<MyAppCompatCheckbox>(value).isChecked = showContactFields and key != 0 view.findViewById<MyAppCompatCheckbox>(value).isChecked = showContactFields and key != 0
} }
@ -54,8 +54,8 @@ class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback:
} }
} }
val hasSomethingChanged = activity.contactsConfig.showContactFields != result val hasSomethingChanged = activity.baseConfig.showContactFields != result
activity.contactsConfig.showContactFields = result activity.baseConfig.showContactFields = result
if (hasSomethingChanged) { if (hasSomethingChanged) {
callback(true) callback(true)

View File

@ -8,7 +8,7 @@ import com.simplemobiletools.commons.helpers.TAB_FAVORITES
import com.simplemobiletools.commons.helpers.TAB_GROUPS import com.simplemobiletools.commons.helpers.TAB_GROUPS
import com.simplemobiletools.commons.views.MyAppCompatCheckbox import com.simplemobiletools.commons.views.MyAppCompatCheckbox
import com.simplemobiletools.contacts.pro.R 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 import com.simplemobiletools.commons.helpers.ALL_TABS_MASK
class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) { class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
@ -22,7 +22,7 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
put(TAB_GROUPS, R.id.manage_visible_tabs_groups) put(TAB_GROUPS, R.id.manage_visible_tabs_groups)
} }
val showTabs = activity.contactsConfig.showTabs val showTabs = activity.baseConfig.showTabs
for ((key, value) in tabs) { for ((key, value) in tabs) {
view.findViewById<MyAppCompatCheckbox>(value).isChecked = showTabs and key != 0 view.findViewById<MyAppCompatCheckbox>(value).isChecked = showTabs and key != 0
} }
@ -47,6 +47,6 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
result = ALL_TABS_MASK result = ALL_TABS_MASK
} }
activity.contactsConfig.showTabs = result activity.baseConfig.showTabs = result
} }
} }

View File

@ -5,7 +5,7 @@ import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.isSPlus import com.simplemobiletools.commons.helpers.isSPlus
import com.simplemobiletools.contacts.pro.R 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 kotlinx.android.synthetic.main.dialog_date_picker.view.*
import org.joda.time.DateTime import org.joda.time.DateTime
import java.util.* 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) val dialogBackgroundColor = activity.getColor(R.color.you_dialog_background_color)
view.dialog_holder.setBackgroundColor(dialogBackgroundColor) view.dialog_holder.setBackgroundColor(dialogBackgroundColor)
view.date_picker.setBackgroundColor(dialogBackgroundColor) view.date_picker.setBackgroundColor(dialogBackgroundColor)

View File

@ -30,7 +30,7 @@ fun SimpleActivity.startCallIntent(recipient: String) {
} }
fun SimpleActivity.tryStartCall(contact: Contact) { fun SimpleActivity.tryStartCall(contact: Contact) {
if (contactsConfig.showCallConfirmation) { if (this.baseConfig.showCallConfirmation) {
CallConfirmationDialog(this, contact.getNameToDisplay()) { CallConfirmationDialog(this, contact.getNameToDisplay()) {
startCall(contact) startCall(contact)
} }
@ -107,7 +107,7 @@ fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
} }
fun SimpleActivity.handleGenericContactClick(contact: Contact) { fun SimpleActivity.handleGenericContactClick(contact: Contact) {
when (contactsConfig.onContactClick) { when (this.baseConfig.onContactClick) {
ON_CLICK_CALL_CONTACT -> callContact(contact) ON_CLICK_CALL_CONTACT -> callContact(contact)
ON_CLICK_VIEW_CONTACT -> viewContact(contact) ON_CLICK_VIEW_CONTACT -> viewContact(contact)
ON_CLICK_EDIT_CONTACT -> editContact(contact) ON_CLICK_EDIT_CONTACT -> editContact(contact)

View File

@ -17,7 +17,7 @@ import com.simplemobiletools.contacts.pro.activities.MainActivity
import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.activities.SimpleActivity
import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter import com.simplemobiletools.contacts.pro.adapters.ContactsAdapter
import com.simplemobiletools.contacts.pro.adapters.GroupsAdapter 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.commons.helpers.Converters
import com.simplemobiletools.contacts.pro.helpers.* import com.simplemobiletools.contacts.pro.helpers.*
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
@ -38,13 +38,13 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
private var lastHashCode = 0 private var lastHashCode = 0
private var contactsIgnoringSearch = ArrayList<Contact>() private var contactsIgnoringSearch = ArrayList<Contact>()
private var groupsIgnoringSearch = ArrayList<Group>() private var groupsIgnoringSearch = ArrayList<Group>()
private lateinit var config: ContactsConfig private lateinit var config: BaseConfig
var skipHashComparing = false var skipHashComparing = false
var forceListRedraw = false var forceListRedraw = false
fun setupFragment(activity: SimpleActivity) { fun setupFragment(activity: SimpleActivity) {
config = activity.contactsConfig config = activity.baseConfig
if (this.activity == null) { if (this.activity == null) {
this.activity = activity this.activity = activity
fragment_fab?.beGoneIf(activity is InsertOrEditContactActivity) fragment_fab?.beGoneIf(activity is InsertOrEditContactActivity)
@ -124,7 +124,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
this is FavoritesFragment -> { this is FavoritesFragment -> {
val favorites = contacts.filter { it.starred == 1 } as ArrayList<Contact> val favorites = contacts.filter { it.starred == 1 } as ArrayList<Contact>
if (activity!!.contactsConfig.isCustomOrderSelected) { if (activity!!.baseConfig.isCustomOrderSelected) {
sortByCustomOrder(favorites) sortByCustomOrder(favorites)
} else { } else {
favorites favorites
@ -158,7 +158,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
} }
private fun sortByCustomOrder(starred: List<Contact>): ArrayList<Contact> { private fun sortByCustomOrder(starred: List<Contact>): ArrayList<Contact> {
val favoritesOrder = activity!!.contactsConfig.favoritesContactsOrder val favoritesOrder = activity!!.baseConfig.favoritesContactsOrder
if (favoritesOrder.isEmpty()) { if (favoritesOrder.isEmpty()) {
return ArrayList(starred) return ArrayList(starred)
@ -218,7 +218,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
} }
} else { } else {
(currAdapter as GroupsAdapter).apply { (currAdapter as GroupsAdapter).apply {
showContactThumbnails = activity.contactsConfig.showContactThumbnails showContactThumbnails = activity.baseConfig.showContactThumbnails
updateItems(storedGroups) updateItems(storedGroups)
} }
} }
@ -280,7 +280,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
activity?.apply { activity?.apply {
val orderIds = items.map { it.id } val orderIds = items.map { it.id }
val orderGsonString = Gson().toJson(orderIds) 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<Contact>) { private fun setupLetterFastscroller(contacts: ArrayList<Contact>) {
val sorting = context.contactsConfig.sorting val sorting = context.baseConfig.sorting
letter_fastscroller.setupWithRecyclerView(fragment_list, { position -> letter_fastscroller.setupWithRecyclerView(fragment_list, { position ->
try { try {
val contact = contacts[position] 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_SURNAME != 0 && contact.surname.isNotEmpty() -> contact.surname
sorting and SORT_BY_MIDDLE_NAME != 0 && contact.middleName.isNotEmpty() -> contact.middleName sorting and SORT_BY_MIDDLE_NAME != 0 && contact.middleName.isNotEmpty() -> contact.middleName
sorting and SORT_BY_FIRST_NAME != 0 && contact.firstName.isNotEmpty() -> contact.firstName 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 else -> contact.firstName
} }

View File

@ -1,7 +1,11 @@
package com.simplemobiletools.contacts.pro.helpers package com.simplemobiletools.contacts.pro.helpers
import android.net.Uri 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 android.provider.MediaStore
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getByteArray import com.simplemobiletools.commons.extensions.getByteArray
@ -79,7 +83,7 @@ class VcfExporter {
} }
contact.events.forEach { event -> 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) val dateTime = event.value.getDateTimeFromDateString(false)
Calendar.getInstance().apply { Calendar.getInstance().apply {
clear() clear()
@ -87,10 +91,11 @@ class VcfExporter {
set(Calendar.YEAR, 1900) set(Calendar.YEAR, 1900)
} else { } else {
set(Calendar.YEAR, dateTime.year) set(Calendar.YEAR, dateTime.year)
} }
set(Calendar.MONTH, dateTime.monthOfYear - 1) set(Calendar.MONTH, dateTime.monthOfYear - 1)
set(Calendar.DAY_OF_MONTH, dateTime.dayOfMonth) 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)) card.birthdays.add(Birthday(time))
} else { } else {
card.anniversaries.add(Anniversary(time)) card.anniversaries.add(Anniversary(time))
@ -108,14 +113,14 @@ class VcfExporter {
contact.IMs.forEach { contact.IMs.forEach {
val impp = when (it.type) { val impp = when (it.type) {
ContactsContract.CommonDataKinds.Im.PROTOCOL_AIM -> Impp.aim(it.value) Im.PROTOCOL_AIM -> Impp.aim(it.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_YAHOO -> Impp.yahoo(it.value) Im.PROTOCOL_YAHOO -> Impp.yahoo(it.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_MSN -> Impp.msn(it.value) Im.PROTOCOL_MSN -> Impp.msn(it.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_ICQ -> Impp.icq(it.value) Im.PROTOCOL_ICQ -> Impp.icq(it.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_SKYPE -> Impp.skype(it.value) Im.PROTOCOL_SKYPE -> Impp.skype(it.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_GOOGLE_TALK -> Impp(HANGOUTS, it.value) Im.PROTOCOL_GOOGLE_TALK -> Impp(HANGOUTS, it.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_QQ -> Impp(QQ, it.value) Im.PROTOCOL_QQ -> Impp(QQ, it.value)
ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER -> Impp(JABBER, it.value) Im.PROTOCOL_JABBER -> Impp(JABBER, it.value)
else -> Impp(it.label, it.value) else -> Impp(it.label, it.value)
} }
@ -171,29 +176,29 @@ class VcfExporter {
} }
private fun getPhoneNumberTypeLabel(type: Int, label: String) = when (type) { private fun getPhoneNumberTypeLabel(type: Int, label: String) = when (type) {
ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE -> CELL Phone.TYPE_MOBILE -> CELL
ContactsContract.CommonDataKinds.Phone.TYPE_HOME -> HOME Phone.TYPE_HOME -> HOME
ContactsContract.CommonDataKinds.Phone.TYPE_WORK -> WORK Phone.TYPE_WORK -> WORK
ContactsContract.CommonDataKinds.Phone.TYPE_MAIN -> PREF Phone.TYPE_MAIN -> PREF
ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK -> WORK_FAX Phone.TYPE_FAX_WORK -> WORK_FAX
ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME -> HOME_FAX Phone.TYPE_FAX_HOME -> HOME_FAX
ContactsContract.CommonDataKinds.Phone.TYPE_PAGER -> PAGER Phone.TYPE_PAGER -> PAGER
ContactsContract.CommonDataKinds.Phone.TYPE_OTHER -> OTHER Phone.TYPE_OTHER -> OTHER
else -> label else -> label
} }
private fun getEmailTypeLabel(type: Int, label: String) = when (type) { private fun getEmailTypeLabel(type: Int, label: String) = when (type) {
ContactsContract.CommonDataKinds.Email.TYPE_HOME -> HOME Email.TYPE_HOME -> HOME
ContactsContract.CommonDataKinds.Email.TYPE_WORK -> WORK Email.TYPE_WORK -> WORK
ContactsContract.CommonDataKinds.Email.TYPE_MOBILE -> MOBILE Email.TYPE_MOBILE -> MOBILE
ContactsContract.CommonDataKinds.Email.TYPE_OTHER -> OTHER Email.TYPE_OTHER -> OTHER
else -> label else -> label
} }
private fun getAddressTypeLabel(type: Int, label: String) = when (type) { private fun getAddressTypeLabel(type: Int, label: String) = when (type) {
ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME -> HOME StructuredPostal.TYPE_HOME -> HOME
ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK -> WORK StructuredPostal.TYPE_WORK -> WORK
ContactsContract.CommonDataKinds.StructuredPostal.TYPE_OTHER -> OTHER StructuredPostal.TYPE_OTHER -> OTHER
else -> label else -> label
} }
} }