mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
Show two initials for avatar
This commit is contained in:
@@ -35,7 +35,9 @@ import com.moez.QKSMS.util.GlideApp
|
||||
import kotlinx.android.synthetic.main.avatar_view.view.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
|
||||
class AvatarView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : FrameLayout(context, attrs) {
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
@Inject lateinit var navigator: Navigator
|
||||
@@ -116,7 +118,11 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
|
||||
private fun updateView() {
|
||||
if (name?.isNotEmpty() == true) {
|
||||
initial.text = name?.substring(0, 1)
|
||||
val initials = name?.split(" ").orEmpty()
|
||||
.filter { name -> name.isNotEmpty() }
|
||||
.map { name -> name[0].toString() }
|
||||
|
||||
initial.text = if (initials.size > 1) initials.first() + initials.last() else initials.first()
|
||||
icon.visibility = GONE
|
||||
} else {
|
||||
initial.text = null
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="match_parent"
|
||||
@@ -30,9 +31,10 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:padding="6dp"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="20sp"
|
||||
tools:text="M" />
|
||||
app:autoSizeMaxTextSize="22sp"
|
||||
app:autoSizeTextType="uniform" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
|
||||
Reference in New Issue
Block a user