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
Hide 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 {
applicationId
"chat.rocket.android"
minSdkVersion
21
targetSdkVersion
versions
.
targetSdk
versionCode
201
0
versionName
"2.0.
0
"
versionCode
201
1
versionName
"2.0.
1
"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled
true
}
...
...
app/src/main/java/chat/rocket/android/authentication/domain/model/LoginDeepLinkInfo.kt
View file @
46eff2d8
package
chat.rocket.android.authentication.domain.model
import
android.annotation.SuppressLint
import
android.content.Intent
import
android.net.Uri
import
android.os.Parcelable
import
kotlinx.android.parcel.Parcelize
import
timber.log.Timber
@SuppressLint
(
"ParcelCreator"
)
@Parcelize
data class
LoginDeepLinkInfo
(
val
url
:
String
,
...
...
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomFragment.kt
View file @
46eff2d8
...
...
@@ -4,6 +4,7 @@ import android.Manifest
import
android.app.Activity
import
android.content.ClipData
import
android.content.ClipboardManager
import
android.content.Context
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.net.Uri
...
...
@@ -17,7 +18,6 @@ import android.support.v7.widget.DefaultItemAnimator
import
android.support.v7.widget.LinearLayoutManager
import
android.support.v7.widget.RecyclerView
import
android.view.*
import
androidx.core.content.systemService
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.adapter.*
import
chat.rocket.android.chatroom.presentation.ChatRoomPresenter
...
...
@@ -408,7 +408,7 @@ class ChatRoomFragment : Fragment(), ChatRoomView, EmojiKeyboardListener, EmojiR
override
fun
copyToClipboard
(
message
:
String
)
{
ui
{
val
clipboard
:
ClipboardManager
=
it
.
systemService
()
val
clipboard
=
it
.
getSystemService
(
Context
.
CLIPBOARD_SERVICE
)
as
ClipboardManager
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
import
android.content.ComponentName
import
android.content.Context
import
android.content.SharedPreferences
import
androidx.core.content.systemService
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.R
import
chat.rocket.android.app.RocketChatDatabase
...
...
@@ -23,8 +22,29 @@ import chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.SharedPrefsLocalRepository
import
chat.rocket.android.push.GroupedPush
import
chat.rocket.android.push.PushManager
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.infraestructure.*
import
chat.rocket.android.server.domain.AccountsRepository
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.TimberLogger
import
chat.rocket.common.internal.FallbackSealedClassJsonAdapter
...
...
@@ -231,8 +251,7 @@ class AppModule {
@Provides
@Singleton
fun
provideMessageRepository
(
context
:
Application
,
@ForMessages
preferences
:
SharedPreferences
,
fun
provideMessageRepository
(
@ForMessages
preferences
:
SharedPreferences
,
moshi
:
Moshi
,
currentServerInteractor
:
GetCurrentServerInteractor
):
MessagesRepository
{
return
SharedPreferencesMessagesRepository
(
preferences
,
moshi
,
currentServerInteractor
)
...
...
@@ -278,7 +297,8 @@ class AppModule {
SharedPreferencesAccountsRepository
(
preferences
,
moshi
)
@Provides
fun
provideNotificationManager
(
context
:
Context
):
NotificationManager
=
context
.
systemService
()
fun
provideNotificationManager
(
context
:
Application
)
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
@Provides
@Singleton
...
...
@@ -287,7 +307,7 @@ class AppModule {
@Provides
@Singleton
fun
providePushManager
(
context
:
Context
,
context
:
Application
,
groupedPushes
:
GroupedPush
,
manager
:
NotificationManager
,
moshi
:
Moshi
,
...
...
app/src/main/java/chat/rocket/android/profile/presentation/ProfilePresenter.kt
View file @
46eff2d8
package
chat.rocket.android.profile.presentation
import
chat.rocket.android.core.behaviours.showMessage
import
chat.rocket.android.core.lifecycle.CancelStrategy
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
...
...
@@ -36,11 +37,7 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView,
myself
.
emails
?.
get
(
0
)
?.
address
!!
)
}
catch
(
exception
:
RocketChatException
)
{
exception
.
message
?.
let
{
view
.
showMessage
(
it
)
}.
ifNull
{
view
.
showGenericErrorMessage
()
}
view
.
showMessage
(
exception
)
}
finally
{
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
import
chat.rocket.android.profile.presentation.ProfileView
import
chat.rocket.android.util.extensions.*
import
dagger.android.support.AndroidSupportInjection
import
io.reactivex.disposables.CompositeDisposable
import
io.reactivex.rxkotlin.Observables
import
kotlinx.android.synthetic.main.app_bar.*
import
kotlinx.android.synthetic.main.avatar_profile.*
...
...
@@ -25,6 +26,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
private
lateinit
var
currentEmail
:
String
private
lateinit
var
currentAvatar
:
String
private
var
actionMode
:
ActionMode
?
=
null
private
val
disposables
=
CompositeDisposable
()
companion
object
{
fun
newInstance
()
=
ProfileFragment
()
...
...
@@ -48,22 +50,29 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
presenter
.
loadUserProfile
()
}
override
fun
onDestroyView
()
{
disposables
.
clear
()
super
.
onDestroyView
()
}
override
fun
showProfile
(
avatarUrl
:
String
,
name
:
String
,
username
:
String
,
email
:
String
)
{
image_avatar
.
setImageURI
(
avatarUrl
)
ui
{
image_avatar
.
setImageURI
(
avatarUrl
)
text_name
.
textContent
=
name
text_username
.
textContent
=
username
text_email
.
textContent
=
email
text_avatar_url
.
textContent
=
""
text_name
.
textContent
=
name
text_username
.
textContent
=
username
text_email
.
textContent
=
email
text_avatar_url
.
textContent
=
""
currentName
=
name
currentUsername
=
username
currentEmail
=
email
currentAvatar
=
avatarUrl
currentName
=
name
currentUsername
=
username
currentEmail
=
email
currentAvatar
=
avatarUrl
profile_container
.
setVisible
(
true
)
profile_container
.
setVisible
(
true
)
listenToChanges
()
listenToChanges
()
}
}
override
fun
showProfileUpdateSuccessfullyMessage
()
{
...
...
@@ -72,22 +81,30 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
override
fun
showLoading
()
{
enableUserInput
(
false
)
view_loading
.
setVisible
(
true
)
ui
{
view_loading
.
setVisible
(
true
)
}
}
override
fun
hideLoading
()
{
if
(
view_loading
!=
null
)
{
view_loading
.
setVisible
(
false
)
ui
{
if
(
view_loading
!=
null
)
{
view_loading
.
setVisible
(
false
)
}
}
enableUserInput
(
true
)
}
override
fun
showMessage
(
resId
:
Int
)
{
showToast
(
resId
)
ui
{
showToast
(
resId
)
}
}
override
fun
showMessage
(
message
:
String
)
{
showToast
(
message
)
ui
{
showToast
(
message
)
}
}
override
fun
showGenericErrorMessage
()
=
showMessage
(
getString
(
R
.
string
.
msg_generic_error
))
...
...
@@ -136,7 +153,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
}
private
fun
listenToChanges
()
{
Observables
.
combineLatest
(
text_name
.
asObservable
(),
disposables
.
add
(
Observables
.
combineLatest
(
text_name
.
asObservable
(),
text_username
.
asObservable
(),
text_email
.
asObservable
(),
text_avatar_url
.
asObservable
())
{
text_name
,
text_username
,
text_email
,
text_avatar_url
->
...
...
@@ -144,7 +161,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
text_username
.
toString
()
!=
currentUsername
||
text_email
.
toString
()
!=
currentEmail
||
(
text_avatar_url
.
toString
()
!=
""
&&
text_avatar_url
.
toString
()
!=
currentAvatar
))
}.
subscribe
(
{
isValid
->
}.
subscribe
{
isValid
->
if
(
isValid
)
{
startActionMode
()
}
else
{
...
...
@@ -162,9 +179,11 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
private
fun
finishActionMode
()
=
actionMode
?.
finish
()
private
fun
enableUserInput
(
value
:
Boolean
)
{
text_username
.
isEnabled
=
value
text_username
.
isEnabled
=
value
text_email
.
isEnabled
=
value
text_avatar_url
.
isEnabled
=
value
ui
{
text_username
.
isEnabled
=
value
text_username
.
isEnabled
=
value
text_email
.
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
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.infraestructure.RocketChatClientFactory
import
chat.rocket.android.util.retryIO
import
chat.rocket.common.RocketChatException
import
chat.rocket.core.internal.rest.registerPushToken
import
com.google.android.gms.gcm.GoogleCloudMessaging
...
...
@@ -32,23 +33,27 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
override
fun
onTokenRefresh
()
{
//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.
val
gcmToken
=
InstanceID
.
getInstance
(
this
)
.
getToken
(
getString
(
R
.
string
.
gcm_sender_id
),
GoogleCloudMessaging
.
INSTANCE_ID_SCOPE
,
null
)
val
currentServer
=
getCurrentServerInteractor
.
get
()
val
client
=
currentServer
?.
let
{
factory
.
create
(
currentServer
)
}
try
{
val
gcmToken
=
InstanceID
.
getInstance
(
this
)
.
getToken
(
getString
(
R
.
string
.
gcm_sender_id
),
GoogleCloudMessaging
.
INSTANCE_ID_SCOPE
,
null
)
val
currentServer
=
getCurrentServerInteractor
.
get
()
val
client
=
currentServer
?.
let
{
factory
.
create
(
currentServer
)
}
gcmToken
?.
let
{
localRepository
.
save
(
LocalRepository
.
KEY_PUSH_TOKEN
,
gcmToken
)
client
?.
let
{
launch
{
try
{
Timber
.
d
(
"Registering push token: $gcmToken for ${client.url}"
)
client
.
registerPushToken
(
gcmToken
)
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
gcmToken
?.
let
{
localRepository
.
save
(
LocalRepository
.
KEY_PUSH_TOKEN
,
gcmToken
)
client
?.
let
{
launch
{
try
{
Timber
.
d
(
"Registering push token: $gcmToken for ${client.url}"
)
retryIO
(
"register push token"
)
{
client
.
registerPushToken
(
gcmToken
)
}
}
catch
(
ex
:
RocketChatException
)
{
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