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
e5aa863f
Commit
e5aa863f
authored
Apr 06, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
If api level under 23 (N) then show the MainActivity - at first
parent
a1793f89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
14 deletions
+35
-14
PushManager.kt
app/src/main/java/chat/rocket/android/push/PushManager.kt
+35
-14
No files found.
app/src/main/java/chat/rocket/android/push/PushManager.kt
View file @
e5aa863f
...
...
@@ -21,6 +21,7 @@ import android.support.v4.app.RemoteInput
import
android.text.Html
import
android.text.Spanned
import
chat.rocket.android.R
import
chat.rocket.android.main.ui.MainActivity
import
chat.rocket.android.server.domain.GetAccountInteractor
import
chat.rocket.android.server.domain.GetSettingsInteractor
import
chat.rocket.android.server.domain.siteName
...
...
@@ -292,13 +293,9 @@ class PushManager @Inject constructor(
val
replyRemoteInput
=
android
.
app
.
RemoteInput
.
Builder
(
REMOTE_INPUT_REPLY
)
.
setLabel
(
replyTextHint
)
.
build
()
//TODO: Implement this when we have sendMessage call
val
replyIntent
=
Intent
(
context
,
DirectReplyReceiver
::
class
.
java
)
replyIntent
.
action
=
ACTION_REPLY
replyIntent
.
putExtra
(
EXTRA_PUSH_MESSAGE
,
pushMessage
as
Parcelable
)
val
filter
=
IntentFilter
().
apply
{
addAction
(
ACTION_REPLY
)
}
replyIntent
.
putExtra
(
EXTRA_PUSH_MESSAGE
,
pushMessage
)
val
pendingIntent
=
PendingIntent
.
getBroadcast
(
context
,
randomizer
.
nextInt
(),
replyIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
val
replyAction
=
Notification
.
Action
.
Builder
(
...
...
@@ -316,15 +313,7 @@ class PushManager @Inject constructor(
val
replyRemoteInput
=
RemoteInput
.
Builder
(
REMOTE_INPUT_REPLY
)
.
setLabel
(
replyTextHint
)
.
build
()
//TODO: Implement when we have sendMessage call
val
replyIntent
=
Intent
(
context
,
DirectReplyReceiver
::
class
.
java
)
replyIntent
.
action
=
ACTION_REPLY
replyIntent
.
putExtra
(
EXTRA_PUSH_MESSAGE
,
pushMessage
as
Parcelable
)
val
filter
=
IntentFilter
().
apply
{
addAction
(
ACTION_REPLY
)
}
val
pendingIntent
=
PendingIntent
.
getBroadcast
(
context
,
randomizer
.
nextInt
(),
replyIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
val
pendingIntent
=
getReplyPendingIntent
(
pushMessage
)
val
replyAction
=
NotificationCompat
.
Action
.
Builder
(
R
.
drawable
.
ic_reply_black_24px
,
replyTextHint
,
pendingIntent
)
.
addRemoteInput
(
replyRemoteInput
)
.
setAllowGeneratedReplies
(
true
)
...
...
@@ -334,6 +323,38 @@ class PushManager @Inject constructor(
return
this
}
private
fun
getReplyIntent
(
pushMessage
:
PushMessage
):
Intent
{
return
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
Intent
(
context
,
DirectReplyReceiver
::
class
.
java
)
}
else
{
Intent
(
context
,
MainActivity
::
class
.
java
).
also
{
it
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
}
}.
also
{
it
.
action
=
ACTION_REPLY
it
.
putExtra
(
EXTRA_PUSH_MESSAGE
,
pushMessage
)
}
}
private
fun
getReplyPendingIntent
(
pushMessage
:
PushMessage
):
PendingIntent
{
val
replyIntent
=
getReplyIntent
(
pushMessage
)
return
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
PendingIntent
.
getBroadcast
(
context
,
randomizer
.
nextInt
(),
replyIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
}
else
{
PendingIntent
.
getActivity
(
context
,
randomizer
.
nextInt
(),
replyIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
)
}
}
private
fun
NotificationCompat
.
Builder
.
setMessageNotification
():
NotificationCompat
.
Builder
{
val
alarmSound
=
RingtoneManager
.
getDefaultUri
(
RingtoneManager
.
TYPE_NOTIFICATION
)
val
res
=
context
.
resources
...
...
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