mirror of
https://github.com/SimpleMobileTools/Simple-Contacts.git
synced 2025-02-17 03:51:03 +01:00
show a favorite icon at the Details screen
This commit is contained in:
parent
3cd116ada8
commit
e19e367852
@ -41,7 +41,7 @@ ext {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.5.4'
|
||||
implementation 'com.simplemobiletools:commons:3.5.5'
|
||||
implementation 'joda-time:joda-time:2.9.9'
|
||||
|
||||
//debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
||||
|
@ -40,6 +40,7 @@ import com.simplemobiletools.contacts.models.Email
|
||||
import com.simplemobiletools.contacts.models.Event
|
||||
import com.simplemobiletools.contacts.models.PhoneNumber
|
||||
import kotlinx.android.synthetic.main.activity_contact.*
|
||||
import kotlinx.android.synthetic.main.activity_contact.view.*
|
||||
import kotlinx.android.synthetic.main.item_email.view.*
|
||||
import kotlinx.android.synthetic.main.item_event.view.*
|
||||
import kotlinx.android.synthetic.main.item_phone_number.view.*
|
||||
@ -165,6 +166,7 @@ class ContactActivity : SimpleActivity() {
|
||||
contact_event_add_new.applyColorFilter(adjustedPrimaryColor)
|
||||
contact_event_add_new.background.applyColorFilter(textColor)
|
||||
|
||||
contact_toggle_favorite.setOnClickListener { toggleFavorite() }
|
||||
contact_photo.setOnClickListener { trySetPhoto() }
|
||||
contact_send_sms.setOnClickListener { trySendSMS() }
|
||||
contact_start_call.setOnClickListener { tryStartCall(contact!!) }
|
||||
@ -231,6 +233,12 @@ class ContactActivity : SimpleActivity() {
|
||||
contact_surname.setText(contact!!.surname)
|
||||
contact_source.text = contact!!.source
|
||||
|
||||
contact_toggle_favorite.apply {
|
||||
setImageDrawable(getStarDrawable(contact!!.starred == 1))
|
||||
tag = contact!!.starred
|
||||
applyColorFilter(config.textColor)
|
||||
}
|
||||
|
||||
setupPhoneNumbers()
|
||||
setupEmails()
|
||||
setupEvents()
|
||||
@ -301,6 +309,11 @@ class ContactActivity : SimpleActivity() {
|
||||
contact = Contact(0, "", "", "", "", ArrayList(), ArrayList(), ArrayList(), "", 0)
|
||||
contact_source.text = config.lastUsedContactSource
|
||||
contact_source.setOnClickListener { showAccountSourcePicker() }
|
||||
|
||||
contact_toggle_favorite.apply {
|
||||
tag = 0
|
||||
applyColorFilter(config.textColor)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showPhotoPlaceholder() {
|
||||
@ -504,6 +517,7 @@ class ContactActivity : SimpleActivity() {
|
||||
emails = getFilledEmails()
|
||||
events = getFilledEvents()
|
||||
source = contact_source.value
|
||||
starred = if (isContactStarred()) 1 else 0
|
||||
|
||||
Thread {
|
||||
config.lastUsedContactSource = source
|
||||
@ -653,6 +667,22 @@ class ContactActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleFavorite() {
|
||||
val isStarred = isContactStarred()
|
||||
contact_toggle_favorite.apply {
|
||||
setImageDrawable(getStarDrawable(!isStarred))
|
||||
tag = if (isStarred) 0 else 1
|
||||
applyColorFilter(config.textColor)
|
||||
}
|
||||
}
|
||||
|
||||
private fun isContactStarred() = contact_toggle_favorite.tag == 1
|
||||
|
||||
private fun getStarDrawable(on: Boolean): Drawable {
|
||||
val newDrawable = resources.getDrawable(if (on) R.drawable.ic_star_on else R.drawable.ic_star_off)
|
||||
return newDrawable
|
||||
}
|
||||
|
||||
private fun trySetPhoto() {
|
||||
val items = arrayListOf(
|
||||
RadioItem(TAKE_PHOTO, getString(R.string.take_photo)),
|
||||
|
@ -17,6 +17,19 @@
|
||||
android:layout_width="@dimen/contact_photo_size"
|
||||
android:layout_height="@dimen/contact_photo_size"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contact_toggle_favorite"
|
||||
style="@style/MyBorderlessBackgroundStyle"
|
||||
android:layout_width="@dimen/contact_actions_size"
|
||||
android:layout_height="@dimen/contact_actions_size"
|
||||
android:layout_alignBottom="@id/contact_photo"
|
||||
android:layout_alignTop="@+id/contact_photo"
|
||||
android:layout_marginLeft="@dimen/medium_margin"
|
||||
android:layout_toRightOf="@+id/contact_photo"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="@dimen/tiny_margin"
|
||||
android:src="@drawable/ic_star_off"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/contact_actions_holder"
|
||||
android:layout_width="match_parent"
|
||||
@ -41,7 +54,7 @@
|
||||
style="@style/MyBorderlessBackgroundStyle"
|
||||
android:layout_width="@dimen/contact_actions_size"
|
||||
android:layout_height="@dimen/contact_actions_size"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:layout_marginLeft="@dimen/normal_margin"
|
||||
android:adjustViewBounds="true"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
@ -53,7 +66,7 @@
|
||||
style="@style/MyBorderlessBackgroundStyle"
|
||||
android:layout_width="@dimen/contact_actions_size"
|
||||
android:layout_height="@dimen/contact_actions_size"
|
||||
android:layout_marginLeft="@dimen/activity_margin"
|
||||
android:layout_marginLeft="@dimen/normal_margin"
|
||||
android:adjustViewBounds="true"
|
||||
android:paddingLeft="@dimen/activity_margin"
|
||||
android:paddingRight="@dimen/activity_margin"
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="contact_photo_size">80dp</dimen>
|
||||
<dimen name="contact_actions_size">50dp</dimen>
|
||||
<dimen name="contact_actions_size">45dp</dimen>
|
||||
<dimen name="contact_icons_size">40dp</dimen>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user