Add an option to show/hide contact thumbnails
This commit is contained in:
parent
4ffcfcd2f4
commit
0a86ce2856
|
@ -42,6 +42,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||
private var storedTextColor = 0
|
||||
private var storedBackgroundColor = 0
|
||||
private var storedPrimaryColor = 0
|
||||
private var storedShowContactThumbnails = false
|
||||
private var storedShowPhoneNumbers = false
|
||||
private var storedStartNameWithSurname = false
|
||||
|
||||
|
@ -76,6 +77,11 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||
return
|
||||
}
|
||||
|
||||
if (storedShowContactThumbnails != config.showContactThumbnails) {
|
||||
restartActivity()
|
||||
return
|
||||
}
|
||||
|
||||
if (storedShowPhoneNumbers != config.showPhoneNumbers) {
|
||||
restartActivity()
|
||||
return
|
||||
|
@ -154,6 +160,7 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||
storedTextColor = textColor
|
||||
storedBackgroundColor = backgroundColor
|
||||
storedPrimaryColor = primaryColor
|
||||
storedShowContactThumbnails = showContactThumbnails
|
||||
storedShowPhoneNumbers = showPhoneNumbers
|
||||
storedStartNameWithSurname = startNameWithSurname
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ class SettingsActivity : SimpleActivity() {
|
|||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupShowInfoBubble()
|
||||
setupShowContactThumbnails()
|
||||
setupShowPhoneNumbers()
|
||||
setupCallContactOnClick()
|
||||
setupStartNameWithSurname()
|
||||
|
@ -51,6 +52,14 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupShowContactThumbnails() {
|
||||
settings_show_contact_thumbnails.isChecked = config.showContactThumbnails
|
||||
settings_show_contact_thumbnails_holder.setOnClickListener {
|
||||
settings_show_contact_thumbnails.toggle()
|
||||
config.showContactThumbnails = settings_show_contact_thumbnails.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupShowPhoneNumbers() {
|
||||
settings_show_phone_numbers.isChecked = config.showPhoneNumbers
|
||||
settings_show_phone_numbers_holder.setOnClickListener {
|
||||
|
|
|
@ -33,10 +33,12 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
|||
lateinit private var contactDrawable: Drawable
|
||||
var config = activity.config
|
||||
var startNameWithSurname: Boolean
|
||||
var showContactThumbnails: Boolean
|
||||
var showPhoneNumbers: Boolean
|
||||
|
||||
init {
|
||||
initDrawables()
|
||||
showContactThumbnails = config.showContactThumbnails
|
||||
showPhoneNumbers = config.showPhoneNumbers
|
||||
startNameWithSurname = config.startNameWithSurname
|
||||
}
|
||||
|
@ -190,16 +192,20 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: MutableList<Co
|
|||
contact_number?.text = contact.phoneNumbers.firstOrNull()?.value ?: ""
|
||||
contact_number?.setTextColor(textColor)
|
||||
|
||||
if (contact.photoUri.isNotEmpty()) {
|
||||
val options = RequestOptions()
|
||||
.signature(ObjectKey(contact.photoUri))
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.error(contactDrawable)
|
||||
.centerCrop()
|
||||
if (showContactThumbnails) {
|
||||
if (contact.photoUri.isNotEmpty()) {
|
||||
val options = RequestOptions()
|
||||
.signature(ObjectKey(contact.photoUri))
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.error(contactDrawable)
|
||||
.centerCrop()
|
||||
|
||||
Glide.with(activity).load(contact.photoUri).transition(DrawableTransitionOptions.withCrossFade()).apply(options).into(contact_tmb)
|
||||
Glide.with(activity).load(contact.photoUri).transition(DrawableTransitionOptions.withCrossFade()).apply(options).into(contact_tmb)
|
||||
} else {
|
||||
contact_tmb.setImageDrawable(contactDrawable)
|
||||
}
|
||||
} else {
|
||||
contact_tmb.setImageDrawable(contactDrawable)
|
||||
contact_tmb.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
|
||||
fun showAllContacts() = displayContactSources.size == 1 && displayContactSources.first() == "-1"
|
||||
|
||||
var showContactThumbnails : Boolean
|
||||
get() = prefs.getBoolean(SHOW_CONTACT_THUMBNAILS, true)
|
||||
set(showContactThumbnails) = prefs.edit().putBoolean(SHOW_CONTACT_THUMBNAILS, showContactThumbnails).apply()
|
||||
|
||||
var showPhoneNumbers: Boolean
|
||||
get() = prefs.getBoolean(SHOW_PHONE_NUMBERS, false)
|
||||
set(showPhoneNumbers) = prefs.edit().putBoolean(SHOW_PHONE_NUMBERS, showPhoneNumbers).apply()
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.provider.ContactsContract.CommonDataKinds
|
|||
|
||||
// shared prefs
|
||||
val CALL_CONTACT_ON_CLICK = "call_contact_on_click"
|
||||
val SHOW_CONTACT_THUMBNAILS = "show_contact_thumbnails"
|
||||
val SHOW_PHONE_NUMBERS = "show_phone_numbers"
|
||||
val DISPLAY_CONTACT_SOURCES = "display_contact_sources"
|
||||
val START_NAME_WITH_SURNAME = "start_name_with_surname"
|
||||
|
|
|
@ -70,6 +70,26 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_show_contact_thumbnails_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||
android:id="@+id/settings_show_contact_thumbnails"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingStart="@dimen/medium_margin"
|
||||
android:text="@string/show_contact_avatars"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_show_phone_numbers_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in New Issue