mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +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.application.NextcloudTalkApplication;
|
||||
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.DisplayUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
||||
@ -50,18 +53,20 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
||||
private String objectId;
|
||||
private String displayName;
|
||||
private String source;
|
||||
private String status;
|
||||
private String statusIcon;
|
||||
private UserEntity currentUser;
|
||||
private Context context;
|
||||
|
||||
public MentionAutocompleteItem(
|
||||
String objectId,
|
||||
String displayName,
|
||||
String source,
|
||||
Mention mention,
|
||||
UserEntity currentUser,
|
||||
Context activityContext) {
|
||||
this.objectId = objectId;
|
||||
this.displayName = displayName;
|
||||
this.source = source;
|
||||
this.objectId = mention.getId();
|
||||
this.displayName = mention.getLabel();
|
||||
this.source = mention.getSource();
|
||||
this.status = mention.getStatus();
|
||||
this.statusIcon = mention.getStatusIcon();
|
||||
this.currentUser = currentUser;
|
||||
this.context = activityContext;
|
||||
}
|
||||
@ -157,6 +162,26 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<UserItem.UserI
|
||||
.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);
|
||||
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
|
||||
|
@ -324,10 +324,10 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
||||
@BindView(R.id.checkedImageView)
|
||||
ImageView checkedImageView;
|
||||
@Nullable
|
||||
@BindView(R.id.conversation_info_participant_emoji)
|
||||
@BindView(R.id.participant_status_emoji)
|
||||
com.vanniktech.emoji.EmojiEditText participantEmoji;
|
||||
@Nullable
|
||||
@BindView(R.id.conversation_info_participant_online_state)
|
||||
@BindView(R.id.participant_online_state)
|
||||
ImageView participantOnlineStateImage;
|
||||
@Nullable
|
||||
@BindView(R.id.conversation_info_status_message)
|
||||
|
@ -336,7 +336,8 @@ public interface NcApi {
|
||||
@GET
|
||||
Observable<MentionOverall> getMentionAutocompleteSuggestions(@Header("Authorization") String authorization,
|
||||
@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
|
||||
@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;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.nextcloud.talk.adapters.items.MentionAutocompleteItem;
|
||||
@ -38,7 +40,9 @@ import com.otaliastudios.autocomplete.RecyclerViewPresenter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@ -54,6 +58,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention> implements FlexibleAdapter.OnItemClickListener {
|
||||
private static final String TAG = "MentionAutocompletePresenter";
|
||||
@Inject
|
||||
NcApi ncApi;
|
||||
@Inject
|
||||
@ -101,10 +106,14 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
||||
int apiVersion = ApiUtils.getChatApiVersion(currentUser, new int[] {1});
|
||||
|
||||
adapter.setFilter(queryString);
|
||||
|
||||
Map<String, String> queryMap = new HashMap<>();
|
||||
queryMap.put("includeStatus", "true");
|
||||
|
||||
ncApi.getMentionAutocompleteSuggestions(
|
||||
ApiUtils.getCredentials(currentUser.getUsername(), currentUser.getToken()),
|
||||
ApiUtils.getUrlForMentionSuggestions(apiVersion, currentUser.getBaseUrl(), roomToken),
|
||||
queryString, 5)
|
||||
queryString, 5, queryMap)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.retry(3)
|
||||
@ -125,9 +134,7 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
||||
for (Mention mention : mentionsList) {
|
||||
internalAbstractFlexibleItemList.add(
|
||||
new MentionAutocompleteItem(
|
||||
mention.getId(),
|
||||
mention.getLabel(),
|
||||
mention.getSource(),
|
||||
mention,
|
||||
currentUser,
|
||||
context));
|
||||
}
|
||||
@ -140,9 +147,11 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter<Mention>
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
@Override
|
||||
public void onError(@NotNull Throwable e) {
|
||||
adapter.clear();
|
||||
Log.e(TAG, "failed to get MentionAutocompleteSuggestions", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,7 +38,7 @@
|
||||
app:roundAsCircle="true" />
|
||||
|
||||
<com.vanniktech.emoji.EmojiEditText
|
||||
android:id="@+id/conversation_info_participant_emoji"
|
||||
android:id="@+id/participant_status_emoji"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/transparent"
|
||||
@ -50,7 +50,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/name_text" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/conversation_info_participant_online_state"
|
||||
android:id="@+id/participant_online_state"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:contentDescription="@null"
|
||||
@ -83,7 +83,7 @@
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
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_constraintEnd_toEndOf="parent"
|
||||
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"
|
||||
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>
|
||||
|
||||
<LinearLayout
|
||||
|
Loading…
Reference in New Issue
Block a user