From 32de5cb8489892a8e47c3cae59a1e53cc3a4dc70 Mon Sep 17 00:00:00 2001 From: Nathan Kerr Date: Mon, 4 Feb 2019 11:18:34 -0800 Subject: [PATCH] Add Android-specific options Now the app can: -Set the channel name and description -Set the notification subtext -Add a "Close" action to the notification, along with customizing the action text and icon Fixed bugs: -Icon is never used if it's in "drawable" rather than "mipmap" -Used "Compat" library to make backwards compatibility easier --- .gitignore | 1 + README.md | 14 +++- plugin.xml | 7 ++ src/android/BackgroundMode.java | 27 ++++++- src/android/ForegroundService.java | 93 +++++++++++++--------- src/android/res/drawable-hdpi/power.png | Bin 0 -> 734 bytes src/android/res/drawable-mdpi/power.png | Bin 0 -> 523 bytes src/android/res/drawable-xhdpi/power.png | Bin 0 -> 1041 bytes src/android/res/drawable-xxhdpi/power.png | Bin 0 -> 1525 bytes src/android/res/drawable/power.xml | 9 +++ www/background-mode.js | 22 +++-- 11 files changed, 121 insertions(+), 52 deletions(-) create mode 100644 .gitignore create mode 100644 src/android/res/drawable-hdpi/power.png create mode 100644 src/android/res/drawable-mdpi/power.png create mode 100644 src/android/res/drawable-xhdpi/power.png create mode 100644 src/android/res/drawable-xxhdpi/power.png create mode 100644 src/android/res/drawable/power.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/README.md b/README.md index bde896a..5b728a1 100644 --- a/README.md +++ b/README.md @@ -145,11 +145,17 @@ The title, text and icon for that notification can be customized as below. Also, cordova.plugins.backgroundMode.setDefaults({ title: String, text: String, - icon: 'icon' // this will look for icon.png in platforms/android/res/drawable|mipmap - color: String // hex format like 'F14F4D' + subText: String, // see https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setSubText(java.lang.CharSequence) + icon: 'icon', // this will look for icon.png in platforms/android/res/drawable|mipmap + color: String, // hex format like 'F14F4D' resume: Boolean, hidden: Boolean, - bigText: Boolean + bigText: Boolean, + channelName: String, // Shown when the user views the app's notification settings + channelDescription: String, // Shown when the user views the channel's settings + allowClose: Boolean, // add a "Close" action to the notification + closeIcon: 'power', // An icon shown for the close action + closeTitle: 'Close' // The text for the close action }) ``` @@ -205,4 +211,4 @@ Made with :yum: from Leipzig [changelog]: CHANGELOG.md [apache2_license]: http://opensource.org/licenses/Apache-2.0 [appplant]: http://appplant.de -[meshfields]: http://meshfields.de \ No newline at end of file +[meshfields]: http://meshfields.de diff --git a/plugin.xml b/plugin.xml index 52bd90e..3f3c7cd 100644 --- a/plugin.xml +++ b/plugin.xml @@ -88,6 +88,13 @@ + + + + + + +