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
14ea5777
Commit
14ea5777
authored
Jan 09, 2017
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just rename methods and variables
parent
e427d271
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
GcmInstanceIDListenerService.java
...rocket/android/push/gcm/GcmInstanceIDListenerService.java
+7
-6
PushSettingsObserver.java
...rocket/android/service/observer/PushSettingsObserver.java
+4
-4
No files found.
app/src/main/java/chat/rocket/android/push/gcm/GcmInstanceIDListenerService.java
View file @
14ea5777
...
@@ -5,6 +5,7 @@ import com.google.android.gms.iid.InstanceIDListenerService;
...
@@ -5,6 +5,7 @@ import com.google.android.gms.iid.InstanceIDListenerService;
import
android.content.Intent
;
import
android.content.Intent
;
import
java.util.List
;
import
java.util.List
;
import
chat.rocket.android.helper.TextUtils
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.model.ddp.PublicSetting
;
import
chat.rocket.android.model.ddp.PublicSetting
;
import
chat.rocket.android.model.ddp.PublicSettingsConstants
;
import
chat.rocket.android.model.ddp.PublicSettingsConstants
;
...
@@ -15,7 +16,7 @@ public class GcmInstanceIDListenerService extends InstanceIDListenerService {
...
@@ -15,7 +16,7 @@ public class GcmInstanceIDListenerService extends InstanceIDListenerService {
@Override
@Override
public
void
onTokenRefresh
()
{
public
void
onTokenRefresh
()
{
updateSyncPushTokenIfNeeded
();
syncGcmPushAvailability
();
if
(!
shouldRefreshToken
())
{
if
(!
shouldRefreshToken
())
{
return
;
return
;
...
@@ -25,7 +26,7 @@ public class GcmInstanceIDListenerService extends InstanceIDListenerService {
...
@@ -25,7 +26,7 @@ public class GcmInstanceIDListenerService extends InstanceIDListenerService {
startService
(
intent
);
startService
(
intent
);
}
}
private
void
updateSyncPushTokenIfNeeded
()
{
private
void
syncGcmPushAvailability
()
{
final
RealmHelper
realmHelper
=
RealmStore
.
getDefault
();
final
RealmHelper
realmHelper
=
RealmStore
.
getDefault
();
List
<
ServerConfig
>
serverConfigs
=
realmHelper
.
executeTransactionForReadResults
(
List
<
ServerConfig
>
serverConfigs
=
realmHelper
.
executeTransactionForReadResults
(
realm
->
realm
.
where
(
ServerConfig
.
class
).
findAll
());
realm
->
realm
.
where
(
ServerConfig
.
class
).
findAll
());
...
@@ -36,15 +37,15 @@ public class GcmInstanceIDListenerService extends InstanceIDListenerService {
...
@@ -36,15 +37,15 @@ public class GcmInstanceIDListenerService extends InstanceIDListenerService {
continue
;
continue
;
}
}
boolean
isPushEnable
=
PublicSetting
boolean
isPushEnable
d
=
PublicSetting
.
getBoolean
(
serverRealmHelper
,
PublicSettingsConstants
.
Push
.
ENABLE
,
false
);
.
getBoolean
(
serverRealmHelper
,
PublicSettingsConstants
.
Push
.
ENABLE
,
false
);
String
senderId
=
PublicSetting
String
senderId
=
PublicSetting
.
getString
(
serverRealmHelper
,
PublicSettingsConstants
.
Push
.
GCM_PROJECT_NUMBER
,
""
).
trim
();
.
getString
(
serverRealmHelper
,
PublicSettingsConstants
.
Push
.
GCM_PROJECT_NUMBER
,
""
).
trim
();
boolean
syncPushToken
=
isPushEnable
&&
!
""
.
equals
(
senderId
);
boolean
gcmPushAvailable
=
isPushEnabled
&&
!
TextUtils
.
isEmpty
(
senderId
);
if
(
serverConfig
.
shouldSyncPushToken
()
!=
syncPushToken
)
{
if
(
serverConfig
.
shouldSyncPushToken
()
!=
gcmPushAvailable
)
{
serverConfig
.
setSyncPushToken
(
syncPushToken
);
serverConfig
.
setSyncPushToken
(
gcmPushAvailable
);
realmHelper
.
executeTransaction
(
realm
->
realm
.
copyToRealmOrUpdate
(
serverConfig
));
realmHelper
.
executeTransaction
(
realm
->
realm
.
copyToRealmOrUpdate
(
serverConfig
));
}
}
}
}
...
...
app/src/main/java/chat/rocket/android/service/observer/PushSettingsObserver.java
View file @
14ea5777
...
@@ -31,9 +31,9 @@ public class PushSettingsObserver extends AbstractModelObserver<PublicSetting> {
...
@@ -31,9 +31,9 @@ public class PushSettingsObserver extends AbstractModelObserver<PublicSetting> {
.
equalTo
(
ServerConfig
.
HOSTNAME
,
ServerPolicyHelper
.
enforceHostname
(
hostname
))
.
equalTo
(
ServerConfig
.
HOSTNAME
,
ServerPolicyHelper
.
enforceHostname
(
hostname
))
.
findFirst
());
.
findFirst
());
boolean
syncPushToken
=
shouldEnablePush
(
results
);
boolean
gcmPushAvailable
=
isGcmPushEnabled
(
results
);
if
(
serverConfig
.
shouldSyncPushToken
()
!=
syncPushToken
)
{
if
(
serverConfig
.
shouldSyncPushToken
()
!=
gcmPushAvailable
)
{
serverConfig
.
setSyncPushToken
(
syncPushToken
);
serverConfig
.
setSyncPushToken
(
gcmPushAvailable
);
RealmStore
.
getDefault
()
RealmStore
.
getDefault
()
.
executeTransaction
(
realm
->
realm
.
copyToRealmOrUpdate
(
serverConfig
))
.
executeTransaction
(
realm
->
realm
.
copyToRealmOrUpdate
(
serverConfig
))
...
@@ -59,7 +59,7 @@ public class PushSettingsObserver extends AbstractModelObserver<PublicSetting> {
...
@@ -59,7 +59,7 @@ public class PushSettingsObserver extends AbstractModelObserver<PublicSetting> {
.
findAll
();
.
findAll
();
}
}
private
boolean
shouldEnablePush
(
List
<
PublicSetting
>
results
)
{
private
boolean
isGcmPushEnabled
(
List
<
PublicSetting
>
results
)
{
return
isPushEnabled
(
results
)
&&
hasValidGcmConfig
(
results
);
return
isPushEnabled
(
results
)
&&
hasValidGcmConfig
(
results
);
}
}
...
...
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