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
6b599ca0
Commit
6b599ca0
authored
May 24, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Farewell GCM
parent
5a678af5
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
60 additions
and
56 deletions
+60
-56
build.gradle
app/build.gradle
+9
-1
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+4
-24
ServiceBuilder.kt
.../java/chat/rocket/android/dagger/module/ServiceBuilder.kt
+4
-4
MainActivity.kt
...src/main/java/chat/rocket/android/main/ui/MainActivity.kt
+7
-6
FirebaseMessagingService.kt
...java/chat/rocket/android/push/FirebaseMessagingService.kt
+24
-0
FirebaseTokenService.kt
...ain/java/chat/rocket/android/push/FirebaseTokenService.kt
+7
-12
FirebaseMessagingServiceProvider.kt
...ocket/android/push/di/FirebaseMessagingServiceProvider.kt
+3
-3
api_keys.xml
app/src/main/res/values/api_keys.xml
+0
-5
debug.keystore
debug.keystore
+0
-0
dependencies.gradle
dependencies.gradle
+2
-1
No files found.
app/build.gradle
View file @
6b599ca0
...
...
@@ -26,6 +26,13 @@ android {
keyAlias
System
.
getenv
(
"KEY_ALIAS"
)
keyPassword
System
.
getenv
(
"KEY_PASSWORD"
)
}
debug
{
storeFile
project
.
rootProject
.
file
(
'debug.keystore'
).
getCanonicalFile
()
storePassword
"android"
keyAlias
"androiddebugkey"
keyPassword
"android"
}
}
buildTypes
{
...
...
@@ -40,6 +47,7 @@ android {
debug
{
buildConfigField
"String"
,
"REQUIRED_SERVER_VERSION"
,
'"0.62.0"'
buildConfigField
"String"
,
"RECOMMENDED_SERVER_VERSION"
,
'"0.63.0"'
signingConfig
signingConfigs
.
debug
applicationIdSuffix
".dev"
}
}
...
...
@@ -73,7 +81,7 @@ dependencies {
kapt
libraries
.
daggerProcessor
kapt
libraries
.
daggerAndroidApt
implementation
libraries
.
playServicesG
cm
implementation
libraries
.
f
cm
implementation
libraries
.
room
kapt
libraries
.
roomProcessor
...
...
app/src/main/AndroidManifest.xml
View file @
6b599ca0
...
...
@@ -3,17 +3,9 @@
package=
"chat.rocket.android"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.WAKE_LOCK"
/>
<uses-permission
android:name=
"android.permission.VIBRATE"
/>
<uses-permission
android:name=
"com.google.android.c2dm.permission.RECEIVE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<permission
android:name=
"${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel=
"signature"
/>
<uses-permission
android:name=
"${applicationId}.permission.C2D_MESSAGE"
/>
<application
android:name=
".app.RocketChatApplication"
android:allowBackup=
"true"
...
...
@@ -90,18 +82,6 @@
android:name=
".settings.about.ui.AboutActivity"
android:theme=
"@style/AppTheme"
/>
<receiver
android:name=
"com.google.android.gms.gcm.GcmReceiver"
android:exported=
"true"
android:permission=
"com.google.android.c2dm.permission.SEND"
>
<intent-filter>
<action
android:name=
"com.google.android.c2dm.intent.RECEIVE"
/>
<action
android:name=
"com.google.android.c2dm.intent.REGISTRATION"
/>
<category
android:name=
"${applicationId}"
/>
</intent-filter>
</receiver>
<receiver
android:name=
".push.DirectReplyReceiver"
android:enabled=
"true"
...
...
@@ -118,13 +98,13 @@
<action
android:name=
"com.google.firebase.INSTANCE_ID_EVENT"
/>
</intent-filter>
</service>
<service
android:name=
".push.GcmListenerService"
android:exported=
"false"
>
<service
android:name=
".push.FirebaseMessagingService"
>
<intent-filter>
<action
android:name=
"com.google.
android.c2dm.intent.RECEIVE
"
/>
<action
android:name=
"com.google.
firebase.MESSAGING_EVENT
"
/>
</intent-filter>
</service>
<service
android:name=
".chatroom.service.MessageService"
android:exported=
"true"
...
...
app/src/main/java/chat/rocket/android/dagger/module/ServiceBuilder.kt
View file @
6b599ca0
...
...
@@ -2,10 +2,10 @@ package chat.rocket.android.dagger.module
import
chat.rocket.android.chatroom.di.MessageServiceProvider
import
chat.rocket.android.chatroom.service.MessageService
import
chat.rocket.android.push.FirebaseMessagingService
import
chat.rocket.android.push.FirebaseTokenService
import
chat.rocket.android.push.
GcmListenerService
import
chat.rocket.android.push.
di.FirebaseMessagingServiceProvider
import
chat.rocket.android.push.di.FirebaseTokenServiceProvider
import
chat.rocket.android.push.di.GcmListenerServiceProvider
import
dagger.Module
import
dagger.android.ContributesAndroidInjector
...
...
@@ -14,8 +14,8 @@ import dagger.android.ContributesAndroidInjector
@ContributesAndroidInjector
(
modules
=
[
FirebaseTokenServiceProvider
::
class
])
abstract
fun
bindFirebaseTokenService
():
FirebaseTokenService
@ContributesAndroidInjector
(
modules
=
[
GcmListener
ServiceProvider
::
class
])
abstract
fun
bindGcmListenerService
():
GcmListener
Service
@ContributesAndroidInjector
(
modules
=
[
FirebaseMessaging
ServiceProvider
::
class
])
abstract
fun
bindGcmListenerService
():
FirebaseMessaging
Service
@ContributesAndroidInjector
(
modules
=
[
MessageServiceProvider
::
class
])
abstract
fun
bindMessageService
():
MessageService
...
...
app/src/main/java/chat/rocket/android/main/ui/MainActivity.kt
View file @
6b599ca0
package
chat.rocket.android.main.ui
import
DrawableHelper
import
android.app.Activity
import
android.app.AlertDialog
import
android.os.Bundle
...
...
@@ -11,8 +12,8 @@ import android.view.MenuItem
import
android.view.View
import
chat.rocket.android.BuildConfig
import
chat.rocket.android.R
import
chat.rocket.android.main.adapter.Selector
import
chat.rocket.android.main.adapter.AccountsAdapter
import
chat.rocket.android.main.adapter.Selector
import
chat.rocket.android.main.presentation.MainPresenter
import
chat.rocket.android.main.presentation.MainView
import
chat.rocket.android.main.viewmodel.NavHeaderViewModel
...
...
@@ -22,8 +23,8 @@ import chat.rocket.android.util.extensions.fadeOut
import
chat.rocket.android.util.extensions.rotateBy
import
chat.rocket.android.util.extensions.showToast
import
chat.rocket.common.model.UserStatus
import
com.google.
android.gms.gcm.GoogleCloudMessaging
import
com.google.
android.gms.iid.InstanceID
import
com.google.
firebase.iid.FirebaseInstanceId
import
com.google.
firebase.messaging.FirebaseMessaging
import
dagger.android.AndroidInjection
import
dagger.android.AndroidInjector
import
dagger.android.DispatchingAndroidInjector
...
...
@@ -52,8 +53,8 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
launch
(
CommonPool
)
{
try
{
val
token
=
InstanceID
.
getInstance
(
this
@MainActivity
).
getToken
(
getString
(
R
.
string
.
gcm_sender_id
),
GoogleCloudMessaging
.
INSTANCE_ID_SCOPE
,
null
)
Timber
.
d
(
"
G
CM token: $token"
)
val
token
=
FirebaseInstanceId
.
getInstance
().
token
Timber
.
d
(
"
F
CM token: $token"
)
presenter
.
refreshToken
(
token
)
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Missing play services..."
)
...
...
@@ -135,7 +136,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
}
override
fun
invalidateToken
(
token
:
String
)
{
InstanceID
.
getInstance
(
this
).
deleteToken
(
token
,
GoogleCloud
Messaging
.
INSTANCE_ID_SCOPE
)
FirebaseInstanceId
.
getInstance
().
deleteToken
(
token
,
Firebase
Messaging
.
INSTANCE_ID_SCOPE
)
}
private
fun
setupAccountsList
(
header
:
View
,
accounts
:
List
<
Account
>)
{
...
...
app/src/main/java/chat/rocket/android/push/
GcmListener
Service.kt
→
app/src/main/java/chat/rocket/android/push/
FirebaseMessaging
Service.kt
View file @
6b599ca0
package
chat.rocket.android.push
import
android.os.Bundle
import
com.google.android.gms.gcm.GcmListenerService
import
androidx.core.os.bundleOf
import
com.google.firebase.messaging.FirebaseMessagingService
import
com.google.firebase.messaging.RemoteMessage
import
dagger.android.AndroidInjection
import
javax.inject.Inject
class
GcmListenerService
:
GcmListener
Service
()
{
class
FirebaseMessagingService
:
FirebaseMessaging
Service
()
{
@Inject
lateinit
var
pushManager
:
PushManager
...
...
@@ -15,9 +16,9 @@ class GcmListenerService : GcmListenerService() {
AndroidInjection
.
inject
(
this
)
}
override
fun
onMessageReceived
(
from
:
String
?,
data
:
Bundle
?
)
{
data
?.
let
{
pushManager
.
handle
(
data
)
override
fun
onMessageReceived
(
message
:
RemoteMessage
)
{
message
.
data
?.
let
{
pushManager
.
handle
(
bundleOf
(*(
it
.
map
{
Pair
(
it
.
key
,
it
.
value
)
}).
toTypedArray
())
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/push/FirebaseTokenService.kt
View file @
6b599ca0
package
chat.rocket.android.push
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
import
com.google.android.gms.iid.InstanceID
import
com.google.firebase.iid.FirebaseInstanceId
import
com.google.firebase.iid.FirebaseInstanceIdService
import
dagger.android.AndroidInjection
import
kotlinx.coroutines.experimental.launch
...
...
@@ -31,21 +29,18 @@ 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.
try
{
val
gcmToken
=
InstanceID
.
getInstance
(
this
)
.
getToken
(
getString
(
R
.
string
.
gcm_sender_id
),
GoogleCloudMessaging
.
INSTANCE_ID_SCOPE
,
null
)
val
fcmToken
=
FirebaseInstanceId
.
getInstance
().
token
val
currentServer
=
getCurrentServerInteractor
.
get
()
val
client
=
currentServer
?.
let
{
factory
.
create
(
currentServer
)
}
g
cmToken
?.
let
{
localRepository
.
save
(
LocalRepository
.
KEY_PUSH_TOKEN
,
g
cmToken
)
f
cmToken
?.
let
{
localRepository
.
save
(
LocalRepository
.
KEY_PUSH_TOKEN
,
f
cmToken
)
client
?.
let
{
launch
{
try
{
Timber
.
d
(
"Registering push token: $
g
cmToken for ${client.url}"
)
retryIO
(
"register push token"
)
{
client
.
registerPushToken
(
gcmToken
)
}
Timber
.
d
(
"Registering push token: $
f
cmToken for ${client.url}"
)
retryIO
(
"register push token"
)
{
client
.
registerPushToken
(
fcmToken
)
}
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
,
"Error registering push token"
)
}
...
...
@@ -53,7 +48,7 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
}
}
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error refreshing Firebase TOKEN"
)
Timber
.
e
(
ex
,
"Error refreshing Firebase TOKEN"
)
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/push/di/
GcmListener
ServiceProvider.kt
→
app/src/main/java/chat/rocket/android/push/di/
FirebaseMessaging
ServiceProvider.kt
View file @
6b599ca0
package
chat.rocket.android.push.di
import
chat.rocket.android.dagger.module.AppModule
import
chat.rocket.android.push.
GcmListener
Service
import
chat.rocket.android.push.
FirebaseMessaging
Service
import
dagger.Module
import
dagger.android.ContributesAndroidInjector
@Module
abstract
class
GcmListener
ServiceProvider
{
@Module
abstract
class
FirebaseMessaging
ServiceProvider
{
@ContributesAndroidInjector
(
modules
=
[
AppModule
::
class
])
abstract
fun
provide
GcmListenerService
():
GcmListener
Service
abstract
fun
provide
FirebaseMessagingService
():
FirebaseMessaging
Service
}
\ No newline at end of file
app/src/main/res/values/api_keys.xml
deleted
100644 → 0
View file @
5a678af5
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- This is the Cordova GCM sender id-->
<string
name=
"gcm_sender_id"
translatable=
"false"
>
673693445664
</string>
</resources>
\ No newline at end of file
debug.keystore
0 → 100644
View file @
6b599ca0
File added
dependencies.gradle
View file @
6b599ca0
...
...
@@ -15,6 +15,7 @@ ext {
dagger
:
'2.14.1'
,
exoPlayer
:
'2.6.0'
,
playServices
:
'11.8.0'
,
firebase
:
'15.0.0'
,
room
:
'1.0.0'
,
lifecycle
:
'1.1.1'
,
rxKotlin
:
'2.2.0'
,
...
...
@@ -58,7 +59,7 @@ ext {
daggerSupport
:
"com.google.dagger:dagger-android-support:${versions.dagger}"
,
daggerProcessor
:
"com.google.dagger:dagger-compiler:${versions.dagger}"
,
daggerAndroidApt
:
"com.google.dagger:dagger-android-processor:${versions.dagger}"
,
playServicesGcm
:
"com.google.android.gms:play-services-gcm:${versions.playServices
}"
,
fcm
:
"com.google.firebase:firebase-messaging:${versions.firebase
}"
,
exoPlayer
:
"com.google.android.exoplayer:exoplayer:${versions.exoPlayer}"
,
room
:
"android.arch.persistence.room:runtime:${versions.room}"
,
...
...
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