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
abe613c1
Unverified
Commit
abe613c1
authored
May 25, 2018
by
Leonardo Aramaki
Committed by
GitHub
May 25, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "[FIX] Better multi-server support for push notifications"
parent
e4d1724a
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
16 additions
and
28 deletions
+16
-28
LoginPresenter.kt
...droid/authentication/login/presentation/LoginPresenter.kt
+1
-1
RegisterUsernamePresenter.kt
...egisterusername/presentation/RegisterUsernamePresenter.kt
+1
-1
SignupPresenter.kt
...oid/authentication/signup/presentation/SignupPresenter.kt
+1
-1
TwoFAPresenter.kt
...d/authentication/twofactor/presentation/TwoFAPresenter.kt
+1
-1
LocalRepository.kt
...ava/chat/rocket/android/infrastructure/LocalRepository.kt
+1
-3
SharedPreferencesLocalRepository.kt
...ndroid/infrastructure/SharedPreferencesLocalRepository.kt
+1
-9
MainPresenter.kt
...va/chat/rocket/android/main/presentation/MainPresenter.kt
+6
-5
FirebaseTokenService.kt
...ain/java/chat/rocket/android/push/FirebaseTokenService.kt
+3
-3
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+1
-4
No files found.
app/src/main/java/chat/rocket/android/authentication/login/presentation/LoginPresenter.kt
View file @
abe613c1
...
@@ -382,7 +382,7 @@ class LoginPresenter @Inject constructor(
...
@@ -382,7 +382,7 @@ class LoginPresenter @Inject constructor(
}
}
private
suspend
fun
registerPushToken
()
{
private
suspend
fun
registerPushToken
()
{
localRepository
.
get
PushToken
(
currentServer
)
?.
let
{
localRepository
.
get
(
LocalRepository
.
KEY_PUSH_TOKEN
)
?.
let
{
client
.
registerPushToken
(
it
,
getAccountsInteractor
.
get
(),
factory
)
client
.
registerPushToken
(
it
,
getAccountsInteractor
.
get
(),
factory
)
}
}
// TODO: When the push token is null, at some point we should receive it with
// TODO: When the push token is null, at some point we should receive it with
...
...
app/src/main/java/chat/rocket/android/authentication/registerusername/presentation/RegisterUsernamePresenter.kt
View file @
abe613c1
...
@@ -65,7 +65,7 @@ class RegisterUsernamePresenter @Inject constructor(
...
@@ -65,7 +65,7 @@ class RegisterUsernamePresenter @Inject constructor(
}
}
private
suspend
fun
registerPushToken
()
{
private
suspend
fun
registerPushToken
()
{
localRepository
.
get
PushToken
(
currentServer
)
?.
let
{
localRepository
.
get
(
LocalRepository
.
KEY_PUSH_TOKEN
)
?.
let
{
client
.
registerPushToken
(
it
,
getAccountsInteractor
.
get
(),
factory
)
client
.
registerPushToken
(
it
,
getAccountsInteractor
.
get
(),
factory
)
}
}
// TODO: When the push token is null, at some point we should receive it with
// TODO: When the push token is null, at some point we should receive it with
...
...
app/src/main/java/chat/rocket/android/authentication/signup/presentation/SignupPresenter.kt
View file @
abe613c1
...
@@ -95,7 +95,7 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
...
@@ -95,7 +95,7 @@ class SignupPresenter @Inject constructor(private val view: SignupView,
}
}
private
suspend
fun
registerPushToken
()
{
private
suspend
fun
registerPushToken
()
{
localRepository
.
get
PushToken
(
currentServer
)
?.
let
{
localRepository
.
get
(
LocalRepository
.
KEY_PUSH_TOKEN
)
?.
let
{
client
.
registerPushToken
(
it
,
getAccountsInteractor
.
get
(),
factory
)
client
.
registerPushToken
(
it
,
getAccountsInteractor
.
get
(),
factory
)
}
}
// TODO: When the push token is null, at some point we should receive it with
// TODO: When the push token is null, at some point we should receive it with
...
...
app/src/main/java/chat/rocket/android/authentication/twofactor/presentation/TwoFAPresenter.kt
View file @
abe613c1
...
@@ -79,7 +79,7 @@ class TwoFAPresenter @Inject constructor(private val view: TwoFAView,
...
@@ -79,7 +79,7 @@ class TwoFAPresenter @Inject constructor(private val view: TwoFAView,
fun
signup
()
=
navigator
.
toSignUp
()
fun
signup
()
=
navigator
.
toSignUp
()
private
suspend
fun
registerPushToken
()
{
private
suspend
fun
registerPushToken
()
{
localRepository
.
get
PushToken
(
currentServer
)
?.
let
{
localRepository
.
get
(
LocalRepository
.
KEY_PUSH_TOKEN
)
?.
let
{
client
.
registerPushToken
(
it
,
getAccountsInteractor
.
get
(),
factory
)
client
.
registerPushToken
(
it
,
getAccountsInteractor
.
get
(),
factory
)
}
}
// TODO: When the push token is null, at some point we should receive it with
// TODO: When the push token is null, at some point we should receive it with
...
...
app/src/main/java/chat/rocket/android/infrastructure/LocalRepository.kt
View file @
abe613c1
...
@@ -18,11 +18,9 @@ interface LocalRepository {
...
@@ -18,11 +18,9 @@ interface LocalRepository {
fun
clearAllFromServer
(
server
:
String
)
fun
clearAllFromServer
(
server
:
String
)
fun
getCurrentUser
(
url
:
String
):
User
?
fun
getCurrentUser
(
url
:
String
):
User
?
fun
saveCurrentUser
(
url
:
String
,
user
:
User
)
fun
saveCurrentUser
(
url
:
String
,
user
:
User
)
fun
savePushToken
(
url
:
String
,
token
:
String
)
fun
getPushToken
(
url
:
String
):
String
?
companion
object
{
companion
object
{
const
val
PUSH_TOKEN_KEY
=
"push_token_
"
const
val
KEY_PUSH_TOKEN
=
"KEY_PUSH_TOKEN
"
const
val
MIGRATION_FINISHED_KEY
=
"MIGRATION_FINISHED_KEY"
const
val
MIGRATION_FINISHED_KEY
=
"MIGRATION_FINISHED_KEY"
const
val
TOKEN_KEY
=
"token_"
const
val
TOKEN_KEY
=
"token_"
const
val
SETTINGS_KEY
=
"settings_"
const
val
SETTINGS_KEY
=
"settings_"
...
...
app/src/main/java/chat/rocket/android/infrastructure/SharedPreferencesLocalRepository.kt
View file @
abe613c1
...
@@ -2,7 +2,6 @@ package chat.rocket.android.infrastructure
...
@@ -2,7 +2,6 @@ package chat.rocket.android.infrastructure
import
android.content.SharedPreferences
import
android.content.SharedPreferences
import
androidx.core.content.edit
import
androidx.core.content.edit
import
chat.rocket.android.infrastructure.LocalRepository.Companion.PUSH_TOKEN_KEY
import
chat.rocket.common.model.User
import
chat.rocket.common.model.User
import
com.squareup.moshi.Moshi
import
com.squareup.moshi.Moshi
...
@@ -45,15 +44,8 @@ class SharedPreferencesLocalRepository(
...
@@ -45,15 +44,8 @@ class SharedPreferencesLocalRepository(
override
fun
clear
(
key
:
String
)
=
preferences
.
edit
{
remove
(
key
)
}
override
fun
clear
(
key
:
String
)
=
preferences
.
edit
{
remove
(
key
)
}
override
fun
savePushToken
(
url
:
String
,
token
:
String
)
{
save
(
PUSH_TOKEN_KEY
+
url
,
token
)
}
override
fun
getPushToken
(
url
:
String
):
String
?
=
preferences
.
getString
(
PUSH_TOKEN_KEY
+
url
,
null
)
override
fun
clearAllFromServer
(
server
:
String
)
{
override
fun
clearAllFromServer
(
server
:
String
)
{
clear
(
LocalRepository
.
PUSH_TOKEN_KEY
)
//TODO: keep this for now to clear up for some version rolls.
clear
(
LocalRepository
.
KEY_PUSH_TOKEN
)
clear
(
LocalRepository
.
PUSH_TOKEN_KEY
+
server
)
clear
(
LocalRepository
.
TOKEN_KEY
+
server
)
clear
(
LocalRepository
.
TOKEN_KEY
+
server
)
clear
(
LocalRepository
.
SETTINGS_KEY
+
server
)
clear
(
LocalRepository
.
SETTINGS_KEY
+
server
)
clear
(
LocalRepository
.
CURRENT_USERNAME_KEY
)
clear
(
LocalRepository
.
CURRENT_USERNAME_KEY
)
...
...
app/src/main/java/chat/rocket/android/main/presentation/MainPresenter.kt
View file @
abe613c1
...
@@ -152,7 +152,7 @@ class MainPresenter @Inject constructor(
...
@@ -152,7 +152,7 @@ class MainPresenter @Inject constructor(
suspend
fun
refreshToken
(
token
:
String
?)
{
suspend
fun
refreshToken
(
token
:
String
?)
{
token
?.
let
{
token
?.
let
{
localRepository
.
save
PushToken
(
currentServer
,
it
)
localRepository
.
save
(
LocalRepository
.
KEY_PUSH_TOKEN
,
token
)
client
.
registerPushToken
(
token
,
getAccountsInteractor
.
get
(),
factory
)
client
.
registerPushToken
(
token
,
getAccountsInteractor
.
get
(),
factory
)
}
}
}
}
...
@@ -172,15 +172,16 @@ class MainPresenter @Inject constructor(
...
@@ -172,15 +172,16 @@ class MainPresenter @Inject constructor(
}
}
private
suspend
fun
clearTokens
()
{
private
suspend
fun
clearTokens
()
{
localRepository
.
get
(
LocalRepository
.
PUSH_TOKEN_KEY
+
currentServer
)
?.
let
{
serverInteractor
.
clear
()
val
pushToken
=
localRepository
.
get
(
LocalRepository
.
KEY_PUSH_TOKEN
)
if
(
pushToken
!=
null
)
{
try
{
try
{
retryIO
(
"unregisterPushToken"
)
{
client
.
unregisterPushToken
(
it
)
}
retryIO
(
"unregisterPushToken"
)
{
client
.
unregisterPushToken
(
pushToken
)
}
view
.
invalidateToken
(
it
)
view
.
invalidateToken
(
pushToken
)
}
catch
(
ex
:
Exception
)
{
}
catch
(
ex
:
Exception
)
{
Timber
.
d
(
ex
,
"Error unregistering push token"
)
Timber
.
d
(
ex
,
"Error unregistering push token"
)
}
}
}
}
serverInteractor
.
clear
()
localRepository
.
clearAllFromServer
(
currentServer
)
localRepository
.
clearAllFromServer
(
currentServer
)
}
}
...
...
app/src/main/java/chat/rocket/android/push/FirebaseTokenService.kt
View file @
abe613c1
...
@@ -39,8 +39,8 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
...
@@ -39,8 +39,8 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
val
currentServer
=
getCurrentServerInteractor
.
get
()
val
currentServer
=
getCurrentServerInteractor
.
get
()
val
client
=
currentServer
?.
let
{
factory
.
create
(
currentServer
)
}
val
client
=
currentServer
?.
let
{
factory
.
create
(
currentServer
)
}
if
(
gcmToken
!=
null
&&
currentServer
!=
null
)
{
gcmToken
?.
let
{
localRepository
.
save
PushToken
(
currentServer
,
gcmToken
)
localRepository
.
save
(
LocalRepository
.
KEY_PUSH_TOKEN
,
gcmToken
)
client
?.
let
{
client
?.
let
{
launch
{
launch
{
try
{
try
{
...
@@ -53,7 +53,7 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
...
@@ -53,7 +53,7 @@ class FirebaseTokenService : FirebaseInstanceIdService() {
}
}
}
}
}
catch
(
ex
:
Exception
)
{
}
catch
(
ex
:
Exception
)
{
Timber
.
e
(
ex
,
"Error refreshing Firebase TOKEN"
)
Timber
.
d
(
ex
,
"Error refreshing Firebase TOKEN"
)
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
abe613c1
...
@@ -250,14 +250,11 @@ class PushManager @Inject constructor(
...
@@ -250,14 +250,11 @@ class PushManager @Inject constructor(
.
setContentIntent
(
contentIntent
)
.
setContentIntent
(
contentIntent
)
.
setMessageNotification
()
.
setMessageNotification
()
if
(
host
.
isEmpty
())
{
builder
.
setContentIntent
(
deleteIntent
)
}
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
val
channelId
:
String
val
channelId
:
String
val
channelName
:
String
val
channelName
:
String
if
(
host
.
isEmpty
())
{
if
(
host
.
isEmpty
())
{
builder
.
setContentIntent
(
deleteIntent
)
channelName
=
"Test Notification"
channelName
=
"Test Notification"
channelId
=
"test-channel"
channelId
=
"test-channel"
}
else
{
}
else
{
...
...
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