mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
show status for autocomplete mentions
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
6a9dea7522
commit
0078778c99
@ -29,12 +29,15 @@ import com.facebook.drawee.interfaces.DraweeController;
|
|||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
|
import com.nextcloud.talk.models.json.mention.Mention;
|
||||||
|
import com.nextcloud.talk.models.json.status.StatusType;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
import com.nextcloud.talk.utils.DisplayUtils;
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.content.res.ResourcesCompat;
|
import androidx.core.content.res.ResourcesCompat;
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
||||||
@ -50,18 +53,20 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||||||
private String objectId;
|
private String objectId;
|
||||||
private String displayName;
|
private String displayName;
|
||||||
private String source;
|
private String source;
|
||||||
|
private String status;
|
||||||
|
private String statusIcon;
|
||||||
private UserEntity currentUser;
|
private UserEntity currentUser;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public MentionAutocompleteItem(
|
public MentionAutocompleteItem(
|
||||||
String objectId,
|
Mention mention,
|
||||||
String displayName,
|
|
||||||
String source,
|
|
||||||
UserEntity currentUser,
|
UserEntity currentUser,
|
||||||
Context activityContext) {
|
Context activityContext) {
|
||||||
this.objectId = objectId;
|
this.objectId = mention.getId();
|
||||||
this.displayName = displayName;
|
this.displayName = mention.getLabel();
|
||||||
this.source = source;
|
this.source = mention.getSource();
|
||||||
|
this.status = mention.getStatus();
|
||||||
|
this.statusIcon = mention.getStatusIcon();
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
this.context = activityContext;
|
this.context = activityContext;
|
||||||
}
|
}
|
||||||
@ -157,6 +162,26 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
|||||||
.build();
|
.build();
|
||||||
holder.participantAvatar.setController(draweeController);
|
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);
|
||||||
|
holder.participantEmoji.setVisibility(View.VISIBLE);
|
||||||
|
holder.participantEmoji.setText(statusIcon);
|
||||||
|
} else if (status != null && status.equals(StatusType.AWAY.getString())) {
|
||||||
|
setOnlineStateIcon(holder, R.drawable.ic_user_status_away_with_border);
|
||||||
|
} 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -324,10 +324,10 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||||||
@BindView(R.id.checkedImageView)
|
@BindView(R.id.checkedImageView)
|
||||||
ImageView checkedImageView;
|
ImageView checkedImageView;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.conversation_info_participant_emoji)
|
@BindView(R.id.participant_status_emoji)
|
||||||
com.vanniktech.emoji.EmojiEditText participantEmoji;
|
com.vanniktech.emoji.EmojiEditText participantEmoji;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.conversation_info_participant_online_state)
|
@BindView(R.id.participant_online_state)
|
||||||
ImageView participantOnlineStateImage;
|
ImageView participantOnlineStateImage;
|
||||||
@Nullable
|
@Nullable
|
||||||
@BindView(R.id.conversation_info_status_message)
|
@BindView(R.id.conversation_info_status_message)
|
||||||
|
@ -336,7 +336,8 @@ public interface NcApi {
|
|||||||
@GET
|
@GET
|
||||||
Observable<MentionOverall> getMentionAutocompleteSuggestions(@Header("Authorization") String authorization,
|
Observable<MentionOverall> getMentionAutocompleteSuggestions(@Header("Authorization") String authorization,
|
||||||
@Url String url, @Query("search") String query,
|
@Url String url, @Query("search") String query,
|
||||||
@Nullable @Query("limit") Integer limit);
|
@Nullable @Query("limit") Integer limit,
|
||||||
|
@QueryMap Map<String, String> fields);
|
||||||
|
|
||||||
// Url is: /api/{apiVersion}/room/{token}/pin
|
// Url is: /api/{apiVersion}/room/{token}/pin
|
||||||
@POST
|
@POST
|
||||||
|
@ -1,110 +0,0 @@
|
|||||||
/*
|
|
||||||
* Nextcloud Talk application
|
|
||||||
*
|
|
||||||
* @author Mario Danic
|
|
||||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.nextcloud.talk.models.json.mention;
|
|
||||||
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonField;
|
|
||||||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
|
||||||
|
|
||||||
import org.parceler.Parcel;
|
|
||||||
|
|
||||||
@Parcel
|
|
||||||
@JsonObject
|
|
||||||
public class Mention {
|
|
||||||
@JsonField(name = "id")
|
|
||||||
String id;
|
|
||||||
|
|
||||||
@JsonField(name = "label")
|
|
||||||
String label;
|
|
||||||
|
|
||||||
// type of user (guests or users or calls)
|
|
||||||
@JsonField(name = "source")
|
|
||||||
String source;
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return this.label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSource() {
|
|
||||||
return this.source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLabel(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSource(String source) {
|
|
||||||
this.source = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(final Object o) {
|
|
||||||
if (o == this) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(o instanceof Mention)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Mention other = (Mention) o;
|
|
||||||
if (!other.canEqual((Object) this)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Object this$id = this.getId();
|
|
||||||
final Object other$id = other.getId();
|
|
||||||
if (this$id == null ? other$id != null : !this$id.equals(other$id)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Object this$label = this.getLabel();
|
|
||||||
final Object other$label = other.getLabel();
|
|
||||||
if (this$label == null ? other$label != null : !this$label.equals(other$label)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Object this$source = this.getSource();
|
|
||||||
final Object other$source = other.getSource();
|
|
||||||
|
|
||||||
return this$source == null ? other$source == null : this$source.equals(other$source);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canEqual(final Object other) {
|
|
||||||
return other instanceof Mention;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
final int PRIME = 59;
|
|
||||||
int result = 1;
|
|
||||||
final Object $id = this.getId();
|
|
||||||
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
|
|
||||||
final Object $label = this.getLabel();
|
|
||||||
result = result * PRIME + ($label == null ? 43 : $label.hashCode());
|
|
||||||
final Object $source = this.getSource();
|
|
||||||
result = result * PRIME + ($source == null ? 43 : $source.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return "Mention(id=" + this.getId() + ", label=" + this.getLabel() + ", source=" + this.getSource() + ")";
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.nextcloud.talk.models.json.mention
|
||||||
|
|
||||||
|
import android.os.Parcelable
|
||||||
|
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||||
|
import com.bluelinelabs.logansquare.annotation.JsonObject
|
||||||
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
@JsonObject
|
||||||
|
data class Mention(
|
||||||
|
@JsonField(name = ["id"])
|
||||||
|
var id : String,
|
||||||
|
|
||||||
|
@JsonField(name = ["label"])
|
||||||
|
var label : String,
|
||||||
|
|
||||||
|
// type of user (guests or users or calls)
|
||||||
|
@JsonField(name = ["source"])
|
||||||
|
var source : String,
|
||||||
|
|
||||||
|
@JsonField(name = ["status"])
|
||||||
|
var status : String?,
|
||||||
|
|
||||||
|
@JsonField(name = ["statusIcon"])
|
||||||
|
var statusIcon : String?,
|
||||||
|
|
||||||
|
@JsonField(name = ["statusMessage"])
|
||||||
|
var statusMessage : String?
|
||||||
|
|
||||||
|
) : Parcelable {
|
||||||
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
|
constructor() : this("", "", "", "", "", "")
|
||||||
|
}
|
@ -22,7 +22,9 @@
|
|||||||
|
|
||||||
package com.nextcloud.talk.presenters;
|
package com.nextcloud.talk.presenters;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.nextcloud.talk.adapters.items.MentionAutocompleteItem;
|
import com.nextcloud.talk.adapters.items.MentionAutocompleteItem;
|
||||||
@ -38,7 +40,9 @@ import com.otaliastudios.autocomplete.RecyclerViewPresenter;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -54,6 +58,7 @@ import io.reactivex.schedulers.Schedulers;
|
|||||||
|
|
||||||
@AutoInjector(NextcloudTalkApplication.class)
|
@AutoInjector(NextcloudTalkApplication.class)
|
||||||
public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention> implements FlexibleAdapter.OnItemClickListener {
|
public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention> implements FlexibleAdapter.OnItemClickListener {
|
||||||
|
private static final String TAG = "MentionAutocompletePresenter";
|
||||||
@Inject
|
@Inject
|
||||||
NcApi ncApi;
|
NcApi ncApi;
|
||||||
@Inject
|
@Inject
|
||||||
@ -101,10 +106,14 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||||||
int apiVersion = ApiUtils.getChatApiVersion(currentUser, new int[] {1});
|
int apiVersion = ApiUtils.getChatApiVersion(currentUser, new int[] {1});
|
||||||
|
|
||||||
adapter.setFilter(queryString);
|
adapter.setFilter(queryString);
|
||||||
|
|
||||||
|
Map<String, String> queryMap = new HashMap<>();
|
||||||
|
queryMap.put("includeStatus", "true");
|
||||||
|
|
||||||
ncApi.getMentionAutocompleteSuggestions(
|
ncApi.getMentionAutocompleteSuggestions(
|
||||||
ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken()),
|
ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken()),
|
||||||
ApiUtils.getUrlForMentionSuggestions(apiVersion, currentUser.getBaseUrl(), roomToken),
|
ApiUtils.getUrlForMentionSuggestions(apiVersion, currentUser.getBaseUrl(), roomToken),
|
||||||
queryString, 5)
|
queryString, 5, queryMap)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.retry(3)
|
.retry(3)
|
||||||
@ -125,9 +134,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||||||
for (Mention mention : mentionsList) {
|
for (Mention mention : mentionsList) {
|
||||||
internalAbstractFlexibleItemList.add(
|
internalAbstractFlexibleItemList.add(
|
||||||
new MentionAutocompleteItem(
|
new MentionAutocompleteItem(
|
||||||
mention.getId(),
|
mention,
|
||||||
mention.getLabel(),
|
|
||||||
mention.getSource(),
|
|
||||||
currentUser,
|
currentUser,
|
||||||
context));
|
context));
|
||||||
}
|
}
|
||||||
@ -140,9 +147,11 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("LongLogTag")
|
||||||
@Override
|
@Override
|
||||||
public void onError(@NotNull Throwable e) {
|
public void onError(@NotNull Throwable e) {
|
||||||
adapter.clear();
|
adapter.clear();
|
||||||
|
Log.e(TAG, "failed to get MentionAutocompleteSuggestions", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
app:roundAsCircle="true" />
|
app:roundAsCircle="true" />
|
||||||
|
|
||||||
<com.vanniktech.emoji.EmojiEditText
|
<com.vanniktech.emoji.EmojiEditText
|
||||||
android:id="@+id/conversation_info_participant_emoji"
|
android:id="@+id/participant_status_emoji"
|
||||||
android:layout_width="22dp"
|
android:layout_width="22dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/transparent"
|
android:background="@color/transparent"
|
||||||
@ -50,7 +50,7 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@+id/name_text" />
|
app:layout_constraintTop_toBottomOf="@+id/name_text" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/conversation_info_participant_online_state"
|
android:id="@+id/participant_online_state"
|
||||||
android:layout_width="16dp"
|
android:layout_width="16dp"
|
||||||
android:layout_height="16dp"
|
android:layout_height="16dp"
|
||||||
android:contentDescription="@null"
|
android:contentDescription="@null"
|
||||||
@ -83,7 +83,7 @@
|
|||||||
android:textAlignment="viewStart"
|
android:textAlignment="viewStart"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
app:layout_constraintStart_toEndOf="@+id/conversation_info_participant_emoji"
|
app:layout_constraintStart_toEndOf="@+id/participant_status_emoji"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/name_text"
|
app:layout_constraintTop_toBottomOf="@+id/name_text"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
tools:text="this is a very long status message. server allows only 81 chars here. 0123456789" />
|
tools:text="this is a very long status message. server allows only 81 chars here. 0123456789" />
|
||||||
|
@ -40,6 +40,25 @@
|
|||||||
android:layout_height="@dimen/avatar_size"
|
android:layout_height="@dimen/avatar_size"
|
||||||
app:roundAsCircle="true" />
|
app:roundAsCircle="true" />
|
||||||
|
|
||||||
|
<com.vanniktech.emoji.EmojiEditText
|
||||||
|
android:id="@+id/participant_status_emoji"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:background="@color/transparent"
|
||||||
|
android:cursorVisible="false"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/default_emoji"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/participant_online_state"
|
||||||
|
android:layout_width="16dp"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:src="@drawable/online_status"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
Loading…
Reference in New Issue
Block a user