Commit 0103fdb6 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #434 from filipedelimabrito/userstatus-on-spotlight-results

User status on spotlight results (for DM rooms)
parents 6ba196c1 84beae90
...@@ -45,7 +45,7 @@ android { ...@@ -45,7 +45,7 @@ android {
applicationId "chat.rocket.android" applicationId "chat.rocket.android"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 32 versionCode 34
versionName "1.0.18" versionName "1.0.18"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
...@@ -176,4 +176,4 @@ dependencies { ...@@ -176,4 +176,4 @@ dependencies {
provided 'com.hadisatrio:Optional:v1.0.1' provided 'com.hadisatrio:Optional:v1.0.1'
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'
\ No newline at end of file
...@@ -483,7 +483,11 @@ public class MethodCallHelper { ...@@ -483,7 +483,11 @@ public class MethodCallHelper {
final JSONObject result = task.getResult(); final JSONObject result = task.getResult();
JSONArray roomJsonArray = (JSONArray) result.get("rooms"); JSONArray roomJsonArray = (JSONArray) result.get("rooms");
if (roomJsonArray.length() > 0) { int roomTotal = roomJsonArray.length();
if (roomTotal > 0) {
for (int i = 0; i < roomTotal; ++i) {
RealmSpotlight.Companion.customizeRoomJSONObject(roomJsonArray.getJSONObject(i));
}
jsonString = roomJsonArray.toString(); jsonString = roomJsonArray.toString();
} }
......
...@@ -11,6 +11,7 @@ import android.support.v7.widget.SearchView; ...@@ -11,6 +11,7 @@ import android.support.v7.widget.SearchView;
import android.view.View; import android.view.View;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.TextView; import android.widget.TextView;
import chat.rocket.android.BuildConfig; import chat.rocket.android.BuildConfig;
import chat.rocket.android.R; import chat.rocket.android.R;
import chat.rocket.android.RocketChatCache; import chat.rocket.android.RocketChatCache;
...@@ -142,7 +143,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain ...@@ -142,7 +143,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
RxSearchView.queryTextChanges(searchView) RxSearchView.queryTextChanges(searchView)
.compose(bindToLifecycle()) .compose(bindToLifecycle())
.debounce(300, TimeUnit.MILLISECONDS) .debounce(100, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.switchMap(charSequence -> { .switchMap(charSequence -> {
if (charSequence.length() == 0) { if (charSequence.length() == 0) {
......
...@@ -19,6 +19,7 @@ import chat.rocket.core.models.Room; ...@@ -19,6 +19,7 @@ import chat.rocket.core.models.Room;
import chat.rocket.core.models.RoomSidebar; import chat.rocket.core.models.RoomSidebar;
import chat.rocket.core.models.Spotlight; import chat.rocket.core.models.Spotlight;
import chat.rocket.core.models.User; import chat.rocket.core.models.User;
import chat.rocket.core.repositories.SpotlightRepository;
import chat.rocket.core.repositories.UserRepository; import chat.rocket.core.repositories.UserRepository;
import chat.rocket.persistence.realm.repositories.RealmSpotlightRepository; import chat.rocket.persistence.realm.repositories.RealmSpotlightRepository;
import io.reactivex.Flowable; import io.reactivex.Flowable;
...@@ -32,7 +33,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View ...@@ -32,7 +33,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
private final RocketChatCache rocketChatCache; private final RocketChatCache rocketChatCache;
private final AbsoluteUrlHelper absoluteUrlHelper; private final AbsoluteUrlHelper absoluteUrlHelper;
private final MethodCallHelper methodCallHelper; private final MethodCallHelper methodCallHelper;
private RealmSpotlightRepository realmSpotlightRepository; private SpotlightRepository realmSpotlightRepository;
private List<RoomSidebar> roomSidebarList; private List<RoomSidebar> roomSidebarList;
public SidebarMainPresenter(String hostname, public SidebarMainPresenter(String hostname,
......
...@@ -48,7 +48,12 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder { ...@@ -48,7 +48,12 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
itemView.setUnreadCount(0); itemView.setUnreadCount(0);
itemView.setTag(spotlight); itemView.setTag(spotlight);
showRoomIcon(spotlight.getType()); String roomType = spotlight.getType();
if (roomType.equals(Room.TYPE_DIRECT_MESSAGE)) {
showUserStatusIcon(spotlight.getStatus());
} else {
showRoomIcon(roomType);
}
} }
/** /**
...@@ -91,7 +96,7 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder { ...@@ -91,7 +96,7 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
itemView.showPrivateChannelIcon(); itemView.showPrivateChannelIcon();
break; break;
default: default:
throw new AssertionError("Room type doesn't satisfies. Room type:" + roomType); throw new AssertionError("Room type doesn't satisfies the method documentation. Room type is:" + roomType);
} }
} }
} }
\ No newline at end of file
...@@ -10,21 +10,26 @@ open class RealmSpotlight : RealmObject() { ...@@ -10,21 +10,26 @@ open class RealmSpotlight : RealmObject() {
@PrimaryKey var _id: String? = null @PrimaryKey var _id: String? = null
var name: String? = null var name: String? = null
var t: String? = null var t: String? = null
var status: String? = null
fun asSpotlight(): Spotlight { fun asSpotlight(): Spotlight {
return Spotlight.builder() return Spotlight.builder()
.setId(_id) .setId(_id)
.setName(name) .setName(name)
.setType(t) .setType(t)
.setStatus(status)
.build() .build()
} }
companion object { companion object {
fun customizeRoomJSONObject(roomJsonObject: JSONObject) {
roomJsonObject.put(Columns.STATUS, "")
}
fun customizeUserJSONObject(userJsonObject: JSONObject) { fun customizeUserJSONObject(userJsonObject: JSONObject) {
userJsonObject.put(Columns.NAME, userJsonObject.get("username")) userJsonObject.put(Columns.NAME, userJsonObject.get("username"))
userJsonObject.put(Columns.TYPE, "d") userJsonObject.put(Columns.TYPE, "d")
userJsonObject.remove("username") userJsonObject.remove("username")
userJsonObject.remove("status")
} }
} }
...@@ -33,6 +38,7 @@ open class RealmSpotlight : RealmObject() { ...@@ -33,6 +38,7 @@ open class RealmSpotlight : RealmObject() {
const val ID = "_id" const val ID = "_id"
const val NAME = "name" const val NAME = "name"
const val TYPE = "t" const val TYPE = "t"
const val STATUS = "status"
} }
} }
} }
\ No newline at end of file
...@@ -11,6 +11,8 @@ public abstract class Spotlight { ...@@ -11,6 +11,8 @@ public abstract class Spotlight {
public abstract String getType(); public abstract String getType();
public abstract String getStatus();
public static Spotlight.Builder builder() { public static Spotlight.Builder builder() {
return new AutoValue_Spotlight.Builder(); return new AutoValue_Spotlight.Builder();
} }
...@@ -24,6 +26,8 @@ public abstract class Spotlight { ...@@ -24,6 +26,8 @@ public abstract class Spotlight {
public abstract Builder setType(String type); public abstract Builder setType(String type);
public abstract Builder setStatus(String status);
public abstract Spotlight build(); public abstract Spotlight build();
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment