mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 21:58:53 +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 kotlinx.android.synthetic.main.avatar_view.view.*
|
||||||
import javax.inject.Inject
|
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 colors: Colors
|
||||||
@Inject lateinit var navigator: Navigator
|
@Inject lateinit var navigator: Navigator
|
||||||
@@ -116,7 +118,11 @@ class AvatarView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
|||||||
|
|
||||||
private fun updateView() {
|
private fun updateView() {
|
||||||
if (name?.isNotEmpty() == true) {
|
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
|
icon.visibility = GONE
|
||||||
} else {
|
} else {
|
||||||
initial.text = null
|
initial.text = null
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
~ along with QKSMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
<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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/avatar"
|
android:id="@+id/avatar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -30,9 +31,10 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
android:padding="6dp"
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
android:textSize="20sp"
|
app:autoSizeMaxTextSize="22sp"
|
||||||
tools:text="M" />
|
app:autoSizeTextType="uniform" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
|
|||||||
Reference in New Issue
Block a user