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
3a91f0c8
Commit
3a91f0c8
authored
Apr 06, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show error Toast when reply fails and show the notification again
parent
aa0f574b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
15 deletions
+25
-15
AppModule.kt
.../main/java/chat/rocket/android/dagger/module/AppModule.kt
+14
-11
DirectReplyReceiver.kt
...main/java/chat/rocket/android/push/DirectReplyReceiver.kt
+10
-3
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+1
-1
No files found.
app/src/main/java/chat/rocket/android/dagger/module/AppModule.kt
View file @
3a91f0c8
...
...
@@ -17,17 +17,8 @@ import chat.rocket.android.helper.MessageParser
import
chat.rocket.android.infrastructure.LocalRepository
import
chat.rocket.android.infrastructure.SharedPrefsLocalRepository
import
chat.rocket.android.push.GroupedPush
import
chat.rocket.android.server.domain.AccountsRepository
import
chat.rocket.android.server.domain.ChatRoomsRepository
import
chat.rocket.android.server.domain.CurrentServerRepository
import
chat.rocket.android.server.domain.GetCurrentServerInteractor
import
chat.rocket.android.server.domain.GetPermissionsInteractor
import
chat.rocket.android.server.domain.MessagesRepository
import
chat.rocket.android.server.domain.MultiServerTokenRepository
import
chat.rocket.android.server.domain.RoomRepository
import
chat.rocket.android.server.domain.SettingsRepository
import
chat.rocket.android.server.domain.TokenRepository
import
chat.rocket.android.server.domain.UsersRepository
import
chat.rocket.android.push.PushManager
import
chat.rocket.android.server.domain.*
import
chat.rocket.android.server.infraestructure.MemoryChatRoomsRepository
import
chat.rocket.android.server.infraestructure.MemoryMessagesRepository
import
chat.rocket.android.server.infraestructure.MemoryRoomRepository
...
...
@@ -275,4 +266,16 @@ class AppModule {
@Provides
@Singleton
fun
provideGroupedPush
()
=
GroupedPush
()
@Provides
@Singleton
fun
providePushManager
(
context
:
Context
,
groupedPushes
:
GroupedPush
,
manager
:
NotificationManager
,
moshi
:
Moshi
,
getAccountInteractor
:
GetAccountInteractor
,
getSettingsInteractor
:
GetSettingsInteractor
):
PushManager
{
return
PushManager
(
groupedPushes
,
manager
,
moshi
,
getAccountInteractor
,
getSettingsInteractor
,
context
)
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/push/DirectReplyReceiver.kt
View file @
3a91f0c8
...
...
@@ -4,6 +4,7 @@ import android.app.NotificationManager
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Intent
import
android.support.v4.app.NotificationManagerCompat
import
android.support.v4.app.RemoteInput
import
android.widget.Toast
import
chat.rocket.android.R
...
...
@@ -26,6 +27,8 @@ class DirectReplyReceiver : BroadcastReceiver() {
lateinit
var
factory
:
ConnectionManagerFactory
@Inject
lateinit
var
groupedPushes
:
GroupedPush
@Inject
lateinit
var
pushManager
:
PushManager
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
AndroidInjection
.
inject
(
this
,
context
)
...
...
@@ -33,18 +36,22 @@ class DirectReplyReceiver : BroadcastReceiver() {
val
message
=
intent
.
getParcelableExtra
<
PushMessage
>(
EXTRA_PUSH_MESSAGE
)
message
?.
let
{
launch
(
UI
)
{
val
manager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
val
notificationId
=
it
.
notificationId
.
toInt
()
val
hostname
=
it
.
info
.
host
try
{
println
(
it
)
sendMessage
(
it
,
extractReplyMessage
(
intent
))
val
manager
=
context
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
)
as
NotificationManager
clearNotificationsByHostAndNotificationId
(
it
.
info
.
host
,
it
.
notificationId
.
toInt
())
manager
.
cancel
(
it
.
notificationId
.
toInt
())
clearNotificationsByHostAndNotificationId
(
hostname
,
notificationId
)
manager
.
cancel
(
notificationId
)
val
feedback
=
context
.
getString
(
R
.
string
.
notif_success_sending
,
it
.
title
)
Toast
.
makeText
(
context
,
feedback
,
Toast
.
LENGTH_SHORT
).
show
()
}
catch
(
ex
:
RocketChatException
)
{
Timber
.
e
(
ex
)
val
feedback
=
context
.
getString
(
R
.
string
.
notif_error_sending
)
Toast
.
makeText
(
context
,
feedback
,
Toast
.
LENGTH_SHORT
).
show
()
clearNotificationsByHostAndNotificationId
(
hostname
,
notificationId
)
pushManager
.
showNotification
(
it
)
}
}
}
...
...
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
3a91f0c8
...
...
@@ -82,7 +82,7 @@ class PushManager @Inject constructor(
}
@SuppressLint
(
"NewApi"
)
private
suspend
fun
showNotification
(
pushMessage
:
PushMessage
)
{
suspend
fun
showNotification
(
pushMessage
:
PushMessage
)
{
if
(!
hasAccount
(
pushMessage
.
info
.
host
))
{
Timber
.
d
(
"ignoring push message: $pushMessage"
)
return
...
...
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