mirror of
https://codeberg.org/monocles/monocles_chat.git
synced 2025-01-15 14:12:21 +01:00
Add active indicator to contacts list
This commit is contained in:
parent
a11e24096f
commit
3ad559daac
8 changed files with 50 additions and 8 deletions
|
@ -221,7 +221,7 @@ public class Bookmark extends Element implements ListItem {
|
|||
for (Element element : getChildren()) {
|
||||
if (element.getName().equals("group") && element.getContent() != null) {
|
||||
String group = element.getContent();
|
||||
tags.add(new Tag(group));
|
||||
tags.add(new Tag(group, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,11 +231,16 @@ public class Bookmark extends Element implements ListItem {
|
|||
@Override
|
||||
public List<Tag> getTags(Context context) {
|
||||
ArrayList<Tag> tags = new ArrayList<>();
|
||||
tags.add(new Tag("Channel"));
|
||||
tags.add(new Tag("Channel", false));
|
||||
tags.addAll(getGroupTags());
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getNick() {
|
||||
return this.findChildContent("nick");
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ public class Contact implements ListItem, Blockable {
|
|||
public List<Tag> getGroupTags() {
|
||||
final ArrayList<Tag> tags = new ArrayList<>();
|
||||
for (final String group : getGroups(true)) {
|
||||
tags.add(new Tag(group));
|
||||
tags.add(new Tag(group, false));
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
@ -216,15 +216,20 @@ public class Contact implements ListItem, Blockable {
|
|||
final HashSet<Tag> tags = new HashSet<>();
|
||||
tags.addAll(getGroupTags());
|
||||
for (final String tag : getSystemTags(true)) {
|
||||
tags.add(new Tag(tag));
|
||||
tags.add(new Tag(tag, isActive()));
|
||||
}
|
||||
Presence.Status status = getShownStatus();
|
||||
if (!showInRoster() && getSystemAccount() != null) {
|
||||
tags.add(new Tag("Android"));
|
||||
tags.add(new Tag("Android", isActive()));
|
||||
}
|
||||
return new ArrayList<>(tags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive() {
|
||||
return isActive();
|
||||
}
|
||||
|
||||
public boolean match(Context context, String needle) {
|
||||
if (TextUtils.isEmpty(needle)) {
|
||||
return true;
|
||||
|
|
|
@ -20,11 +20,16 @@ public interface ListItem extends Comparable<ListItem>, AvatarService.Avatarable
|
|||
|
||||
List<Tag> getTags(Context context);
|
||||
|
||||
boolean getActive();
|
||||
|
||||
final class Tag implements Serializable, Comparable {
|
||||
private final String name;
|
||||
private final boolean active;
|
||||
|
||||
public Tag(final String name) {
|
||||
|
||||
public Tag(final String name, final boolean active) {
|
||||
this.name = name;
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
|
@ -54,6 +54,11 @@ public class RawBlockable implements ListItem, Blockable {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(Context context, String needle) {
|
||||
if (TextUtils.isEmpty(needle)) {
|
||||
|
|
|
@ -1951,7 +1951,7 @@ public class StartConversationActivity extends XmppActivity
|
|||
}
|
||||
|
||||
public void setTags(final List<ListItem.Tag> tags) {
|
||||
ListItem.Tag channelTag = new ListItem.Tag("Channel");
|
||||
ListItem.Tag channelTag = new ListItem.Tag("Channel", false);
|
||||
String needle = mSearchEditText == null ? "" : mSearchEditText.getText().toString().toLowerCase(Locale.US).trim();
|
||||
HashSet<String> parts = new HashSet<>(Arrays.asList(needle.split("[,\\s]+")));
|
||||
this.tags = tags.stream().filter(
|
||||
|
|
|
@ -153,6 +153,11 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
|||
}
|
||||
viewHolder.name.setText(item.getDisplayName());
|
||||
AvatarWorkerTask.loadAvatar(item, viewHolder.avatar, R.dimen.avatar);
|
||||
if (item.getActive()) {
|
||||
viewHolder.userActiveIndicator.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.userActiveIndicator.setVisibility(View.GONE);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -173,6 +178,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
|||
private View inner;
|
||||
private ConstraintLayout tags;
|
||||
private Flow flowWidget;
|
||||
private ImageView userActiveIndicator;
|
||||
|
||||
private ViewHolder() {
|
||||
|
||||
|
@ -187,6 +193,7 @@ public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
|||
viewHolder.tags = binding.tags;
|
||||
viewHolder.inner = binding.inner;
|
||||
viewHolder.flowWidget = binding.flowWidget;
|
||||
viewHolder.userActiveIndicator = binding.userActiveIndicator;
|
||||
binding.getRoot().setTag(viewHolder);
|
||||
return viewHolder;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,17 @@
|
|||
android:layout_alignParentStart="true"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/user_active_indicator"
|
||||
android:layout_width="13dp"
|
||||
android:layout_height="13dp"
|
||||
android:layout_alignBottom="@+id/contact_photo"
|
||||
android:layout_alignEnd="@+id/contact_photo"
|
||||
android:layout_marginBottom="0dp"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/active_indicator" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -45,7 +45,11 @@ public class TagEditorView extends TokenCompleteTextView<ListItem.Tag> {
|
|||
|
||||
@Override
|
||||
protected ListItem.Tag defaultObject(String completionText) {
|
||||
return new ListItem.Tag(completionText);
|
||||
return defaultObject(completionText, false);
|
||||
}
|
||||
|
||||
protected ListItem.Tag defaultObject(String completionText, boolean isActive) {
|
||||
return new ListItem.Tag(completionText, isActive);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue