mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-06-05 21:59:27 +02:00
do not show contact phone numbers on the main screen by default
This commit is contained in:
@ -26,6 +26,7 @@ class MainActivity : SimpleActivity() {
|
||||
private var storedTextColor = 0
|
||||
private var storedBackgroundColor = 0
|
||||
private var storedPrimaryColor = 0
|
||||
private var storedShowPhoneNumbers = false
|
||||
private var storedStartNameWithSurname = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -58,6 +59,11 @@ class MainActivity : SimpleActivity() {
|
||||
return
|
||||
}
|
||||
|
||||
if (storedShowPhoneNumbers != config.showPhoneNumbers) {
|
||||
restartActivity()
|
||||
return
|
||||
}
|
||||
|
||||
val configTextColor = config.textColor
|
||||
if (storedTextColor != configTextColor) {
|
||||
main_tabs_holder.getTabAt(getOtherViewPagerItem(viewpager.currentItem))?.icon?.applyColorFilter(configTextColor)
|
||||
@ -124,6 +130,7 @@ class MainActivity : SimpleActivity() {
|
||||
storedTextColor = textColor
|
||||
storedBackgroundColor = backgroundColor
|
||||
storedPrimaryColor = primaryColor
|
||||
storedShowPhoneNumbers = showPhoneNumbers
|
||||
storedStartNameWithSurname = startNameWithSurname
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupShowInfoBubble()
|
||||
setupShowPhoneNumbers()
|
||||
setupCallContactOnClick()
|
||||
setupStartNameWithSurname()
|
||||
updateTextColors(settings_holder)
|
||||
@ -50,6 +51,14 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowPhoneNumbers() {
|
||||
settings_show_phone_numbers.isChecked = config.showPhoneNumbers
|
||||
settings_show_phone_numbers_holder.setOnClickListener {
|
||||
settings_show_phone_numbers.toggle()
|
||||
config.showPhoneNumbers = settings_show_phone_numbers.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupCallContactOnClick() {
|
||||
settings_call_contact_on_click.isChecked = config.callContact
|
||||
settings_call_contact_on_click_holder.setOnClickListener {
|
||||
|
@ -21,7 +21,7 @@ import com.simplemobiletools.contacts.extensions.config
|
||||
import com.simplemobiletools.contacts.extensions.openContact
|
||||
import com.simplemobiletools.contacts.helpers.ContactsHelper
|
||||
import com.simplemobiletools.contacts.models.Contact
|
||||
import kotlinx.android.synthetic.main.item_contact.view.*
|
||||
import kotlinx.android.synthetic.main.item_contact_with_number.view.*
|
||||
|
||||
class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Contact>, val listener: RefreshRecyclerViewListener?,
|
||||
recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||
@ -29,9 +29,11 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
||||
var config = activity.config
|
||||
lateinit private var contactDrawable: Drawable
|
||||
var startNameWithSurname: Boolean
|
||||
var showPhoneNumbers: Boolean
|
||||
|
||||
init {
|
||||
initDrawables()
|
||||
showPhoneNumbers = config.showPhoneNumbers
|
||||
startNameWithSurname = config.startNameWithSurname
|
||||
}
|
||||
|
||||
@ -59,7 +61,10 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
||||
|
||||
override fun getSelectableItemCount() = contactItems.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int) = createViewHolder(R.layout.item_contact, parent)
|
||||
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): ViewHolder {
|
||||
val layout = if (showPhoneNumbers) R.layout.item_contact_with_number else R.layout.item_contact_without_number
|
||||
return createViewHolder(layout, parent)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||
val contact = contactItems[position]
|
||||
@ -112,10 +117,10 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
||||
|
||||
private fun setupView(view: View, contact: Contact) {
|
||||
view.apply {
|
||||
contact_first_name.text = contact.getFullName(startNameWithSurname)
|
||||
contact_first_name.setTextColor(textColor)
|
||||
contact_number.text = contact.phoneNumbers.firstOrNull()?.value ?: ""
|
||||
contact_number.setTextColor(textColor)
|
||||
contact_name.text = contact.getFullName(startNameWithSurname)
|
||||
contact_name.setTextColor(textColor)
|
||||
contact_number?.text = contact.phoneNumbers.firstOrNull()?.value ?: ""
|
||||
contact_number?.setTextColor(textColor)
|
||||
|
||||
if (contact.photoUri.isNotEmpty()) {
|
||||
val options = RequestOptions()
|
||||
|
@ -130,6 +130,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
|
||||
} else {
|
||||
(currAdapter as ContactsAdapter).apply {
|
||||
startNameWithSurname = config.startNameWithSurname
|
||||
showPhoneNumbers = config.showPhoneNumbers
|
||||
updateItems(contacts)
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,17 @@ package com.simplemobiletools.contacts.fragments
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.simplemobiletools.contacts.activities.MainActivity
|
||||
import kotlinx.android.synthetic.main.fragment_favorites.view.*
|
||||
|
||||
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
||||
var activity: MainActivity? = null
|
||||
override fun initFragment(activity: MainActivity) {
|
||||
if (this.activity == null) {
|
||||
this.activity = activity
|
||||
favorites_fab.setOnClickListener {
|
||||
addNewFavorites()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun textColorChanged(color: Int) {
|
||||
@ -19,4 +27,8 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
||||
|
||||
override fun onActivityResume() {
|
||||
}
|
||||
|
||||
private fun addNewFavorites() {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,10 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
|
||||
fun showAllContacts() = displayContactSources.size == 1 && displayContactSources.first() == "-1"
|
||||
|
||||
var showPhoneNumbers: Boolean
|
||||
get() = prefs.getBoolean(SHOW_PHONE_NUMBERS, false)
|
||||
set(showPhoneNumbers) = prefs.edit().putBoolean(SHOW_PHONE_NUMBERS, showPhoneNumbers).apply()
|
||||
|
||||
var startNameWithSurname: Boolean
|
||||
get() = prefs.getBoolean(START_NAME_WITH_SURNAME, false)
|
||||
set(startNameWithSurname) = prefs.edit().putBoolean(START_NAME_WITH_SURNAME, startNameWithSurname).apply()
|
||||
|
@ -2,6 +2,7 @@ package com.simplemobiletools.contacts.helpers
|
||||
|
||||
// shared prefs
|
||||
val CALL_CONTACT_ON_CLICK = "call_contact_on_click"
|
||||
val SHOW_PHONE_NUMBERS = "show_phone_numbers"
|
||||
val DISPLAY_CONTACT_SOURCES = "display_contact_sources"
|
||||
val START_NAME_WITH_SURNAME = "start_name_with_surname"
|
||||
val LAST_USED_CONTACT_SOURCE = "last_used_contact_source"
|
||||
|
@ -71,11 +71,13 @@ class ContactsHelper(val activity: BaseSimpleActivity) {
|
||||
cursor?.close()
|
||||
}
|
||||
|
||||
val phoneNumbers = getPhoneNumbers()
|
||||
val size = phoneNumbers.size()
|
||||
for (i in 0 until size) {
|
||||
val key = phoneNumbers.keyAt(i)
|
||||
contacts[key]?.phoneNumbers = phoneNumbers.valueAt(i)
|
||||
if (activity.config.showPhoneNumbers) {
|
||||
val phoneNumbers = getPhoneNumbers()
|
||||
val size = phoneNumbers.size()
|
||||
for (i in 0 until size) {
|
||||
val key = phoneNumbers.keyAt(i)
|
||||
contacts[key]?.phoneNumbers = phoneNumbers.valueAt(i)
|
||||
}
|
||||
}
|
||||
|
||||
val contactsSize = contacts.size()
|
||||
|
Reference in New Issue
Block a user