Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4da154e3 authored by moezbhatti's avatar moezbhatti Committed by Moez Bhatti
Browse files

Show two initials for avatar

parent a8efaa19
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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
+4 −2
Original line number Diff line number Diff line
@@ -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"