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
46eff2d8
Unverified
Commit
46eff2d8
authored
Apr 18, 2018
by
divyanshu bhargava
Committed by
GitHub
Apr 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9 from RocketChat/develop
merge
parents
95a28de4
7b7997d5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
51 deletions
+94
-51
build.gradle
app/build.gradle
+2
-2
LoginDeepLinkInfo.kt
.../android/authentication/domain/model/LoginDeepLinkInfo.kt
+2
-0
ChatRoomFragment.kt
.../java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
+2
-2
AppModule.kt
.../main/java/chat/rocket/android/dagger/module/AppModule.kt
+27
-7
ProfilePresenter.kt
...t/rocket/android/profile/presentation/ProfilePresenter.kt
+2
-5
ProfileFragment.kt
...in/java/chat/rocket/android/profile/ui/ProfileFragment.kt
+41
-22
FirebaseTokenService.kt
...ain/java/chat/rocket/android/push/FirebaseTokenService.kt
+18
-13
No files found.
app/build.gradle
View file @
46eff2d8
...
@@ -13,8 +13,8 @@ android {
...
@@ -13,8 +13,8 @@ android {
applicationId
"chat.rocket.android"
applicationId
"chat.rocket.android"
minSdkVersion
21
minSdkVersion
21
targetSdkVersion
versions
.
targetSdk
targetSdkVersion
versions
.
targetSdk
versionCode
201
0
versionCode
201
1
versionName
"2.0.
0
"
versionName
"2.0.
1
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled
true
multiDexEnabled
true
}
}
...
...
app/src/main/java/chat/rocket/android/authentication/domain/model/LoginDeepLinkInfo.kt
View file @
46eff2d8
package
chat.rocket.android.authentication.domain.model
package
chat.rocket.android.authentication.domain.model
import
android.annotation.SuppressLint
import
android.content.Intent
import
android.content.Intent
import
android.net.Uri
import
android.net.Uri
import
android.os.Parcelable
import
android.os.Parcelable
import
kotlinx.android.parcel.Parcelize
import
kotlinx.android.parcel.Parcelize
import
timber.log.Timber
import
timber.log.Timber
@SuppressLint
(
"ParcelCreator"
)
@Parcelize
@Parcelize
data class
LoginDeepLinkInfo
(
data class
LoginDeepLinkInfo
(
val
url
:
String
,
val
url
:
String
,
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
46eff2d8
...
@@ -4,6 +4,7 @@ import android.Manifest
...
@@ -4,6 +4,7 @@ import android.Manifest
import
android.app.Activity
import
android.app.Activity
import
android.content.ClipData
import
android.content.ClipData
import
android.content.ClipboardManager
import
android.content.ClipboardManager
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.net.Uri
import
android.net.Uri
...
@@ -17,7 +18,6 @@ import android.support.v7.widget.DefaultItemAnimator
...
@@ -17,7 +18,6 @@ import android.support.v7.widget.DefaultItemAnimator
import
android.support.v7.widget.LinearLayoutManager
import
android.support.v7.widget.LinearLayoutManager
import
android.support.v7.widget.RecyclerView
import
android.support.v7.widget.RecyclerView
import
android.view.*
import
android.view.*
import
androidx.core.content.systemService
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.*
import
chat.rocket.android.chatroom.adapter.*
import
chat.rocket.android.chatroom.presentation.ChatRoomPresenter
import
chat.rocket.android.chatroom.presentation.ChatRoomPresenter
...
@@ -408,7 +408,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
...
@@ -408,7 +408,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
copyToClipboard
(
message
:
String
)
{
override
fun
copyToClipboard
(
message
:
String
)
{
ui
{
ui
{
val
clipboard
:
ClipboardManager
=
it
.
systemService
()
val
clipboard
=
it
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
)
as
ClipboardManager
clipboard
.
primaryClip
=
ClipData
.
newPlainText
(
""
,
message
)
clipboard
.
primaryClip
=
ClipData
.
newPlainText
(
""
,
message
)
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/dagger/module/AppModule.kt
View file @
46eff2d8
...
@@ -8,7 +8,6 @@ import android.arch.persistence.room.Room
...
@@ -8,7 +8,6 @@ import android.arch.persistence.room.Room
import
android.content.ComponentName
import
android.content.ComponentName
import
android.content.Context
import
android.content.Context
import
android.content.SharedPreferences
import
android.content.SharedPreferences
import
androidx.core.content.systemService
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.R
import
chat.rocket.android.R
import
chat.rocket.android.app.RocketChatDatabase
import
chat.rocket.android.app.RocketChatDatabase
...
@@ -23,8 +22,29 @@ import chat.rocket.android.infrastructure.LocalRepository
...
@@ -23,8 +22,29 @@ import chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.SharedPrefsLocalRepository
import
chat.rocket.android.infrastructure.SharedPrefsLocalRepository
import
chat.rocket.android.push.GroupedPush
import
chat.rocket.android.push.GroupedPush
import
chat.rocket.android.push.PushManager
import
chat.rocket.android.push.PushManager
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.domain.AccountsRepository
import
chat.rocket.android.server.infraestructure.*
import
chat.rocket.android.server.domain.ChatRoomsRepository
import
chat.rocket.android.server.domain.CurrentServerRepository
import
chat.rocket.android.server.domain.GetAccountInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetPermissionsInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
import
chat.rocket.android.server.domain.JobSchedulerInteractor
import
chat.rocket.android.server.domain.MessagesRepository
import
chat.rocket.android.server.domain.MultiServerTokenRepository
import
chat.rocket.android.server.domain.RoomRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.domain.UsersRepository
import
chat.rocket.android.server.infraestructure.JobSchedulerInteractorImpl
import
chat.rocket.android.server.infraestructure.MemoryChatRoomsRepository
import
chat.rocket.android.server.infraestructure.MemoryRoomRepository
import
chat.rocket.android.server.infraestructure.MemoryUsersRepository
import
chat.rocket.android.server.infraestructure.ServerDao
import
chat.rocket.android.server.infraestructure.SharedPreferencesAccountsRepository
import
chat.rocket.android.server.infraestructure.SharedPreferencesMessagesRepository
import
chat.rocket.android.server.infraestructure.SharedPreferencesSettingsRepository
import
chat.rocket.android.server.infraestructure.SharedPrefsCurrentServerRepository
import
chat.rocket.android.util.AppJsonAdapterFactory
import
chat.rocket.android.util.AppJsonAdapterFactory
import
chat.rocket.android.util.TimberLogger
import
chat.rocket.android.util.TimberLogger
import
chat.rocket.common.internal.FallbackSealedClassJsonAdapter
import
chat.rocket.common.internal.FallbackSealedClassJsonAdapter
...
@@ -231,8 +251,7 @@ class AppModule {
...
@@ -231,8 +251,7 @@ class AppModule {
@Provides
@Provides
@Singleton
@Singleton
fun
provideMessageRepository
(
context
:
Application
,
fun
provideMessageRepository
(
@ForMessages
preferences
:
SharedPreferences
,
@ForMessages
preferences
:
SharedPreferences
,
moshi
:
Moshi
,
moshi
:
Moshi
,
currentServerInteractor
:
GetCurrentServerInteractor
):
MessagesRepository
{
currentServerInteractor
:
GetCurrentServerInteractor
):
MessagesRepository
{
return
SharedPreferencesMessagesRepository
(
preferences
,
moshi
,
currentServerInteractor
)
return
SharedPreferencesMessagesRepository
(
preferences
,
moshi
,
currentServerInteractor
)
...
@@ -278,7 +297,8 @@ class AppModule {
...
@@ -278,7 +297,8 @@ class AppModule {
SharedPreferencesAccountsRepository
(
preferences
,
moshi
)
SharedPreferencesAccountsRepository
(
preferences
,
moshi
)
@Provides
@Provides
fun
provideNotificationManager
(
context
:
Context
):
NotificationManager
=
context
.
systemService
()
fun
provideNotificationManager
(
context
:
Application
)
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
@Provides
@Provides
@Singleton
@Singleton
...
@@ -287,7 +307,7 @@ class AppModule {
...
@@ -287,7 +307,7 @@ class AppModule {
@Provides
@Provides
@Singleton
@Singleton
fun
providePushManager
(
fun
providePushManager
(
context
:
Context
,
context
:
Application
,
groupedPushes
:
GroupedPush
,
groupedPushes
:
GroupedPush
,
manager
:
NotificationManager
,
manager
:
NotificationManager
,
moshi
:
Moshi
,
moshi
:
Moshi
,
...
...
app/src/main/java/chat/rocket/android/profile/presentation/ProfilePresenter.kt
View file @
46eff2d8
package
chat.rocket.android.profile.presentation
package
chat.rocket.android.profile.presentation
import
chat.rocket.android.core.behaviours.showMessage
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
...
@@ -36,11 +37,7 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView,
...
@@ -36,11 +37,7 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView,
myself
.
emails
?.
get
(
0
)
?.
address
!!
myself
.
emails
?.
get
(
0
)
?.
address
!!
)
)
}
catch
(
exception
:
RocketChatException
)
{
}
catch
(
exception
:
RocketChatException
)
{
exception
.
message
?.
let
{
view
.
showMessage
(
exception
)
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
}
finally
{
}
finally
{
view
.
hideLoading
()
view
.
hideLoading
()
}
}
...
...
app/src/main/java/chat/rocket/android/profile/ui/ProfileFragment.kt
View file @
46eff2d8
...
@@ -12,6 +12,7 @@ import chat.rocket.android.profile.presentation.ProfilePresenter
...
@@ -12,6 +12,7 @@ import chat.rocket.android.profile.presentation.ProfilePresenter
import
chat.rocket.android.profile.presentation.ProfileView
import
chat.rocket.android.profile.presentation.ProfileView
import
chat.rocket.android.util.extensions.*
import
chat.rocket.android.util.extensions.*
import
dagger.android.support.AndroidSupportInjection
import
dagger.android.support.AndroidSupportInjection
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.rxkotlin.Observables
import
io.reactivex.rxkotlin.Observables
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.avatar_profile.*
import
kotlinx.android.synthetic.main.avatar_profile.*
...
@@ -25,6 +26,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -25,6 +26,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
private
lateinit
var
currentEmail
:
String
private
lateinit
var
currentEmail
:
String
private
lateinit
var
currentAvatar
:
String
private
lateinit
var
currentAvatar
:
String
private
var
actionMode
:
ActionMode
?
=
null
private
var
actionMode
:
ActionMode
?
=
null
private
val
disposables
=
CompositeDisposable
()
companion
object
{
companion
object
{
fun
newInstance
()
=
ProfileFragment
()
fun
newInstance
()
=
ProfileFragment
()
...
@@ -48,7 +50,13 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -48,7 +50,13 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
presenter
.
loadUserProfile
()
presenter
.
loadUserProfile
()
}
}
override
fun
onDestroyView
()
{
disposables
.
clear
()
super
.
onDestroyView
()
}
override
fun
showProfile
(
avatarUrl
:
String
,
name
:
String
,
username
:
String
,
email
:
String
)
{
override
fun
showProfile
(
avatarUrl
:
String
,
name
:
String
,
username
:
String
,
email
:
String
)
{
ui
{
image_avatar
.
setImageURI
(
avatarUrl
)
image_avatar
.
setImageURI
(
avatarUrl
)
text_name
.
textContent
=
name
text_name
.
textContent
=
name
...
@@ -65,6 +73,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -65,6 +73,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
listenToChanges
()
listenToChanges
()
}
}
}
override
fun
showProfileUpdateSuccessfullyMessage
()
{
override
fun
showProfileUpdateSuccessfullyMessage
()
{
showMessage
(
getString
(
R
.
string
.
msg_profile_update_successfully
))
showMessage
(
getString
(
R
.
string
.
msg_profile_update_successfully
))
...
@@ -72,23 +81,31 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -72,23 +81,31 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
override
fun
showLoading
()
{
override
fun
showLoading
()
{
enableUserInput
(
false
)
enableUserInput
(
false
)
ui
{
view_loading
.
setVisible
(
true
)
view_loading
.
setVisible
(
true
)
}
}
}
override
fun
hideLoading
()
{
override
fun
hideLoading
()
{
ui
{
if
(
view_loading
!=
null
)
{
if
(
view_loading
!=
null
)
{
view_loading
.
setVisible
(
false
)
view_loading
.
setVisible
(
false
)
}
}
}
enableUserInput
(
true
)
enableUserInput
(
true
)
}
}
override
fun
showMessage
(
resId
:
Int
)
{
override
fun
showMessage
(
resId
:
Int
)
{
ui
{
showToast
(
resId
)
showToast
(
resId
)
}
}
}
override
fun
showMessage
(
message
:
String
)
{
override
fun
showMessage
(
message
:
String
)
{
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
))
...
@@ -136,7 +153,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -136,7 +153,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
}
}
private
fun
listenToChanges
()
{
private
fun
listenToChanges
()
{
Observables
.
combineLatest
(
text_name
.
asObservable
(),
disposables
.
add
(
Observables
.
combineLatest
(
text_name
.
asObservable
(),
text_username
.
asObservable
(),
text_username
.
asObservable
(),
text_email
.
asObservable
(),
text_email
.
asObservable
(),
text_avatar_url
.
asObservable
())
{
text_name
,
text_username
,
text_email
,
text_avatar_url
->
text_avatar_url
.
asObservable
())
{
text_name
,
text_username
,
text_email
,
text_avatar_url
->
...
@@ -144,7 +161,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -144,7 +161,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
text_username
.
toString
()
!=
currentUsername
||
text_username
.
toString
()
!=
currentUsername
||
text_email
.
toString
()
!=
currentEmail
||
text_email
.
toString
()
!=
currentEmail
||
(
text_avatar_url
.
toString
()
!=
""
&&
text_avatar_url
.
toString
()
!=
currentAvatar
))
(
text_avatar_url
.
toString
()
!=
""
&&
text_avatar_url
.
toString
()
!=
currentAvatar
))
}.
subscribe
(
{
isValid
->
}.
subscribe
{
isValid
->
if
(
isValid
)
{
if
(
isValid
)
{
startActionMode
()
startActionMode
()
}
else
{
}
else
{
...
@@ -162,9 +179,11 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
...
@@ -162,9 +179,11 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
private
fun
finishActionMode
()
=
actionMode
?.
finish
()
private
fun
finishActionMode
()
=
actionMode
?.
finish
()
private
fun
enableUserInput
(
value
:
Boolean
)
{
private
fun
enableUserInput
(
value
:
Boolean
)
{
ui
{
text_username
.
isEnabled
=
value
text_username
.
isEnabled
=
value
text_username
.
isEnabled
=
value
text_username
.
isEnabled
=
value
text_email
.
isEnabled
=
value
text_email
.
isEnabled
=
value
text_avatar_url
.
isEnabled
=
value
text_avatar_url
.
isEnabled
=
value
}
}
}
}
}
app/src/main/java/chat/rocket/android/push/FirebaseTokenService.kt
View file @
46eff2d8
...
@@ -4,6 +4,7 @@ import chat.rocket.android.R
...
@@ -4,6 +4,7 @@ import chat.rocket.android.R
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.RocketChatException
import
chat.rocket.common.RocketChatException
import
chat.rocket.core.internal.rest.registerPushToken
import
chat.rocket.core.internal.rest.registerPushToken
import
com.google.android.gms.gcm.GoogleCloudMessaging
import
com.google.android.gms.gcm.GoogleCloudMessaging
...
@@ -32,6 +33,7 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
...
@@ -32,6 +33,7 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
override
fun
onTokenRefresh
()
{
override
fun
onTokenRefresh
()
{
//TODO: We need to use the Cordova Project gcm_sender_id since it's the one configured on RC
//TODO: We need to use the Cordova Project gcm_sender_id since it's the one configured on RC
// default push gateway. We should register this project's own project sender id into it.
// default push gateway. We should register this project's own project sender id into it.
try
{
val
gcmToken
=
InstanceID
.
getInstance
(
this
)
val
gcmToken
=
InstanceID
.
getInstance
(
this
)
.
getToken
(
getString
(
R
.
string
.
gcm_sender_id
),
GoogleCloudMessaging
.
INSTANCE_ID_SCOPE
,
null
)
.
getToken
(
getString
(
R
.
string
.
gcm_sender_id
),
GoogleCloudMessaging
.
INSTANCE_ID_SCOPE
,
null
)
val
currentServer
=
getCurrentServerInteractor
.
get
()
val
currentServer
=
getCurrentServerInteractor
.
get
()
...
@@ -43,12 +45,15 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
...
@@ -43,12 +45,15 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
launch
{
launch
{
try
{
try
{
Timber
.
d
(
"Registering push token: $gcmToken for ${client.url}"
)
Timber
.
d
(
"Registering push token: $gcmToken for ${client.url}"
)
client
.
registerPushToken
(
gcmToken
)
retryIO
(
"register push token"
)
{
client
.
registerPushToken
(
gcmToken
)
}
}
catch
(
ex
:
RocketChatException
)
{
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
Timber
.
e
(
ex
,
"Error registering push token"
)
}
}
}
}
}
}
}
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error refreshing Firebase TOKEN"
)
}
}
}
}
}
}
\ No newline at end of file
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