show local contacts in the lists

This commit is contained in:
tibbi 2018-02-11 20:28:45 +01:00
parent eb4833ff1e
commit 6c39757cec
6 changed files with 24 additions and 5 deletions

View File

@ -105,8 +105,8 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
if (storedPrimaryColor != configPrimaryColor) {
main_tabs_holder.setSelectedTabIndicatorColor(getAdjustedPrimaryColor())
main_tabs_holder.getTabAt(viewpager.currentItem)?.icon?.applyColorFilter(getAdjustedPrimaryColor())
contacts_fragment.primaryColorChanged(configPrimaryColor)
favorites_fragment.primaryColorChanged(configPrimaryColor)
contacts_fragment.primaryColorChanged()
favorites_fragment.primaryColorChanged()
}
val configStartNameWithSurname = config.startNameWithSurname

View File

@ -9,6 +9,7 @@ import com.simplemobiletools.commons.interfaces.MyAdapterListener
import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.activities.SimpleActivity
import com.simplemobiletools.contacts.extensions.config
import com.simplemobiletools.contacts.helpers.SMT_PRIVATE
import com.simplemobiletools.contacts.models.ContactSource
import kotlinx.android.synthetic.main.item_filter_contact_source.view.*
import java.util.*
@ -27,6 +28,10 @@ class FilterContactSourcesAdapter(val activity: SimpleActivity, private val cont
if (contactSource.name == activity.config.localAccountName && contactSource.type == activity.config.localAccountType) {
contactSource.name = activity.getString(R.string.phone_storage)
}
if (contactSource.type == SMT_PRIVATE && displayContactSources.contains(SMT_PRIVATE)) {
selectedPositions.add(index)
}
}
}

View File

@ -7,6 +7,7 @@ import com.simplemobiletools.contacts.activities.SimpleActivity
import com.simplemobiletools.contacts.adapters.FilterContactSourcesAdapter
import com.simplemobiletools.contacts.extensions.config
import com.simplemobiletools.contacts.helpers.ContactsHelper
import com.simplemobiletools.contacts.helpers.SMT_PRIVATE
import com.simplemobiletools.contacts.models.ContactSource
import kotlinx.android.synthetic.main.dialog_filter_contact_sources.view.*
import java.util.*
@ -41,7 +42,7 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
val selectedIndexes = (view.filter_contact_sources_list.adapter as FilterContactSourcesAdapter).getSelectedItemsSet()
val selectedContactSources = HashSet<String>()
selectedIndexes.forEach {
selectedContactSources.add(contactSources[it].name)
selectedContactSources.add(if (contactSources[it].type == SMT_PRIVATE) SMT_PRIVATE else contactSources[it].name)
}
if (activity.config.displayContactSources != selectedContactSources) {

View File

@ -13,6 +13,7 @@ import com.simplemobiletools.contacts.BuildConfig
import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.activities.SimpleActivity
import com.simplemobiletools.contacts.helpers.ContactsHelper
import com.simplemobiletools.contacts.helpers.SMT_PRIVATE
import com.simplemobiletools.contacts.helpers.VcfExporter
import com.simplemobiletools.contacts.models.Contact
import java.io.File
@ -62,6 +63,8 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
items.add(RadioItem(index, publicAccount))
if (account == currentSource) {
currentSourceIndex = index
} else if (currentSource == SMT_PRIVATE && account == getString(R.string.phone_storage_hidden)) {
currentSourceIndex = index
}
}
@ -73,7 +76,13 @@ fun SimpleActivity.showContactSourcePicker(currentSource: String, callback: (new
}
}
fun SimpleActivity.getPublicContactSource(source: String) = if (source == config.localAccountName) getString(R.string.phone_storage) else source
fun SimpleActivity.getPublicContactSource(source: String): String {
return when (source) {
config.localAccountName -> getString(R.string.phone_storage)
SMT_PRIVATE -> getString(R.string.phone_storage_hidden)
else -> source
}
}
fun BaseSimpleActivity.shareContacts(contacts: ArrayList<Contact>) {
val file = getTempFile()

View File

@ -59,7 +59,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
}
}
fun primaryColorChanged(color: Int) {
fun primaryColorChanged() {
fragment_fastscroller.updatePrimaryColor()
fragment_fastscroller.updateBubblePrimaryColor()
}

View File

@ -78,6 +78,10 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
contacts[key]?.emails = emails.valueAt(i)
}
activity.dbHelper.getContacts().forEach {
contacts.put(it.id, it)
}
val contactsSize = contacts.size()
var resultContacts = ArrayList<Contact>(contactsSize)
(0 until contactsSize).mapTo(resultContacts) { contacts.valueAt(it) }