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
b704af6f
Commit
b704af6f
authored
Mar 21, 2017
by
Tiago Cunha
Committed by
GitHub
Mar 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #241 from RocketChat/feature/show-favorites-grouping
Show favorites grouping on room list
parents
99cacc3a
6d01ed69
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 @
b704af6f
...
@@ -27,6 +27,7 @@ import chat.rocket.android.helper.AbsoluteUrlHelper;
...
@@ -27,6 +27,7 @@ import chat.rocket.android.helper.AbsoluteUrlHelper;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.ChannelRoomListHeader
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.ChannelRoomListHeader
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.DirectMessageRoomListHeader
;
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.RoomListAdapter
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.RoomListHeader
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.RoomListHeader
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.UnreadRoomListHeader
;
import
chat.rocket.android.layouthelper.chatroom.roomlist.UnreadRoomListHeader
;
...
@@ -179,6 +180,10 @@ public class SidebarMainFragment extends AbstractFragment implements SidebarMain
...
@@ -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
(
roomListHeaders
.
add
(
new
ChannelRoomListHeader
(
getString
(
R
.
string
.
fragment_sidebar_main_channels_title
),
getString
(
R
.
string
.
fragment_sidebar_main_channels_title
),
()
->
showAddRoomDialog
(
AddChannelDialogFragment
.
create
(
hostname
))
()
->
showAddRoomDialog
(
AddChannelDialogFragment
.
create
(
hostname
))
...
...
app/src/main/java/chat/rocket/android/layouthelper/chatroom/roomlist/FavoriteRoomListHeader.java
0 → 100644
View file @
b704af6f
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 @
b704af6f
<resources>
<resources>
<string
name=
"app_name"
>
Rocket.Chat+
</string>
<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_channels_title"
>
CHANNELS
</string>
<string
name=
"fragment_sidebar_main_direct_messages_title"
>
DIRECT MESSAGES
</string>
<string
name=
"fragment_sidebar_main_direct_messages_title"
>
DIRECT MESSAGES
</string>
<string
name=
"user_status_online"
>
Online
</string>
<string
name=
"user_status_online"
>
Online
</string>
...
...
persistence-realm/src/main/java/chat/rocket/persistence/realm/Migration.java
0 → 100644
View file @
b704af6f
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 @
b704af6f
...
@@ -15,7 +15,8 @@ public class RocketChatPersistenceRealm {
...
@@ -15,7 +15,8 @@ public class RocketChatPersistenceRealm {
new
RealmConfiguration
.
Builder
()
new
RealmConfiguration
.
Builder
()
.
name
(
"rocket.chat.persistence.realm"
)
.
name
(
"rocket.chat.persistence.realm"
)
.
modules
(
new
RocketChatLibraryModule
())
.
modules
(
new
RocketChatLibraryModule
())
.
deleteRealmIfMigrationNeeded
()
.
schemaVersion
(
1
)
.
migration
(
new
Migration
())
.
build
());
.
build
());
}
}
}
}
persistence-realm/src/main/java/chat/rocket/persistence/realm/models/ddp/RealmRoom.java
View file @
b704af6f
...
@@ -24,6 +24,7 @@ public class RealmRoom extends RealmObject {
...
@@ -24,6 +24,7 @@ public class RealmRoom extends RealmObject {
public
static
final
String
UNREAD
=
"unread"
;
public
static
final
String
UNREAD
=
"unread"
;
public
static
final
String
UPDATED_AT
=
"_updatedAt"
;
public
static
final
String
UPDATED_AT
=
"_updatedAt"
;
public
static
final
String
LAST_SEEN
=
"ls"
;
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_CHANNEL
=
"c"
;
public
static
final
String
TYPE_PRIVATE
=
"p"
;
public
static
final
String
TYPE_PRIVATE
=
"p"
;
...
@@ -39,6 +40,7 @@ public class RealmRoom extends RealmObject {
...
@@ -39,6 +40,7 @@ public class RealmRoom extends RealmObject {
private
int
unread
;
private
int
unread
;
private
long
_updatedAt
;
private
long
_updatedAt
;
private
long
ls
;
//last seen.
private
long
ls
;
//last seen.
private
boolean
f
;
public
static
JSONObject
customizeJson
(
JSONObject
roomSubscriptionJson
)
throws
JSONException
{
public
static
JSONObject
customizeJson
(
JSONObject
roomSubscriptionJson
)
throws
JSONException
{
if
(!
roomSubscriptionJson
.
isNull
(
LAST_SEEN
))
{
if
(!
roomSubscriptionJson
.
isNull
(
LAST_SEEN
))
{
...
@@ -128,6 +130,14 @@ public class RealmRoom extends RealmObject {
...
@@ -128,6 +130,14 @@ public class RealmRoom extends RealmObject {
this
.
ls
=
ls
;
this
.
ls
=
ls
;
}
}
public
boolean
isFavorite
()
{
return
f
;
}
public
void
setFavorite
(
boolean
f
)
{
this
.
f
=
f
;
}
public
Room
asRoom
()
{
public
Room
asRoom
()
{
return
Room
.
builder
()
return
Room
.
builder
()
.
setId
(
_id
)
.
setId
(
_id
)
...
@@ -139,6 +149,7 @@ public class RealmRoom extends RealmObject {
...
@@ -139,6 +149,7 @@ public class RealmRoom extends RealmObject {
.
setUnread
(
unread
)
.
setUnread
(
unread
)
.
setUpdatedAt
(
_updatedAt
)
.
setUpdatedAt
(
_updatedAt
)
.
setLastSeen
(
ls
)
.
setLastSeen
(
ls
)
.
setFavorite
(
f
)
.
build
();
.
build
();
}
}
}
}
rocket-chat-core/src/main/java/chat/rocket/core/models/Room.java
View file @
b704af6f
...
@@ -27,6 +27,8 @@ public abstract class Room {
...
@@ -27,6 +27,8 @@ public abstract class Room {
public
abstract
long
getLastSeen
();
public
abstract
long
getLastSeen
();
public
abstract
boolean
isFavorite
();
public
boolean
isChannel
()
{
public
boolean
isChannel
()
{
return
TYPE_CHANNEL
.
equals
(
getType
());
return
TYPE_CHANNEL
.
equals
(
getType
());
}
}
...
@@ -64,6 +66,8 @@ public abstract class Room {
...
@@ -64,6 +66,8 @@ public abstract class Room {
public
abstract
Builder
setLastSeen
(
long
lastSeen
);
public
abstract
Builder
setLastSeen
(
long
lastSeen
);
public
abstract
Builder
setFavorite
(
boolean
favorite
);
public
abstract
Room
build
();
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