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