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
75382d39
Commit
75382d39
authored
Apr 16, 2019
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code refactor
parent
69270690
Changes
43
Show whitespace changes
Inline
Side-by-side
Showing
43 changed files
with
306 additions
and
515 deletions
+306
-515
build.gradle
app/build.gradle
+2
-2
RocketChatApplication.kt
...ain/java/chat/rocket/android/app/RocketChatApplication.kt
+16
-62
LoginFragment.kt
...t/rocket/android/authentication/login/ui/LoginFragment.kt
+1
-1
LoginOptionsFragment.kt
...id/authentication/loginoptions/ui/LoginOptionsFragment.kt
+1
-1
OnBoardingFragment.kt
...ndroid/authentication/onboarding/ui/OnBoardingFragment.kt
+1
-1
RegisterUsernameFragment.kt
...ntication/registerusername/ui/RegisterUsernameFragment.kt
+1
-1
ResetPasswordFragment.kt
.../authentication/resetpassword/ui/ResetPasswordFragment.kt
+1
-1
ServerFragment.kt
...rocket/android/authentication/server/ui/ServerFragment.kt
+1
-1
SignupFragment.kt
...rocket/android/authentication/signup/ui/SignupFragment.kt
+1
-1
TwoFAFragment.kt
...cket/android/authentication/twofactor/ui/TwoFAFragment.kt
+1
-1
ChatDetailsFragment.kt
...chat/rocket/android/chatdetails/ui/ChatDetailsFragment.kt
+12
-16
MessageInfoFragment.kt
.../rocket/android/chatinformation/ui/MessageInfoFragment.kt
+1
-1
MessageServiceProvider.kt
...chat/rocket/android/chatroom/di/MessageServiceProvider.kt
+3
-0
ChatRoomPresenter.kt
...rocket/android/chatroom/presentation/ChatRoomPresenter.kt
+23
-56
ChatRoomView.kt
...chat/rocket/android/chatroom/presentation/ChatRoomView.kt
+0
-2
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+49
-68
UiModelMapper.kt
...ava/chat/rocket/android/chatroom/uimodel/UiModelMapper.kt
+1
-1
ChatRoomsPresenter.kt
...cket/android/chatrooms/presentation/ChatRoomsPresenter.kt
+1
-1
ChatRoomsFragment.kt
...ava/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
+74
-106
CreateChannelFragment.kt
.../rocket/android/createchannel/ui/CreateChannelFragment.kt
+6
-18
AndroidWorkerInjectionModule.kt
...ket/android/dagger/module/AndroidWorkerInjectionModule.kt
+1
-0
AppModule.kt
.../main/java/chat/rocket/android/dagger/module/AppModule.kt
+36
-103
UserDao.kt
app/src/main/java/chat/rocket/android/db/UserDao.kt
+1
-1
FavoriteMessagesFragment.kt
...t/android/favoritemessages/ui/FavoriteMessagesFragment.kt
+1
-1
FilesFragment.kt
...c/main/java/chat/rocket/android/files/ui/FilesFragment.kt
+1
-1
MainActivity.kt
...src/main/java/chat/rocket/android/main/ui/MainActivity.kt
+5
-9
MembersFragment.kt
...in/java/chat/rocket/android/members/ui/MembersFragment.kt
+1
-1
MentionsFragment.kt
.../java/chat/rocket/android/mentions/ui/MentionsFragment.kt
+1
-1
PinnedMessagesFragment.kt
...ocket/android/pinnedmessages/ui/PinnedMessagesFragment.kt
+1
-1
ProfileFragment.kt
...in/java/chat/rocket/android/profile/ui/ProfileFragment.kt
+1
-1
DirectReplyReceiverProvider.kt
...a/chat/rocket/android/push/DirectReplyReceiverProvider.kt
+3
-0
DeleteReceiverProvider.kt
...ava/chat/rocket/android/push/di/DeleteReceiverProvider.kt
+3
-0
SettingsRepository.kt
...a/chat/rocket/android/server/domain/SettingsRepository.kt
+1
-1
ChangeServerPresenter.kt
...cket/android/server/presentation/ChangeServerPresenter.kt
+0
-7
ServersBottomSheetFragment.kt
...t/rocket/android/servers/ui/ServersBottomSheetFragment.kt
+1
-1
SettingsFragment.kt
.../java/chat/rocket/android/settings/ui/SettingsFragment.kt
+42
-32
SortingAndGroupingBottomSheetFragment.kt
...ngandgrouping/ui/SortingAndGroupingBottomSheetFragment.kt
+1
-1
UserDetailsFragment.kt
...chat/rocket/android/userdetails/ui/UserDetailsFragment.kt
+1
-1
strings.xml
app/src/main/res/values-ar/strings.xml
+1
-1
ServiceBuilder.kt
.../java/chat/rocket/android/dagger/module/ServiceBuilder.kt
+1
-3
FirebaseMessagingService.kt
...java/chat/rocket/android/push/FirebaseMessagingService.kt
+2
-4
FirebaseMessagingServiceProvider.kt
...ocket/android/push/di/FirebaseMessagingServiceProvider.kt
+3
-0
TokenRegistrationWorker.kt
...hat/rocket/android/push/worker/TokenRegistrationWorker.kt
+2
-4
No files found.
app/build.gradle
View file @
75382d39
...
@@ -18,8 +18,8 @@ android {
...
@@ -18,8 +18,8 @@ android {
applicationId
"chat.rocket.android"
applicationId
"chat.rocket.android"
minSdkVersion
versions
.
minSdk
minSdkVersion
versions
.
minSdk
targetSdkVersion
versions
.
targetSdk
targetSdkVersion
versions
.
targetSdk
versionCode
206
0
versionCode
206
1
versionName
"3.
3
.0"
versionName
"3.
4
.0"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled
true
multiDexEnabled
true
...
...
app/src/main/java/chat/rocket/android/app/RocketChatApplication.kt
View file @
75382d39
...
@@ -22,7 +22,6 @@ import chat.rocket.android.infrastructure.LocalRepository
...
@@ -22,7 +22,6 @@ import chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.AccountsRepository
import
chat.rocket.android.server.domain.AccountsRepository
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.SITE_URL
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.retryIO
import
chat.rocket.android.util.retryIO
...
@@ -45,44 +44,25 @@ import javax.inject.Inject
...
@@ -45,44 +44,25 @@ import javax.inject.Inject
class
RocketChatApplication
:
Application
(),
HasActivityInjector
,
HasServiceInjector
,
class
RocketChatApplication
:
Application
(),
HasActivityInjector
,
HasServiceInjector
,
HasBroadcastReceiverInjector
,
HasWorkerInjector
{
HasBroadcastReceiverInjector
,
HasWorkerInjector
{
@Inject
lateinit
var
activityDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Activity
>
@Inject
lateinit
var
serviceDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Service
>
@Inject
lateinit
var
broadcastReceiverInjector
:
DispatchingAndroidInjector
<
BroadcastReceiver
>
@Inject
lateinit
var
workerInjector
:
DispatchingAndroidInjector
<
Worker
>
@Inject
@Inject
lateinit
var
appLifecycleObserver
:
AppLifecycleObserver
lateinit
var
appLifecycleObserver
:
AppLifecycleObserver
@Inject
@Inject
lateinit
var
imagePipelineConfig
:
ImagePipelineConfig
lateinit
var
activityDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Activity
>
@Inject
lateinit
var
draweeConfig
:
DraweeConfig
@Inject
lateinit
var
serviceDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Service
>
@Inject
lateinit
var
broadcastReceiverInjector
:
DispatchingAndroidInjector
<
BroadcastReceiver
>
@Inject
lateinit
var
workerInjector
:
DispatchingAndroidInjector
<
Worker
>
@Inject
lateinit
var
imagePipelineConfig
:
ImagePipelineConfig
@Inject
lateinit
var
draweeConfig
:
DraweeConfig
// TODO - remove this from here when we have a proper service handling the connection.
// TODO - remove this from here when we have a proper service handling the connection.
@Inject
@Inject
lateinit
var
getCurrentServerInteractor
:
GetCurrentServerInteractor
lateinit
var
getCurrentServerInteractor
:
GetCurrentServerInteractor
@Inject
lateinit
var
settingsInteractor
:
GetSettingsInteractor
@Inject
@Inject
lateinit
var
tokenRepository
:
TokenRepository
lateinit
var
settingsInteractor
:
GetSettingsInteractor
@Inject
lateinit
var
localRepository
:
LocalRepository
@Inject
@Inject
lateinit
var
accountRepository
:
AccountsRepository
lateinit
var
tokenRepository
:
TokenRepository
@Inject
lateinit
var
factory
:
RocketChatClientFactory
@Inject
lateinit
var
localRepository
:
LocalRepository
@Inject
@field
:
ForMessages
lateinit
var
messagesPrefs
:
SharedPreferences
@Inject
lateinit
var
accountRepository
:
AccountsRepository
@Inject
lateinit
var
factory
:
RocketChatClientFactory
@Inject
@field
:
ForMessages
lateinit
var
messagesPrefs
:
SharedPreferences
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
super
.
onCreate
()
...
@@ -92,9 +72,7 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
...
@@ -92,9 +72,7 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
.
build
()
.
build
()
.
inject
(
this
)
.
inject
(
this
)
ProcessLifecycleOwner
.
get
()
ProcessLifecycleOwner
.
get
().
lifecycle
.
addObserver
(
appLifecycleObserver
)
.
lifecycle
.
addObserver
(
appLifecycleObserver
)
context
=
WeakReference
(
applicationContext
)
context
=
WeakReference
(
applicationContext
)
...
@@ -111,34 +89,10 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
...
@@ -111,34 +89,10 @@ class RocketChatApplication : Application(), HasActivityInjector, HasServiceInje
localRepository
.
setOldMessagesCleanedUp
()
localRepository
.
setOldMessagesCleanedUp
()
}
}
// TODO - remove REALM files.
// TODO - remove this
checkCurrentServer
()
// TODO - FIXME - we need to properly inject and initialize the EmojiRepository
// TODO - FIXME - we need to properly inject and initialize the EmojiRepository
loadEmojis
()
loadEmojis
()
}
}
private
fun
checkCurrentServer
()
{
val
currentServer
=
getCurrentServerInteractor
.
get
()
?:
"<unknown>"
if
(
currentServer
==
"<unknown>"
)
{
val
message
=
"null currentServer"
Timber
.
d
(
IllegalStateException
(
message
),
message
)
}
val
settings
=
settingsInteractor
.
get
(
currentServer
)
if
(
settings
.
isEmpty
())
{
val
message
=
"Empty settings for: $currentServer"
Timber
.
d
(
IllegalStateException
(
message
),
message
)
}
val
baseUrl
=
settings
[
SITE_URL
]
if
(
baseUrl
==
null
)
{
val
message
=
"Server $currentServer SITE_URL"
Timber
.
d
(
IllegalStateException
(
message
),
message
)
}
}
private
fun
setupFresco
()
{
private
fun
setupFresco
()
{
Fresco
.
initialize
(
this
,
imagePipelineConfig
,
draweeConfig
)
Fresco
.
initialize
(
this
,
imagePipelineConfig
,
draweeConfig
)
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/login/ui/LoginFragment.kt
View file @
75382d39
...
@@ -54,8 +54,8 @@ class LoginFragment : Fragment(), LoginView {
...
@@ -54,8 +54,8 @@ class LoginFragment : Fragment(), LoginView {
private
val
editTextsDisposable
=
CompositeDisposable
()
private
val
editTextsDisposable
=
CompositeDisposable
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
serverName
=
getString
(
SERVER_NAME
)
serverName
=
getString
(
SERVER_NAME
)
...
...
app/src/main/java/chat/rocket/android/authentication/loginoptions/ui/LoginOptionsFragment.kt
View file @
75382d39
...
@@ -152,8 +152,8 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
...
@@ -152,8 +152,8 @@ class LoginOptionsFragment : Fragment(), LoginOptionsView {
private
var
deepLinkInfo
:
LoginDeepLinkInfo
?
=
null
private
var
deepLinkInfo
:
LoginDeepLinkInfo
?
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
serverName
=
getString
(
SERVER_NAME
)
serverName
=
getString
(
SERVER_NAME
)
...
...
app/src/main/java/chat/rocket/android/authentication/onboarding/ui/OnBoardingFragment.kt
View file @
75382d39
...
@@ -30,8 +30,8 @@ class OnBoardingFragment : Fragment(), OnBoardingView {
...
@@ -30,8 +30,8 @@ class OnBoardingFragment : Fragment(), OnBoardingView {
lateinit
var
analyticsManager
:
AnalyticsManager
lateinit
var
analyticsManager
:
AnalyticsManager
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
}
}
override
fun
onCreateView
(
override
fun
onCreateView
(
...
...
app/src/main/java/chat/rocket/android/authentication/registerusername/ui/RegisterUsernameFragment.kt
View file @
75382d39
...
@@ -48,8 +48,8 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView {
...
@@ -48,8 +48,8 @@ class RegisterUsernameFragment : Fragment(), RegisterUsernameView {
private
lateinit
var
usernameDisposable
:
Disposable
private
lateinit
var
usernameDisposable
:
Disposable
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
userId
=
getString
(
BUNDLE_USER_ID
,
""
)
userId
=
getString
(
BUNDLE_USER_ID
,
""
)
...
...
app/src/main/java/chat/rocket/android/authentication/resetpassword/ui/ResetPasswordFragment.kt
View file @
75382d39
...
@@ -37,8 +37,8 @@ class ResetPasswordFragment : Fragment(), ResetPasswordView {
...
@@ -37,8 +37,8 @@ class ResetPasswordFragment : Fragment(), ResetPasswordView {
private
lateinit
var
emailAddressDisposable
:
Disposable
private
lateinit
var
emailAddressDisposable
:
Disposable
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
}
}
override
fun
onCreateView
(
override
fun
onCreateView
(
...
...
app/src/main/java/chat/rocket/android/authentication/server/ui/ServerFragment.kt
View file @
75382d39
...
@@ -64,8 +64,8 @@ class ServerFragment : Fragment(), ServerView {
...
@@ -64,8 +64,8 @@ class ServerFragment : Fragment(), ServerView {
}
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
deepLinkInfo
=
arguments
?.
getParcelable
(
DEEP_LINK_INFO
)
deepLinkInfo
=
arguments
?.
getParcelable
(
DEEP_LINK_INFO
)
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/signup/ui/SignupFragment.kt
View file @
75382d39
...
@@ -40,8 +40,8 @@ class SignupFragment : Fragment(), SignupView {
...
@@ -40,8 +40,8 @@ class SignupFragment : Fragment(), SignupView {
private
val
editTextsDisposable
=
CompositeDisposable
()
private
val
editTextsDisposable
=
CompositeDisposable
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
}
}
override
fun
onCreateView
(
override
fun
onCreateView
(
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/ui/TwoFAFragment.kt
View file @
75382d39
...
@@ -45,8 +45,8 @@ class TwoFAFragment : Fragment(), TwoFAView {
...
@@ -45,8 +45,8 @@ class TwoFAFragment : Fragment(), TwoFAView {
private
lateinit
var
twoFaCodeDisposable
:
Disposable
private
lateinit
var
twoFaCodeDisposable
:
Disposable
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
username
=
getString
(
BUNDLE_USERNAME
,
""
)
username
=
getString
(
BUNDLE_USERNAME
,
""
)
...
...
app/src/main/java/chat/rocket/android/chatdetails/ui/ChatDetailsFragment.kt
View file @
75382d39
...
@@ -60,14 +60,10 @@ private const val BUNDLE_IS_FAVORITE = "BUNDLE_IS_FAVORITE"
...
@@ -60,14 +60,10 @@ private const val BUNDLE_IS_FAVORITE = "BUNDLE_IS_FAVORITE"
private
const
val
BUNDLE_DISABLE_MENU
=
"BUNDLE_DISABLE_MENU"
private
const
val
BUNDLE_DISABLE_MENU
=
"BUNDLE_DISABLE_MENU"
class
ChatDetailsFragment
:
Fragment
(),
ChatDetailsView
{
class
ChatDetailsFragment
:
Fragment
(),
ChatDetailsView
{
@Inject
@Inject
lateinit
var
presenter
:
ChatDetailsPresenter
lateinit
var
presenter
:
ChatDetailsPresenter
@Inject
lateinit
var
factory
:
ChatDetailsViewModelFactory
@Inject
@Inject
lateinit
var
serverUrl
:
CurrentServerRepository
lateinit
var
factory
:
ChatDetailsViewModelFactory
@Inject
lateinit
var
settings
:
GetSettingsInteractor
@Inject
lateinit
var
serverUrl
:
CurrentServerRepository
@Inject
lateinit
var
settings
:
GetSettingsInteractor
private
var
adapter
:
ChatDetailsAdapter
?
=
null
private
var
adapter
:
ChatDetailsAdapter
?
=
null
private
lateinit
var
viewModel
:
ChatDetailsViewModel
private
lateinit
var
viewModel
:
ChatDetailsViewModel
...
@@ -78,8 +74,8 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
...
@@ -78,8 +74,8 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
private
var
disableMenu
:
Boolean
=
false
private
var
disableMenu
:
Boolean
=
false
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
)
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
)
...
@@ -154,19 +150,19 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
...
@@ -154,19 +150,19 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
adapter
?.
let
{
adapter
?.
let
{
if
(!
disableMenu
)
{
if
(!
disableMenu
)
{
it
.
addOption
(
getString
(
R
.
string
.
title_files
),
R
.
drawable
.
ic_files_24dp
)
{
it
.
addOption
(
getString
(
R
.
string
.
title_files
),
R
.
drawable
.
ic_files_24dp
)
{
presenter
.
toFiles
(
chatRoomId
!!
)
presenter
.
toFiles
(
chatRoomId
)
}
}
}
}
if
(
chatRoomType
!=
RoomType
.
DIRECT_MESSAGE
&&
!
disableMenu
)
{
if
(
chatRoomType
!=
RoomType
.
DIRECT_MESSAGE
&&
!
disableMenu
)
{
it
.
addOption
(
getString
(
R
.
string
.
msg_mentions
),
R
.
drawable
.
ic_at_black_20dp
)
{
it
.
addOption
(
getString
(
R
.
string
.
msg_mentions
),
R
.
drawable
.
ic_at_black_20dp
)
{
presenter
.
toMentions
(
chatRoomId
!!
)
presenter
.
toMentions
(
chatRoomId
)
}
}
it
.
addOption
(
it
.
addOption
(
getString
(
R
.
string
.
title_members
),
getString
(
R
.
string
.
title_members
),
R
.
drawable
.
ic_people_outline_black_24dp
R
.
drawable
.
ic_people_outline_black_24dp
)
{
)
{
presenter
.
toMembers
(
chatRoomId
!!
)
presenter
.
toMembers
(
chatRoomId
)
}
}
}
}
...
@@ -174,13 +170,13 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
...
@@ -174,13 +170,13 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
getString
(
R
.
string
.
title_favorite_messages
),
getString
(
R
.
string
.
title_favorite_messages
),
R
.
drawable
.
ic_star_border_white_24dp
R
.
drawable
.
ic_star_border_white_24dp
)
{
)
{
presenter
.
toFavorites
(
chatRoomId
!!
)
presenter
.
toFavorites
(
chatRoomId
)
}
}
it
.
addOption
(
it
.
addOption
(
getString
(
R
.
string
.
title_pinned_messages
),
getString
(
R
.
string
.
title_pinned_messages
),
R
.
drawable
.
ic_action_message_pin_24dp
R
.
drawable
.
ic_action_message_pin_24dp
)
{
)
{
presenter
.
toPinned
(
chatRoomId
!!
)
presenter
.
toPinned
(
chatRoomId
)
}
}
}
}
}
}
...
@@ -206,11 +202,11 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
...
@@ -206,11 +202,11 @@ class ChatDetailsFragment : Fragment(), ChatDetailsView {
private
fun
getDetails
()
{
private
fun
getDetails
()
{
if
(
isSubscribed
)
if
(
isSubscribed
)
viewModel
.
getDetails
(
chatRoomId
!!
).
observe
(
viewLifecycleOwner
,
Observer
{
details
->
viewModel
.
getDetails
(
chatRoomId
).
observe
(
viewLifecycleOwner
,
Observer
{
details
->
displayDetails
(
details
)
displayDetails
(
details
)
})
})
else
else
presenter
.
getDetails
(
chatRoomId
!!
,
chatRoomType
!!
)
presenter
.
getDetails
(
chatRoomId
,
chatRoomType
)
}
}
private
fun
setupOptions
()
{
private
fun
setupOptions
()
{
...
...
app/src/main/java/chat/rocket/android/chatinformation/ui/MessageInfoFragment.kt
View file @
75382d39
...
@@ -42,8 +42,8 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
...
@@ -42,8 +42,8 @@ class MessageInfoFragment : Fragment(), MessageInfoView {
private
lateinit
var
messageId
:
String
private
lateinit
var
messageId
:
String
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
val
bundle
=
arguments
val
bundle
=
arguments
if
(
bundle
!=
null
)
{
if
(
bundle
!=
null
)
{
...
...
app/src/main/java/chat/rocket/android/chatroom/di/MessageServiceProvider.kt
View file @
75382d39
package
chat.rocket.android.chatroom.di
package
chat.rocket.android.chatroom.di
import
chat.rocket.android.chatroom.service.MessageService
import
chat.rocket.android.chatroom.service.MessageService
import
chat.rocket.android.dagger.module.AppModule
import
dagger.Module
import
dagger.Module
import
dagger.android.ContributesAndroidInjector
@Module
@Module
abstract
class
MessageServiceProvider
{
abstract
class
MessageServiceProvider
{
@ContributesAndroidInjector
(
modules
=
[
AppModule
::
class
])
abstract
fun
provideMessageService
():
MessageService
abstract
fun
provideMessageService
():
MessageService
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomPresenter.kt
View file @
75382d39
...
@@ -34,7 +34,6 @@ import chat.rocket.android.server.domain.uploadMaxFileSize
...
@@ -34,7 +34,6 @@ import chat.rocket.android.server.domain.uploadMaxFileSize
import
chat.rocket.android.server.domain.uploadMimeTypeFilter
import
chat.rocket.android.server.domain.uploadMimeTypeFilter
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.server.domain.useRealName
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.state
import
chat.rocket.android.util.extension.getByteArray
import
chat.rocket.android.util.extension.getByteArray
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extensions.avatarUrl
import
chat.rocket.android.util.extensions.avatarUrl
...
@@ -47,7 +46,6 @@ import chat.rocket.common.model.UserStatus
...
@@ -47,7 +46,6 @@ import chat.rocket.common.model.UserStatus
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.model.roomTypeOf
import
chat.rocket.common.util.ifNull
import
chat.rocket.common.util.ifNull
import
chat.rocket.core.internal.realtime.setTypingStatus
import
chat.rocket.core.internal.realtime.setTypingStatus
import
chat.rocket.core.internal.realtime.socket.model.State
import
chat.rocket.core.internal.realtime.subscribeTypingStatus
import
chat.rocket.core.internal.realtime.subscribeTypingStatus
import
chat.rocket.core.internal.realtime.unsubscribe
import
chat.rocket.core.internal.realtime.unsubscribe
import
chat.rocket.core.internal.rest.chatRoomRoles
import
chat.rocket.core.internal.rest.chatRoomRoles
...
@@ -112,30 +110,29 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -112,30 +110,29 @@ class ChatRoomPresenter @Inject constructor(
private
val
currentLoggedUsername
=
userHelper
.
username
()
private
val
currentLoggedUsername
=
userHelper
.
username
()
private
val
messagesChannel
=
Channel
<
Message
>()
private
val
messagesChannel
=
Channel
<
Message
>()
private
var
chatRoomId
:
String
?
=
null
private
lateinit
var
chatRoomId
:
String
private
lateinit
var
chatRoomType
:
String
private
lateinit
var
chatRoomType
:
String
private
var
chatIsBroadcast
:
Boolean
=
false
private
var
chatIsBroadcast
:
Boolean
=
false
private
var
chatRoles
=
emptyList
<
ChatRoomRole
>()
private
var
chatRoles
=
emptyList
<
ChatRoomRole
>()
private
val
stateChannel
=
Channel
<
State
>()
private
var
typingStatusSubscriptionId
:
String
?
=
null
private
var
typingStatusSubscriptionId
:
String
?
=
null
private
var
lastState
=
manager
.
state
private
var
typingStatusList
=
arrayListOf
<
String
>()
private
var
typingStatusList
=
arrayListOf
<
String
>()
private
val
roomChangesChannel
=
Channel
<
Room
>(
Channel
.
CONFLATED
)
private
val
roomChangesChannel
=
Channel
<
Room
>(
Channel
.
CONFLATED
)
private
lateinit
var
draftKey
:
String
private
lateinit
var
draftKey
:
String
fun
setupChatRoom
(
fun
setup
(
roomId
:
String
,
roomType
:
String
)
{
roomId
:
String
,
chatRoomId
=
roomId
chatRoomType
=
roomType
draftKey
=
"${currentServer}_${LocalRepository.DRAFT_KEY}$roomId"
}
fun
loadChatRoomRolesAndMessages
(
roomName
:
String
,
roomName
:
String
,
roomType
:
String
,
chatRoomMessage
:
String
?
=
null
chatRoomMessage
:
String
?
=
null
)
{
)
{
draftKey
=
"${currentServer}_${LocalRepository.DRAFT_KEY}$roomId"
chatRoomId
=
roomId
chatRoomType
=
roomType
GlobalScope
.
launch
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
GlobalScope
.
launch
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
try
{
try
{
chatRoles
=
if
(
roomTypeOf
(
r
oomType
)
!
is
RoomType
.
DirectMessage
)
{
chatRoles
=
if
(
roomTypeOf
(
chatR
oomType
)
!
is
RoomType
.
DirectMessage
)
{
client
.
chatRoomRoles
(
roomType
=
roomTypeOf
(
r
oomType
),
roomName
=
roomName
)
client
.
chatRoomRoles
(
roomType
=
roomTypeOf
(
chatR
oomType
),
roomName
=
roomName
)
}
else
{
}
else
{
emptyList
()
emptyList
()
}
}
...
@@ -146,7 +143,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -146,7 +143,7 @@ class ChatRoomPresenter @Inject constructor(
// User has at least an 'owner' or 'moderator' role.
// User has at least an 'owner' or 'moderator' role.
val
canModerate
=
isOwnerOrMod
()
val
canModerate
=
isOwnerOrMod
()
// Can post anyway if has the 'post-readonly' permission on server.
// Can post anyway if has the 'post-readonly' permission on server.
val
room
=
dbManager
.
getRoom
(
r
oomId
)
val
room
=
dbManager
.
getRoom
(
chatR
oomId
)
room
?.
let
{
room
?.
let
{
chatIsBroadcast
=
it
.
chatRoom
.
broadcast
?:
false
chatIsBroadcast
=
it
.
chatRoom
.
broadcast
?:
false
val
roomUiModel
=
roomMapper
.
map
(
it
,
true
)
val
roomUiModel
=
roomMapper
.
map
(
it
,
true
)
...
@@ -159,7 +156,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -159,7 +156,7 @@ class ChatRoomPresenter @Inject constructor(
}
}
}
}
loadMessages
(
roomId
,
r
oomType
,
clearDataSet
=
true
)
loadMessages
(
chatRoomId
,
chatR
oomType
,
clearDataSet
=
true
)
chatRoomMessage
?.
let
{
messageHelper
.
messageIdFromPermalink
(
it
)
}
chatRoomMessage
?.
let
{
messageHelper
.
messageIdFromPermalink
(
it
)
}
?.
let
{
messageId
->
?.
let
{
messageId
->
val
name
=
messageHelper
.
roomNameFromPermalink
(
chatRoomMessage
)
val
name
=
messageHelper
.
roomNameFromPermalink
(
chatRoomMessage
)
...
@@ -177,8 +174,7 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -177,8 +174,7 @@ class ChatRoomPresenter @Inject constructor(
private
suspend
fun
subscribeRoomChanges
()
{
private
suspend
fun
subscribeRoomChanges
()
{
withContext
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
withContext
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
chatRoomId
?.
let
{
manager
.
addRoomChannel
(
chatRoomId
,
roomChangesChannel
)
manager
.
addRoomChannel
(
it
,
roomChangesChannel
)
for
(
room
in
roomChangesChannel
)
{
for
(
room
in
roomChangesChannel
)
{
dbManager
.
getRoom
(
room
.
id
)
?.
let
{
chatRoom
->
dbManager
.
getRoom
(
room
.
id
)
?.
let
{
chatRoom
->
view
.
onRoomUpdated
(
roomMapper
.
map
(
chatRoom
=
chatRoom
,
showLastMessage
=
true
))
view
.
onRoomUpdated
(
roomMapper
.
map
(
chatRoom
=
chatRoom
,
showLastMessage
=
true
))
...
@@ -186,10 +182,9 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -186,10 +182,9 @@ class ChatRoomPresenter @Inject constructor(
}
}
}
}
}
}
}
private
fun
unsubscribeRoomChanges
()
{
private
fun
unsubscribeRoomChanges
()
{
chatRoomId
?.
let
{
manager
.
removeRoomChannel
(
it
)
}
manager
.
removeRoomChannel
(
chatRoomId
)
}
}
private
fun
isOwnerOrMod
():
Boolean
{
private
fun
isOwnerOrMod
():
Boolean
{
...
@@ -248,7 +243,6 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -248,7 +243,6 @@ class ChatRoomPresenter @Inject constructor(
}
}
subscribeTypingStatus
()
subscribeTypingStatus
()
subscribeState
()
}
}
}
}
...
@@ -521,16 +515,16 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -521,16 +515,16 @@ class ChatRoomPresenter @Inject constructor(
fun
sendTyping
()
{
fun
sendTyping
()
{
GlobalScope
.
launch
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
GlobalScope
.
launch
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
if
(
c
hatRoomId
!=
null
&&
c
urrentLoggedUsername
!=
null
)
{
if
(
currentLoggedUsername
!=
null
)
{
client
.
setTypingStatus
(
chatRoomId
.
toString
()
,
currentLoggedUsername
,
true
)
client
.
setTypingStatus
(
chatRoomId
,
currentLoggedUsername
,
true
)
}
}
}
}
}
}
fun
sendNotTyping
()
{
fun
sendNotTyping
()
{
GlobalScope
.
launch
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
GlobalScope
.
launch
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
if
(
c
hatRoomId
!=
null
&&
c
urrentLoggedUsername
!=
null
)
{
if
(
currentLoggedUsername
!=
null
)
{
client
.
setTypingStatus
(
chatRoomId
.
toString
()
,
currentLoggedUsername
,
false
)
client
.
setTypingStatus
(
chatRoomId
,
currentLoggedUsername
,
false
)
}
}
}
}
}
}
...
@@ -546,28 +540,6 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -546,28 +540,6 @@ class ChatRoomPresenter @Inject constructor(
}
}
}
}
private
suspend
fun
subscribeState
()
{
Timber
.
d
(
"Subscribing to Status changes"
)
lastState
=
manager
.
state
manager
.
addStatusChannel
(
stateChannel
)
GlobalScope
.
launch
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
for
(
state
in
stateChannel
)
{
Timber
.
d
(
"Got new state: $state - last: $lastState"
)
if
(
state
!=
lastState
)
{
launch
(
Dispatchers
.
Main
)
{
view
.
showConnectionState
(
state
)
}
if
(
state
is
State
.
Connected
)
{
jobSchedulerInteractor
.
scheduleSendingMessages
()
loadMissingMessages
()
}
}
lastState
=
state
}
}
}
private
fun
subscribeMessages
(
roomId
:
String
)
{
private
fun
subscribeMessages
(
roomId
:
String
)
{
manager
.
subscribeRoomMessages
(
roomId
,
messagesChannel
)
manager
.
subscribeRoomMessages
(
roomId
,
messagesChannel
)
...
@@ -581,7 +553,6 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -581,7 +553,6 @@ class ChatRoomPresenter @Inject constructor(
private
fun
loadMissingMessages
()
{
private
fun
loadMissingMessages
()
{
GlobalScope
.
launch
(
strategy
.
jobs
)
{
GlobalScope
.
launch
(
strategy
.
jobs
)
{
chatRoomId
?.
let
{
chatRoomId
->
val
roomType
=
roomTypeOf
(
chatRoomType
)
val
roomType
=
roomTypeOf
(
chatRoomType
)
val
lastSyncDate
=
messagesRepository
.
getLastSyncDate
(
chatRoomId
)
val
lastSyncDate
=
messagesRepository
.
getLastSyncDate
(
chatRoomId
)
// lastSyncDate or 0. LastSyncDate could be in case when we sent some messages offline(and saved them locally),
// lastSyncDate or 0. LastSyncDate could be in case when we sent some messages offline(and saved them locally),
...
@@ -626,7 +597,6 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -626,7 +597,6 @@ class ChatRoomPresenter @Inject constructor(
}
}
}
}
}
}
}
/**
/**
* Delete the message with the given id.
* Delete the message with the given id.
...
@@ -1188,14 +1158,12 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1188,14 +1158,12 @@ class ChatRoomPresenter @Inject constructor(
fun
disconnect
()
{
fun
disconnect
()
{
unsubscribeRoomChanges
()
unsubscribeRoomChanges
()
unsubscribeTypingStatus
()
unsubscribeTypingStatus
()
if
(
chatRoomId
!=
null
)
{
unsubscribeMessages
(
chatRoomId
)
unsubscribeMessages
(
chatRoomId
.
toString
())
}
}
}
private
fun
subscribeTypingStatus
()
{
private
fun
subscribeTypingStatus
()
{
GlobalScope
.
launch
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
GlobalScope
.
launch
(
Dispatchers
.
IO
+
strategy
.
jobs
)
{
client
.
subscribeTypingStatus
(
chatRoomId
.
toString
()
)
{
_
,
id
->
client
.
subscribeTypingStatus
(
chatRoomId
)
{
_
,
id
->
typingStatusSubscriptionId
=
id
typingStatusSubscriptionId
=
id
}
}
...
@@ -1237,7 +1205,6 @@ class ChatRoomPresenter @Inject constructor(
...
@@ -1237,7 +1205,6 @@ class ChatRoomPresenter @Inject constructor(
}
}
private
fun
unsubscribeMessages
(
chatRoomId
:
String
)
{
private
fun
unsubscribeMessages
(
chatRoomId
:
String
)
{
manager
.
removeStatusChannel
(
stateChannel
)
manager
.
unsubscribeRoomMessages
(
chatRoomId
)
manager
.
unsubscribeRoomMessages
(
chatRoomId
)
// All messages during the subscribed period are assumed to be read,
// All messages during the subscribed period are assumed to be read,
// and lastSeen is updated as the time when the user leaves the room
// and lastSeen is updated as the time when the user leaves the room
...
...
app/src/main/java/chat/rocket/android/chatroom/presentation/ChatRoomView.kt
View file @
75382d39
...
@@ -117,8 +117,6 @@ interface ChatRoomView : LoadingView, MessageView {
...
@@ -117,8 +117,6 @@ interface ChatRoomView : LoadingView, MessageView {
fun
showInvalidFileSize
(
fileSize
:
Int
,
maxFileSize
:
Int
)
fun
showInvalidFileSize
(
fileSize
:
Int
,
maxFileSize
:
Int
)
fun
showConnectionState
(
state
:
State
)
fun
populatePeopleSuggestions
(
members
:
List
<
PeopleSuggestionUiModel
>)
fun
populatePeopleSuggestions
(
members
:
List
<
PeopleSuggestionUiModel
>)
fun
populateRoomSuggestions
(
chatRooms
:
List
<
ChatRoomSuggestionUiModel
>)
fun
populateRoomSuggestions
(
chatRooms
:
List
<
ChatRoomSuggestionUiModel
>)
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
75382d39
...
@@ -149,7 +149,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -149,7 +149,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
lateinit
var
analyticsManager
:
AnalyticsManager
lateinit
var
analyticsManager
:
AnalyticsManager
@Inject
@Inject
lateinit
var
navigator
:
ChatRoomNavigator
lateinit
var
navigator
:
ChatRoomNavigator
private
lateinit
var
a
dapter
:
ChatRoomAdapter
private
lateinit
var
chatRoomA
dapter
:
ChatRoomAdapter
internal
lateinit
var
chatRoomId
:
String
internal
lateinit
var
chatRoomId
:
String
private
lateinit
var
chatRoomName
:
String
private
lateinit
var
chatRoomName
:
String
internal
lateinit
var
chatRoomType
:
String
internal
lateinit
var
chatRoomType
:
String
...
@@ -266,8 +266,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -266,8 +266,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
...
@@ -282,16 +282,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -282,16 +282,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
?:
requireNotNull
(
arguments
)
{
"no arguments supplied when the fragment was instantiated"
}
?:
requireNotNull
(
arguments
)
{
"no arguments supplied when the fragment was instantiated"
}
adapter
=
ChatRoomAdapter
(
roomId
=
chatRoomId
,
roomType
=
chatRoomType
,
roomName
=
chatRoomName
,
actionSelectListener
=
this
,
reactionListener
=
this
,
navigator
=
navigator
,
analyticsManager
=
analyticsManager
)
setHasOptionsMenu
(
true
)
setHasOptionsMenu
(
true
)
}
}
...
@@ -305,8 +295,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -305,8 +295,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
super
.
onViewCreated
(
view
,
savedInstanceState
)
super
.
onViewCreated
(
view
,
savedInstanceState
)
setupToolbar
(
chatRoomName
)
setupToolbar
(
chatRoomName
)
presenter
.
setup
ChatRoom
(
chatRoomId
,
chatRoomName
,
chatRoomType
,
chatRoomMessag
e
)
presenter
.
setup
(
chatRoomId
,
chatRoomTyp
e
)
presenter
.
loadChatRoomsSuggestions
()
setupRecyclerView
()
setupRecyclerView
()
setupFab
()
setupFab
()
setupSuggestionsView
()
setupSuggestionsView
()
...
@@ -326,6 +316,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -326,6 +316,8 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
getDraftMessage
()
getDraftMessage
()
subscribeComposeTextMessage
()
subscribeComposeTextMessage
()
presenter
.
loadChatRoomRolesAndMessages
(
chatRoomName
,
chatRoomMessage
)
presenter
.
loadChatRoomsSuggestions
()
analyticsManager
.
logScreenView
(
ScreenViewEvent
.
ChatRoom
)
analyticsManager
.
logScreenView
(
ScreenViewEvent
.
ChatRoom
)
}
}
...
@@ -381,7 +373,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -381,7 +373,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
showMessages
(
dataSet
:
List
<
BaseUiModel
<*
>>,
clearDataSet
:
Boolean
)
{
override
fun
showMessages
(
dataSet
:
List
<
BaseUiModel
<*
>>,
clearDataSet
:
Boolean
)
{
ui
{
ui
{
if
(
clearDataSet
)
{
if
(
clearDataSet
)
{
a
dapter
.
clearData
()
chatRoomA
dapter
.
clearData
()
}
}
if
(
dataSet
.
isNotEmpty
())
{
if
(
dataSet
.
isNotEmpty
())
{
...
@@ -422,8 +414,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -422,8 +414,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
}
}
if
(
recycler_view
.
adapter
==
null
)
{
recycler_view
.
adapter
=
adapter
if
(
dataSet
.
size
>=
30
)
{
if
(
dataSet
.
size
>=
30
)
{
recycler_view
.
addOnScrollListener
(
endlessRecyclerViewScrollListener
)
recycler_view
.
addOnScrollListener
(
endlessRecyclerViewScrollListener
)
}
}
...
@@ -432,25 +422,24 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -432,25 +422,24 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
// Load just once, on the first page...
// Load just once, on the first page...
presenter
.
loadActiveMembers
(
chatRoomId
,
chatRoomType
,
filterSelfOut
=
true
)
presenter
.
loadActiveMembers
(
chatRoomId
,
chatRoomType
,
filterSelfOut
=
true
)
}
val
oldMessagesCount
=
a
dapter
.
itemCount
val
oldMessagesCount
=
chatRoomA
dapter
.
itemCount
a
dapter
.
appendData
(
dataSet
)
chatRoomA
dapter
.
appendData
(
dataSet
)
if
(
oldMessagesCount
==
0
&&
dataSet
.
isNotEmpty
())
{
if
(
oldMessagesCount
==
0
&&
dataSet
.
isNotEmpty
())
{
recycler_view
.
scrollToPosition
(
0
)
recycler_view
.
scrollToPosition
(
0
)
verticalScrollOffset
.
set
(
0
)
verticalScrollOffset
.
set
(
0
)
}
}
presenter
.
loadActiveMembers
(
chatRoomId
,
chatRoomType
,
filterSelfOut
=
true
)
presenter
.
loadActiveMembers
(
chatRoomId
,
chatRoomType
,
filterSelfOut
=
true
)
empty_chat_view
.
isVisible
=
a
dapter
.
itemCount
==
0
empty_chat_view
.
isVisible
=
chatRoomA
dapter
.
itemCount
==
0
dismissEmojiKeyboard
()
dismissEmojiKeyboard
()
}
}
}
}
override
fun
showSearchedMessages
(
dataSet
:
List
<
BaseUiModel
<*
>>)
{
override
fun
showSearchedMessages
(
dataSet
:
List
<
BaseUiModel
<*
>>)
{
recycler_view
.
removeOnScrollListener
(
endlessRecyclerViewScrollListener
)
recycler_view
.
removeOnScrollListener
(
endlessRecyclerViewScrollListener
)
a
dapter
.
clearData
()
chatRoomA
dapter
.
clearData
()
a
dapter
.
prependData
(
dataSet
)
chatRoomA
dapter
.
prependData
(
dataSet
)
empty_chat_view
.
isVisible
=
a
dapter
.
itemCount
==
0
empty_chat_view
.
isVisible
=
chatRoomA
dapter
.
itemCount
==
0
dismissEmojiKeyboard
()
dismissEmojiKeyboard
()
}
}
...
@@ -534,7 +523,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -534,7 +523,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
showNewMessage
(
message
:
List
<
BaseUiModel
<*
>>,
isMessageReceived
:
Boolean
)
{
override
fun
showNewMessage
(
message
:
List
<
BaseUiModel
<*
>>,
isMessageReceived
:
Boolean
)
{
ui
{
ui
{
a
dapter
.
prependData
(
message
)
chatRoomA
dapter
.
prependData
(
message
)
if
(
isMessageReceived
&&
button_fab
.
isVisible
)
{
if
(
isMessageReceived
&&
button_fab
.
isVisible
)
{
newMessageCount
++
newMessageCount
++
if
(
newMessageCount
<=
99
)
{
if
(
newMessageCount
<=
99
)
{
...
@@ -547,7 +536,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -547,7 +536,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
recycler_view
.
scrollToPosition
(
0
)
recycler_view
.
scrollToPosition
(
0
)
}
}
verticalScrollOffset
.
set
(
0
)
verticalScrollOffset
.
set
(
0
)
empty_chat_view
.
isVisible
=
a
dapter
.
itemCount
==
0
empty_chat_view
.
isVisible
=
chatRoomA
dapter
.
itemCount
==
0
dismissEmojiKeyboard
()
dismissEmojiKeyboard
()
}
}
}
}
...
@@ -557,9 +546,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -557,9 +546,9 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
// TODO - investigate WHY we get a empty list here
// TODO - investigate WHY we get a empty list here
if
(
message
.
isEmpty
())
return
@ui
if
(
message
.
isEmpty
())
return
@ui
if
(
a
dapter
.
updateItem
(
message
.
last
()))
{
if
(
chatRoomA
dapter
.
updateItem
(
message
.
last
()))
{
if
(
message
.
size
>
1
)
{
if
(
message
.
size
>
1
)
{
a
dapter
.
prependData
(
listOf
(
message
.
first
()))
chatRoomA
dapter
.
prependData
(
listOf
(
message
.
first
()))
}
}
}
else
{
}
else
{
showNewMessage
(
message
,
true
)
showNewMessage
(
message
,
true
)
...
@@ -570,7 +559,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -570,7 +559,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
dispatchDeleteMessage
(
msgId
:
String
)
{
override
fun
dispatchDeleteMessage
(
msgId
:
String
)
{
ui
{
ui
{
a
dapter
.
removeItem
(
msgId
)
chatRoomA
dapter
.
removeItem
(
msgId
)
}
}
}
}
...
@@ -771,28 +760,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -771,28 +760,6 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
showMessage
(
getString
(
R
.
string
.
max_file_size_exceeded
,
fileSize
,
maxFileSize
))
showMessage
(
getString
(
R
.
string
.
max_file_size_exceeded
,
fileSize
,
maxFileSize
))
}
}
override
fun
showConnectionState
(
state
:
State
)
{
ui
{
text_connection_status
.
fadeIn
()
handler
.
removeCallbacks
(
dismissStatus
)
text_connection_status
.
text
=
when
(
state
)
{
is
State
.
Connected
->
{
handler
.
postDelayed
(
dismissStatus
,
2000
)
getString
(
R
.
string
.
status_connected
)
}
is
State
.
Disconnected
->
getString
(
R
.
string
.
status_disconnected
)
is
State
.
Connecting
->
getString
(
R
.
string
.
status_connecting
)
is
State
.
Authenticating
->
getString
(
R
.
string
.
status_authenticating
)
is
State
.
Disconnecting
->
getString
(
R
.
string
.
status_disconnecting
)
is
State
.
Waiting
->
getString
(
R
.
string
.
status_waiting
,
state
.
seconds
)
else
->
{
handler
.
postDelayed
(
dismissStatus
,
500
)
""
}
}
}
}
override
fun
onJoined
(
roomUiModel
:
RoomUiModel
)
{
override
fun
onJoined
(
roomUiModel
:
RoomUiModel
)
{
ui
{
ui
{
input_container
.
isVisible
=
true
input_container
.
isVisible
=
true
...
@@ -802,18 +769,32 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -802,18 +769,32 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
}
}
private
fun
setupRecyclerView
()
{
private
fun
setupRecyclerView
()
{
chatRoomAdapter
=
ChatRoomAdapter
(
roomId
=
chatRoomId
,
roomType
=
chatRoomType
,
roomName
=
chatRoomName
,
actionSelectListener
=
this
,
reactionListener
=
this
,
navigator
=
navigator
,
analyticsManager
=
analyticsManager
)
with
(
recycler_view
)
{
if
(
adapter
==
null
)
adapter
=
chatRoomAdapter
// Initialize the endlessRecyclerViewScrollListener so we don't NPE at onDestroyView
// Initialize the endlessRecyclerViewScrollListener so we don't NPE at onDestroyView
val
linearLayoutManager
=
LinearLayoutManager
(
context
,
RecyclerView
.
VERTICAL
,
true
)
val
linearLayoutManager
=
LinearLayoutManager
(
context
,
RecyclerView
.
VERTICAL
,
true
)
linearLayoutManager
.
stackFromEnd
=
true
linearLayoutManager
.
stackFromEnd
=
true
recycler_view
.
layoutManager
=
linearLayoutManager
layoutManager
=
linearLayoutManager
recycler_view
.
itemAnimator
=
DefaultItemAnimator
()
itemAnimator
=
DefaultItemAnimator
()
endlessRecyclerViewScrollListener
=
object
:
endlessRecyclerViewScrollListener
=
object
:
EndlessRecyclerViewScrollListener
(
recycler_view
.
layoutManager
as
LinearLayoutManager
)
{
EndlessRecyclerViewScrollListener
(
recycler_view
.
layoutManager
as
LinearLayoutManager
)
{
override
fun
onLoadMore
(
page
:
Int
,
totalItemsCount
:
Int
,
recyclerView
:
RecyclerView
)
{
override
fun
onLoadMore
(
page
:
Int
,
totalItemsCount
:
Int
,
recyclerView
:
RecyclerView
)
{
presenter
.
loadMessages
(
chatRoomId
,
chatRoomType
,
page
*
30L
)
presenter
.
loadMessages
(
chatRoomId
,
chatRoomType
,
page
*
30L
)
}
}
}
}
recycler_view
.
addOnScrollListener
(
fabScrollListener
)
addOnScrollListener
(
fabScrollListener
)
}
}
}
private
fun
setupFab
()
{
private
fun
setupFab
()
{
...
...
app/src/main/java/chat/rocket/android/chatroom/uimodel/UiModelMapper.kt
View file @
75382d39
...
@@ -402,7 +402,7 @@ class UiModelMapper @Inject constructor(
...
@@ -402,7 +402,7 @@ class UiModelMapper @Inject constructor(
private
fun
attachmentUrl
(
url
:
String
?):
String
?
{
private
fun
attachmentUrl
(
url
:
String
?):
String
?
{
if
(
url
.
isNullOrEmpty
())
return
null
if
(
url
.
isNullOrEmpty
())
return
null
if
(
url
!!
.
startsWith
(
"http"
))
return
url
if
(
url
.
startsWith
(
"http"
))
return
url
val
fullUrl
=
"$baseUrl$url"
val
fullUrl
=
"$baseUrl$url"
val
httpUrl
=
HttpUrl
.
parse
(
fullUrl
)
val
httpUrl
=
HttpUrl
.
parse
(
fullUrl
)
...
...
app/src/main/java/chat/rocket/android/chatrooms/presentation/ChatRoomsPresenter.kt
View file @
75382d39
...
@@ -108,7 +108,7 @@ class ChatRoomsPresenter @Inject constructor(
...
@@ -108,7 +108,7 @@ class ChatRoomsPresenter @Inject constructor(
}
}
}
}
suspend
fun
loadChatRoom
(
chatRoom
:
ChatRoomEntity
,
local
:
Boolean
=
false
)
{
private
suspend
fun
loadChatRoom
(
chatRoom
:
ChatRoomEntity
,
local
:
Boolean
=
false
)
{
with
(
chatRoom
)
{
with
(
chatRoom
)
{
val
isDirectMessage
=
roomTypeOf
(
type
)
is
RoomType
.
DirectMessage
val
isDirectMessage
=
roomTypeOf
(
type
)
is
RoomType
.
DirectMessage
val
roomName
=
val
roomName
=
...
...
app/src/main/java/chat/rocket/android/chatrooms/ui/ChatRoomsFragment.kt
View file @
75382d39
...
@@ -55,6 +55,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
...
@@ -55,6 +55,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
@Inject
lateinit
var
presenter
:
ChatRoomsPresenter
@Inject
lateinit
var
presenter
:
ChatRoomsPresenter
@Inject
lateinit
var
factory
:
ChatRoomsViewModelFactory
@Inject
lateinit
var
factory
:
ChatRoomsViewModelFactory
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
@Inject
lateinit
var
analyticsManager
:
AnalyticsManager
private
val
roomsAdapter
=
RoomsAdapter
{
presenter
.
loadChatRoom
(
it
)
}
private
lateinit
var
viewModel
:
ChatRoomsViewModel
private
lateinit
var
viewModel
:
ChatRoomsViewModel
private
var
chatRoomId
:
String
?
=
null
private
var
chatRoomId
:
String
?
=
null
private
var
isSortByName
=
false
private
var
isSortByName
=
false
...
@@ -63,8 +64,8 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
...
@@ -63,8 +64,8 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
private
var
isGroupByFavorites
=
false
private
var
isGroupByFavorites
=
false
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
)
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
)
...
@@ -86,6 +87,8 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
...
@@ -86,6 +87,8 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
super
.
onViewCreated
(
view
,
savedInstanceState
)
super
.
onViewCreated
(
view
,
savedInstanceState
)
setupRecyclerView
()
setupListeners
()
with
(
presenter
)
{
with
(
presenter
)
{
getCurrentServerName
()
getCurrentServerName
()
...
@@ -94,43 +97,11 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
...
@@ -94,43 +97,11 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
viewModel
=
ViewModelProviders
.
of
(
this
,
factory
).
get
(
ChatRoomsViewModel
::
class
.
java
)
viewModel
=
ViewModelProviders
.
of
(
this
,
factory
).
get
(
ChatRoomsViewModel
::
class
.
java
)
subscribeUi
()
subscribeUi
()
s
etupListener
s
()
s
howAllChat
s
()
analyticsManager
.
logScreenView
(
ScreenViewEvent
.
ChatRooms
)
analyticsManager
.
logScreenView
(
ScreenViewEvent
.
ChatRooms
)
}
}
override
fun
setupToolbar
(
serverName
:
String
)
{
with
((
activity
as
AppCompatActivity
))
{
with
(
toolbar
)
{
setSupportActionBar
(
this
)
setNavigationOnClickListener
{
presenter
.
toSettings
()
}
}
}
text_server_name
.
text
=
serverName
}
override
fun
setupSortingAndGrouping
(
isSortByName
:
Boolean
,
isUnreadOnTop
:
Boolean
,
isGroupByType
:
Boolean
,
isGroupByFavorites
:
Boolean
)
{
this
.
isSortByName
=
isSortByName
this
.
isUnreadOnTop
=
isUnreadOnTop
this
.
isGroupByType
=
isGroupByType
this
.
isGroupByFavorites
=
isGroupByFavorites
if
(
isSortByName
)
{
text_sort_by
.
text
=
getString
(
R
.
string
.
msg_sort_by
,
getString
(
R
.
string
.
msg_sort_by_name
).
toLowerCase
())
}
else
{
text_sort_by
.
text
=
getString
(
R
.
string
.
msg_sort_by
,
getString
(
R
.
string
.
msg_sort_by_activity
).
toLowerCase
()
)
}
}
override
fun
onCreateOptionsMenu
(
menu
:
Menu
,
inflater
:
MenuInflater
)
{
override
fun
onCreateOptionsMenu
(
menu
:
Menu
,
inflater
:
MenuInflater
)
{
super
.
onCreateOptionsMenu
(
menu
,
inflater
)
super
.
onCreateOptionsMenu
(
menu
,
inflater
)
inflater
.
inflate
(
R
.
menu
.
chatrooms
,
menu
)
inflater
.
inflate
(
R
.
menu
.
chatrooms
,
menu
)
...
@@ -167,92 +138,104 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
...
@@ -167,92 +138,104 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
return
super
.
onOptionsItemSelected
(
item
)
return
super
.
onOptionsItemSelected
(
item
)
}
}
private
fun
showNoChatRoomsToDisplay
()
{
override
fun
setupToolbar
(
serverName
:
String
)
{
// ui { text_no_data_to_display.isVisible = true }
with
((
activity
as
AppCompatActivity
))
{
with
(
toolbar
)
{
setSupportActionBar
(
this
)
setNavigationOnClickListener
{
presenter
.
toSettings
()
}
}
}
text_server_name
.
text
=
serverName
}
override
fun
setupSortingAndGrouping
(
isSortByName
:
Boolean
,
isUnreadOnTop
:
Boolean
,
isGroupByType
:
Boolean
,
isGroupByFavorites
:
Boolean
)
{
this
.
isSortByName
=
isSortByName
this
.
isUnreadOnTop
=
isUnreadOnTop
this
.
isGroupByType
=
isGroupByType
this
.
isGroupByFavorites
=
isGroupByFavorites
if
(
isSortByName
)
{
text_sort_by
.
text
=
getString
(
R
.
string
.
msg_sort_by
,
getString
(
R
.
string
.
msg_sort_by_name
).
toLowerCase
())
}
else
{
text_sort_by
.
text
=
getString
(
R
.
string
.
msg_sort_by
,
getString
(
R
.
string
.
msg_sort_by_activity
).
toLowerCase
()
)
}
}
}
override
fun
showLoading
()
{
override
fun
showLoading
()
{
ui
{
view_loading
.
isVisible
=
true
view_loading
.
isVisible
=
true
}
}
}
override
fun
hideLoading
()
{
override
fun
hideLoading
()
{
view_loading
.
isVisible
=
false
ui
{
view_loading
.
isVisible
=
false
}
}
}
override
fun
showMessage
(
resId
:
Int
)
{
override
fun
showMessage
(
resId
:
Int
)
{
ui
{
ui
{
showToast
(
resId
)
}
showToast
(
resId
)
}
}
}
override
fun
showMessage
(
message
:
String
)
{
override
fun
showMessage
(
message
:
String
)
{
ui
{
ui
{
showToast
(
message
)
}
showToast
(
message
)
}
}
}
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
private
fun
showConnectionState
(
state
:
State
)
{
private
fun
setupRecyclerView
()
{
Timber
.
d
(
"Got new state: $state"
)
// ui {
// text_connection_status.fadeIn()
// handler.removeCallbacks(dismissStatus)
// text_connection_status.text = when (state) {
// is State.Connected -> {
// handler.postDelayed(dismissStatus, 2000)
// getString(R.string.status_connected)
// }
// is State.Disconnected -> getString(R.string.status_disconnected)
// is State.Connecting -> getString(R.string.status_connecting)
// is State.Authenticating -> getString(R.string.status_authenticating)
// is State.Disconnecting -> getString(R.string.status_disconnecting)
// is State.Waiting -> getString(R.string.status_waiting, state.seconds)
// else -> {
// handler.postDelayed(dismissStatus, 500)
// ""
// }
// }
// }
}
private
fun
subscribeUi
()
{
ui
{
ui
{
val
adapter
=
RoomsAdapter
{
room
->
with
(
recycler_view
)
{
presenter
.
loadChatRoom
(
room
)
if
(
adapter
==
null
)
{
adapter
=
roomsAdapter
}
}
with
(
recycler_view
)
{
layoutManager
=
LinearLayoutManager
(
context
)
layoutManager
=
LinearLayoutManager
(
it
)
addItemDecoration
(
addItemDecoration
(
DividerItemDecoration
(
DividerItemDecoration
(
i
t
,
contex
t
,
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_start
),
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_start
),
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_end
)
resources
.
getDimensionPixelSize
(
R
.
dimen
.
divider_item_decorator_bound_end
)
)
)
)
)
itemAnimator
=
DefaultItemAnimator
()
itemAnimator
=
DefaultItemAnimator
()
}
}
}
}
viewModel
.
getChatRooms
().
observe
(
viewLifecycleOwner
,
Observer
{
rooms
->
private
fun
setupListeners
()
{
rooms
?.
let
{
text_server_name
.
setOnClickListener
{
adapter
.
values
=
it
ServersBottomSheetFragment
().
show
(
if
(
recycler_view
.
adapter
!=
adapter
)
{
activity
?.
supportFragmentManager
,
recycler_view
.
adapter
=
adapter
chat
.
rocket
.
android
.
servers
.
ui
.
TAG
)
}
}
if
(
rooms
.
isNotEmpty
())
{
// text_no_data_to_display.isVisible = false
text_sort_by
.
setOnClickListener
{
SortingAndGroupingBottomSheetFragment
().
show
(
activity
?.
supportFragmentManager
,
chat
.
rocket
.
android
.
sortingandgrouping
.
ui
.
TAG
)
}
}
}
}
private
fun
subscribeUi
()
{
ui
{
viewModel
.
getChatRooms
().
observe
(
viewLifecycleOwner
,
Observer
{
roomModel
->
roomModel
?.
let
{
roomsAdapter
.
values
=
it
}
})
})
viewModel
.
loadingState
.
observe
(
viewLifecycleOwner
,
Observer
{
state
->
viewModel
.
loadingState
.
observe
(
viewLifecycleOwner
,
Observer
{
state
->
when
(
state
)
{
when
(
state
)
{
is
LoadingState
.
Loading
->
if
(
state
.
count
==
0L
)
showLoading
()
is
LoadingState
.
Loading
->
showLoading
()
is
LoadingState
.
Loaded
->
{
is
LoadingState
.
Loaded
->
hideLoading
()
hideLoading
()
if
(
state
.
count
==
0L
)
showNoChatRoomsToDisplay
()
}
is
LoadingState
.
Error
->
{
is
LoadingState
.
Error
->
{
hideLoading
()
hideLoading
()
showGenericErrorMessage
()
showGenericErrorMessage
()
...
@@ -260,27 +243,12 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
...
@@ -260,27 +243,12 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
}
}
})
})
// Actually it is fetching the rooms. We should fix it.
viewModel
.
getStatus
().
observe
(
viewLifecycleOwner
,
Observer
{
status
->
viewModel
.
getStatus
().
observe
(
viewLifecycleOwner
,
Observer
{
status
->
status
?.
let
{
showConnectionState
(
status
)
}
status
?.
let
{
})
//showConnectionState(status)
showAllChats
()
}
}
}
})
private
fun
setupListeners
()
{
text_server_name
.
setOnClickListener
{
ServersBottomSheetFragment
().
show
(
activity
?.
supportFragmentManager
,
chat
.
rocket
.
android
.
servers
.
ui
.
TAG
)
}
text_sort_by
.
setOnClickListener
{
SortingAndGroupingBottomSheetFragment
().
show
(
activity
?.
supportFragmentManager
,
chat
.
rocket
.
android
.
sortingandgrouping
.
ui
.
TAG
)
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/createchannel/ui/CreateChannelFragment.kt
View file @
75382d39
...
@@ -108,32 +108,22 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback
...
@@ -108,32 +108,22 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback
}
}
override
fun
showLoading
()
{
override
fun
showLoading
()
{
ui
{
ui
{
view_loading
.
isVisible
=
true
}
view_loading
.
isVisible
=
true
}
}
}
override
fun
hideLoading
()
{
override
fun
hideLoading
()
{
ui
{
ui
{
view_loading
.
isVisible
=
false
}
view_loading
.
isVisible
=
false
}
}
}
override
fun
showMessage
(
resId
:
Int
)
{
override
fun
showMessage
(
resId
:
Int
)
{
ui
{
ui
{
showToast
(
resId
)
}
showToast
(
resId
)
}
}
}
override
fun
showMessage
(
message
:
String
)
{
override
fun
showMessage
(
message
:
String
)
{
ui
{
ui
{
showToast
(
message
)
}
showToast
(
message
)
}
}
}
override
fun
showGenericErrorMessage
()
{
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
}
override
fun
showUserSuggestion
(
dataSet
:
List
<
MemberUiModel
>)
{
override
fun
showUserSuggestion
(
dataSet
:
List
<
MemberUiModel
>)
{
adapter
.
clearData
()
adapter
.
clearData
()
...
@@ -246,9 +236,7 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback
...
@@ -246,9 +236,7 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback
compositeDisposable
.
addAll
(
channelNameDisposable
,
inviteMembersDisposable
)
compositeDisposable
.
addAll
(
channelNameDisposable
,
inviteMembersDisposable
)
}
}
private
fun
unsubscribeEditTexts
()
{
private
fun
unsubscribeEditTexts
()
=
compositeDisposable
.
dispose
()
compositeDisposable
.
dispose
()
}
private
fun
startActionMode
()
{
private
fun
startActionMode
()
{
if
(
actionMode
==
null
)
{
if
(
actionMode
==
null
)
{
...
...
app/src/main/java/chat/rocket/android/dagger/module/AndroidWorkerInjectionModule.kt
View file @
75382d39
...
@@ -7,6 +7,7 @@ import dagger.multibindings.Multibinds
...
@@ -7,6 +7,7 @@ import dagger.multibindings.Multibinds
@Module
@Module
abstract
class
AndroidWorkerInjectionModule
{
abstract
class
AndroidWorkerInjectionModule
{
@Multibinds
@Multibinds
abstract
fun
workerInjectorFactories
():
Map
<
Class
<
out
Worker
>,
AndroidInjector
.
Factory
<
out
Worker
>>
abstract
fun
workerInjectorFactories
():
Map
<
Class
<
out
Worker
>,
AndroidInjector
.
Factory
<
out
Worker
>>
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/dagger/module/AppModule.kt
View file @
75382d39
...
@@ -88,13 +88,11 @@ import javax.inject.Singleton
...
@@ -88,13 +88,11 @@ import javax.inject.Singleton
class
AppModule
{
class
AppModule
{
@Provides
@Provides
@Singleton
fun
provideContext
(
application
:
Application
):
Context
{
fun
provideContext
(
application
:
Application
):
Context
{
return
application
return
application
}
}
@Provides
@Provides
@Singleton
fun
provideHttpLoggingInterceptor
():
HttpLoggingInterceptor
{
fun
provideHttpLoggingInterceptor
():
HttpLoggingInterceptor
{
val
interceptor
=
HttpLoggingInterceptor
(
object
:
HttpLoggingInterceptor
.
Logger
{
val
interceptor
=
HttpLoggingInterceptor
(
object
:
HttpLoggingInterceptor
.
Logger
{
override
fun
log
(
message
:
String
)
{
override
fun
log
(
message
:
String
)
{
...
@@ -112,19 +110,13 @@ class AppModule {
...
@@ -112,19 +110,13 @@ class AppModule {
}
}
@Provides
@Provides
@Singleton
fun
provideBasicAuthenticatorInterceptor
(
fun
provideBasicAuthenticatorInterceptor
(
getBasicAuthInteractor
:
GetBasicAuthInteractor
,
getBasicAuthInteractor
:
GetBasicAuthInteractor
,
saveBasicAuthInteractor
:
SaveBasicAuthInteractor
saveBasicAuthInteractor
:
SaveBasicAuthInteractor
):
BasicAuthenticatorInterceptor
{
):
BasicAuthenticatorInterceptor
=
return
BasicAuthenticatorInterceptor
(
BasicAuthenticatorInterceptor
(
getBasicAuthInteractor
,
saveBasicAuthInteractor
)
getBasicAuthInteractor
,
saveBasicAuthInteractor
)
}
@Provides
@Provides
@Singleton
fun
provideOkHttpClient
(
fun
provideOkHttpClient
(
logger
:
HttpLoggingInterceptor
,
logger
:
HttpLoggingInterceptor
,
basicAuthenticator
:
BasicAuthenticatorInterceptor
basicAuthenticator
:
BasicAuthenticatorInterceptor
...
@@ -139,7 +131,6 @@ class AppModule {
...
@@ -139,7 +131,6 @@ class AppModule {
}
}
@Provides
@Provides
@Singleton
fun
provideImagePipelineConfig
(
fun
provideImagePipelineConfig
(
context
:
Context
,
context
:
Context
,
okHttpClient
:
OkHttpClient
okHttpClient
:
OkHttpClient
...
@@ -153,92 +144,60 @@ class AppModule {
...
@@ -153,92 +144,60 @@ class AppModule {
}
}
@Provides
@Provides
@Singleton
fun
provideDraweeConfig
():
DraweeConfig
=
DraweeConfig
.
newBuilder
().
build
()
fun
provideDraweeConfig
():
DraweeConfig
{
return
DraweeConfig
.
newBuilder
().
build
()
}
@Provides
@Provides
@Singleton
fun
provideTokenRepository
(
prefs
:
SharedPreferences
,
moshi
:
Moshi
):
TokenRepository
=
fun
provideTokenRepository
(
prefs
:
SharedPreferences
,
moshi
:
Moshi
):
TokenRepository
{
SharedPreferencesTokenRepository
(
prefs
,
moshi
)
return
SharedPreferencesTokenRepository
(
prefs
,
moshi
)
}
@Provides
@Provides
@Singleton
fun
providePlatformLogger
():
PlatformLogger
=
TimberLogger
fun
providePlatformLogger
():
PlatformLogger
{
return
TimberLogger
}
@Provides
@Provides
@Singleton
fun
provideSharedPreferences
(
context
:
Application
)
=
fun
provideSharedPreferences
(
context
:
Application
)
=
context
.
getSharedPreferences
(
"rocket.chat"
,
Context
.
MODE_PRIVATE
)
context
.
getSharedPreferences
(
"rocket.chat"
,
Context
.
MODE_PRIVATE
)
@Provides
@Provides
@ForMessages
@ForMessages
fun
provideMessagesSharedPreferences
(
context
:
Application
)
=
fun
provideMessagesSharedPreferences
(
context
:
Application
)
=
context
.
getSharedPreferences
(
"messages"
,
Context
.
MODE_PRIVATE
)
context
.
getSharedPreferences
(
"messages"
,
Context
.
MODE_PRIVATE
)
@Provides
@Provides
@Singleton
fun
provideLocalRepository
(
prefs
:
SharedPreferences
,
moshi
:
Moshi
):
LocalRepository
=
fun
provideLocalRepository
(
prefs
:
SharedPreferences
,
moshi
:
Moshi
):
LocalRepository
{
SharedPreferencesLocalRepository
(
prefs
,
moshi
)
return
SharedPreferencesLocalRepository
(
prefs
,
moshi
)
}
@Provides
@Provides
@Singleton
fun
provideCurrentServerRepository
(
prefs
:
SharedPreferences
):
CurrentServerRepository
=
fun
provideCurrentServerRepository
(
prefs
:
SharedPreferences
):
CurrentServerRepository
{
SharedPrefsCurrentServerRepository
(
prefs
)
return
SharedPrefsCurrentServerRepository
(
prefs
)
}
@Provides
@Provides
@Singleton
fun
provideAnalyticsTrackingRepository
(
prefs
:
SharedPreferences
):
AnalyticsTrackingRepository
=
fun
provideAnalyticsTrackingRepository
(
prefs
:
SharedPreferences
):
AnalyticsTrackingRepository
{
SharedPrefsAnalyticsTrackingRepository
(
prefs
)
return
SharedPrefsAnalyticsTrackingRepository
(
prefs
)
}
@Provides
@Provides
@Singleton
fun
provideSortingAndGroupingRepository
(
prefs
:
SharedPreferences
):
SortingAndGroupingRepository
=
fun
provideSortingAndGroupingRepository
(
prefs
:
SharedPreferences
):
SortingAndGroupingRepository
{
SharedPrefsSortingAndGroupingRepository
(
prefs
)
return
SharedPrefsSortingAndGroupingRepository
(
prefs
)
}
@Provides
@Provides
@ForAuthentication
@ForAuthentication
fun
provideConnectingServerRepository
(
prefs
:
SharedPreferences
):
CurrentServerRepository
{
fun
provideConnectingServerRepository
(
prefs
:
SharedPreferences
):
CurrentServerRepository
=
return
SharedPrefsConnectingServerRepository
(
prefs
)
SharedPrefsConnectingServerRepository
(
prefs
)
}
@Provides
@Provides
@Singleton
fun
provideSettingsRepository
(
localRepository
:
LocalRepository
):
SettingsRepository
=
fun
provideSettingsRepository
(
localRepository
:
LocalRepository
):
SettingsRepository
{
SharedPreferencesSettingsRepository
(
localRepository
)
return
SharedPreferencesSettingsRepository
(
localRepository
)
}
@Provides
@Provides
@Singleton
fun
providePermissionsRepository
(
fun
providePermissionsRepository
(
localRepository
:
LocalRepository
,
localRepository
:
LocalRepository
,
moshi
:
Moshi
moshi
:
Moshi
):
PermissionsRepository
{
):
PermissionsRepository
=
SharedPreferencesPermissionsRepository
(
localRepository
,
moshi
)
return
SharedPreferencesPermissionsRepository
(
localRepository
,
moshi
)
}
@Provides
@Provides
@Singleton
fun
provideChatRoomRepository
():
ChatRoomsRepository
=
MemoryChatRoomsRepository
()
fun
provideChatRoomRepository
():
ChatRoomsRepository
{
return
MemoryChatRoomsRepository
()
}
@Provides
@Provides
@Singleton
fun
provideMoshi
():
Moshi
{
fun
provideMoshi
(
logger
:
PlatformLogger
,
currentServerInteractor
:
GetCurrentServerInteractor
):
Moshi
{
val
url
=
currentServerInteractor
.
get
()
?:
""
return
Moshi
.
Builder
()
return
Moshi
.
Builder
()
.
add
(
FallbackSealedClassJsonAdapter
.
ADAPTER_FACTORY
)
.
add
(
FallbackSealedClassJsonAdapter
.
ADAPTER_FACTORY
)
.
add
(
AppJsonAdapterFactory
.
INSTANCE
)
.
add
(
AppJsonAdapterFactory
.
INSTANCE
)
...
@@ -258,27 +217,19 @@ class AppModule {
...
@@ -258,27 +217,19 @@ class AppModule {
}
}
@Provides
@Provides
@Singleton
fun
provideMultiServerTokenRepository
(
fun
provideMultiServerTokenRepository
(
repository
:
LocalRepository
,
repository
:
LocalRepository
,
moshi
:
Moshi
moshi
:
Moshi
):
MultiServerTokenRepository
{
):
MultiServerTokenRepository
=
SharedPreferencesMultiServerTokenRepository
(
repository
,
moshi
)
return
SharedPreferencesMultiServerTokenRepository
(
repository
,
moshi
)
}
@Provides
@Provides
fun
provideMessageRepository
(
databaseManager
:
DatabaseManager
):
MessagesRepository
{
fun
provideMessageRepository
(
databaseManager
:
DatabaseManager
):
MessagesRepository
=
return
DatabaseMessagesRepository
(
databaseManager
,
DatabaseMessageMapper
(
databaseManager
))
DatabaseMessagesRepository
(
databaseManager
,
DatabaseMessageMapper
(
databaseManager
))
}
@Provides
@Provides
@Singleton
fun
provideUserRepository
():
UsersRepository
=
MemoryUsersRepository
()
fun
provideUserRepository
():
UsersRepository
{
return
MemoryUsersRepository
()
}
@Provides
@Provides
@Singleton
fun
provideConfiguration
(
context
:
Application
):
SpannableConfiguration
{
fun
provideConfiguration
(
context
:
Application
):
SpannableConfiguration
{
val
res
=
context
.
resources
val
res
=
context
.
resources
return
SpannableConfiguration
.
builder
(
context
)
return
SpannableConfiguration
.
builder
(
context
)
...
@@ -303,31 +254,25 @@ class AppModule {
...
@@ -303,31 +254,25 @@ class AppModule {
}
}
@Provides
@Provides
@Singleton
fun
provideBasicAuthRepository
(
fun
provideBasicAuthRepository
(
preferences
:
SharedPreferences
,
preferences
:
SharedPreferences
,
moshi
:
Moshi
moshi
:
Moshi
):
BasicAuthRepository
=
):
BasicAuthRepository
=
SharedPrefsBasicAuthRepository
(
preferences
,
moshi
)
SharedPrefsBasicAuthRepository
(
preferences
,
moshi
)
@Provides
@Provides
@Singleton
fun
provideAccountsRepository
(
fun
provideAccountsRepository
(
preferences
:
SharedPreferences
,
preferences
:
SharedPreferences
,
moshi
:
Moshi
moshi
:
Moshi
):
AccountsRepository
=
):
AccountsRepository
=
SharedPreferencesAccountsRepository
(
preferences
,
moshi
)
SharedPreferencesAccountsRepository
(
preferences
,
moshi
)
@Provides
@Provides
fun
provideNotificationManager
(
context
:
Application
)
=
fun
provideNotificationManager
(
context
:
Application
)
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
@Provides
@Provides
@Singleton
fun
provideGroupedPush
()
=
GroupedPush
()
fun
provideGroupedPush
()
=
GroupedPush
()
@Provides
@Provides
@Singleton
fun
providePushManager
(
fun
providePushManager
(
context
:
Application
,
context
:
Application
,
groupedPushes
:
GroupedPush
,
groupedPushes
:
GroupedPush
,
...
@@ -347,9 +292,8 @@ class AppModule {
...
@@ -347,9 +292,8 @@ class AppModule {
}
}
@Provides
@Provides
fun
provideJobScheduler
(
context
:
Application
):
JobScheduler
{
fun
provideJobScheduler
(
context
:
Application
):
JobScheduler
=
return
context
.
getSystemService
(
Context
.
JOB_SCHEDULER_SERVICE
)
as
JobScheduler
context
.
getSystemService
(
Context
.
JOB_SCHEDULER_SERVICE
)
as
JobScheduler
}
@Provides
@Provides
fun
provideSendMessageJob
(
context
:
Application
):
JobInfo
{
fun
provideSendMessageJob
(
context
:
Application
):
JobInfo
{
...
@@ -365,38 +309,27 @@ class AppModule {
...
@@ -365,38 +309,27 @@ class AppModule {
fun
provideJobSchedulerInteractor
(
fun
provideJobSchedulerInteractor
(
jobScheduler
:
JobScheduler
,
jobScheduler
:
JobScheduler
,
jobInfo
:
JobInfo
jobInfo
:
JobInfo
):
JobSchedulerInteractor
{
):
JobSchedulerInteractor
=
JobSchedulerInteractorImpl
(
jobScheduler
,
jobInfo
)
return
JobSchedulerInteractorImpl
(
jobScheduler
,
jobInfo
)
}
@Provides
@Provides
@Named
(
"currentServer"
)
@Named
(
"currentServer"
)
fun
provideCurrentServer
(
currentServerInteractor
:
GetCurrentServerInteractor
):
String
{
fun
provideCurrentServer
(
currentServerInteractor
:
GetCurrentServerInteractor
):
String
=
return
currentServerInteractor
.
get
()
!!
currentServerInteractor
.
get
()
!!
}
@Provides
@Provides
fun
provideDatabaseManager
(
fun
provideDatabaseManager
(
factory
:
DatabaseManagerFactory
,
factory
:
DatabaseManagerFactory
,
@Named
(
"currentServer"
)
currentServer
:
String
@Named
(
"currentServer"
)
currentServer
:
String
):
DatabaseManager
{
):
DatabaseManager
=
factory
.
create
(
currentServer
)
return
factory
.
create
(
currentServer
)
}
@Provides
@Provides
@Singleton
fun
provideAnswersAnalytics
():
AnswersAnalytics
=
AnswersAnalytics
()
fun
provideAnswersAnalytics
():
AnswersAnalytics
{
return
AnswersAnalytics
()
}
@Provides
@Provides
@Singleton
fun
provideGoogleAnalyticsForFirebase
(
context
:
Application
):
GoogleAnalyticsForFirebase
=
fun
provideGoogleAnalyticsForFirebase
(
context
:
Application
):
GoogleAnalyticsForFirebase
{
GoogleAnalyticsForFirebase
(
context
)
return
GoogleAnalyticsForFirebase
(
context
)
}
@Provides
@Provides
@Singleton
fun
provideAnalyticsManager
(
fun
provideAnalyticsManager
(
analyticsTrackingInteractor
:
AnalyticsTrackingInteractor
,
analyticsTrackingInteractor
:
AnalyticsTrackingInteractor
,
getCurrentServerInteractor
:
GetCurrentServerInteractor
,
getCurrentServerInteractor
:
GetCurrentServerInteractor
,
...
...
app/src/main/java/chat/rocket/android/db/UserDao.kt
View file @
75382d39
...
@@ -41,7 +41,7 @@ abstract class UserDao : BaseDao<UserEntity> {
...
@@ -41,7 +41,7 @@ abstract class UserDao : BaseDao<UserEntity> {
users
.
forEach
{
internalUpsert
(
it
)
}
users
.
forEach
{
internalUpsert
(
it
)
}
}
}
private
inline
fun
internalUpsert
(
user
:
BaseUserEntity
)
{
private
fun
internalUpsert
(
user
:
BaseUserEntity
)
{
val
count
=
if
(
user
is
UserStatus
)
{
val
count
=
if
(
user
is
UserStatus
)
{
update
(
user
.
id
,
user
.
status
)
update
(
user
.
id
,
user
.
status
)
}
else
{
}
else
{
...
...
app/src/main/java/chat/rocket/android/favoritemessages/ui/FavoriteMessagesFragment.kt
View file @
75382d39
...
@@ -43,8 +43,8 @@ class FavoriteMessagesFragment : Fragment(), FavoriteMessagesView {
...
@@ -43,8 +43,8 @@ class FavoriteMessagesFragment : Fragment(), FavoriteMessagesView {
private
val
adapter
=
ChatRoomAdapter
(
enableActions
=
false
)
private
val
adapter
=
ChatRoomAdapter
(
enableActions
=
false
)
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
chatRoomId
=
getString
(
INTENT_CHAT_ROOM_ID
,
""
)
chatRoomId
=
getString
(
INTENT_CHAT_ROOM_ID
,
""
)
...
...
app/src/main/java/chat/rocket/android/files/ui/FilesFragment.kt
View file @
75382d39
...
@@ -50,8 +50,8 @@ class FilesFragment : Fragment(), FilesView {
...
@@ -50,8 +50,8 @@ class FilesFragment : Fragment(), FilesView {
private
lateinit
var
chatRoomId
:
String
private
lateinit
var
chatRoomId
:
String
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
...
...
app/src/main/java/chat/rocket/android/main/ui/MainActivity.kt
View file @
75382d39
...
@@ -17,14 +17,10 @@ import dagger.android.HasActivityInjector
...
@@ -17,14 +17,10 @@ import dagger.android.HasActivityInjector
import
dagger.android.support.HasSupportFragmentInjector
import
dagger.android.support.HasSupportFragmentInjector
import
javax.inject.Inject
import
javax.inject.Inject
class
MainActivity
:
AppCompatActivity
(),
HasActivityInjector
,
class
MainActivity
:
AppCompatActivity
(),
HasActivityInjector
,
HasSupportFragmentInjector
{
HasSupportFragmentInjector
{
@Inject
lateinit
var
activityDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Activity
>
@Inject
@Inject
lateinit
var
fragmentDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Fragment
>
lateinit
var
activityDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Activity
>
@Inject
lateinit
var
presenter
:
MainPresenter
@Inject
lateinit
var
fagmentDispatchingAndroidInjector
:
DispatchingAndroidInjector
<
Fragment
>
@Inject
lateinit
var
presenter
:
MainPresenter
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
AndroidInjection
.
inject
(
this
)
AndroidInjection
.
inject
(
this
)
...
@@ -51,7 +47,7 @@ class MainActivity : AppCompatActivity(), HasActivityInjector,
...
@@ -51,7 +47,7 @@ class MainActivity : AppCompatActivity(), HasActivityInjector,
activityDispatchingAndroidInjector
activityDispatchingAndroidInjector
override
fun
supportFragmentInjector
():
AndroidInjector
<
Fragment
>
=
override
fun
supportFragmentInjector
():
AndroidInjector
<
Fragment
>
=
fagmentDispatchingAndroidInjector
f
r
agmentDispatchingAndroidInjector
private
fun
clearAppNotifications
()
=
private
fun
clearAppNotifications
()
=
(
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
).
cancelAll
()
(
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
).
cancelAll
()
...
...
app/src/main/java/chat/rocket/android/members/ui/MembersFragment.kt
View file @
75382d39
...
@@ -47,8 +47,8 @@ class MembersFragment : Fragment(), MembersView {
...
@@ -47,8 +47,8 @@ class MembersFragment : Fragment(), MembersView {
private
lateinit
var
chatRoomId
:
String
private
lateinit
var
chatRoomId
:
String
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
...
...
app/src/main/java/chat/rocket/android/mentions/ui/MentionsFragment.kt
View file @
75382d39
...
@@ -43,8 +43,8 @@ class MentionsFragment : Fragment(), MentionsView {
...
@@ -43,8 +43,8 @@ class MentionsFragment : Fragment(), MentionsView {
private
val
adapter
=
ChatRoomAdapter
(
enableActions
=
false
)
private
val
adapter
=
ChatRoomAdapter
(
enableActions
=
false
)
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
...
...
app/src/main/java/chat/rocket/android/pinnedmessages/ui/PinnedMessagesFragment.kt
View file @
75382d39
...
@@ -43,8 +43,8 @@ class PinnedMessagesFragment : Fragment(), PinnedMessagesView {
...
@@ -43,8 +43,8 @@ class PinnedMessagesFragment : Fragment(), PinnedMessagesView {
private
val
adapter
=
ChatRoomAdapter
(
enableActions
=
false
)
private
val
adapter
=
ChatRoomAdapter
(
enableActions
=
false
)
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
chatRoomId
=
getString
(
BUNDLE_CHAT_ROOM_ID
,
""
)
...
...
app/src/main/java/chat/rocket/android/profile/ui/ProfileFragment.kt
View file @
75382d39
...
@@ -62,8 +62,8 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -62,8 +62,8 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
private
val
editTextsDisposable
=
CompositeDisposable
()
private
val
editTextsDisposable
=
CompositeDisposable
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
setHasOptionsMenu
(
true
)
setHasOptionsMenu
(
true
)
}
}
...
...
app/src/main/java/chat/rocket/android/push/DirectReplyReceiverProvider.kt
View file @
75382d39
package
chat.rocket.android.push
package
chat.rocket.android.push
import
chat.rocket.android.dagger.module.AppModule
import
dagger.Module
import
dagger.Module
import
dagger.android.ContributesAndroidInjector
@Module
@Module
abstract
class
DirectReplyReceiverProvider
{
abstract
class
DirectReplyReceiverProvider
{
@ContributesAndroidInjector
(
modules
=
[
AppModule
::
class
])
abstract
fun
provideDirectReplyReceiver
():
DirectReplyReceiver
abstract
fun
provideDirectReplyReceiver
():
DirectReplyReceiver
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/push/di/DeleteReceiverProvider.kt
View file @
75382d39
package
chat.rocket.android.push.di
package
chat.rocket.android.push.di
import
chat.rocket.android.dagger.module.AppModule
import
chat.rocket.android.push.DeleteReceiver
import
chat.rocket.android.push.DeleteReceiver
import
dagger.Module
import
dagger.Module
import
dagger.android.ContributesAndroidInjector
@Module
@Module
abstract
class
DeleteReceiverProvider
{
abstract
class
DeleteReceiverProvider
{
@ContributesAndroidInjector
(
modules
=
[
AppModule
::
class
])
abstract
fun
provideDeleteReceiver
():
DeleteReceiver
abstract
fun
provideDeleteReceiver
():
DeleteReceiver
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/server/domain/SettingsRepository.kt
View file @
75382d39
...
@@ -116,7 +116,7 @@ fun PublicSettings.messageReadReceiptStoreUsers(): Boolean = this[MESSAGE_READ_R
...
@@ -116,7 +116,7 @@ fun PublicSettings.messageReadReceiptStoreUsers(): Boolean = this[MESSAGE_READ_R
fun
PublicSettings
.
uploadMimeTypeFilter
():
Array
<
String
>?
{
fun
PublicSettings
.
uploadMimeTypeFilter
():
Array
<
String
>?
{
val
values
=
this
[
UPLOAD_WHITELIST_MIMETYPES
]
?.
value
as
String
?
val
values
=
this
[
UPLOAD_WHITELIST_MIMETYPES
]
?.
value
as
String
?
if
(!
values
.
isNullOrBlank
())
{
if
(!
values
.
isNullOrBlank
())
{
return
values
!!
.
split
(
","
).
mapToTypedArray
{
it
.
trim
()
}
return
values
.
split
(
","
).
mapToTypedArray
{
it
.
trim
()
}
}
}
return
null
return
null
}
}
...
...
app/src/main/java/chat/rocket/android/server/presentation/ChangeServerPresenter.kt
View file @
75382d39
...
@@ -7,7 +7,6 @@ import chat.rocket.android.server.domain.GetAccountInteractor
...
@@ -7,7 +7,6 @@ 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.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.SaveCurrentServerInteractor
import
chat.rocket.android.server.domain.SaveCurrentServerInteractor
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import
chat.rocket.android.util.extension.launchUI
import
chat.rocket.android.util.extension.launchUI
...
@@ -23,7 +22,6 @@ class ChangeServerPresenter @Inject constructor(
...
@@ -23,7 +22,6 @@ class ChangeServerPresenter @Inject constructor(
private
val
getAccountInteractor
:
GetAccountInteractor
,
private
val
getAccountInteractor
:
GetAccountInteractor
,
private
val
getAccountsInteractor
:
GetAccountsInteractor
,
private
val
getAccountsInteractor
:
GetAccountsInteractor
,
private
val
analyticsManager
:
AnalyticsManager
,
private
val
analyticsManager
:
AnalyticsManager
,
private
val
settingsRepository
:
SettingsRepository
,
private
val
tokenRepository
:
TokenRepository
,
private
val
tokenRepository
:
TokenRepository
,
private
val
localRepository
:
LocalRepository
,
private
val
localRepository
:
LocalRepository
,
private
val
connectionManager
:
ConnectionManagerFactory
private
val
connectionManager
:
ConnectionManagerFactory
...
@@ -48,11 +46,6 @@ class ChangeServerPresenter @Inject constructor(
...
@@ -48,11 +46,6 @@ class ChangeServerPresenter @Inject constructor(
return
@launchUI
return
@launchUI
}
}
val
settings
=
settingsRepository
.
get
(
serverUrl
)
if
(
settings
==
null
)
{
// TODO - reload settings...
}
// Call disconnect on the old url if any...
// Call disconnect on the old url if any...
getCurrentServerInteractor
.
get
()
?.
let
{
url
->
getCurrentServerInteractor
.
get
()
?.
let
{
url
->
connectionManager
.
get
(
url
)
?.
disconnect
()
connectionManager
.
get
(
url
)
?.
disconnect
()
...
...
app/src/main/java/chat/rocket/android/servers/ui/ServersBottomSheetFragment.kt
View file @
75382d39
...
@@ -24,8 +24,8 @@ class ServersBottomSheetFragment : BottomSheetDialogFragment(), ServersView {
...
@@ -24,8 +24,8 @@ class ServersBottomSheetFragment : BottomSheetDialogFragment(), ServersView {
lateinit
var
presenter
:
ServersPresenter
lateinit
var
presenter
:
ServersPresenter
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
}
}
override
fun
onCreateView
(
override
fun
onCreateView
(
...
...
app/src/main/java/chat/rocket/android/settings/ui/SettingsFragment.kt
View file @
75382d39
...
@@ -22,6 +22,7 @@ import chat.rocket.android.settings.presentation.SettingsPresenter
...
@@ -22,6 +22,7 @@ import chat.rocket.android.settings.presentation.SettingsPresenter
import
chat.rocket.android.settings.presentation.SettingsView
import
chat.rocket.android.settings.presentation.SettingsView
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.inflate
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.android.util.extensions.ui
import
chat.rocket.android.util.invalidateFirebaseToken
import
chat.rocket.android.util.invalidateFirebaseToken
import
com.bumptech.glide.Glide
import
com.bumptech.glide.Glide
import
dagger.android.support.AndroidSupportInjection
import
dagger.android.support.AndroidSupportInjection
...
@@ -39,8 +40,8 @@ class SettingsFragment : Fragment(), SettingsView {
...
@@ -39,8 +40,8 @@ class SettingsFragment : Fragment(), SettingsView {
@Inject
lateinit
var
presenter
:
SettingsPresenter
@Inject
lateinit
var
presenter
:
SettingsPresenter
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
}
}
override
fun
onCreateView
(
override
fun
onCreateView
(
...
@@ -65,6 +66,7 @@ class SettingsFragment : Fragment(), SettingsView {
...
@@ -65,6 +66,7 @@ class SettingsFragment : Fragment(), SettingsView {
isDeleteAccountEnabled
:
Boolean
,
isDeleteAccountEnabled
:
Boolean
,
serverVersion
:
String
serverVersion
:
String
)
{
)
{
ui
{
context
?.
let
{
Glide
.
with
(
it
).
load
(
avatar
).
into
(
image_avatar
)
}
context
?.
let
{
Glide
.
with
(
it
).
load
(
avatar
).
into
(
image_avatar
)
}
text_display_name
.
text
=
displayName
text_display_name
.
text
=
displayName
...
@@ -82,14 +84,21 @@ class SettingsFragment : Fragment(), SettingsView {
...
@@ -82,14 +84,21 @@ class SettingsFragment : Fragment(), SettingsView {
text_share_this_app
.
setOnClickListener
{
shareApp
()
}
text_share_this_app
.
setOnClickListener
{
shareApp
()
}
text_license
.
setOnClickListener
{
text_license
.
setOnClickListener
{
presenter
.
toLicense
(
getString
(
R
.
string
.
license_url
),
getString
(
R
.
string
.
title_licence
))
presenter
.
toLicense
(
getString
(
R
.
string
.
license_url
),
getString
(
R
.
string
.
title_licence
)
)
}
}
text_app_version
.
text
=
getString
(
R
.
string
.
msg_app_version
,
BuildConfig
.
VERSION_NAME
,
BuildConfig
.
VERSION_CODE
)
text_app_version
.
text
=
getString
(
R
.
string
.
msg_app_version
,
BuildConfig
.
VERSION_NAME
,
BuildConfig
.
VERSION_CODE
)
text_server_version
.
text
=
getString
(
R
.
string
.
msg_server_version
,
serverVersion
)
text_server_version
.
text
=
getString
(
R
.
string
.
msg_server_version
,
serverVersion
)
text_logout
.
setOnClickListener
{
showLogoutDialog
()
}
text_logout
.
setOnClickListener
{
showLogoutDialog
()
}
with
(
text_administration
)
{
with
(
text_administration
)
{
isVisible
=
isAdministrationEnabled
isVisible
=
isAdministrationEnabled
...
@@ -109,23 +118,24 @@ class SettingsFragment : Fragment(), SettingsView {
...
@@ -109,23 +118,24 @@ class SettingsFragment : Fragment(), SettingsView {
setOnClickListener
{
showDeleteAccountDialog
()
}
setOnClickListener
{
showDeleteAccountDialog
()
}
}
}
}
}
}
override
fun
invalidateToken
(
token
:
String
)
=
invalidateFirebaseToken
(
token
)
override
fun
invalidateToken
(
token
:
String
)
=
invalidateFirebaseToken
(
token
)
override
fun
showLoading
()
{
override
fun
showLoading
()
{
view_loading
.
isVisible
=
true
ui
{
view_loading
.
isVisible
=
true
}
}
}
override
fun
hideLoading
()
{
override
fun
hideLoading
()
{
view_loading
.
isVisible
=
false
ui
{
view_loading
.
isVisible
=
false
}
}
}
override
fun
showMessage
(
resId
:
Int
)
{
override
fun
showMessage
(
resId
:
Int
)
{
showToast
(
resId
)
ui
{
showToast
(
resId
)
}
}
}
override
fun
showMessage
(
message
:
String
)
{
override
fun
showMessage
(
message
:
String
)
{
showToast
(
message
)
ui
{
showToast
(
message
)
}
}
}
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
...
...
app/src/main/java/chat/rocket/android/sortingandgrouping/ui/SortingAndGroupingBottomSheetFragment.kt
View file @
75382d39
...
@@ -37,8 +37,8 @@ class SortingAndGroupingBottomSheetFragment : BottomSheetDialogFragment(), Sorti
...
@@ -37,8 +37,8 @@ class SortingAndGroupingBottomSheetFragment : BottomSheetDialogFragment(), Sorti
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
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
}
}
override
fun
onCreateView
(
override
fun
onCreateView
(
...
...
app/src/main/java/chat/rocket/android/userdetails/ui/UserDetailsFragment.kt
View file @
75382d39
...
@@ -47,8 +47,8 @@ class UserDetailsFragment : Fragment(), UserDetailsView {
...
@@ -47,8 +47,8 @@ class UserDetailsFragment : Fragment(), UserDetailsView {
private
val
handler
=
Handler
()
private
val
handler
=
Handler
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
AndroidSupportInjection
.
inject
(
this
)
AndroidSupportInjection
.
inject
(
this
)
super
.
onCreate
(
savedInstanceState
)
arguments
?.
run
{
arguments
?.
run
{
userId
=
getString
(
BUNDLE_USER_ID
,
""
)
userId
=
getString
(
BUNDLE_USER_ID
,
""
)
...
...
app/src/main/res/values-ar/strings.xml
View file @
75382d39
...
@@ -275,7 +275,7 @@
...
@@ -275,7 +275,7 @@
<string
name=
"msg_all_files_appear_here"
>
الملفات تظهر هنا
</string>
<string
name=
"msg_all_files_appear_here"
>
الملفات تظهر هنا
</string>
<!-- Upload Messages -->
<!-- Upload Messages -->
<string
name=
"max_file_size_exceeded"
>
ملف كبير
</string
>
<string
name=
"max_file_size_exceeded"
>
File size %1$d bytes exceeded max upload size of %2$d bytes
</string>
<!-- TODO Translate --
>
<!-- Socket status -->
<!-- Socket status -->
<string
name=
"status_connected"
>
اتصال
</string>
<string
name=
"status_connected"
>
اتصال
</string>
...
...
app/src/play/java/chat/rocket/android/dagger/module/ServiceBuilder.kt
View file @
75382d39
...
@@ -26,7 +26,5 @@ abstract class ServiceBuilder {
...
@@ -26,7 +26,5 @@ abstract class ServiceBuilder {
@Binds
@Binds
@IntoMap
@IntoMap
@WorkerKey
(
TokenRegistrationWorker
::
class
)
@WorkerKey
(
TokenRegistrationWorker
::
class
)
abstract
fun
bindTokenRegistrationWorkerFactory
(
abstract
fun
bindTokenRegistrationWorkerFactory
(
builder
:
TokenRegistrationSubComponent
.
Builder
):
AndroidInjector
.
Factory
<
out
Worker
>
builder
:
TokenRegistrationSubComponent
.
Builder
):
AndroidInjector
.
Factory
<
out
Worker
>
}
}
\ No newline at end of file
app/src/play/java/chat/rocket/android/push/FirebaseMessagingService.kt
View file @
75382d39
...
@@ -13,13 +13,11 @@ import dagger.android.AndroidInjection
...
@@ -13,13 +13,11 @@ import dagger.android.AndroidInjection
import
javax.inject.Inject
import
javax.inject.Inject
class
FirebaseMessagingService
:
FirebaseMessagingService
()
{
class
FirebaseMessagingService
:
FirebaseMessagingService
()
{
@Inject
lateinit
var
pushManager
:
PushManager
@Inject
lateinit
var
pushManager
:
PushManager
override
fun
onCreate
()
{
override
fun
onCreate
()
{
super
.
onCreate
()
AndroidInjection
.
inject
(
this
)
AndroidInjection
.
inject
(
this
)
super
.
onCreate
()
}
}
override
fun
onMessageReceived
(
message
:
RemoteMessage
)
{
override
fun
onMessageReceived
(
message
:
RemoteMessage
)
{
...
...
app/src/play/java/chat/rocket/android/push/di/FirebaseMessagingServiceProvider.kt
View file @
75382d39
package
chat.rocket.android.push.di
package
chat.rocket.android.push.di
import
chat.rocket.android.dagger.module.AppModule
import
chat.rocket.android.push.FirebaseMessagingService
import
chat.rocket.android.push.FirebaseMessagingService
import
dagger.Module
import
dagger.Module
import
dagger.android.ContributesAndroidInjector
@Module
@Module
abstract
class
FirebaseMessagingServiceProvider
{
abstract
class
FirebaseMessagingServiceProvider
{
@ContributesAndroidInjector
(
modules
=
[
AppModule
::
class
])
abstract
fun
provideFirebaseMessagingService
():
FirebaseMessagingService
abstract
fun
provideFirebaseMessagingService
():
FirebaseMessagingService
}
}
\ No newline at end of file
app/src/play/java/chat/rocket/android/push/worker/TokenRegistrationWorker.kt
View file @
75382d39
...
@@ -15,10 +15,8 @@ import kotlinx.coroutines.runBlocking
...
@@ -15,10 +15,8 @@ import kotlinx.coroutines.runBlocking
import
timber.log.Timber
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
class
TokenRegistrationWorker
@Inject
constructor
(
class
TokenRegistrationWorker
(
appContext
:
Context
,
workerParams
:
WorkerParameters
)
:
appContext
:
Context
,
Worker
(
appContext
,
workerParams
)
{
workerParams
:
WorkerParameters
)
:
Worker
(
appContext
,
workerParams
)
{
@Inject
lateinit
var
factory
:
RocketChatClientFactory
@Inject
lateinit
var
factory
:
RocketChatClientFactory
@Inject
lateinit
var
getAccountsInteractor
:
GetAccountsInteractor
@Inject
lateinit
var
getAccountsInteractor
:
GetAccountsInteractor
@Inject
lateinit
var
localRepository
:
LocalRepository
@Inject
lateinit
var
localRepository
:
LocalRepository
...
...
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