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
c822c8df
Commit
c822c8df
authored
Jan 10, 2017
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "remove push interactor."
This reverts commit
4d709b6e
.
parent
3f49c4ed
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
13 deletions
+42
-13
PushNotificationHandler.java
...ava/chat/rocket/android/push/PushNotificationHandler.java
+9
-12
GCMIntentService.java
...n/java/chat/rocket/android/push/gcm/GCMIntentService.java
+9
-1
DefaultPushInteractor.java
...ocket/android/push/interactors/DefaultPushInteractor.java
+19
-0
PushInteractor.java
.../chat/rocket/android/push/interactors/PushInteractor.java
+5
-0
No files found.
app/src/main/java/chat/rocket/android/push/PushNotificationHandler.java
View file @
c822c8df
...
...
@@ -20,6 +20,7 @@ import android.support.v4.util.SparseArrayCompat;
import
android.text.Html
;
import
android.text.Spanned
;
import
android.util.Log
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
...
...
@@ -31,9 +32,7 @@ import java.net.URL;
import
java.util.ArrayList
;
import
java.util.Random
;
import
chat.rocket.android.activity.MainActivity
;
import
chat.rocket.android.helper.ServerPolicyHelper
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.realm_helper.RealmStore
;
import
chat.rocket.android.push.interactors.PushInteractor
;
public
class
PushNotificationHandler
implements
PushConstants
{
...
...
@@ -57,7 +56,8 @@ public class PushNotificationHandler implements PushConstants {
}
}
public
void
showNotificationIfPossible
(
Context
context
,
Bundle
extras
)
{
public
void
showNotificationIfPossible
(
Context
context
,
PushInteractor
pushInteractor
,
Bundle
extras
)
{
// Send a notification if there is a message or title, otherwise just send data
String
message
=
extras
.
getString
(
MESSAGE
);
...
...
@@ -79,11 +79,11 @@ public class PushNotificationHandler implements PushConstants {
extras
.
putString
(
TITLE
,
getAppName
(
context
));
}
createNotification
(
context
,
extras
);
createNotification
(
context
,
pushInteractor
,
extras
);
}
}
public
void
createNotification
(
Context
context
,
Bundle
extras
)
{
public
void
createNotification
(
Context
context
,
PushInteractor
pushInteractor
,
Bundle
extras
)
{
NotificationManager
mNotificationManager
=
(
NotificationManager
)
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
String
appName
=
getAppName
(
context
);
...
...
@@ -97,11 +97,8 @@ public class PushNotificationHandler implements PushConstants {
return
;
}
ServerConfig
serverConfig
=
RealmStore
.
getDefault
().
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
)
.
equalTo
(
ServerConfig
.
HOSTNAME
,
ServerPolicyHelper
.
enforceHostname
(
serverUrl
))
.
findFirst
());
if
(
serverConfig
==
null
)
{
String
serverConfigId
=
pushInteractor
.
getServerConfigId
(
serverUrl
);
if
(
serverConfigId
==
null
)
{
return
;
}
...
...
@@ -109,7 +106,7 @@ public class PushNotificationHandler implements PushConstants {
Intent
notificationIntent
=
new
Intent
(
context
,
MainActivity
.
class
);
notificationIntent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_SINGLE_TOP
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
notificationIntent
.
putExtra
(
PUSH_BUNDLE
,
extras
);
notificationIntent
.
putExtra
(
SERVER_CONFIG_ID
,
serverConfig
.
getServerConfigId
()
);
notificationIntent
.
putExtra
(
SERVER_CONFIG_ID
,
serverConfig
Id
);
notificationIntent
.
putExtra
(
ROOM_ID
,
roomId
);
notificationIntent
.
putExtra
(
NOT_ID
,
notId
);
...
...
app/src/main/java/chat/rocket/android/push/gcm/GCMIntentService.java
View file @
c822c8df
...
...
@@ -2,6 +2,7 @@ package chat.rocket.android.push.gcm;
import
com.google.android.gms.gcm.GcmListenerService
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.content.res.Resources
;
import
android.os.Bundle
;
...
...
@@ -14,7 +15,10 @@ import java.util.ArrayList;
import
java.util.Iterator
;
import
chat.rocket.android.push.PushConstants
;
import
chat.rocket.android.push.PushNotificationHandler
;
import
chat.rocket.android.push.interactors.DefaultPushInteractor
;
import
chat.rocket.android.push.interactors.PushInteractor
;
@SuppressLint
(
"NewApi"
)
public
class
GCMIntentService
extends
GcmListenerService
implements
PushConstants
{
private
static
final
String
LOG_TAG
=
"GCMIntentService"
;
...
...
@@ -29,9 +33,13 @@ public class GCMIntentService extends GcmListenerService implements PushConstant
Context
applicationContext
=
getApplicationContext
();
PushInteractor
pushInteractor
=
new
DefaultPushInteractor
();
extras
=
normalizeExtras
(
applicationContext
,
extras
);
new
PushNotificationHandler
().
showNotificationIfPossible
(
applicationContext
,
extras
);
PushNotificationHandler
pushNotificationHandler
=
new
PushNotificationHandler
();
pushNotificationHandler
.
showNotificationIfPossible
(
applicationContext
,
pushInteractor
,
extras
);
}
/*
...
...
app/src/main/java/chat/rocket/android/push/interactors/DefaultPushInteractor.java
0 → 100644
View file @
c822c8df
package
chat
.
rocket
.
android
.
push
.
interactors
;
import
chat.rocket.android.helper.ServerPolicyHelper
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.realm_helper.RealmStore
;
public
class
DefaultPushInteractor
implements
PushInteractor
{
@Override
public
String
getServerConfigId
(
String
hostname
)
{
final
ServerConfig
serverConfig
=
RealmStore
.
getDefault
()
.
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
)
.
equalTo
(
ServerConfig
.
HOSTNAME
,
ServerPolicyHelper
.
enforceHostname
(
hostname
))
.
findFirst
());
return
serverConfig
!=
null
?
serverConfig
.
getServerConfigId
()
:
""
;
}
}
app/src/main/java/chat/rocket/android/push/interactors/PushInteractor.java
0 → 100644
View file @
c822c8df
package
chat
.
rocket
.
android
.
push
.
interactors
;
public
interface
PushInteractor
{
String
getServerConfigId
(
String
hostname
);
}
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