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
c50327a8
Commit
c50327a8
authored
Jan 09, 2017
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename PushHelper to RaixPushHelper
parent
14ea5777
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
5 deletions
+43
-5
RaixPushHelper.java
...src/main/java/chat/rocket/android/api/RaixPushHelper.java
+38
-0
GcmRegistrationIntentService.java
...rocket/android/push/gcm/GcmRegistrationIntentService.java
+2
-2
CurrentUserObserver.java
.../rocket/android/service/observer/CurrentUserObserver.java
+3
-3
No files found.
app/src/main/java/chat/rocket/android/api/PushHelper.java
→
app/src/main/java/chat/rocket/android/api/
Raix
PushHelper.java
View file @
c50327a8
...
...
@@ -3,28 +3,31 @@ package chat.rocket.android.api;
import
android.content.Context
;
import
android.support.annotation.NonNull
;
import
android.support.annotation.Nullable
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
bolts.Task
;
import
chat.rocket.android.realm_helper.RealmHelper
;
public
class
PushHelper
extends
MethodCallHelper
{
public
PushHelper
(
Context
context
,
String
serverConfigId
)
{
public
class
Raix
PushHelper
extends
MethodCallHelper
{
public
Raix
PushHelper
(
Context
context
,
String
serverConfigId
)
{
super
(
context
,
serverConfigId
);
}
public
PushHelper
(
RealmHelper
realmHelper
,
public
Raix
PushHelper
(
RealmHelper
realmHelper
,
DDPClientWrapper
ddpClient
)
{
super
(
realmHelper
,
ddpClient
);
}
public
Task
<
Void
>
pushUpdate
(
@NonNull
String
pushId
,
@NonNull
String
t
oken
,
public
Task
<
Void
>
pushUpdate
(
@NonNull
String
pushId
,
@NonNull
String
gcmT
oken
,
@Nullable
String
userId
)
{
return
call
(
"raix:push-update"
,
TIMEOUT_MS
,
()
->
new
JSONArray
().
put
(
new
Params
(
pushId
,
token
,
userId
).
toJson
()))
return
call
(
"raix:push-update"
,
TIMEOUT_MS
,
()
->
new
JSONArray
().
put
(
new
JSONObject
()
.
put
(
"id"
,
pushId
)
.
put
(
"appName"
,
"main"
)
.
put
(
"userId"
,
userId
!=
null
?
userId
:
JSONObject
.
NULL
)
.
put
(
"metadata"
,
new
JSONObject
())
.
put
(
"token"
,
new
JSONObject
().
put
(
"gcm"
,
gcmToken
))))
.
onSuccessTask
(
task
->
Task
.
forResult
(
null
));
}
...
...
@@ -32,32 +35,4 @@ public class PushHelper extends MethodCallHelper {
return
call
(
"raix:push-setuser"
,
TIMEOUT_MS
,
()
->
new
JSONArray
().
put
(
pushId
))
.
onSuccessTask
(
task
->
Task
.
forResult
(
null
));
}
private
static
class
Params
{
private
String
pushId
;
private
String
gcmToken
;
private
String
userId
;
public
Params
(
@NonNull
String
pushId
,
@NonNull
String
gcmToken
,
@Nullable
String
userId
)
{
this
.
pushId
=
pushId
;
this
.
gcmToken
=
gcmToken
;
this
.
userId
=
userId
;
}
public
JSONObject
toJson
()
throws
JSONException
{
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"id"
,
pushId
);
param
.
put
(
"appName"
,
"main"
);
param
.
put
(
"userId"
,
userId
!=
null
?
userId
:
JSONObject
.
NULL
);
param
.
put
(
"metadata"
,
new
JSONObject
());
JSONObject
tokenParam
=
new
JSONObject
();
tokenParam
.
put
(
"gcm"
,
gcmToken
);
param
.
put
(
"token"
,
tokenParam
);
return
param
;
}
}
}
app/src/main/java/chat/rocket/android/push/gcm/GcmRegistrationIntentService.java
View file @
c50327a8
...
...
@@ -9,7 +9,7 @@ import android.content.Intent;
import
java.io.IOException
;
import
java.util.List
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.PushHelper
;
import
chat.rocket.android.api.
Raix
PushHelper
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.model.ddp.PublicSetting
;
import
chat.rocket.android.model.ddp.PublicSettingsConstants
;
...
...
@@ -52,7 +52,7 @@ public class GcmRegistrationIntentService extends IntentService {
final
User
currentUser
=
realmHelper
.
executeTransactionForRead
(
realm
->
User
.
queryCurrentUser
(
realm
).
findFirst
());
new
PushHelper
(
getBaseContext
(),
serverConfig
.
getServerConfigId
()).
pushUpdate
(
new
Raix
PushHelper
(
getBaseContext
(),
serverConfig
.
getServerConfigId
()).
pushUpdate
(
RocketChatCache
.
getPushId
(
this
),
gcmToken
,
currentUser
!=
null
?
currentUser
.
getId
()
:
null
)
.
onSuccess
(
task
->
{
markRefreshAsDone
(
serverConfig
);
...
...
app/src/main/java/chat/rocket/android/service/observer/CurrentUserObserver.java
View file @
c50327a8
...
...
@@ -9,7 +9,7 @@ import java.util.List;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.api.DDPClientWrapper
;
import
chat.rocket.android.api.MethodCallHelper
;
import
chat.rocket.android.api.PushHelper
;
import
chat.rocket.android.api.
Raix
PushHelper
;
import
chat.rocket.android.helper.LogcatIfError
;
import
chat.rocket.android.model.ddp.User
;
import
chat.rocket.android.realm_helper.RealmHelper
;
...
...
@@ -22,7 +22,7 @@ import hugo.weaving.DebugLog;
*/
public
class
CurrentUserObserver
extends
AbstractModelObserver
<
User
>
{
private
final
MethodCallHelper
methodCall
;
private
final
PushHelper
pushHelper
;
private
final
Raix
PushHelper
pushHelper
;
private
boolean
currentUserExists
;
private
ArrayList
<
Registrable
>
listeners
;
...
...
@@ -30,7 +30,7 @@ public class CurrentUserObserver extends AbstractModelObserver<User> {
RealmHelper
realmHelper
,
DDPClientWrapper
ddpClient
)
{
super
(
context
,
hostname
,
realmHelper
,
ddpClient
);
methodCall
=
new
MethodCallHelper
(
realmHelper
,
ddpClient
);
pushHelper
=
new
PushHelper
(
realmHelper
,
ddpClient
);
pushHelper
=
new
Raix
PushHelper
(
realmHelper
,
ddpClient
);
currentUserExists
=
false
;
}
...
...
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