refactor message status. use more icons

This commit is contained in:
Daniel Gultsch 2024-04-14 13:38:46 +02:00
parent 35c8833dd5
commit d5ef06055f
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
8 changed files with 575 additions and 238 deletions

View file

@ -1,5 +1,6 @@
package eu.siacs.conversations.ui.adapter;
import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.util.Pair;
import android.view.LayoutInflater;
@ -8,6 +9,7 @@ import android.view.ViewGroup;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.core.widget.ImageViewCompat;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;
@ -68,15 +70,47 @@ public class ConversationAdapter
}
if (conversation == ConversationFragment.getConversation(activity)) {
viewHolder.binding.frame.setBackgroundResource(R.drawable.background_selected_item_conversation);
//viewHolder.binding.frame.setBackgroundColor(MaterialColors.getColor(viewHolder.binding.frame, com.google.android.material.R.attr.colorSurfaceDim));
viewHolder.binding.frame.setBackgroundResource(
R.drawable.background_selected_item_conversation);
// viewHolder.binding.frame.setBackgroundColor(MaterialColors.getColor(viewHolder.binding.frame, com.google.android.material.R.attr.colorSurfaceDim));
} else {
viewHolder.binding.frame.setBackgroundColor(MaterialColors.getColor(viewHolder.binding.frame, com.google.android.material.R.attr.colorSurface));
viewHolder.binding.frame.setBackgroundColor(
MaterialColors.getColor(
viewHolder.binding.frame,
com.google.android.material.R.attr.colorSurface));
}
final Message message = conversation.getLatestMessage();
final int status = message.getStatus();
final int unreadCount = conversation.unreadCount();
final boolean isRead = conversation.isRead();
final @DrawableRes Integer messageStatusDrawable =
MessageAdapter.getMessageStatusAsDrawable(message, status);
if (messageStatusDrawable == null) {
if (status <= Message.STATUS_RECEIVED) {
viewHolder.binding.messageStatus.setVisibility(View.GONE);
} else {
viewHolder.binding.messageStatus.setVisibility(View.INVISIBLE);
}
} else {
viewHolder.binding.messageStatus.setImageResource(messageStatusDrawable);
if (status == Message.STATUS_SEND_DISPLAYED) {
ImageViewCompat.setImageTintList(
viewHolder.binding.messageStatus,
ColorStateList.valueOf(
MaterialColors.getColor(
viewHolder.binding.messageStatus,
com.google.android.material.R.attr.colorPrimary)));
} else {
ImageViewCompat.setImageTintList(
viewHolder.binding.messageStatus,
ColorStateList.valueOf(
MaterialColors.getColor(
viewHolder.binding.messageStatus,
com.google.android.material.R.attr.colorControlNormal)));
}
viewHolder.binding.messageStatus.setVisibility(View.VISIBLE);
}
final Conversation.Draft draft = isRead ? conversation.getDraft() : null;
if (unreadCount > 0) {
viewHolder.binding.unreadCount.setVisibility(View.VISIBLE);
@ -143,7 +177,7 @@ public class ConversationAdapter
viewHolder.binding.senderName.setTypeface(null, Typeface.BOLD);
}
}
if (message.getStatus() == Message.STATUS_RECEIVED) {
if (status == Message.STATUS_RECEIVED) {
if (conversation.getMode() == Conversation.MODE_MULTI) {
viewHolder.binding.senderName.setVisibility(View.VISIBLE);
viewHolder.binding.senderName.setText(
@ -171,21 +205,25 @@ public class ConversationAdapter
if (ongoingCall.isPresent()) {
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
viewHolder.binding.notificationStatus.setImageResource(R.drawable.ic_phone_in_talk_24dp);
viewHolder.binding.notificationStatus.setImageResource(
R.drawable.ic_phone_in_talk_24dp);
} else {
final long muted_till =
conversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL, 0);
if (muted_till == Long.MAX_VALUE) {
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
viewHolder.binding.notificationStatus.setImageResource(R.drawable.ic_notifications_off_24dp);
viewHolder.binding.notificationStatus.setImageResource(
R.drawable.ic_notifications_off_24dp);
} else if (muted_till >= System.currentTimeMillis()) {
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
viewHolder.binding.notificationStatus.setImageResource(R.drawable.ic_notifications_paused_24dp);
viewHolder.binding.notificationStatus.setImageResource(
R.drawable.ic_notifications_paused_24dp);
} else if (conversation.alwaysNotify()) {
viewHolder.binding.notificationStatus.setVisibility(View.GONE);
} else {
viewHolder.binding.notificationStatus.setVisibility(View.VISIBLE);
viewHolder.binding.notificationStatus.setImageResource(R.drawable.ic_notifications_none_24dp);
viewHolder.binding.notificationStatus.setImageResource(
R.drawable.ic_notifications_none_24dp);
}
}

View file

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M6,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM18,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z" />
</vector>

View file

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?colorControlNormal"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="@android:color/white"
android:pathData="M160,800Q127,800 103.5,776.5Q80,753 80,720L80,160Q80,127 103.5,103.5Q127,80 160,80L360,80Q393,80 416.5,103.5Q440,127 440,160L440,360L360,360L360,280L160,280L160,600L440,600L440,720Q440,753 416.5,776.5Q393,800 360,800L160,800ZM600,880Q567,880 543.5,856.5Q520,833 520,800L520,600L600,600L600,680L800,680L800,360L520,360L520,240Q520,207 543.5,183.5Q567,160 600,160L800,160Q833,160 856.5,183.5Q880,207 880,240L880,800Q880,833 856.5,856.5Q833,880 800,880L600,880ZM320,520Q303,520 291.5,508.5Q280,497 280,480Q280,463 291.5,451.5Q303,440 320,440Q337,440 348.5,451.5Q360,463 360,480Q360,497 348.5,508.5Q337,520 320,520ZM480,520Q463,520 451.5,508.5Q440,497 440,480Q440,463 451.5,451.5Q463,440 480,440Q497,440 508.5,451.5Q520,463 520,480Q520,497 508.5,508.5Q497,520 480,520ZM640,520Q623,520 611.5,508.5Q600,497 600,480Q600,463 611.5,451.5Q623,440 640,440Q657,440 668.5,451.5Q680,463 680,480Q680,497 668.5,508.5Q657,520 640,520Z" />
</vector>

View file

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M5,20h14v-2H5V20zM5,10h4v6h6v-6h4l-7,-7L5,10z" />
</vector>

View file

@ -74,7 +74,7 @@
android:layout_height="wrap_content"
android:layout_alignWithParentIfMissing="true"
android:layout_centerVertical="true"
android:layout_toStartOf="@+id/notification_status"
android:layout_toStartOf="@+id/message_status"
android:layout_toEndOf="@id/sender_name"
android:orientation="horizontal">
@ -98,6 +98,18 @@
tools:text="Hi. Whats up?" />
</LinearLayout>
<ImageView
android:id="@+id/message_status"
android:layout_width="18sp"
android:layout_height="18sp"
android:layout_alignWithParentIfMissing="true"
android:layout_centerVertical="true"
android:layout_marginStart="4dp"
android:layout_toStartOf="@+id/notification_status"
android:src="@drawable/ic_done_all_24dp"
app:tint="?colorPrimary"
android:visibility="visible" />
<ImageView
android:id="@+id/notification_status"
android:layout_width="18sp"

View file

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
android:layout_width="fill_parent"
@ -46,8 +47,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:orientation="horizontal"
android:paddingBottom="2dp">
android:layout_marginVertical="1sp"
android:orientation="horizontal">
<TextView
android:id="@+id/message_encryption"
@ -57,7 +58,8 @@
android:layout_marginEnd="4sp"
android:gravity="center_vertical"
android:textAppearance="?textAppearanceBodySmall"
android:textColor="?colorOnTertiaryContainer" />
android:textColor="?colorOnTertiaryContainer"
tools:text="@string/not_trusted" />
<ImageView
android:id="@+id/security_indicator"
@ -87,9 +89,9 @@
android:accessibilityTraversalAfter="@id/message_photo"
android:accessibilityTraversalBefore="@id/message_content"
android:gravity="center_vertical"
android:text="@string/sending"
android:textAppearance="?textAppearanceBodySmall"
android:textColor="?colorOnTertiaryContainer" />
android:textColor="?colorOnTertiaryContainer"
tools:text="10:42" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -56,15 +56,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:orientation="horizontal"
android:paddingBottom="2dp">
android:layout_marginVertical="1sp"
android:orientation="horizontal">
<TextView
android:id="@+id/message_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="4sp"
android:layout_marginEnd="2sp"
android:accessibilityTraversalAfter="@id/message_photo"
android:accessibilityTraversalBefore="@id/message_content"
android:gravity="center_vertical"
@ -77,6 +77,7 @@
android:layout_width="12sp"
android:layout_height="12sp"
android:layout_gravity="center_vertical"
android:layout_marginStart="4sp"
android:gravity="center_vertical"
android:src="@drawable/ic_lock_24dp"
app:tint="?colorOnSecondaryContainer" />
@ -86,6 +87,7 @@
android:layout_width="12sp"
android:layout_height="12sp"
android:layout_gravity="center_vertical"
android:layout_marginStart="4sp"
android:gravity="center_vertical"
android:src="@drawable/ic_edit_24dp"
app:tint="?colorOnSecondaryContainer" />
@ -95,6 +97,7 @@
android:layout_width="16sp"
android:layout_height="16sp"
android:layout_gravity="center_vertical"
android:layout_marginStart="4sp"
android:gravity="center_vertical"
android:src="@drawable/ic_done_24dp"
app:tint="?colorOnSecondaryContainer" />