create chip for avatar icon and name

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-12-09 09:11:08 +01:00
parent ca4ace687c
commit 9a481aefc8
No known key found for this signature in database
GPG Key ID: F7AA2A8B65B50220
4 changed files with 72 additions and 11 deletions

View File

@ -72,6 +72,7 @@ import androidx.work.WorkInfo
import androidx.work.WorkManager
import autodagger.AutoInjector
import coil.imageLoader
import coil.load
import coil.request.CachePolicy
import coil.request.ImageRequest
import coil.target.Target
@ -1125,10 +1126,24 @@ class ChatActivity :
}
if (uiState.userAbsence.replacementUserDisplayName != null) {
binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).text = String.format(
context.resources.getString(R.string.user_absence_replacement),
var imageUri = Uri.parse(ApiUtils.getUrlForAvatar(conversationUser?.baseUrl, uiState.userAbsence
.replacementUserId, false))
if (DisplayUtils.isDarkModeOn(context)) {
imageUri = Uri.parse(ApiUtils.getUrlForAvatarDarkTheme(conversationUser?.baseUrl, uiState
.userAbsence
.replacementUserId, false))
}
binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).text = context.resources.getString(R.string.user_absence_replacement)
binding.outOfOfficeContainer.findViewById<ImageView>(R.id.replacement_user_avatar)
.load(imageUri){
transformations(CircleCropTransformation())
placeholder(R.drawable.account_circle_96dp)
error(R.drawable.account_circle_96dp)
crossfade(true)
}
binding.outOfOfficeContainer.findViewById<TextView>(R.id.replacement_user_name).text =
uiState.userAbsence.replacementUserDisplayName
)
} else {
binding.outOfOfficeContainer.findViewById<TextView>(R.id.absenceReplacement).visibility = View.GONE
}

View File

@ -372,6 +372,12 @@ object ApiUtils {
return baseUrl + "/index.php/avatar/" + Uri.encode(name) + "/" + avatarSize
}
@JvmStatic
fun getUrlForAvatarDarkTheme(baseUrl: String?, name: String?, requestBigSize: Boolean): String {
val avatarSize = if (requestBigSize) AVATAR_SIZE_BIG else AVATAR_SIZE_SMALL
return baseUrl + "/index.php/avatar/" + Uri.encode(name) + "/" + avatarSize + "/dark"
}
@JvmStatic
fun getUrlForFederatedAvatar(
baseUrl: String,

View File

@ -7,8 +7,8 @@
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="150dp"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="150dp"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/out_of_office_view">
@ -44,13 +44,53 @@
android:textSize="14sp"
tools:text="Dec 5, 2024 - Dec 15, 2024"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop ="8dp"
android:gravity="center_vertical">
<TextView
android:id="@+id/absenceReplacement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:textSize="14sp"
tools:text="Replacement: Bob"/>
tools:text="Replacement: "/>
<androidx.cardview.widget.CardView
android:id="@+id/avatar_chip"
android:layout_width="wrap_content"
android:layout_height="28dp"
android:layout_marginStart="8dp"
app:cardCornerRadius="16dp"
android:layout_gravity="center_vertical"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding = "4dp"
android:gravity="center_vertical">
<ImageView
android:id="@+id/replacement_user_avatar"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="4dp"
android:scaleType="centerCrop"
android:contentDescription="@null" />
<TextView
android:id="@+id/replacement_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:gravity="center_vertical"
tools:text="Bob" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<TextView
android:id="@+id/userAbsenceLongMessage"

View File

@ -842,5 +842,5 @@ How to translate with transifex:
<string name="user_absence">%1$s is out of office and might not respond</string>
<string name="user_absence_for_one_day">%1$s is out of office today</string>
<string name="user_absence_replacement">Replacement: %1$s</string>
<string name="user_absence_replacement">Replacement</string>
</resources>