use a different placeholder image at group conversations, not a letter
This commit is contained in:
parent
a4adf59323
commit
32d3e0b21a
|
@ -36,7 +36,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:5.25.6'
|
implementation 'com.simplemobiletools:commons:5.25.7'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
|
||||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||||
implementation 'com.klinkerapps:android-smsmms:5.2.6'
|
implementation 'com.klinkerapps:android-smsmms:5.2.6'
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.simplemobiletools.smsmessenger.adapters
|
package com.simplemobiletools.smsmessenger.adapters
|
||||||
|
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -8,6 +9,7 @@ import android.widget.TextView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
|
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||||
import com.simplemobiletools.commons.extensions.formatDateOrTime
|
import com.simplemobiletools.commons.extensions.formatDateOrTime
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.views.FastScroller
|
import com.simplemobiletools.commons.views.FastScroller
|
||||||
|
@ -16,6 +18,7 @@ import com.simplemobiletools.smsmessenger.R
|
||||||
import com.simplemobiletools.smsmessenger.activities.SimpleActivity
|
import com.simplemobiletools.smsmessenger.activities.SimpleActivity
|
||||||
import com.simplemobiletools.smsmessenger.extensions.deleteConversation
|
import com.simplemobiletools.smsmessenger.extensions.deleteConversation
|
||||||
import com.simplemobiletools.smsmessenger.extensions.loadImage
|
import com.simplemobiletools.smsmessenger.extensions.loadImage
|
||||||
|
import com.simplemobiletools.smsmessenger.helpers.letterBackgroundColors
|
||||||
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
|
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
|
||||||
import com.simplemobiletools.smsmessenger.models.Conversation
|
import com.simplemobiletools.smsmessenger.models.Conversation
|
||||||
import kotlinx.android.synthetic.main.item_conversation.view.*
|
import kotlinx.android.synthetic.main.item_conversation.view.*
|
||||||
|
@ -135,7 +138,17 @@ class ConversationsAdapter(
|
||||||
it.setTextColor(textColor)
|
it.setTextColor(textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
context.loadImage(conversation.photoUri, conversation_image, conversation.title)
|
// at group conversations we use an icon as the placeholder, not any letter
|
||||||
|
val placeholder = if (conversation.isGroupConversation) {
|
||||||
|
val icon = activity.resources.getDrawable(R.drawable.group_conversation_icon)
|
||||||
|
val bgColor = letterBackgroundColors[Math.abs(conversation.title.hashCode()) % letterBackgroundColors.size].toInt()
|
||||||
|
(icon as LayerDrawable).findDrawableByLayerId(R.id.attendee_circular_background).applyColorFilter(bgColor)
|
||||||
|
icon
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
|
context.loadImage(conversation.photoUri, conversation_image, conversation.title, placeholder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.graphics.Bitmap
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
import android.media.AudioAttributes
|
import android.media.AudioAttributes
|
||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.media.RingtoneManager
|
import android.media.RingtoneManager
|
||||||
|
@ -159,7 +160,8 @@ fun Context.getConversations(): ArrayList<Conversation> {
|
||||||
val names = getThreadContactNames(phoneNumbers)
|
val names = getThreadContactNames(phoneNumbers)
|
||||||
val title = TextUtils.join(", ", names.toTypedArray())
|
val title = TextUtils.join(", ", names.toTypedArray())
|
||||||
val photoUri = if (phoneNumbers.size == 1) getPhotoUriFromPhoneNumber(phoneNumbers.first()) else ""
|
val photoUri = if (phoneNumbers.size == 1) getPhotoUriFromPhoneNumber(phoneNumbers.first()) else ""
|
||||||
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri)
|
val isGroupConversation = phoneNumbers.size > 1
|
||||||
|
val conversation = Conversation(id, snippet, date.toInt(), read, title, photoUri, isGroupConversation)
|
||||||
conversations.add(conversation)
|
conversations.add(conversation)
|
||||||
}
|
}
|
||||||
return conversations
|
return conversations
|
||||||
|
@ -595,8 +597,12 @@ fun Context.getNotificationLetterIcon(name: String): Bitmap {
|
||||||
return bitmap
|
return bitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.loadImage(path: String, imageView: ImageView, placeholderName: String) {
|
fun Context.loadImage(path: String, imageView: ImageView, placeholderName: String, placeholderImage: Drawable? = null) {
|
||||||
val placeholder = BitmapDrawable(resources, getNotificationLetterIcon(placeholderName))
|
val placeholder = if (placeholderImage == null) {
|
||||||
|
BitmapDrawable(resources, getNotificationLetterIcon(placeholderName))
|
||||||
|
} else {
|
||||||
|
placeholderImage
|
||||||
|
}
|
||||||
|
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
package com.simplemobiletools.smsmessenger.models
|
package com.simplemobiletools.smsmessenger.models
|
||||||
|
|
||||||
data class Conversation(val id: Int, val snippet: String, val date: Int, val read: Boolean, val title: String, val photoUri: String)
|
data class Conversation(
|
||||||
|
val id: Int, val snippet: String, val date: Int, val read: Boolean, val title: String, val photoUri: String,
|
||||||
|
val isGroupConversation: Boolean
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/attendee_circular_background">
|
||||||
|
<shape android:shape="oval">
|
||||||
|
<solid android:color="@color/color_primary" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:bottom="@dimen/medium_margin"
|
||||||
|
android:drawable="@drawable/ic_people_vector"
|
||||||
|
android:left="@dimen/medium_margin"
|
||||||
|
android:right="@dimen/medium_margin"
|
||||||
|
android:top="@dimen/medium_margin" />
|
||||||
|
|
||||||
|
</layer-list>
|
Loading…
Reference in New Issue