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 {
applicationId "chat.rocket.android"
minSdkVersion 16
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 32
versionCode 34
versionName "1.0.18"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
......
......@@ -483,7 +483,11 @@ public class MethodCallHelper {
final JSONObject result = task.getResult();
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();
}
......
......@@ -11,6 +11,7 @@ import android.support.v7.widget.SearchView;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.TextView;
import chat.rocket.android.BuildConfig;
import chat.rocket.android.R;
import chat.rocket.android.RocketChatCache;
......@@ -142,7 +143,7 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
RxSearchView.queryTextChanges(searchView)
.compose(bindToLifecycle())
.debounce(300, TimeUnit.MILLISECONDS)
.debounce(100, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.switchMap(charSequence -> {
if (charSequence.length() == 0) {
......
......@@ -19,6 +19,7 @@ import chat.rocket.core.models.Room;
import chat.rocket.core.models.RoomSidebar;
import chat.rocket.core.models.Spotlight;
import chat.rocket.core.models.User;
import chat.rocket.core.repositories.SpotlightRepository;
import chat.rocket.core.repositories.UserRepository;
import chat.rocket.persistence.realm.repositories.RealmSpotlightRepository;
import io.reactivex.Flowable;
......@@ -32,7 +33,7 @@ public class SidebarMainPresenter extends BasePresenter<SidebarMainContract.View
private final RocketChatCache rocketChatCache;
private final AbsoluteUrlHelper absoluteUrlHelper;
private final MethodCallHelper methodCallHelper;
private RealmSpotlightRepository realmSpotlightRepository;
private SpotlightRepository realmSpotlightRepository;
private List<RoomSidebar> roomSidebarList;
public SidebarMainPresenter(String hostname,
......
......@@ -48,7 +48,12 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
itemView.setUnreadCount(0);
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 {
itemView.showPrivateChannelIcon();
break;
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() {
@PrimaryKey var _id: String? = null
var name: String? = null
var t: String? = null
var status: String? = null
fun asSpotlight(): Spotlight {
return Spotlight.builder()
.setId(_id)
.setName(name)
.setType(t)
.setStatus(status)
.build()
}
companion object {
fun customizeRoomJSONObject(roomJsonObject: JSONObject) {
roomJsonObject.put(Columns.STATUS, "")
}
fun customizeUserJSONObject(userJsonObject: JSONObject) {
userJsonObject.put(Columns.NAME, userJsonObject.get("username"))
userJsonObject.put(Columns.TYPE, "d")
userJsonObject.remove("username")
userJsonObject.remove("status")
}
}
......@@ -33,6 +38,7 @@ open class RealmSpotlight : RealmObject() {
const val ID = "_id"
const val NAME = "name"
const val TYPE = "t"
const val STATUS = "status"
}
}
}
\ No newline at end of file
......@@ -11,6 +11,8 @@ public abstract class Spotlight {
public abstract String getType();
public abstract String getStatus();
public static Spotlight.Builder builder() {
return new AutoValue_Spotlight.Builder();
}
......@@ -24,6 +26,8 @@ public abstract class Spotlight {
public abstract Builder setType(String type);
public abstract Builder setStatus(String status);
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