account indicator near conversations

This commit is contained in:
kosyak 2024-08-05 23:18:55 +02:00
parent 9892ff8d77
commit d7d922c1d1
7 changed files with 61 additions and 0 deletions

View file

@ -1,5 +1,6 @@
package eu.siacs.conversations.ui.adapter;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -17,6 +18,7 @@ import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.ui.XmppActivity;
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import eu.siacs.conversations.ui.util.StyledAttributes;
import eu.siacs.conversations.utils.UIHelper;
public class AccountAdapter extends ArrayAdapter<Account> {
@ -80,6 +82,13 @@ public class AccountAdapter extends ArrayAdapter<Account> {
((OnTglAccountState) activity).onClickTglAccountState(account, b);
}
});
if (activity.xmppConnectionService.getAccounts().size() > 1) {
viewHolder.binding.accountIndicator.setBackgroundColor(UIHelper.getColorForName(account.getJid().asBareJid().getEscapedLocal()));
} else {
viewHolder.binding.accountIndicator.setBackgroundColor(Color.TRANSPARENT);
}
return view;
}

View file

@ -2,6 +2,7 @@ package eu.siacs.conversations.ui.adapter;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.preference.PreferenceManager;
@ -397,6 +398,14 @@ public class ConversationAdapter
viewHolder.binding.presenceIndicator.setStatus(null);
}
Account account = conversation.getAccount();
if (account != null && activity.xmppConnectionService.getAccounts().size() > 1) {
viewHolder.binding.accountIndicator.setBackgroundColor(UIHelper.getColorForName(account.getJid().asBareJid().getEscapedLocal()));
} else {
viewHolder.binding.accountIndicator.setBackgroundColor(Color.TRANSPARENT);
}
if (draft != null) {
viewHolder.binding.conversationLastmsgImg.setVisibility(View.GONE);
viewHolder.binding.conversationLastmsg.setText(draft.getMessage());

View file

@ -1,6 +1,7 @@
package eu.siacs.conversations.ui.adapter;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
@ -17,6 +18,8 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.databinding.ContactBinding;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Bookmark;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.ListItem;
import eu.siacs.conversations.ui.SettingsActivity;
@ -25,6 +28,7 @@ import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import eu.siacs.conversations.ui.util.StyledAttributes;
import eu.siacs.conversations.ui.widget.PresenceIndicator;
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.xmpp.Jid;
public class ListItemAdapter extends ArrayAdapter<ListItem> {
@ -95,6 +99,20 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
viewHolder.presenceIndicator.setStatus(null);
}
Account account = null;
if (item instanceof Contact) {
account = ((Contact) item).getAccount();
} else if (item instanceof Bookmark) {
account = ((Bookmark) item).getAccount();
}
if (account != null && activity.xmppConnectionService.getAccounts().size() > 1) {
viewHolder.accountIndicator.setBackgroundColor(UIHelper.getColorForName(account.getJid().asBareJid().getEscapedLocal()));
} else {
viewHolder.accountIndicator.setBackgroundColor(Color.TRANSPARENT);
}
return view;
}
@ -115,6 +133,8 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
private PresenceIndicator presenceIndicator;
private View accountIndicator;
private ViewHolder() {
}
@ -126,6 +146,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
viewHolder.avatar = binding.contactPhoto;
viewHolder.tags = binding.tags;
viewHolder.presenceIndicator = binding.presenceIndicator;
viewHolder.accountIndicator = binding.accountIndicator;
binding.getRoot().setTag(viewHolder);
return viewHolder;
}

View file

@ -6,10 +6,17 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clipToPadding="false"
android:paddingLeft="8dp"
android:paddingBottom="8dp"
android:paddingTop="8dp">
<View
android:id="@+id/account_indicator"
android:layout_width="@dimen/account_indicator_width"
android:layout_marginStart="-4dp"
android:layout_height="48dp" />
<eu.siacs.conversations.ui.widget.AvatarView
android:id="@+id/account_image"
android:layout_width="48dp"

View file

@ -6,8 +6,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clipToPadding="false"
android:padding="@dimen/list_padding">
<View
android:id="@+id/account_indicator"
android:layout_width="@dimen/account_indicator_width"
android:layout_marginStart="-4dp"
android:layout_height="48dp" />
<eu.siacs.conversations.ui.widget.AvatarView
android:id="@+id/contact_photo"
android:layout_width="48dp"

View file

@ -17,8 +17,15 @@
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:orientation="horizontal"
android:clipToPadding="false"
android:padding="8dp">
<View
android:id="@+id/account_indicator"
android:layout_width="@dimen/account_indicator_width"
android:layout_marginStart="-4dp"
android:layout_height="56dp" />
<eu.siacs.conversations.ui.widget.AvatarView
android:id="@+id/conversation_image"
android:layout_width="56dp"

View file

@ -82,4 +82,5 @@
<dimen name="avatar_corners_radius">8dp</dimen>
<dimen name="presence_indicator_size">12dp</dimen>
<dimen name="presence_indicator_offset">2dp</dimen>
<dimen name="account_indicator_width">2dp</dimen>
</resources>