Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
6d01ed69
Commit
6d01ed69
authored
Mar 21, 2017
by
Tiago Cunha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show favorites grouping on room list
parent
99cacc3a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
86 additions
and
1 deletion
+86
-1
SidebarMainFragment.java
.../rocket/android/fragment/sidebar/SidebarMainFragment.java
+5
-0
FavoriteRoomListHeader.java
...ayouthelper/chatroom/roomlist/FavoriteRoomListHeader.java
+41
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
Migration.java
...rc/main/java/chat/rocket/persistence/realm/Migration.java
+22
-0
RocketChatPersistenceRealm.java
.../rocket/persistence/realm/RocketChatPersistenceRealm.java
+2
-1
RealmRoom.java
...a/chat/rocket/persistence/realm/models/ddp/RealmRoom.java
+11
-0
Room.java
...chat-core/src/main/java/chat/rocket/core/models/Room.java
+4
-0
No files found.
app/src/main/java/chat/rocket/android/fragment/sidebar/SidebarMainFragment.java
View file @
6d01ed69
...
...
@@ -27,6 +27,7 @@ import chat.rocket.android.helper.AbsoluteUrlHelper;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.ChannelRoomListHeader
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.DirectMessageRoomListHeader
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.FavoriteRoomListHeader
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.RoomListAdapter
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.RoomListHeader
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.UnreadRoomListHeader
;
...
...
@@ -179,6 +180,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
));
}
roomListHeaders
.
add
(
new
FavoriteRoomListHeader
(
getString
(
R
.
string
.
fragment_sidebar_main_favorite_title
)
));
roomListHeaders
.
add
(
new
ChannelRoomListHeader
(
getString
(
R
.
string
.
fragment_sidebar_main_channels_title
),
()
->
showAddRoomDialog
(
AddChannelDialogFragment
.
create
(
hostname
))
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/roomlist/FavoriteRoomListHeader.java
0 → 100644
View file @
6d01ed69
package
chat
.
rocket
.
android
.
layouthelper
.
chatroom
.
roomlist
;
import
android.support.annotation.NonNull
;
import
java.util.List
;
import
chat.rocket.core.models.Room
;
public
class
FavoriteRoomListHeader
implements
RoomListHeader
{
private
final
String
title
;
public
FavoriteRoomListHeader
(
String
title
)
{
this
.
title
=
title
;
}
@Override
public
String
getTitle
()
{
return
title
;
}
@Override
public
boolean
owns
(
Room
room
)
{
return
room
.
isFavorite
();
}
@Override
public
boolean
shouldShow
(
@NonNull
List
<
Room
>
roomList
)
{
for
(
int
i
=
0
,
size
=
roomList
.
size
();
i
<
size
;
i
++)
{
if
(
roomList
.
get
(
i
).
isFavorite
())
{
return
true
;
}
}
return
false
;
}
@Override
public
ClickListener
getClickListener
()
{
return
null
;
}
}
app/src/main/res/values/strings.xml
View file @
6d01ed69
<resources>
<string
name=
"app_name"
>
Rocket.Chat+
</string>
<string
name=
"fragment_sidebar_main_favorite_title"
>
FAVORITES
</string>
<string
name=
"fragment_sidebar_main_channels_title"
>
CHANNELS
</string>
<string
name=
"fragment_sidebar_main_direct_messages_title"
>
DIRECT MESSAGES
</string>
<string
name=
"user_status_online"
>
Online
</string>
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/Migration.java
0 → 100644
View file @
6d01ed69
package
chat
.
rocket
.
persistence
.
realm
;
import
io.realm.DynamicRealm
;
import
io.realm.RealmMigration
;
import
io.realm.RealmObjectSchema
;
import
io.realm.RealmSchema
;
public
class
Migration
implements
RealmMigration
{
@Override
public
void
migrate
(
DynamicRealm
dynamicRealm
,
long
oldVersion
,
long
newVersion
)
{
RealmSchema
schema
=
dynamicRealm
.
getSchema
();
if
(
oldVersion
==
0
)
{
RealmObjectSchema
roomSchema
=
schema
.
get
(
"RealmRoom"
);
roomSchema
.
addField
(
"f"
,
boolean
.
class
);
oldVersion
++;
}
}
}
persistence-realm/src/main/java/chat/rocket/persistence/realm/RocketChatPersistenceRealm.java
View file @
6d01ed69
...
...
@@ -15,7 +15,8 @@ public class RocketChatPersistenceRealm {
new
RealmConfiguration
.
Builder
()
.
name
(
"rocket.chat.persistence.realm"
)
.
modules
(
new
RocketChatLibraryModule
())
.
deleteRealmIfMigrationNeeded
()
.
schemaVersion
(
1
)
.
migration
(
new
Migration
())
.
build
());
}
}
persistence-realm/src/main/java/chat/rocket/persistence/realm/models/ddp/RealmRoom.java
View file @
6d01ed69
...
...
@@ -24,6 +24,7 @@ public class RealmRoom extends RealmObject {
public
static
final
String
UNREAD
=
"unread"
;
public
static
final
String
UPDATED_AT
=
"_updatedAt"
;
public
static
final
String
LAST_SEEN
=
"ls"
;
public
static
final
String
FAVORITE
=
"f"
;
public
static
final
String
TYPE_CHANNEL
=
"c"
;
public
static
final
String
TYPE_PRIVATE
=
"p"
;
...
...
@@ -39,6 +40,7 @@ public class RealmRoom extends RealmObject {
private
int
unread
;
private
long
_updatedAt
;
private
long
ls
;
//last seen.
private
boolean
f
;
public
static
JSONObject
customizeJson
(
JSONObject
roomSubscriptionJson
)
throws
JSONException
{
if
(!
roomSubscriptionJson
.
isNull
(
LAST_SEEN
))
{
...
...
@@ -128,6 +130,14 @@ public class RealmRoom extends RealmObject {
this
.
ls
=
ls
;
}
public
boolean
isFavorite
()
{
return
f
;
}
public
void
setFavorite
(
boolean
f
)
{
this
.
f
=
f
;
}
public
Room
asRoom
()
{
return
Room
.
builder
()
.
setId
(
_id
)
...
...
@@ -139,6 +149,7 @@ public class RealmRoom extends RealmObject {
.
setUnread
(
unread
)
.
setUpdatedAt
(
_updatedAt
)
.
setLastSeen
(
ls
)
.
setFavorite
(
f
)
.
build
();
}
}
rocket-chat-core/src/main/java/chat/rocket/core/models/Room.java
View file @
6d01ed69
...
...
@@ -27,6 +27,8 @@ public abstract class Room {
public
abstract
long
getLastSeen
();
public
abstract
boolean
isFavorite
();
public
boolean
isChannel
()
{
return
TYPE_CHANNEL
.
equals
(
getType
());
}
...
...
@@ -64,6 +66,8 @@ public abstract class Room {
public
abstract
Builder
setLastSeen
(
long
lastSeen
);
public
abstract
Builder
setFavorite
(
boolean
favorite
);
public
abstract
Room
build
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment