diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.java index 5cf654130..1b9491c7b 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/MentionAutocompleteItem.java @@ -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 @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) diff --git a/app/src/main/java/com/nextcloud/talk/api/NcApi.java b/app/src/main/java/com/nextcloud/talk/api/NcApi.java index 688416959..f05910afa 100644 --- a/app/src/main/java/com/nextcloud/talk/api/NcApi.java +++ b/app/src/main/java/com/nextcloud/talk/api/NcApi.java @@ -336,7 +336,8 @@ public interface NcApi { @GET Observable getMentionAutocompleteSuggestions(@Header("Authorization") String authorization, @Url String url, @Query("search") String query, - @Nullable @Query("limit") Integer limit); + @Nullable @Query("limit") Integer limit, + @QueryMap Map fields); // Url is: /api/{apiVersion}/room/{token}/pin @POST diff --git a/app/src/main/java/com/nextcloud/talk/models/json/mention/Mention.java b/app/src/main/java/com/nextcloud/talk/models/json/mention/Mention.java deleted file mode 100644 index 7770eb13f..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/mention/Mention.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017-2018 Mario Danic - * - * 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 . - */ -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() + ")"; - } -} diff --git a/app/src/main/java/com/nextcloud/talk/models/json/mention/Mention.kt b/app/src/main/java/com/nextcloud/talk/models/json/mention/Mention.kt new file mode 100644 index 000000000..0ab861725 --- /dev/null +++ b/app/src/main/java/com/nextcloud/talk/models/json/mention/Mention.kt @@ -0,0 +1,52 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2018 Mario Danic + * + * 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 . + */ +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("", "", "", "", "", "") +} \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java b/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java index a70f81f84..e87c9c1a0 100644 --- a/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java +++ b/app/src/main/java/com/nextcloud/talk/presenters/MentionAutocompletePresenter.java @@ -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 implements FlexibleAdapter.OnItemClickListener { + private static final String TAG = "MentionAutocompletePresenter"; @Inject NcApi ncApi; @Inject @@ -101,10 +106,14 @@ public class MentionAutocompletePresenter extends RecyclerViewPresenter int apiVersion = ApiUtils.getChatApiVersion(currentUser, new int[] {1}); adapter.setFilter(queryString); + + Map 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 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 } } + @SuppressLint("LongLogTag") @Override public void onError(@NotNull Throwable e) { adapter.clear(); + Log.e(TAG, "failed to get MentionAutocompleteSuggestions", e); } @Override diff --git a/app/src/main/res/layout/rv_item_conversation_info_participant.xml b/app/src/main/res/layout/rv_item_conversation_info_participant.xml index 6576ca36e..bde617f15 100644 --- a/app/src/main/res/layout/rv_item_conversation_info_participant.xml +++ b/app/src/main/res/layout/rv_item_conversation_info_participant.xml @@ -38,7 +38,7 @@ app:roundAsCircle="true" /> diff --git a/app/src/main/res/layout/rv_item_mention.xml b/app/src/main/res/layout/rv_item_mention.xml index 54e5d47c1..09f2d14ab 100644 --- a/app/src/main/res/layout/rv_item_mention.xml +++ b/app/src/main/res/layout/rv_item_mention.xml @@ -40,6 +40,25 @@ android:layout_height="@dimen/avatar_size" app:roundAsCircle="true" /> + + + +