Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Nabil Sadki
cordova-plugin-local-notifications
Commits
d85f6af1
Commit
d85f6af1
authored
Oct 11, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for big-text and inbox style on Android
parent
b953e96a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
4 deletions
+54
-4
Builder.java
src/android/notification/Builder.java
+45
-0
Options.java
src/android/notification/Options.java
+7
-0
AssetUtil.java
src/android/notification/util/AssetUtil.java
+0
-3
local-notification-util.js
www/local-notification-util.js
+2
-1
No files found.
src/android/notification/Builder.java
View file @
d85f6af1
...
...
@@ -117,6 +117,7 @@ public class Builder {
builder
.
setSmallIcon
(
options
.
getIcon
());
}
applyStyle
(
builder
);
applyDeleteReceiver
(
builder
);
applyContentReceiver
(
builder
);
...
...
@@ -124,6 +125,50 @@ public class Builder {
}
/**
* Find out and set the notification style.
*
* @param builder Local notification builder instance
*/
private
void
applyStyle
(
NotificationCompat
.
Builder
builder
)
{
String
summary
=
options
.
getSummary
();
String
text
=
options
.
getText
();
if
(
summary
==
null
&&
text
==
null
)
return
;
if
(
text
.
contains
(
"\n"
))
{
NotificationCompat
.
InboxStyle
style
=
new
NotificationCompat
.
InboxStyle
(
builder
)
.
setBigContentTitle
(
options
.
getTitle
());
if
(
summary
!=
null
)
{
style
.
setSummaryText
(
summary
);
}
for
(
String
line
:
text
.
split
(
"\n"
))
{
style
.
addLine
(
line
);
}
builder
.
setStyle
(
style
);
return
;
}
if
(
summary
==
null
&&
text
.
length
()
<
45
)
return
;
NotificationCompat
.
BigTextStyle
style
=
new
NotificationCompat
.
BigTextStyle
(
builder
)
.
setBigContentTitle
(
options
.
getTitle
())
.
bigText
(
text
);
if
(
summary
!=
null
)
{
style
.
setSummaryText
(
summary
);
}
builder
.
setStyle
(
style
);
}
/**
* Set intent to handle the delete event. Will clean up some persisted
* preferences.
*
...
...
src/android/notification/Options.java
View file @
d85f6af1
...
...
@@ -445,6 +445,13 @@ public class Options {
}
/**
* The summary for inbox style notifications.
*/
String
getSummary
()
{
return
options
.
optString
(
"summary"
);
}
/**
* Gets the raw trigger spec as provided by the user.
*/
public
JSONObject
getTrigger
()
{
...
...
src/android/notification/util/AssetUtil.java
View file @
d85f6af1
...
...
@@ -27,7 +27,6 @@ import android.content.res.AssetManager;
import
android.content.res.Resources
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.media.RingtoneManager
;
import
android.net.Uri
;
import
android.os.StrictMode
;
import
android.util.Log
;
...
...
@@ -43,8 +42,6 @@ import java.net.MalformedURLException;
import
java.net.URL
;
import
java.util.UUID
;
import
static
android
.
media
.
RingtoneManager
.
TYPE_NOTIFICATION
;
/**
* Util class to map unified asset URIs to native URIs. URIs like file:///
* map to absolute paths while file:// point relatively to the www folder
...
...
www/local-notification-util.js
View file @
d85f6af1
...
...
@@ -51,6 +51,7 @@ exports.applyPlatformSpecificOptions = function () {
switch
(
device
.
platform
)
{
case
'Android'
:
defaults
.
summary
=
undefined
;
defaults
.
icon
=
'res://icon'
;
defaults
.
smallIcon
=
undefined
;
defaults
.
sticky
=
false
;
...
...
@@ -83,7 +84,7 @@ exports.mergeWithDefaults = function (options) {
options
.
autoClear
=
this
.
getValueFor
(
options
,
'autoClear'
,
'autoCancel'
);
}
if
(
options
.
autoClear
!==
true
&&
options
.
sticky
)
{
if
(
options
.
autoClear
!==
true
&&
options
.
ongoing
)
{
options
.
autoClear
=
false
;
}
...
...
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