Skip to content

Commit

Permalink
improve autocomplete mentions UI
Browse files Browse the repository at this point in the history
add status message and emoji
match parent
improve design
use rv_item_mention_conversation_info_participant instead of rv_item_mention.xml

Signed-off-by: Marcel Hibbe <[email protected]>
  • Loading branch information
mahibi committed Feb 23, 2022
1 parent 8205ebf commit 8a1f39e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
private String source;
private String status;
private String statusIcon;
private String statusMessage;
private UserEntity currentUser;
private Context context;

Expand All @@ -67,6 +68,7 @@ public MentionAutocompleteItem(
this.source = mention.getSource();
this.status = mention.getStatus();
this.statusIcon = mention.getStatusIcon();
this.statusMessage = mention.getStatusMessage();
this.currentUser = currentUser;
this.context = activityContext;
}
Expand Down Expand Up @@ -99,7 +101,7 @@ public boolean equals(Object o) {

@Override
public int getLayoutRes() {
return R.layout.rv_item_mention;
return R.layout.rv_item_conversation_info_participant;
}

@Override
Expand All @@ -124,13 +126,13 @@ public void bindViewHolder(
displayName,
String.valueOf(adapter.getFilter(String.class)),
NextcloudTalkApplication.Companion.getSharedApplication()
.getResources().getColor(R.color.colorPrimary));
.getResources().getColor(R.color.colorPrimary));
if (holder.contactMentionId != null) {
FlexibleUtils.highlightText(holder.contactMentionId,
"@" + objectId,
String.valueOf(adapter.getFilter(String.class)),
NextcloudTalkApplication.Companion.getSharedApplication()
.getResources().getColor(R.color.colorPrimary));
.getResources().getColor(R.color.colorPrimary));
}
} else {
holder.contactDisplayName.setText(displayName);
Expand All @@ -149,37 +151,53 @@ public void bindViewHolder(
if (SOURCE_GUESTS.equals(source)) {
avatarId = displayName;
avatarUrl = ApiUtils.getUrlForAvatarWithNameForGuests(
currentUser.getBaseUrl(),
avatarId,
R.dimen.avatar_size_big);
currentUser.getBaseUrl(),
avatarId,
R.dimen.avatar_size_big);
}

holder.participantAvatar.setController(null);
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
.setOldController(holder.participantAvatar.getController())
.setAutoPlayAnimations(true)
.setImageRequest(DisplayUtils.getImageRequestForUrl(avatarUrl, null))
.build();
.setOldController(holder.participantAvatar.getController())
.setAutoPlayAnimations(true)
.setImageRequest(DisplayUtils.getImageRequestForUrl(avatarUrl, null))
.build();
holder.participantAvatar.setController(draweeController);
}
if (status != null && status.equals(StatusType.DND.getString())) {
setOnlineStateIcon(holder, R.drawable.ic_user_status_dnd_with_border);
} else if (statusIcon != null && statusIcon.isEmpty()) {
holder.participantOnlineStateImage.setVisibility(View.GONE);

if (statusMessage != null) {
holder.statusMessage.setText(statusMessage);
} else {
holder.statusMessage.setText("");
}

if (statusIcon != null && !statusIcon.isEmpty()) {
holder.participantEmoji.setVisibility(View.VISIBLE);
holder.participantEmoji.setText(statusIcon);
} else {
holder.participantEmoji.setVisibility(View.GONE);
holder.participantEmoji.setText("");
}

if (status != null && status.equals(StatusType.DND.getString())) {
setOnlineStateIcon(holder, R.drawable.ic_user_status_dnd_with_border);
if (statusMessage == null || statusMessage.isEmpty()) {
holder.statusMessage.setText(R.string.dnd);
}
} else if (status != null && status.equals(StatusType.AWAY.getString())) {
setOnlineStateIcon(holder, R.drawable.ic_user_status_away_with_border);
if (statusMessage == null || statusMessage.isEmpty()) {
holder.statusMessage.setText(R.string.away);
}
} else if (status != null && status.equals(StatusType.ONLINE.getString())) {
setOnlineStateIcon(holder, R.drawable.online_status_with_border);
} else {
holder.participantEmoji.setVisibility(View.GONE);
holder.participantOnlineStateImage.setVisibility(View.GONE);
}
}


private void setOnlineStateIcon(UserItem.UserItemViewHolder holder, int icon) {
holder.participantEmoji.setVisibility(View.GONE);
holder.participantOnlineStateImage.setVisibility(View.VISIBLE);
holder.participantOnlineStateImage.setImageDrawable(ContextCompat.getDrawable(context, icon));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public void bindViewHolder(FlexibleAdapter adapter, UserItemViewHolder holder, i

if (participant.statusMessage != null) {
holder.statusMessage.setText(participant.statusMessage);
} else {
holder.statusMessage.setText("");
}

if (participant.statusIcon != null && !participant.statusIcon.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import com.nextcloud.talk.adapters.items.MentionAutocompleteItem;
import com.nextcloud.talk.api.NcApi;
Expand Down Expand Up @@ -93,6 +94,14 @@ protected RecyclerView.Adapter instantiateAdapter() {
return adapter;
}

@Override
protected PopupDimensions getPopupDimensions() {
PopupDimensions popupDimensions = new PopupDimensions();
popupDimensions.width = ViewGroup.LayoutParams.MATCH_PARENT;
popupDimensions.height = ViewGroup.LayoutParams.WRAP_CONTENT;
return popupDimensions;
}

@Override
protected void onQuery(@Nullable CharSequence query) {

Expand Down
28 changes: 16 additions & 12 deletions app/src/main/res/layout/rv_item_conversation_info_participant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/standard_half_margin"
android:layout_marginTop="@dimen/standard_margin">


<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/conversation_info_participant_avatar"
android:layout_width="@dimen/small_item_height"
android:layout_height="@dimen/small_item_height"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginStart="@dimen/standard_margin"
android:contentDescription="@null"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand Down Expand Up @@ -63,9 +64,8 @@
android:id="@+id/name_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginStart="@dimen/standard_margin"
android:layout_marginTop="2dp"
android:ellipsize="middle"
android:singleLine="true"
android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceListItem"
Expand All @@ -78,42 +78,46 @@
android:id="@+id/conversation_info_status_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="2"
android:layout_marginBottom="4dp"
android:ellipsize="end"
android:maxLines="3"
android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceListItem"
android:textColor="?android:attr/textColorSecondary"
android:layout_marginEnd="@dimen/side_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/participant_status_emoji"
app:layout_constraintTop_toBottomOf="@+id/name_text"
app:layout_constraintEnd_toEndOf="parent"
tools:text="this is a very long status message. server allows only 81 chars here. 0123456789" />

<androidx.emoji.widget.EmojiTextView
android:id="@+id/secondary_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:ellipsize="middle"
android:singleLine="true"
android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceListItem"
android:textColor="?android:attr/textColorSecondary"
android:layout_marginEnd="@dimen/side_margin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/name_text"
app:layout_constraintTop_toTopOf="@+id/name_text"
tools:text="@string/nc_moderator" />
tools:text="Moderator (or userid for autocomplete mention)" />


<ImageView
android:id="@+id/videoCallIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="@dimen/standard_half_margin"
android:layout_marginEnd="@dimen/standard_half_margin"
android:contentDescription="@null"
android:src="@drawable/ic_videocam_grey_600_24dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toTopOf="@+id/secondary_text"
tools:visibility="visible" />

</androidx.constraintlayout.widget.ConstraintLayout>
89 changes: 0 additions & 89 deletions app/src/main/res/layout/rv_item_mention.xml

This file was deleted.

0 comments on commit 8a1f39e

Please sign in to comment.