adding a helper function for getting a colored group icon
This commit is contained in:
parent
a9a6315146
commit
a78c3b8977
3 changed files with 26 additions and 1 deletions
|
@ -7,7 +7,7 @@ buildscript {
|
|||
propMinSdkVersion = 21
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '5.25.18'
|
||||
propVersionName = '5.25.19'
|
||||
kotlin_version = '1.3.72'
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ import android.content.pm.PackageManager
|
|||
import android.content.res.Configuration
|
||||
import android.database.Cursor
|
||||
import android.graphics.*
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.media.ExifInterface
|
||||
import android.media.MediaMetadataRetriever
|
||||
import android.media.RingtoneManager
|
||||
|
@ -854,3 +856,10 @@ fun Context.getContactLetterIcon(name: String): Bitmap {
|
|||
view.draw(canvas)
|
||||
return bitmap
|
||||
}
|
||||
|
||||
fun Context.getColoredGroupIcon(title: String): Drawable {
|
||||
val icon = resources.getDrawable(R.drawable.ic_group_circle_bg)
|
||||
val bgColor = letterBackgroundColors[Math.abs(title.hashCode()) % letterBackgroundColors.size].toInt()
|
||||
(icon as LayerDrawable).findDrawableByLayerId(R.id.attendee_circular_background).applyColorFilter(bgColor)
|
||||
return icon
|
||||
}
|
||||
|
|
16
commons/src/main/res/drawable/ic_group_circle_bg.xml
Normal file
16
commons/src/main/res/drawable/ic_group_circle_bg.xml
Normal file
|
@ -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 a new issue