mirror of
https://github.com/ChronosX88/Influence.git
synced 2024-11-23 10:02:18 +00:00
Now avatars are round
This commit is contained in:
parent
64975460d3
commit
04fe69a3e8
@ -17,6 +17,8 @@
|
||||
package io.github.chronosx88.influence.presenters
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import com.amulyakhare.textdrawable.TextDrawable
|
||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
||||
import com.google.gson.Gson
|
||||
import com.stfalcon.chatkit.commons.ImageLoader
|
||||
import com.stfalcon.chatkit.messages.MessagesListAdapter
|
||||
@ -48,7 +50,13 @@ class ChatPresenter(private val view: CoreContracts.IChatViewContract, private v
|
||||
this.chatEntity = LocalDBWrapper.getChatByChatID(chatID)
|
||||
gson = Gson()
|
||||
chatAdapter = MessagesListAdapter(AppHelper.getJid(), ImageLoader { imageView, url, _ ->
|
||||
imageView.setImageResource(R.mipmap.ic_launcher)
|
||||
val firstLetter = Character.toString(Character.toUpperCase(url!!.get(0)))
|
||||
imageView.setImageDrawable(TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.width(64)
|
||||
.height(64)
|
||||
.endConfig()
|
||||
.buildRound(firstLetter, ColorGenerator.MATERIAL.getColor(firstLetter)))
|
||||
CompletableFuture.supplyAsync { while (AppHelper.getXmppConnection() == null) ;
|
||||
while (!AppHelper.getXmppConnection().isConnectionAlive) ;
|
||||
var jid: EntityBareJid? = null
|
||||
|
@ -54,12 +54,12 @@ public class DialogListPresenter implements CoreContracts.IDialogListPresenterCo
|
||||
private ConcurrentHashMap<String, byte[]> avatarsMap = new ConcurrentHashMap<>();
|
||||
private CoreContracts.IChatListViewContract view;
|
||||
private CoreContracts.IDialogListLogicContract logic;
|
||||
private DialogsListAdapter<GenericDialog> dialogListAdapter = new DialogsListAdapter<>((imageView, url, payload) -> {
|
||||
private DialogsListAdapter<GenericDialog> dialogListAdapter = new DialogsListAdapter<>(R.layout.item_dialog_custom, (imageView, url, payload) -> {
|
||||
String firstLetter = Character.toString(Character.toUpperCase(url.charAt(0)));
|
||||
imageView.setImageDrawable(TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.width(32)
|
||||
.height(32)
|
||||
.width(64)
|
||||
.height(64)
|
||||
.endConfig()
|
||||
.buildRound(firstLetter, ColorGenerator.MATERIAL.getColor(firstLetter)));
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
|
@ -100,8 +100,8 @@ class ChatActivity : AppCompatActivity(), CoreContracts.IChatViewContract {
|
||||
val firstLetter = Character.toString(chatName[0].toUpperCase())
|
||||
chatAvatar!!.setImageDrawable(TextDrawable.builder()
|
||||
.beginConfig()
|
||||
.width(32)
|
||||
.height(32)
|
||||
.width(64)
|
||||
.height(64)
|
||||
.endConfig()
|
||||
.buildRound(firstLetter, ColorGenerator.MATERIAL.getColor(firstLetter)))
|
||||
}
|
||||
|
130
app/src/main/res/layout/item_dialog_custom.xml
Normal file
130
app/src/main/res/layout/item_dialog_custom.xml
Normal file
@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2019 ChronosX88
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@id/dialogRootLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@id/dialogContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@id/dialogAvatar"
|
||||
android:layout_width="@dimen/dialog_avatar_width"
|
||||
android:layout_height="@dimen/dialog_avatar_height"
|
||||
android:layout_margin="16dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@id/dialogName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="19dp"
|
||||
android:layout_toEndOf="@id/dialogAvatar"
|
||||
android:layout_toLeftOf="@id/dialogDate"
|
||||
android:layout_toRightOf="@id/dialogAvatar"
|
||||
android:layout_toStartOf="@id/dialogDate"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@string/font_fontFamily_medium"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"/>
|
||||
|
||||
<TextView
|
||||
android:id="@id/dialogDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/dialogName"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:layout_toEndOf="@id/dialogAvatar"
|
||||
android:layout_toLeftOf="@+id/dialogUnreadBubble"
|
||||
android:layout_toRightOf="@id/dialogAvatar"
|
||||
android:layout_toStartOf="@+id/dialogUnreadBubble">
|
||||
|
||||
<com.stfalcon.chatkit.utils.ShapeImageView
|
||||
android:id="@id/dialogLastMessageUserAvatar"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="7dp"
|
||||
android:layout_marginRight="7dp"/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@id/dialogLastMessage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/dialogLastMessageUserAvatar"
|
||||
android:layout_toRightOf="@id/dialogLastMessageUserAvatar"
|
||||
android:ellipsize="end"
|
||||
android:gravity="top"
|
||||
android:maxLines="1"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@id/dialogUnreadBubble"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@id/dialogDate"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginRight="24dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/bubble_circle"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@string/font_fontFamily_medium"
|
||||
android:gravity="center"
|
||||
android:lines="1"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@id/dialogDividerContainer"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginTop="16dp">
|
||||
|
||||
<View
|
||||
android:id="@id/dialogDivider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/dialog_divider"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user