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
1ceae466
Commit
1ceae466
authored
Apr 04, 2019
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Saves the sorting and grouping preferences for each server.
parent
e463622d
Changes
22
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
406 additions
and
224 deletions
+406
-224
MessageInfoFragment.kt
.../rocket/android/chatinformation/ui/MessageInfoFragment.kt
+2
-1
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+2
-1
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+16
-15
ChatRoomsView.kt
...at/rocket/android/chatrooms/presentation/ChatRoomsView.kt
+15
-4
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+114
-121
ActivityBuilder.kt
...java/chat/rocket/android/dagger/module/ActivityBuilder.kt
+2
-0
AppModule.kt
.../main/java/chat/rocket/android/dagger/module/AppModule.kt
+19
-8
Constants.kt
app/src/main/java/chat/rocket/android/helper/Constants.kt
+0
-18
SharedPreferenceHelper.kt
...java/chat/rocket/android/helper/SharedPreferenceHelper.kt
+0
-48
MainNavigator.kt
...va/chat/rocket/android/main/presentation/MainNavigator.kt
+1
-1
ProfileFragment.kt
...in/java/chat/rocket/android/profile/ui/ProfileFragment.kt
+1
-1
SortingAndGroupingInteractor.kt
...ket/android/server/domain/SortingAndGroupingInteractor.kt
+32
-0
SortingAndGroupingRepository.kt
...ket/android/server/domain/SortingAndGroupingRepository.kt
+20
-0
SharedPrefsSortingAndGroupingRepository.kt
...nfraestructure/SharedPrefsSortingAndGroupingRepository.kt
+39
-0
ServersBottomSheetFragmentModule.kt
...et/android/servers/di/ServersBottomSheetFragmentModule.kt
+1
-2
SortingAndGroupingBottomSheetFragmentModule.kt
...rouping/di/SortingAndGroupingBottomSheetFragmentModule.kt
+16
-0
SortingAndGroupingBottomSheetFragmentProvider.kt
...uping/di/SortingAndGroupingBottomSheetFragmentProvider.kt
+15
-0
SortingAndGroupingPresenter.kt
...ngandgrouping/presentation/SortingAndGroupingPresenter.kt
+38
-0
SortingAndGroupingView.kt
...sortingandgrouping/presentation/SortingAndGroupingView.kt
+19
-0
SortingAndGroupingBottomSheetFragment.kt
...ngandgrouping/ui/SortingAndGroupingBottomSheetFragment.kt
+52
-3
app_bar_chat_rooms.xml
app/src/main/res/layout/app_bar_chat_rooms.xml
+1
-0
bottom_sheet_fragment_sort_by.xml
app/src/main/res/layout/bottom_sheet_fragment_sort_by.xml
+1
-1
No files found.
app/src/main/java/chat/rocket/android/chatinformation/ui/MessageInfoFragment.kt
View file @
1ceae466
...
@@ -44,7 +44,6 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
...
@@ -44,7 +44,6 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
setHasOptionsMenu
(
true
)
val
bundle
=
arguments
val
bundle
=
arguments
if
(
bundle
!=
null
)
{
if
(
bundle
!=
null
)
{
...
@@ -52,6 +51,8 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
...
@@ -52,6 +51,8 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
}
else
{
}
else
{
requireNotNull
(
bundle
)
{
"no arguments supplied when the fragment was instantiated"
}
requireNotNull
(
bundle
)
{
"no arguments supplied when the fragment was instantiated"
}
}
}
setHasOptionsMenu
(
true
)
}
}
override
fun
onCreateView
(
override
fun
onCreateView
(
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
1ceae466
...
@@ -268,7 +268,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -268,7 +268,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
setHasOptionsMenu
(
true
)
arguments
?.
run
{
arguments
?.
run
{
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
...
@@ -292,6 +291,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -292,6 +291,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
navigator
=
navigator
,
navigator
=
navigator
,
analyticsManager
=
analyticsManager
analyticsManager
=
analyticsManager
)
)
setHasOptionsMenu
(
true
)
}
}
override
fun
onCreateView
(
override
fun
onCreateView
(
...
...
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
1ceae466
...
@@ -9,20 +9,18 @@ import chat.rocket.android.db.model.ChatRoomEntity
...
@@ -9,20 +9,18 @@ import chat.rocket.android.db.model.ChatRoomEntity
import
chat.rocket.android.helper.UserHelper
import
chat.rocket.android.helper.UserHelper
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.main.presentation.MainNavigator
import
chat.rocket.android.main.presentation.MainNavigator
import
chat.rocket.android.server.domain.GetAccountsInteractor
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.SortingAndGroupingInteractor
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.server.domain.useSpecialCharsOnRoom
import
chat.rocket.android.server.domain.useSpecialCharsOnRoom
import
chat.rocket.android.server.infraestructure.ConnectionManager
import
chat.rocket.android.server.infraestructure.ConnectionManager
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.retryDB
import
chat.rocket.android.util.retryDB
import
chat.rocket.android.util.retryIO
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.RocketChatAuthException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.RoomType
import
chat.rocket.common.model.User
import
chat.rocket.common.model.User
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.internal.realtime.createDirectMessage
import
chat.rocket.core.internal.realtime.createDirectMessage
import
chat.rocket.core.internal.rest.me
import
chat.rocket.core.internal.rest.me
import
chat.rocket.core.internal.rest.show
import
chat.rocket.core.internal.rest.show
...
@@ -38,7 +36,7 @@ class ChatRoomsPresenter @Inject constructor(
...
@@ -38,7 +36,7 @@ class ChatRoomsPresenter @Inject constructor(
private
val
strategy
:
CancelStrategy
,
private
val
strategy
:
CancelStrategy
,
private
val
navigator
:
MainNavigator
,
private
val
navigator
:
MainNavigator
,
@Named
(
"currentServer"
)
private
val
currentServer
:
String
,
@Named
(
"currentServer"
)
private
val
currentServer
:
String
,
private
val
getAccountsInteractor
:
GetAccounts
Interactor
,
private
val
sortingAndGroupingInteractor
:
SortingAndGrouping
Interactor
,
private
val
dbManager
:
DatabaseManager
,
private
val
dbManager
:
DatabaseManager
,
manager
:
ConnectionManager
,
manager
:
ConnectionManager
,
private
val
localRepository
:
LocalRepository
,
private
val
localRepository
:
LocalRepository
,
...
@@ -52,33 +50,38 @@ class ChatRoomsPresenter @Inject constructor(
...
@@ -52,33 +50,38 @@ class ChatRoomsPresenter @Inject constructor(
fun
toSettings
()
=
navigator
.
toSettings
()
fun
toSettings
()
=
navigator
.
toSettings
()
fun
getCurrentServerName
()
{
fun
getCurrentServerName
()
=
view
.
setupToolbar
(
currentServer
)
view
.
setupToolbar
(
currentServer
)
fun
getSortingAndGroupingPreferences
()
{
with
(
sortingAndGroupingInteractor
)
{
view
.
setupSortingAndGrouping
(
getSortByName
(
currentServer
),
getUnreadOnTop
(
currentServer
),
getGroupByType
(
currentServer
),
getGroupByFavorites
(
currentServer
)
)
}
}
}
fun
loadChatRoom
(
roomId
:
String
)
{
fun
loadChatRoom
(
roomId
:
String
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
view
.
showLoadingRoom
(
""
)
try
{
try
{
val
room
=
dbManager
.
getRoom
(
roomId
)
val
room
=
dbManager
.
getRoom
(
roomId
)
if
(
room
!=
null
)
{
if
(
room
!=
null
)
{
loadChatRoom
(
room
.
chatRoom
,
true
)
loadChatRoom
(
room
.
chatRoom
,
true
)
}
else
{
}
else
{
Timber
.
d
(
"Error loading channel"
)
Timber
.
e
(
"Error loading channel"
)
view
.
showGenericErrorMessage
()
view
.
showGenericErrorMessage
()
}
}
}
catch
(
ex
:
Exception
)
{
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error loading channel"
)
Timber
.
e
(
ex
,
"Error loading channel"
)
view
.
showGenericErrorMessage
()
view
.
showGenericErrorMessage
()
}
finally
{
view
.
hideLoadingRoom
()
}
}
}
}
}
}
fun
loadChatRoom
(
chatRoom
:
RoomUiModel
)
{
fun
loadChatRoom
(
chatRoom
:
RoomUiModel
)
{
launchUI
(
strategy
)
{
launchUI
(
strategy
)
{
view
.
showLoadingRoom
(
chatRoom
.
name
)
try
{
try
{
val
room
=
retryDB
(
"getRoom(${chatRoom.id}"
)
{
dbManager
.
getRoom
(
chatRoom
.
id
)
}
val
room
=
retryDB
(
"getRoom(${chatRoom.id}"
)
{
dbManager
.
getRoom
(
chatRoom
.
id
)
}
if
(
room
!=
null
)
{
if
(
room
!=
null
)
{
...
@@ -98,10 +101,8 @@ class ChatRoomsPresenter @Inject constructor(
...
@@ -98,10 +101,8 @@ class ChatRoomsPresenter @Inject constructor(
}
}
}
}
}
catch
(
ex
:
Exception
)
{
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error loading channel"
)
Timber
.
e
(
ex
,
"Error loading channel"
)
view
.
showGenericErrorMessage
()
view
.
showGenericErrorMessage
()
}
finally
{
view
.
hideLoadingRoom
()
}
}
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsView.kt
View file @
1ceae466
...
@@ -2,7 +2,6 @@ package chat.rocket.android.chatrooms.presentation
...
@@ -2,7 +2,6 @@ package chat.rocket.android.chatrooms.presentation
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.LoadingView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.android.core.behaviours.MessageView
import
chat.rocket.android.server.domain.model.Account
interface
ChatRoomsView
:
LoadingView
,
MessageView
{
interface
ChatRoomsView
:
LoadingView
,
MessageView
{
...
@@ -13,7 +12,19 @@ interface ChatRoomsView : LoadingView, MessageView {
...
@@ -13,7 +12,19 @@ interface ChatRoomsView : LoadingView, MessageView {
*/
*/
fun
setupToolbar
(
serverName
:
String
)
fun
setupToolbar
(
serverName
:
String
)
fun
showLoadingRoom
(
name
:
CharSequence
)
/**
* Setups the sorting and grouping in the bases of the user preference for
fun
hideLoadingRoom
()
* the current logged in server.
*
* @param isSortByName True if sorting by name, false otherwise.
* @param isUnreadOnTop True if grouping by unread on top, false otherwise.
* @param isGroupByType True if grouping by type , false otherwise.
* @param isGroupByFavorites True if grouping by favorites, false otherwise.
*/
fun
setupSortingAndGrouping
(
isSortByName
:
Boolean
,
isUnreadOnTop
:
Boolean
,
isGroupByType
:
Boolean
,
isGroupByFavorites
:
Boolean
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
1ceae466
This diff is collapsed.
Click to expand it.
app/src/main/java/chat/rocket/android/dagger/module/ActivityBuilder.kt
View file @
1ceae466
...
@@ -37,6 +37,7 @@ import chat.rocket.android.servers.di.ServersBottomSheetFragmentProvider
...
@@ -37,6 +37,7 @@ import chat.rocket.android.servers.di.ServersBottomSheetFragmentProvider
import
chat.rocket.android.settings.di.SettingsFragmentProvider
import
chat.rocket.android.settings.di.SettingsFragmentProvider
import
chat.rocket.android.settings.password.di.PasswordFragmentProvider
import
chat.rocket.android.settings.password.di.PasswordFragmentProvider
import
chat.rocket.android.settings.password.ui.PasswordActivity
import
chat.rocket.android.settings.password.ui.PasswordActivity
import
chat.rocket.android.sortingandgrouping.di.SortingAndGroupingBottomSheetFragmentProvider
import
chat.rocket.android.userdetails.di.UserDetailsFragmentProvider
import
chat.rocket.android.userdetails.di.UserDetailsFragmentProvider
import
chat.rocket.android.videoconference.di.VideoConferenceModule
import
chat.rocket.android.videoconference.di.VideoConferenceModule
import
chat.rocket.android.videoconference.ui.VideoConferenceActivity
import
chat.rocket.android.videoconference.ui.VideoConferenceActivity
...
@@ -67,6 +68,7 @@ abstract class ActivityBuilder {
...
@@ -67,6 +68,7 @@ abstract class ActivityBuilder {
modules
=
[
MainModule
::
class
,
modules
=
[
MainModule
::
class
,
ChatRoomsFragmentProvider
::
class
,
ChatRoomsFragmentProvider
::
class
,
ServersBottomSheetFragmentProvider
::
class
,
ServersBottomSheetFragmentProvider
::
class
,
SortingAndGroupingBottomSheetFragmentProvider
::
class
,
CreateChannelProvider
::
class
,
CreateChannelProvider
::
class
,
ProfileFragmentProvider
::
class
,
ProfileFragmentProvider
::
class
,
SettingsFragmentProvider
::
class
,
SettingsFragmentProvider
::
class
,
...
...
app/src/main/java/chat/rocket/android/dagger/module/AppModule.kt
View file @
1ceae466
...
@@ -27,23 +27,23 @@ import chat.rocket.android.push.PushManager
...
@@ -27,23 +27,23 @@ import chat.rocket.android.push.PushManager
import
chat.rocket.android.server.domain.AccountsRepository
import
chat.rocket.android.server.domain.AccountsRepository
import
chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import
chat.rocket.android.server.domain.AnalyticsTrackingInteractor
import
chat.rocket.android.server.domain.AnalyticsTrackingRepository
import
chat.rocket.android.server.domain.AnalyticsTrackingRepository
import
chat.rocket.android.server.domain.BasicAuthRepository
import
chat.rocket.android.server.domain.ChatRoomsRepository
import
chat.rocket.android.server.domain.ChatRoomsRepository
import
chat.rocket.android.server.domain.CurrentServerRepository
import
chat.rocket.android.server.domain.CurrentServerRepository
import
chat.rocket.android.server.domain.GetAccountInteractor
import
chat.rocket.android.server.domain.GetAccountInteractor
import
chat.rocket.android.server.domain.GetAccountsInteractor
import
chat.rocket.android.server.domain.GetAccountsInteractor
import
chat.rocket.android.server.domain.GetBasicAuthInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
import
chat.rocket.android.server.domain.JobSchedulerInteractor
import
chat.rocket.android.server.domain.JobSchedulerInteractor
import
chat.rocket.android.server.domain.MessagesRepository
import
chat.rocket.android.server.domain.MessagesRepository
import
chat.rocket.android.server.domain.MultiServerTokenRepository
import
chat.rocket.android.server.domain.MultiServerTokenRepository
import
chat.rocket.android.server.domain.PermissionsRepository
import
chat.rocket.android.server.domain.PermissionsRepository
import
chat.rocket.android.server.domain.SaveBasicAuthInteractor
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.SortingAndGroupingRepository
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.domain.UsersRepository
import
chat.rocket.android.server.domain.UsersRepository
import
chat.rocket.android.server.domain.BasicAuthRepository
import
chat.rocket.android.server.domain.GetBasicAuthInteractor
import
chat.rocket.android.server.domain.SaveBasicAuthInteractor
import
chat.rocket.android.server.infraestructure.SharedPrefsBasicAuthRepository
import
chat.rocket.android.server.infraestructure.DatabaseMessageMapper
import
chat.rocket.android.server.infraestructure.DatabaseMessageMapper
import
chat.rocket.android.server.infraestructure.DatabaseMessagesRepository
import
chat.rocket.android.server.infraestructure.DatabaseMessagesRepository
import
chat.rocket.android.server.infraestructure.JobSchedulerInteractorImpl
import
chat.rocket.android.server.infraestructure.JobSchedulerInteractorImpl
...
@@ -53,11 +53,13 @@ import chat.rocket.android.server.infraestructure.SharedPreferencesAccountsRepos
...
@@ -53,11 +53,13 @@ import chat.rocket.android.server.infraestructure.SharedPreferencesAccountsRepos
import
chat.rocket.android.server.infraestructure.SharedPreferencesPermissionsRepository
import
chat.rocket.android.server.infraestructure.SharedPreferencesPermissionsRepository
import
chat.rocket.android.server.infraestructure.SharedPreferencesSettingsRepository
import
chat.rocket.android.server.infraestructure.SharedPreferencesSettingsRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsAnalyticsTrackingRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsAnalyticsTrackingRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsBasicAuthRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsConnectingServerRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsConnectingServerRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsCurrentServerRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsCurrentServerRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsSortingAndGroupingRepository
import
chat.rocket.android.util.AppJsonAdapterFactory
import
chat.rocket.android.util.AppJsonAdapterFactory
import
chat.rocket.android.util.HttpLoggingInterceptor
import
chat.rocket.android.util.BasicAuthenticatorInterceptor
import
chat.rocket.android.util.BasicAuthenticatorInterceptor
import
chat.rocket.android.util.HttpLoggingInterceptor
import
chat.rocket.android.util.TimberLogger
import
chat.rocket.android.util.TimberLogger
import
chat.rocket.common.internal.FallbackSealedClassJsonAdapter
import
chat.rocket.common.internal.FallbackSealedClassJsonAdapter
import
chat.rocket.common.internal.ISO8601Date
import
chat.rocket.common.internal.ISO8601Date
...
@@ -123,7 +125,10 @@ class AppModule {
...
@@ -123,7 +125,10 @@ class AppModule {
@Provides
@Provides
@Singleton
@Singleton
fun
provideOkHttpClient
(
logger
:
HttpLoggingInterceptor
,
basicAuthenticator
:
BasicAuthenticatorInterceptor
):
OkHttpClient
{
fun
provideOkHttpClient
(
logger
:
HttpLoggingInterceptor
,
basicAuthenticator
:
BasicAuthenticatorInterceptor
):
OkHttpClient
{
return
OkHttpClient
.
Builder
()
return
OkHttpClient
.
Builder
()
.
addInterceptor
(
logger
)
.
addInterceptor
(
logger
)
.
addInterceptor
(
basicAuthenticator
)
.
addInterceptor
(
basicAuthenticator
)
...
@@ -194,6 +199,12 @@ class AppModule {
...
@@ -194,6 +199,12 @@ class AppModule {
return
SharedPrefsAnalyticsTrackingRepository
(
prefs
)
return
SharedPrefsAnalyticsTrackingRepository
(
prefs
)
}
}
@Provides
@Singleton
fun
provideSortingAndGroupingRepository
(
prefs
:
SharedPreferences
):
SortingAndGroupingRepository
{
return
SharedPrefsSortingAndGroupingRepository
(
prefs
)
}
@Provides
@Provides
@ForAuthentication
@ForAuthentication
fun
provideConnectingServerRepository
(
prefs
:
SharedPreferences
):
CurrentServerRepository
{
fun
provideConnectingServerRepository
(
prefs
:
SharedPreferences
):
CurrentServerRepository
{
...
@@ -293,7 +304,7 @@ class AppModule {
...
@@ -293,7 +304,7 @@ class AppModule {
@Provides
@Provides
@Singleton
@Singleton
fun
provideBasicAuthRepository
(
fun
provideBasicAuthRepository
(
preferences
:
SharedPreferences
,
preferences
:
SharedPreferences
,
moshi
:
Moshi
moshi
:
Moshi
):
BasicAuthRepository
=
):
BasicAuthRepository
=
...
...
app/src/main/java/chat/rocket/android/helper/Constants.kt
deleted
100644 → 0
View file @
e463622d
package
chat.rocket.android.helper
object
Constants
{
const
val
CHATROOM_SORT_TYPE_KEY
:
String
=
"chatroom_sort_type"
const
val
CHATROOM_GROUP_BY_TYPE_KEY
:
String
=
"chatroom_group_by_type"
const
val
CHATROOM_GROUP_FAVOURITES_KEY
:
String
=
"chatroom_group_favourites"
//Used to sort chat rooms
const
val
CHATROOM_CHANNEL
=
0
const
val
CHATROOM_PRIVATE_GROUP
=
1
const
val
CHATROOM_DM
=
2
const
val
CHATROOM_LIVE_CHAT
=
3
}
object
ChatRoomsSortOrder
{
const
val
ALPHABETICAL
:
Int
=
0
const
val
ACTIVITY
:
Int
=
1
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/helper/SharedPreferenceHelper.kt
deleted
100644 → 0
View file @
e463622d
package
chat.rocket.android.helper
import
android.content.SharedPreferences
import
android.preference.PreferenceManager
import
chat.rocket.android.app.RocketChatApplication
object
SharedPreferenceHelper
{
private
var
sharedPreferences
:
SharedPreferences
=
PreferenceManager
.
getDefaultSharedPreferences
(
RocketChatApplication
.
getAppContext
())
private
var
editor
:
SharedPreferences
.
Editor
?
=
sharedPreferences
.
edit
()
//Add more methods for other types if needed
fun
putInt
(
key
:
String
,
value
:
Int
)
{
editor
!!
.
putInt
(
key
,
value
).
apply
()
}
fun
getInt
(
key
:
String
,
defaultValue
:
Int
):
Int
{
return
sharedPreferences
.
getInt
(
key
,
defaultValue
)
}
fun
putLong
(
key
:
String
,
value
:
Long
)
{
editor
!!
.
putLong
(
key
,
value
).
apply
()
}
fun
getLong
(
key
:
String
,
defaultValue
:
Long
):
Long
{
return
sharedPreferences
.
getLong
(
key
,
defaultValue
)
}
fun
putString
(
key
:
String
,
value
:
String
)
{
editor
!!
.
putString
(
key
,
value
).
apply
()
}
fun
getString
(
key
:
String
,
defaultValue
:
String
):
String
?
{
return
sharedPreferences
.
getString
(
key
,
defaultValue
)
}
fun
putBoolean
(
key
:
String
,
value
:
Boolean
)
{
editor
!!
.
putBoolean
(
key
,
value
).
apply
()
}
fun
getBoolean
(
key
:
String
,
defaultValue
:
Boolean
):
Boolean
{
return
sharedPreferences
.
getBoolean
(
key
,
defaultValue
)
}
fun
remove
(
key
:
String
)
{
editor
!!
.
remove
(
key
).
apply
()
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/main/presentation/MainNavigator.kt
View file @
1ceae466
...
@@ -21,7 +21,7 @@ class MainNavigator(internal val activity: MainActivity) {
...
@@ -21,7 +21,7 @@ class MainNavigator(internal val activity: MainActivity) {
fun
toChatList
(
chatRoomId
:
String
?
=
null
)
{
fun
toChatList
(
chatRoomId
:
String
?
=
null
)
{
activity
.
addFragment
(
TAG_CHAT_ROOMS_FRAGMENT
,
R
.
id
.
fragment_container
)
{
activity
.
addFragment
(
TAG_CHAT_ROOMS_FRAGMENT
,
R
.
id
.
fragment_container
)
{
ChatRoomsFragment
.
newInstance
(
chatRoomId
)
chat
.
rocket
.
android
.
chatrooms
.
ui
.
newInstance
(
chatRoomId
)
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/profile/ui/ProfileFragment.kt
View file @
1ceae466
...
@@ -63,8 +63,8 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -63,8 +63,8 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
}
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
setHasOptionsMenu
(
true
)
setHasOptionsMenu
(
true
)
}
}
...
...
app/src/main/java/chat/rocket/android/server/domain/SortingAndGroupingInteractor.kt
0 → 100644
View file @
1ceae466
package
chat.rocket.android.server.domain
import
javax.inject.Inject
class
SortingAndGroupingInteractor
@Inject
constructor
(
val
repository
:
SortingAndGroupingRepository
)
{
fun
save
(
currentServerUrl
:
String
,
isSortByName
:
Boolean
,
isUnreadOnTop
:
Boolean
,
isGroupByType
:
Boolean
,
isGroupByFavorites
:
Boolean
)
=
repository
.
save
(
currentServerUrl
,
isSortByName
,
isUnreadOnTop
,
isGroupByType
,
isGroupByFavorites
)
fun
getSortByName
(
currentServerUrl
:
String
):
Boolean
=
repository
.
getSortByName
(
currentServerUrl
)
fun
getUnreadOnTop
(
currentServerUrl
:
String
):
Boolean
=
repository
.
getUnreadOnTop
(
currentServerUrl
)
fun
getGroupByType
(
currentServerUrl
:
String
):
Boolean
=
repository
.
getGroupByType
(
currentServerUrl
)
fun
getGroupByFavorites
(
currentServerUrl
:
String
):
Boolean
=
repository
.
getGroupByFavorites
(
currentServerUrl
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/domain/SortingAndGroupingRepository.kt
0 → 100644
View file @
1ceae466
package
chat.rocket.android.server.domain
interface
SortingAndGroupingRepository
{
fun
save
(
currentServerUrl
:
String
,
isSortByName
:
Boolean
,
isUnreadOnTop
:
Boolean
,
isGroupByType
:
Boolean
,
isGroupByFavorites
:
Boolean
)
fun
getSortByName
(
currentServerUrl
:
String
):
Boolean
fun
getUnreadOnTop
(
currentServerUrl
:
String
):
Boolean
fun
getGroupByType
(
currentServerUrl
:
String
):
Boolean
fun
getGroupByFavorites
(
currentServerUrl
:
String
):
Boolean
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/infraestructure/SharedPrefsSortingAndGroupingRepository.kt
0 → 100644
View file @
1ceae466
package
chat.rocket.android.server.infraestructure
import
android.content.SharedPreferences
import
chat.rocket.android.server.domain.SortingAndGroupingRepository
private
const
val
SORT_BY_NAME_KEY
=
"SORT_BY_NAME_KEY"
private
const
val
UNREAD_ON_TOP_KEY
=
"UNREAD_ON_TOP_KEY"
private
const
val
GROUP_BY_TYPE_KEY
=
"GROUP_BY_TYPE_KEY"
private
const
val
GROUP_BY_FAVORITES_KEY
=
"GROUP_BY_FAVORITES_KEY"
class
SharedPrefsSortingAndGroupingRepository
(
private
val
preferences
:
SharedPreferences
)
:
SortingAndGroupingRepository
{
override
fun
save
(
currentServerUrl
:
String
,
isSortByName
:
Boolean
,
isUnreadOnTop
:
Boolean
,
isGroupByType
:
Boolean
,
isGroupByFavorites
:
Boolean
)
{
preferences
.
edit
().
putBoolean
(
SORT_BY_NAME_KEY
+
currentServerUrl
,
isSortByName
).
apply
()
preferences
.
edit
().
putBoolean
(
UNREAD_ON_TOP_KEY
+
currentServerUrl
,
isUnreadOnTop
).
apply
()
preferences
.
edit
().
putBoolean
(
GROUP_BY_TYPE_KEY
+
currentServerUrl
,
isGroupByType
).
apply
()
preferences
.
edit
().
putBoolean
(
GROUP_BY_FAVORITES_KEY
+
currentServerUrl
,
isGroupByFavorites
)
.
apply
()
}
override
fun
getSortByName
(
currentServerUrl
:
String
):
Boolean
=
preferences
.
getBoolean
(
SORT_BY_NAME_KEY
+
currentServerUrl
,
false
)
override
fun
getUnreadOnTop
(
currentServerUrl
:
String
):
Boolean
=
preferences
.
getBoolean
(
UNREAD_ON_TOP_KEY
+
currentServerUrl
,
false
)
override
fun
getGroupByType
(
currentServerUrl
:
String
):
Boolean
=
preferences
.
getBoolean
(
GROUP_BY_TYPE_KEY
+
currentServerUrl
,
false
)
override
fun
getGroupByFavorites
(
currentServerUrl
:
String
):
Boolean
=
preferences
.
getBoolean
(
GROUP_BY_FAVORITES_KEY
+
currentServerUrl
,
false
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/servers/di/ServersBottomSheetFragmentModule.kt
View file @
1ceae466
...
@@ -11,6 +11,5 @@ class ServersBottomSheetFragmentModule {
...
@@ -11,6 +11,5 @@ class ServersBottomSheetFragmentModule {
@Provides
@Provides
@PerFragment
@PerFragment
fun
membersView
(
frag
:
ServersBottomSheetFragment
):
ServersView
=
frag
fun
serversView
(
frag
:
ServersBottomSheetFragment
):
ServersView
=
frag
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/sortingandgrouping/di/SortingAndGroupingBottomSheetFragmentModule.kt
0 → 100644
View file @
1ceae466
package
chat.rocket.android.sortingandgrouping.di
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.sortingandgrouping.presentation.SortingAndGroupingView
import
chat.rocket.android.sortingandgrouping.ui.SortingAndGroupingBottomSheetFragment
import
dagger.Module
import
dagger.Provides
@Module
class
SortingAndGroupingBottomSheetFragmentModule
{
@Provides
@PerFragment
fun
sortingAndGroupingView
(
frag
:
SortingAndGroupingBottomSheetFragment
):
SortingAndGroupingView
=
frag
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/sortingandgrouping/di/SortingAndGroupingBottomSheetFragmentProvider.kt
0 → 100644
View file @
1ceae466
package
chat.rocket.android.sortingandgrouping.di
import
chat.rocket.android.dagger.scope.PerFragment
import
chat.rocket.android.sortingandgrouping.ui.SortingAndGroupingBottomSheetFragment
import
dagger.Module
import
dagger.android.ContributesAndroidInjector
@Module
abstract
class
SortingAndGroupingBottomSheetFragmentProvider
{
@ContributesAndroidInjector
(
modules
=
[
SortingAndGroupingBottomSheetFragmentModule
::
class
])
@PerFragment
abstract
fun
provideSortingAndGroupingBottomSheetFragment
():
SortingAndGroupingBottomSheetFragment
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/sortingandgrouping/presentation/SortingAndGroupingPresenter.kt
0 → 100644
View file @
1ceae466
package
chat.rocket.android.sortingandgrouping.presentation
import
chat.rocket.android.server.domain.SortingAndGroupingInteractor
import
javax.inject.Inject
import
javax.inject.Named
class
SortingAndGroupingPresenter
@Inject
constructor
(
private
val
view
:
SortingAndGroupingView
,
private
val
sortingAndGroupingInteractor
:
SortingAndGroupingInteractor
,
@Named
(
"currentServer"
)
private
val
currentServerUrl
:
String
)
{
fun
getSortingAndGroupingPreferences
()
{
with
(
sortingAndGroupingInteractor
)
{
view
.
showSortingAndGroupingPreferences
(
getSortByName
(
currentServerUrl
),
getUnreadOnTop
(
currentServerUrl
),
getGroupByType
(
currentServerUrl
),
getGroupByFavorites
(
currentServerUrl
)
)
}
}
fun
saveSortingAndGroupingPreferences
(
isSortByName
:
Boolean
,
isUnreadOnTop
:
Boolean
,
isGroupByType
:
Boolean
,
isGroupByFavorites
:
Boolean
)
{
sortingAndGroupingInteractor
.
save
(
currentServerUrl
,
isSortByName
,
isUnreadOnTop
,
isGroupByType
,
isGroupByFavorites
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/sortingandgrouping/presentation/SortingAndGroupingView.kt
0 → 100644
View file @
1ceae466
package
chat.rocket.android.sortingandgrouping.presentation
interface
SortingAndGroupingView
{
/**
* Shows the sorting and grouping preferences for the current logged in server.
*
* @param isSortByName True if sorting by name, false otherwise.
* @param isUnreadOnTop True if grouping by unread on top, false otherwise.
* @param isGroupByType True if grouping by type , false otherwise.
* @param isGroupByFavorites True if grouping by favorites, false otherwise.
*/
fun
showSortingAndGroupingPreferences
(
isSortByName
:
Boolean
,
isUnreadOnTop
:
Boolean
,
isGroupByType
:
Boolean
,
isGroupByFavorites
:
Boolean
)
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/
chatrooms/ui/SortBy
BottomSheetFragment.kt
→
app/src/main/java/chat/rocket/android/
sortingandgrouping/ui/SortingAndGrouping
BottomSheetFragment.kt
View file @
1ceae466
package
chat.rocket.android.
chatrooms
.ui
package
chat.rocket.android.
sortingandgrouping
.ui
import
DrawableHelper
import
DrawableHelper
import
android.content.DialogInterface
import
android.os.Bundle
import
android.os.Bundle
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
...
@@ -8,12 +9,20 @@ import android.view.ViewGroup
...
@@ -8,12 +9,20 @@ import android.view.ViewGroup
import
android.widget.TextView
import
android.widget.TextView
import
androidx.annotation.DrawableRes
import
androidx.annotation.DrawableRes
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.chatrooms.ui.ChatRoomsFragment
import
chat.rocket.android.chatrooms.ui.TAG_CHAT_ROOMS_FRAGMENT
import
chat.rocket.android.sortingandgrouping.presentation.SortingAndGroupingPresenter
import
chat.rocket.android.sortingandgrouping.presentation.SortingAndGroupingView
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
import
com.google.android.material.bottomsheet.BottomSheetDialogFragment
import
dagger.android.support.AndroidSupportInjection
import
kotlinx.android.synthetic.main.bottom_sheet_fragment_sort_by.*
import
kotlinx.android.synthetic.main.bottom_sheet_fragment_sort_by.*
import
javax.inject.Inject
const
val
TAG
=
"Sort
By
BottomSheetFragment"
const
val
TAG
=
"Sort
ingAndGrouping
BottomSheetFragment"
class
SortByBottomSheetFragment
:
BottomSheetDialogFragment
()
{
class
SortingAndGroupingBottomSheetFragment
:
BottomSheetDialogFragment
(),
SortingAndGroupingView
{
@Inject
lateinit
var
presenter
:
SortingAndGroupingPresenter
private
var
isSortByName
=
false
private
var
isSortByName
=
false
private
var
isUnreadOnTop
=
false
private
var
isUnreadOnTop
=
false
private
var
isGroupByType
=
false
private
var
isGroupByType
=
false
...
@@ -27,6 +36,11 @@ class SortByBottomSheetFragment : BottomSheetDialogFragment() {
...
@@ -27,6 +36,11 @@ class SortByBottomSheetFragment : BottomSheetDialogFragment() {
private
val
groupByTypeDrawable
by
lazy
{
R
.
drawable
.
ic_group_by_type_20dp
}
private
val
groupByTypeDrawable
by
lazy
{
R
.
drawable
.
ic_group_by_type_20dp
}
private
val
groupByFavoritesDrawable
by
lazy
{
R
.
drawable
.
ic_favorites_20dp
}
private
val
groupByFavoritesDrawable
by
lazy
{
R
.
drawable
.
ic_favorites_20dp
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
}
override
fun
onCreateView
(
override
fun
onCreateView
(
inflater
:
LayoutInflater
,
inflater
:
LayoutInflater
,
container
:
ViewGroup
?,
container
:
ViewGroup
?,
...
@@ -36,9 +50,44 @@ class SortByBottomSheetFragment : BottomSheetDialogFragment() {
...
@@ -36,9 +50,44 @@ class SortByBottomSheetFragment : BottomSheetDialogFragment() {
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
super
.
onViewCreated
(
view
,
savedInstanceState
)
presenter
.
getSortingAndGroupingPreferences
()
setupListeners
()
setupListeners
()
}
}
override
fun
onCancel
(
dialog
:
DialogInterface
?)
{
super
.
onCancel
(
dialog
)
presenter
.
saveSortingAndGroupingPreferences
(
isSortByName
,
isUnreadOnTop
,
isGroupByType
,
isGroupByFavorites
)
}
override
fun
showSortingAndGroupingPreferences
(
isSortByName
:
Boolean
,
isUnreadOnTop
:
Boolean
,
isGroupByType
:
Boolean
,
isGroupByFavorites
:
Boolean
)
{
this
.
isSortByName
=
isSortByName
this
.
isUnreadOnTop
=
isUnreadOnTop
this
.
isGroupByType
=
isGroupByType
this
.
isGroupByFavorites
=
isGroupByFavorites
if
(
isSortByName
)
{
changeSortByTitle
(
getString
(
R
.
string
.
msg_sort_by_name
))
checkSelection
(
text_name
,
filterDrawable
)
}
else
{
changeSortByTitle
(
getString
(
R
.
string
.
msg_sort_by_activity
))
checkSelection
(
text_activity
,
activityDrawable
)
}
if
(
isUnreadOnTop
)
checkSelection
(
text_unread_on_top
,
unreadOnTopDrawable
)
if
(
isGroupByType
)
checkSelection
(
text_group_by_type
,
groupByTypeDrawable
)
if
(
isGroupByFavorites
)
checkSelection
(
text_group_by_favorites
,
groupByFavoritesDrawable
)
}
private
fun
setupListeners
()
{
private
fun
setupListeners
()
{
text_name
.
setOnClickListener
{
text_name
.
setOnClickListener
{
changeSortByTitle
(
getString
(
R
.
string
.
msg_sort_by_name
))
changeSortByTitle
(
getString
(
R
.
string
.
msg_sort_by_name
))
...
...
app/src/main/res/layout/app_bar_chat_rooms.xml
View file @
1ceae466
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
android:drawableEnd=
"@drawable/ic_arrow_expand_20dp"
android:drawableEnd=
"@drawable/ic_arrow_expand_20dp"
android:drawablePadding=
"10dp"
android:drawablePadding=
"10dp"
android:fontFamily=
"sans-serif-medium"
android:fontFamily=
"sans-serif-medium"
android:maxLines=
"1"
android:textColor=
"#FFFFFF"
android:textColor=
"#FFFFFF"
android:textSize=
"20sp"
android:textSize=
"20sp"
android:textStyle=
"normal"
android:textStyle=
"normal"
...
...
app/src/main/res/layout/bottom_sheet_fragment_sort_by.xml
View file @
1ceae466
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:orientation=
"vertical"
tools:context=
".
chatrooms.ui.SortBy
BottomSheetFragment"
>
tools:context=
".
sortingandgrouping.ui.SortingAndGrouping
BottomSheetFragment"
>
<TextView
<TextView
android:id=
"@+id/text_sort_by"
android:id=
"@+id/text_sort_by"
...
...
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