fix: use reference config instead of baseConfig

This commit is contained in:
ismailnurudeen 2023-02-24 11:37:21 +01:00
parent 8a84e84a8d
commit 25daf4de8f
21 changed files with 116 additions and 105 deletions

View file

@ -10,9 +10,7 @@ import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.media.RingtoneManager import android.media.RingtoneManager
import android.net.Uri import android.net.Uri
import android.provider.ContactsContract
import android.provider.ContactsContract.CommonDataKinds.* import android.provider.ContactsContract.CommonDataKinds.*
import android.provider.ContactsContract.CommonDataKinds.Email
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
@ -31,7 +29,7 @@ import com.simplemobiletools.commons.helpers.letterBackgroundColors
import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.extensions.shareContacts import com.simplemobiletools.contacts.pro.extensions.shareContacts
import com.simplemobiletools.commons.models.contacts.* import com.simplemobiletools.commons.models.contacts.Contact
abstract class ContactActivity : SimpleActivity() { abstract class ContactActivity : SimpleActivity() {
protected val PICK_RINGTONE_INTENT_ID = 1500 protected val PICK_RINGTONE_INTENT_ID = 1500
@ -209,8 +207,8 @@ abstract class ContactActivity : SimpleActivity() {
} }
fun getEventTextId(type: Int) = when (type) { fun getEventTextId(type: Int) = when (type) {
ContactsContract.CommonDataKinds.Event.TYPE_ANNIVERSARY -> R.string.anniversary Event.TYPE_ANNIVERSARY -> R.string.anniversary
ContactsContract.CommonDataKinds.Event.TYPE_BIRTHDAY -> R.string.birthday Event.TYPE_BIRTHDAY -> R.string.birthday
else -> R.string.other else -> R.string.other
} }

View file

@ -388,7 +388,7 @@ class EditContactActivity : ContactActivity() {
} }
private fun setupFieldVisibility() { private fun setupFieldVisibility() {
val showFields = baseConfig.showContactFields val showFields = config.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()) baseConfig.lastUsedContactSource else SMT_PRIVATE originalContactSource = if (hasContactPermissions()) config.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 {
baseConfig.lastUsedContactSource = contact!!.source config.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

@ -13,17 +13,17 @@ import android.widget.TextView
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.contacts.*
import com.simplemobiletools.contacts.pro.R 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.baseConfig import com.simplemobiletools.contacts.pro.extensions.config
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
import com.simplemobiletools.contacts.pro.helpers.KEY_NAME import com.simplemobiletools.contacts.pro.helpers.KEY_NAME
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
import com.simplemobiletools.commons.models.contacts.*
import kotlinx.android.synthetic.main.activity_insert_edit_contact.* import kotlinx.android.synthetic.main.activity_insert_edit_contact.*
import kotlinx.android.synthetic.main.fragment_contacts.* import kotlinx.android.synthetic.main.fragment_contacts.*
import kotlinx.android.synthetic.main.fragment_favorites.* import kotlinx.android.synthetic.main.fragment_favorites.*
@ -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 (baseConfig.showTabs and value != 0) { if (config.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 (baseConfig.showTabs and TAB_FAVORITES != 0) { if (config.showTabs and TAB_FAVORITES != 0) {
mask += TAB_FAVORITES mask += TAB_FAVORITES
} }
return mask return mask

View file

@ -18,7 +18,6 @@ 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.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
@ -30,6 +29,7 @@ import com.simplemobiletools.contacts.pro.dialogs.ChangeSortingDialog
import com.simplemobiletools.contacts.pro.dialogs.ExportContactsDialog import com.simplemobiletools.contacts.pro.dialogs.ExportContactsDialog
import com.simplemobiletools.contacts.pro.dialogs.FilterContactSourcesDialog import com.simplemobiletools.contacts.pro.dialogs.FilterContactSourcesDialog
import com.simplemobiletools.contacts.pro.dialogs.ImportContactsDialog import com.simplemobiletools.contacts.pro.dialogs.ImportContactsDialog
import com.simplemobiletools.contacts.pro.extensions.config
import com.simplemobiletools.contacts.pro.extensions.handleGenericContactClick import com.simplemobiletools.contacts.pro.extensions.handleGenericContactClick
import com.simplemobiletools.contacts.pro.fragments.FavoritesFragment import com.simplemobiletools.contacts.pro.fragments.FavoritesFragment
import com.simplemobiletools.contacts.pro.fragments.MyViewPagerFragment import com.simplemobiletools.contacts.pro.fragments.MyViewPagerFragment
@ -90,19 +90,19 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (storedShowPhoneNumbers != baseConfig.showPhoneNumbers) { if (storedShowPhoneNumbers != config.showPhoneNumbers) {
System.exit(0) System.exit(0)
return return
} }
if (storedShowTabs != baseConfig.showTabs) { if (storedShowTabs != config.showTabs) {
baseConfig.lastUsedViewPagerPage = 0 config.lastUsedViewPagerPage = 0
finish() finish()
startActivity(intent) startActivity(intent)
return return
} }
val configShowContactThumbnails = baseConfig.showContactThumbnails val configShowContactThumbnails = config.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 = baseConfig.startNameWithSurname val configStartNameWithSurname = config.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 = baseConfig.fontSize val configFontSize = config.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(baseConfig.showDialpadButton) beVisibleIf(config.showDialpadButton)
} }
isFirstResume = false isFirstResume = false
checkShortcuts() checkShortcuts()
if (!baseConfig.wasUpgradedFromFreeShown && isPackageInstalled("com.simplemobiletools.contacts")) { if (!config.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) {}
baseConfig.wasUpgradedFromFreeShown = true config.wasUpgradedFromFreeShown = true
} }
} }
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
storeStateVariables() storeStateVariables()
baseConfig.lastUsedViewPagerPage = view_pager.currentItem config.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 = !baseConfig.showDialpadButton findItem(R.id.dialpad).isVisible = !config.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() {
baseConfig.apply { config.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 = baseConfig.appIconColor val appIconColor = config.appIconColor
if (isNougatMR1Plus() && baseConfig.lastHandledShortcutColor != appIconColor) { if (isNougatMR1Plus() && config.lastHandledShortcutColor != appIconColor) {
val createNewContact = getCreateNewContactShortcut(appIconColor) val createNewContact = getCreateNewContactShortcut(appIconColor)
try { try {
shortcutManager.dynamicShortcuts = Arrays.asList(createNewContact) shortcutManager.dynamicShortcuts = Arrays.asList(createNewContact)
baseConfig.lastHandledShortcutColor = appIconColor config.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 = baseConfig.showTabs val showTabs = config.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 = baseConfig.showTabs val showTabs = config.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 = baseConfig.showTabs val showTabs = config.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 (baseConfig.showTabs and value != 0) { if (config.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, baseConfig.lastExportPath, true) { file, ignoredContactSources -> ExportContactsDialog(this, config.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, baseConfig.lastExportPath, false) { file, ignoredContactSources -> ExportContactsDialog(this, config.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, baseConfig.showTabs) view_pager.adapter = ViewPagerAdapter(this, tabsList, config.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 = baseConfig.showTabs val showTabsMask = config.showTabs
return when (baseConfig.defaultTab) { return when (config.defaultTab) {
TAB_LAST_USED -> baseConfig.lastUsedViewPagerPage TAB_LAST_USED -> config.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.baseConfig import com.simplemobiletools.contacts.pro.extensions.config
import kotlinx.android.synthetic.main.activity_settings.* import kotlinx.android.synthetic.main.activity_settings.*
import java.util.* import java.util.*
@ -77,8 +77,8 @@ 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, baseConfig.defaultTab) { RadioGroupDialog(this@SettingsActivity, items, config.defaultTab) {
baseConfig.defaultTab = it as Int config.defaultTab = it as Int
settings_default_tab.text = getDefaultTabText() settings_default_tab.text = getDefaultTabText()
} }
} }
@ -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, baseConfig.fontSize) { RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
baseConfig.fontSize = it as Int config.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((baseConfig.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus()) settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
settings_use_english.isChecked = baseConfig.useEnglish settings_use_english.isChecked = config.useEnglish
settings_use_english_holder.setOnClickListener { settings_use_english_holder.setOnClickListener {
settings_use_english.toggle() settings_use_english.toggle()
baseConfig.useEnglish = settings_use_english.isChecked config.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 = baseConfig.showContactThumbnails settings_show_contact_thumbnails.isChecked = config.showContactThumbnails
settings_show_contact_thumbnails_holder.setOnClickListener { settings_show_contact_thumbnails_holder.setOnClickListener {
settings_show_contact_thumbnails.toggle() settings_show_contact_thumbnails.toggle()
baseConfig.showContactThumbnails = settings_show_contact_thumbnails.isChecked config.showContactThumbnails = settings_show_contact_thumbnails.isChecked
} }
} }
private fun setupShowPhoneNumbers() { private fun setupShowPhoneNumbers() {
settings_show_phone_numbers.isChecked = baseConfig.showPhoneNumbers settings_show_phone_numbers.isChecked = config.showPhoneNumbers
settings_show_phone_numbers_holder.setOnClickListener { settings_show_phone_numbers_holder.setOnClickListener {
settings_show_phone_numbers.toggle() settings_show_phone_numbers.toggle()
baseConfig.showPhoneNumbers = settings_show_phone_numbers.isChecked config.showPhoneNumbers = settings_show_phone_numbers.isChecked
} }
} }
private fun setupShowContactsWithNumbers() { private fun setupShowContactsWithNumbers() {
settings_show_only_contacts_with_numbers.isChecked = baseConfig.showOnlyContactsWithNumbers settings_show_only_contacts_with_numbers.isChecked = config.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()
baseConfig.showOnlyContactsWithNumbers = settings_show_only_contacts_with_numbers.isChecked config.showOnlyContactsWithNumbers = settings_show_only_contacts_with_numbers.isChecked
} }
} }
private fun setupStartNameWithSurname() { private fun setupStartNameWithSurname() {
settings_start_name_with_surname.isChecked = baseConfig.startNameWithSurname settings_start_name_with_surname.isChecked = config.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()
baseConfig.startNameWithSurname = settings_start_name_with_surname.isChecked config.startNameWithSurname = settings_start_name_with_surname.isChecked
} }
} }
private fun setupShowDialpadButton() { private fun setupShowDialpadButton() {
settings_show_dialpad_button.isChecked = baseConfig.showDialpadButton settings_show_dialpad_button.isChecked = config.showDialpadButton
settings_show_dialpad_button_holder.setOnClickListener { settings_show_dialpad_button_holder.setOnClickListener {
settings_show_dialpad_button.toggle() settings_show_dialpad_button.toggle()
baseConfig.showDialpadButton = settings_show_dialpad_button.isChecked config.showDialpadButton = settings_show_dialpad_button.isChecked
} }
} }
private fun setupShowPrivateContacts() { private fun setupShowPrivateContacts() {
settings_show_private_contacts.isChecked = baseConfig.showPrivateContacts settings_show_private_contacts.isChecked = config.showPrivateContacts
settings_show_private_contacts_holder.setOnClickListener { settings_show_private_contacts_holder.setOnClickListener {
settings_show_private_contacts.toggle() settings_show_private_contacts.toggle()
baseConfig.showPrivateContacts = settings_show_private_contacts.isChecked config.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, baseConfig.onContactClick) { RadioGroupDialog(this@SettingsActivity, items, config.onContactClick) {
baseConfig.onContactClick = it as Int config.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 (baseConfig.onContactClick) { when (config.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 = baseConfig.showCallConfirmation settings_show_call_confirmation.isChecked = config.showCallConfirmation
settings_show_call_confirmation_holder.setOnClickListener { settings_show_call_confirmation_holder.setOnClickListener {
settings_show_call_confirmation.toggle() settings_show_call_confirmation.toggle()
baseConfig.showCallConfirmation = settings_show_call_confirmation.isChecked config.showCallConfirmation = settings_show_call_confirmation.isChecked
} }
} }
private fun setupMergeDuplicateContacts() { private fun setupMergeDuplicateContacts() {
settings_merge_duplicate_contacts.isChecked = baseConfig.mergeDuplicateContacts settings_merge_duplicate_contacts.isChecked = config.mergeDuplicateContacts
settings_merge_duplicate_contacts_holder.setOnClickListener { settings_merge_duplicate_contacts_holder.setOnClickListener {
settings_merge_duplicate_contacts.toggle() settings_merge_duplicate_contacts.toggle()
baseConfig.mergeDuplicateContacts = settings_merge_duplicate_contacts.isChecked config.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() = baseConfig.mergeDuplicateContacts private val mergeDuplicate: Boolean get() = config.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 = baseConfig.showContactFields showFields = config.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 = baseConfig.showContactFields showFields = config.showContactFields
ensureBackgroundThread { ensureBackgroundThread {
initContact() initContact()
} }
@ -388,7 +388,7 @@ class ViewContactActivity : ContactActivity() {
copyOnLongClick(phoneNumber.value) copyOnLongClick(phoneNumber.value)
setOnClickListener { setOnClickListener {
if (baseConfig.showCallConfirmation) { if (config.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.baseConfig private var config = activity.config
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.baseConfig.isCustomOrderSelected = true activity.config.isCustomOrderSelected = true
if (fromPosition < toPosition) { if (fromPosition < toPosition) {
for (i in fromPosition until toPosition) { for (i in fromPosition until toPosition) {

View file

@ -17,6 +17,7 @@ import com.simplemobiletools.contacts.pro.activities.SimpleActivity
import com.simplemobiletools.contacts.pro.dialogs.RenameGroupDialog import com.simplemobiletools.contacts.pro.dialogs.RenameGroupDialog
import com.simplemobiletools.commons.helpers.ContactsHelper import com.simplemobiletools.commons.helpers.ContactsHelper
import com.simplemobiletools.commons.models.contacts.Group import com.simplemobiletools.commons.models.contacts.Group
import com.simplemobiletools.contacts.pro.extensions.config
import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
import kotlinx.android.synthetic.main.item_group.view.* import kotlinx.android.synthetic.main.item_group.view.*
import java.util.* import java.util.*
@ -27,7 +28,7 @@ class GroupsAdapter(
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate { ) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
private var textToHighlight = "" private var textToHighlight = ""
var showContactThumbnails = activity.baseConfig.showContactThumbnails var showContactThumbnails = activity.config.showContactThumbnails
var fontSize = activity.getTextSize() var fontSize = activity.getTextSize()
init { init {

View file

@ -11,12 +11,12 @@ 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.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
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.extensions.config
import kotlinx.android.synthetic.main.item_add_favorite_with_number.view.* import kotlinx.android.synthetic.main.item_add_favorite_with_number.view.*
class SelectContactsAdapter( class SelectContactsAdapter(
@ -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.baseConfig private val config = activity.config
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.helpers.LocalContactsHelper import com.simplemobiletools.commons.helpers.LocalContactsHelper
import com.simplemobiletools.contacts.pro.extensions.config
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!!.baseConfig.showPrivateContacts) { if (context == null || !context!!.config.showPrivateContacts) {
return null return null
} else { } else {
val matrixCursor = MatrixCursor( val matrixCursor = MatrixCursor(

View file

@ -2,16 +2,16 @@ 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.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.*
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.extensions.config
import kotlinx.android.synthetic.main.dialog_change_sorting.view.* 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.baseConfig private var config = activity.config
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,13 +5,13 @@ 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.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.*
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.contacts.pro.extensions.config
import kotlinx.android.synthetic.main.dialog_export_contacts.view.* import kotlinx.android.synthetic.main.dialog_export_contacts.view.*
import java.io.File import java.io.File
@ -80,7 +80,7 @@ class ExportContactsDialog(
ignoreClicks = true ignoreClicks = true
ensureBackgroundThread { ensureBackgroundThread {
activity.baseConfig.lastExportPath = file.absolutePath.getParentPath() activity.config.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,10 +7,10 @@ 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.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.*
import com.simplemobiletools.contacts.pro.extensions.config
import kotlinx.android.synthetic.main.dialog_filter_contact_sources.view.* import kotlinx.android.synthetic.main.dialog_filter_contact_sources.view.*
class FilterContactSourcesDialog(val activity: SimpleActivity, private val callback: () -> Unit) { class FilterContactSourcesDialog(val activity: SimpleActivity, private val callback: () -> Unit) {
@ -77,7 +77,7 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
}.toHashSet() }.toHashSet()
if (activity.getVisibleContactSources() != ignoredContactSources) { if (activity.getVisibleContactSources() != ignoredContactSources) {
activity.baseConfig.ignoredContactSources = ignoredContactSources activity.config.ignoredContactSources = ignoredContactSources
callback() callback()
} }
dialog?.dismiss() dialog?.dismiss()

View file

@ -8,6 +8,7 @@ import com.simplemobiletools.commons.helpers.SMT_PRIVATE
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
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.extensions.config
import com.simplemobiletools.contacts.pro.extensions.showContactSourcePicker import com.simplemobiletools.contacts.pro.extensions.showContactSourcePicker
import com.simplemobiletools.contacts.pro.helpers.VcfImporter import com.simplemobiletools.contacts.pro.helpers.VcfImporter
import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_FAIL import com.simplemobiletools.contacts.pro.helpers.VcfImporter.ImportResult.IMPORT_FAIL
@ -19,7 +20,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.baseConfig.lastUsedContactSource targetContactSource = activity.config.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,8 +5,8 @@ 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.baseConfig
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.contacts.pro.extensions.config
class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback: (hasSomethingChanged: Boolean) -> Unit) { class ManageVisibleFieldsDialog(val activity: BaseSimpleActivity, val callback: (hasSomethingChanged: Boolean) -> Unit) {
private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_visible_fields, null) private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_visible_fields, null)
@ -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.baseConfig.showContactFields val showContactFields = activity.config.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.baseConfig.showContactFields != result val hasSomethingChanged = activity.config.showContactFields != result
activity.baseConfig.showContactFields = result activity.config.showContactFields = result
if (hasSomethingChanged) { if (hasSomethingChanged) {
callback(true) callback(true)

View file

@ -8,8 +8,8 @@ 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.baseConfig
import com.simplemobiletools.commons.helpers.ALL_TABS_MASK import com.simplemobiletools.commons.helpers.ALL_TABS_MASK
import com.simplemobiletools.contacts.pro.extensions.config
class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) { class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_visible_tabs, null) private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_visible_tabs, null)
@ -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.baseConfig.showTabs val showTabs = activity.config.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.baseConfig.showTabs = result activity.config.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.baseConfig import com.simplemobiletools.contacts.pro.extensions.config
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.baseConfig.isUsingSystemTheme && isSPlus()) { if (activity.config.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

@ -9,13 +9,12 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.RadioItem import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.commons.models.contacts.Contact
import com.simplemobiletools.contacts.pro.BuildConfig import com.simplemobiletools.contacts.pro.BuildConfig
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.activities.EditContactActivity import com.simplemobiletools.contacts.pro.activities.EditContactActivity
import com.simplemobiletools.contacts.pro.activities.SimpleActivity import com.simplemobiletools.contacts.pro.activities.SimpleActivity
import com.simplemobiletools.contacts.pro.activities.ViewContactActivity import com.simplemobiletools.contacts.pro.activities.ViewContactActivity
import com.simplemobiletools.contacts.pro.helpers.*
import com.simplemobiletools.commons.models.contacts.*
import com.simplemobiletools.contacts.pro.helpers.DEFAULT_FILE_NAME import com.simplemobiletools.contacts.pro.helpers.DEFAULT_FILE_NAME
import com.simplemobiletools.contacts.pro.helpers.VcfExporter import com.simplemobiletools.contacts.pro.helpers.VcfExporter
@ -30,7 +29,7 @@ fun SimpleActivity.startCallIntent(recipient: String) {
} }
fun SimpleActivity.tryStartCall(contact: Contact) { fun SimpleActivity.tryStartCall(contact: Contact) {
if (baseConfig.showCallConfirmation) { if (config.showCallConfirmation) {
CallConfirmationDialog(this, contact.getNameToDisplay()) { CallConfirmationDialog(this, contact.getNameToDisplay()) {
startCall(contact) startCall(contact)
} }
@ -107,7 +106,7 @@ fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
} }
fun SimpleActivity.handleGenericContactClick(contact: Contact) { fun SimpleActivity.handleGenericContactClick(contact: Contact) {
when (baseConfig.onContactClick) { when (config.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

@ -11,8 +11,10 @@ import com.simplemobiletools.commons.helpers.VIBER_PACKAGE
import com.simplemobiletools.commons.helpers.WHATSAPP_PACKAGE import com.simplemobiletools.commons.helpers.WHATSAPP_PACKAGE
import com.simplemobiletools.contacts.pro.BuildConfig import com.simplemobiletools.contacts.pro.BuildConfig
import com.simplemobiletools.contacts.pro.R import com.simplemobiletools.contacts.pro.R
import com.simplemobiletools.contacts.pro.helpers.Config
import java.io.File import java.io.File
val Context.config: Config get() = Config.newInstance(applicationContext)
fun Context.getCachePhotoUri(file: File = getCachePhoto()) = FileProvider.getUriForFile(this, "${BuildConfig.APPLICATION_ID}.provider", file) fun Context.getCachePhotoUri(file: File = getCachePhoto()) = FileProvider.getUriForFile(this, "${BuildConfig.APPLICATION_ID}.provider", file)
@SuppressLint("UseCompatLoadingForDrawables") @SuppressLint("UseCompatLoadingForDrawables")

View file

@ -17,11 +17,11 @@ 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.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
import com.simplemobiletools.commons.models.contacts.* import com.simplemobiletools.commons.models.contacts.*
import com.simplemobiletools.contacts.pro.extensions.config
import kotlinx.android.synthetic.main.fragment_layout.view.* import kotlinx.android.synthetic.main.fragment_layout.view.*
import kotlinx.android.synthetic.main.fragment_layout.view.fragment_fab import kotlinx.android.synthetic.main.fragment_layout.view.fragment_fab
import kotlinx.android.synthetic.main.fragment_layout.view.fragment_list import kotlinx.android.synthetic.main.fragment_layout.view.fragment_list
@ -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: BaseConfig private lateinit var config: Config
var skipHashComparing = false var skipHashComparing = false
var forceListRedraw = false var forceListRedraw = false
fun setupFragment(activity: SimpleActivity) { fun setupFragment(activity: SimpleActivity) {
config = activity.baseConfig config = activity.config
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!!.baseConfig.isCustomOrderSelected) { if (activity!!.config.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!!.baseConfig.favoritesContactsOrder val favoritesOrder = activity!!.config.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.baseConfig.showContactThumbnails showContactThumbnails = activity.config.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)
baseConfig.favoritesContactsOrder = orderGsonString config.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.baseConfig.sorting val sorting = context.config.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.baseConfig.startNameWithSurname -> contact.surname context.config.startNameWithSurname -> contact.surname
else -> contact.firstName else -> contact.firstName
} }

View file

@ -0,0 +1,10 @@
package com.simplemobiletools.contacts.pro.helpers
import android.content.Context
import com.simplemobiletools.commons.helpers.BaseConfig
class Config(context: Context) : BaseConfig(context) {
companion object {
fun newInstance(context: Context) = Config(context)
}
}