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
c69e62f5
Commit
c69e62f5
authored
Dec 11, 2016
by
Yusuke Iwaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement notification click handler
parent
901b6289
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
AbstractAuthedActivity.java
.../chat/rocket/android/activity/AbstractAuthedActivity.java
+21
-0
StreamNotifyUserNotifier.java
...rocket/android/notification/StreamNotifyUserNotifier.java
+23
-1
No files found.
app/src/main/java/chat/rocket/android/activity/AbstractAuthedActivity.java
View file @
c69e62f5
package
chat
.
rocket
.
android
.
activity
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.support.annotation.Nullable
;
import
chat.rocket.android.LaunchUtil
;
import
chat.rocket.android.RocketChatCache
;
import
chat.rocket.android.model.ServerConfig
;
...
...
@@ -34,6 +36,25 @@ abstract class AbstractAuthedActivity extends AbstractFragmentActivity {
}
};
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
if
(
savedInstanceState
==
null
)
{
Intent
intent
=
getIntent
();
if
(
intent
!=
null
)
{
if
(
intent
.
hasExtra
(
"serverConfigId"
))
{
SharedPreferences
.
Editor
editor
=
RocketChatCache
.
get
(
this
).
edit
();
editor
.
putString
(
RocketChatCache
.
KEY_SELECTED_SERVER_CONFIG_ID
,
intent
.
getStringExtra
(
"serverConfigId"
));
if
(
intent
.
hasExtra
(
"roomId"
))
{
editor
.
putString
(
RocketChatCache
.
KEY_SELECTED_ROOM_ID
,
intent
.
getStringExtra
(
"roomId"
));
}
editor
.
apply
();
}
}
}
}
private
void
updateServerConfigIdIfNeeded
(
SharedPreferences
prefs
)
{
String
newServerConfigId
=
prefs
.
getString
(
RocketChatCache
.
KEY_SELECTED_SERVER_CONFIG_ID
,
null
);
if
(
serverConfigId
==
null
)
{
...
...
app/src/main/java/chat/rocket/android/notification/StreamNotifyUserNotifier.java
View file @
c69e62f5
package
chat
.
rocket
.
android
.
notification
;
import
android.app.Notification
;
import
android.app.PendingIntent
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.app.NotificationManagerCompat
;
import
android.support.v4.content.ContextCompat
;
import
bolts.Task
;
import
chat.rocket.android.R
;
import
chat.rocket.android.activity.MainActivity
;
import
chat.rocket.android.helper.Avatar
;
import
chat.rocket.android.model.ServerConfig
;
import
chat.rocket.android.realm_helper.RealmStore
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
/**
...
...
@@ -71,12 +77,28 @@ public class StreamNotifyUserNotifier implements Notifier {
}
private
Notification
generateNotification
(
Bitmap
largeIcon
)
{
Intent
intent
=
new
Intent
(
context
,
MainActivity
.
class
);
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
|
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
ServerConfig
config
=
RealmStore
.
getDefault
().
executeTransactionForRead
(
realm
->
realm
.
where
(
ServerConfig
.
class
).
equalTo
(
"hostname"
,
hostname
).
findFirst
());
if
(
config
!=
null
)
{
intent
.
putExtra
(
"serverConfigId"
,
config
.
getServerConfigId
());
try
{
intent
.
putExtra
(
"roomId"
,
payload
.
getString
(
"rid"
));
}
catch
(
JSONException
exception
)
{
}
}
PendingIntent
pendingIntent
=
PendingIntent
.
getActivity
(
context
.
getApplicationContext
(),
(
int
)
(
System
.
currentTimeMillis
()
%
Integer
.
MAX_VALUE
),
intent
,
PendingIntent
.
FLAG_ONE_SHOT
);
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
context
)
.
setContentTitle
(
title
)
.
setContentText
(
text
)
.
setAutoCancel
(
true
)
.
setColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
colorPrimary
))
.
setSmallIcon
(
R
.
drawable
.
rocket_chat_notification_24dp
);
.
setSmallIcon
(
R
.
drawable
.
rocket_chat_notification_24dp
)
.
setContentIntent
(
pendingIntent
);
if
(
largeIcon
!=
null
)
{
builder
.
setLargeIcon
(
largeIcon
);
}
...
...
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