Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Tapping contact photo in lists now launches the contact details page ([#452])

### Fixed
- Fixed incorrect spacing between prefix and last name ([#157])
Expand Down Expand Up @@ -118,6 +120,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#339]: https://github.com/FossifyOrg/Contacts/issues/339
[#360]: https://github.com/FossifyOrg/Contacts/issues/360
[#415]: https://github.com/FossifyOrg/Contacts/issues/415
[#452]: https://github.com/FossifyOrg/Contacts/issues/452

[Unreleased]: https://github.com/FossifyOrg/Contacts/compare/1.5.0...HEAD
[1.5.0]: https://github.com/FossifyOrg/Contacts/compare/1.4.0...1.5.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.fossify.contacts.adapters.ContactsAdapter
import org.fossify.contacts.databinding.ActivityGroupContactsBinding
import org.fossify.contacts.dialogs.SelectContactsDialog
import org.fossify.contacts.extensions.handleGenericContactClick
import org.fossify.contacts.extensions.viewContact
import org.fossify.contacts.helpers.GROUP
import org.fossify.contacts.helpers.LOCATION_GROUP_CONTACTS
import org.fossify.contacts.interfaces.RefreshContactsListener
Expand Down Expand Up @@ -153,10 +154,14 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
recyclerView = binding.groupContactsList,
location = LOCATION_GROUP_CONTACTS,
removeListener = this,
refreshListener = this
) {
contactClicked(it as Contact)
}.apply {
refreshListener = this,
itemClick = {
contactClicked(it as Contact)
},
profileIconClick = {
viewContact(it as Contact)
}
).apply {
binding.groupContactsList.adapter = this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import org.fossify.contacts.helpers.*
import org.fossify.contacts.interfaces.RefreshContactsListener
import org.fossify.contacts.interfaces.RemoveFromGroupListener
import java.util.Collections
import androidx.core.graphics.drawable.toDrawable

class ContactsAdapter(
activity: SimpleActivity,
Expand All @@ -58,7 +59,8 @@ class ContactsAdapter(
private val location: Int,
private val removeListener: RemoveFromGroupListener?,
private val enableDrag: Boolean = false,
itemClick: (Any) -> Unit
itemClick: (Any) -> Unit,
private val profileIconClick: ((Any) -> Unit)? = null
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate, ItemTouchHelperContract {

private val NEW_GROUP_ID = -1
Expand Down Expand Up @@ -350,11 +352,7 @@ class ContactsAdapter(
.error(placeholderImage)

val size = activity.resources.getDimension(org.fossify.commons.R.dimen.shortcut_size).toInt()
val itemToLoad: Any? = if (contact.photoUri.isNotEmpty()) {
contact.photoUri
} else {
contact.photo
}
val itemToLoad: Any? = contact.photoUri.ifEmpty { contact.photo }

val builder = Glide.with(activity)
.asDrawable()
Expand Down Expand Up @@ -424,10 +422,27 @@ class ContactsAdapter(
}
}

findViewById<TextView>(org.fossify.commons.R.id.item_contact_image).beVisibleIf(showContactThumbnails)
findViewById<ImageView>(org.fossify.commons.R.id.item_contact_image).apply {
beVisibleIf(showContactThumbnails)
if (profileIconClick != null && viewType != VIEW_TYPE_GRID) {
setBackgroundResource(R.drawable.selector_clickable_circle)
setOnClickListener {
if (!actModeCallback.isSelectable) {
profileIconClick.invoke(contact)
} else {
holder.viewClicked(contact)
}
}
setOnLongClickListener {
holder.viewLongClicked()
true
}
}
}

if (showContactThumbnails) {
val placeholderImage = BitmapDrawable(resources, SimpleContactsHelper(context).getContactLetterIcon(fullName))
val placeholderImage =
SimpleContactsHelper(context).getContactLetterIcon(fullName).toDrawable(resources)
if (contact.photoUri.isEmpty() && contact.photo == null) {
findViewById<ImageView>(org.fossify.commons.R.id.item_contact_image).setImageDrawable(placeholderImage)
} else {
Expand All @@ -437,11 +452,7 @@ class ContactsAdapter(
.error(placeholderImage)
.centerCrop()

val itemToLoad: Any? = if (contact.photoUri.isNotEmpty()) {
contact.photoUri
} else {
contact.photo
}
val itemToLoad: Any? = contact.photoUri.ifEmpty { contact.photo }

Glide.with(activity)
.load(itemToLoad)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.fossify.contacts.adapters.ContactsAdapter
import org.fossify.contacts.databinding.FragmentContactsBinding
import org.fossify.contacts.databinding.FragmentLettersLayoutBinding
import org.fossify.contacts.extensions.config
import org.fossify.contacts.extensions.viewContact
import org.fossify.contacts.helpers.LOCATION_CONTACTS_TAB
import org.fossify.contacts.interfaces.RefreshContactsListener

Expand Down Expand Up @@ -58,9 +59,13 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
removeListener = null,
recyclerView = innerBinding.fragmentList,
enableDrag = false,
) {
(activity as RefreshContactsListener).contactClicked(it as Contact)
}.apply {
itemClick = {
(activity as RefreshContactsListener).contactClicked(it as Contact)
},
profileIconClick = {
activity?.viewContact(it as Contact)
}
).apply {
innerBinding.fragmentList.adapter = this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.fossify.contacts.databinding.FragmentFavoritesBinding
import org.fossify.contacts.databinding.FragmentLettersLayoutBinding
import org.fossify.contacts.dialogs.SelectContactsDialog
import org.fossify.contacts.extensions.config
import org.fossify.contacts.extensions.viewContact
import org.fossify.contacts.helpers.LOCATION_FAVORITES_TAB
import org.fossify.contacts.interfaces.RefreshContactsListener

Expand Down Expand Up @@ -79,9 +80,13 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
removeListener = null,
recyclerView = innerBinding.fragmentList,
enableDrag = true,
) {
(activity as RefreshContactsListener).contactClicked(it as Contact)
}.apply {
itemClick = {
(activity as RefreshContactsListener).contactClicked(it as Contact)
},
profileIconClick = {
activity?.viewContact(it as Contact)
}
).apply {
innerBinding.fragmentList.adapter = this
setupZoomListener(zoomListener)
onDragEndListener = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/activated_item_foreground">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="@android:color/white" />
</shape>
</item>
</ripple>
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/selector_clickable_circle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<selector>
<item android:state_selected="true">
<shape android:shape="oval">
<solid android:color="@color/activated_item_foreground" />
</shape>
</item>
<item android:drawable="@drawable/ripple_selector_background_circle" />
</selector>
</item>
</layer-list>
Loading