Commit d85f6af1 by Sebastián Katzer

Support for big-text and inbox style on Android

parent b953e96a
...@@ -117,6 +117,7 @@ public class Builder { ...@@ -117,6 +117,7 @@ public class Builder {
builder.setSmallIcon(options.getIcon()); builder.setSmallIcon(options.getIcon());
} }
applyStyle(builder);
applyDeleteReceiver(builder); applyDeleteReceiver(builder);
applyContentReceiver(builder); applyContentReceiver(builder);
...@@ -124,6 +125,50 @@ public class 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 * Set intent to handle the delete event. Will clean up some persisted
* preferences. * preferences.
* *
......
...@@ -445,6 +445,13 @@ public class Options { ...@@ -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. * Gets the raw trigger spec as provided by the user.
*/ */
public JSONObject getTrigger() { public JSONObject getTrigger() {
......
...@@ -27,7 +27,6 @@ import android.content.res.AssetManager; ...@@ -27,7 +27,6 @@ import android.content.res.AssetManager;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.media.RingtoneManager;
import android.net.Uri; import android.net.Uri;
import android.os.StrictMode; import android.os.StrictMode;
import android.util.Log; import android.util.Log;
...@@ -43,8 +42,6 @@ import java.net.MalformedURLException; ...@@ -43,8 +42,6 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.UUID; import java.util.UUID;
import static android.media.RingtoneManager.TYPE_NOTIFICATION;
/** /**
* Util class to map unified asset URIs to native URIs. URIs like file:/// * 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 * map to absolute paths while file:// point relatively to the www folder
......
...@@ -51,6 +51,7 @@ exports.applyPlatformSpecificOptions = function () { ...@@ -51,6 +51,7 @@ exports.applyPlatformSpecificOptions = function () {
switch (device.platform) { switch (device.platform) {
case 'Android': case 'Android':
defaults.summary = undefined;
defaults.icon = 'res://icon'; defaults.icon = 'res://icon';
defaults.smallIcon = undefined; defaults.smallIcon = undefined;
defaults.sticky = false; defaults.sticky = false;
...@@ -83,7 +84,7 @@ exports.mergeWithDefaults = function (options) { ...@@ -83,7 +84,7 @@ exports.mergeWithDefaults = function (options) {
options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel'); options.autoClear = this.getValueFor(options, 'autoClear', 'autoCancel');
} }
if (options.autoClear !== true && options.sticky) { if (options.autoClear !== true && options.ongoing) {
options.autoClear = false; options.autoClear = false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment