From 8f26b4299ca38b7b32f75aed74ccc8683a166055 Mon Sep 17 00:00:00 2001 From: Nathan Kerr Date: Tue, 30 Jul 2019 13:01:08 -0700 Subject: [PATCH] Allow the user to set a "large icon" Need to actually test this. --- src/android/ForegroundService.java | 6 ++++++ www/background-mode.js | 1 + 2 files changed, 7 insertions(+) diff --git a/src/android/ForegroundService.java b/src/android/ForegroundService.java index e4ae337..5ffff70 100644 --- a/src/android/ForegroundService.java +++ b/src/android/ForegroundService.java @@ -27,6 +27,7 @@ import android.app.*; import android.content.Context; import android.content.Intent; import android.content.res.Resources; +import android.graphics.BitmapFactory; import android.graphics.drawable.Icon; import android.os.Binder; import android.os.Build; @@ -189,6 +190,7 @@ public class ForegroundService extends Service { String text = settings.optString("text", NOTIFICATION_TEXT); boolean bigText = settings.optBoolean("bigText", false); String subText = settings.optString("subText", ""); + String largeIcon = settings.optString("largeIcon", null); Context context = getApplicationContext(); String pkgName = context.getPackageName(); @@ -206,6 +208,10 @@ public class ForegroundService extends Service { notification.setSubText(subText); } + if (largeIcon != null) { + notification.setLargeIcon(BitmapFactory.decodeResource(getResources(), getIconResId(largeIcon))); + } + if (settings.optBoolean("allowClose", false)) { final Intent clostAppIntent = new Intent("com.backgroundmode.close" + pkgName); diff --git a/www/background-mode.js b/www/background-mode.js index 3bfdf86..644139d 100644 --- a/www/background-mode.js +++ b/www/background-mode.js @@ -419,6 +419,7 @@ exports._defaults = { hidden: true, color: undefined, icon: 'icon', + largeIcon: undefined, channelName: 'cordova-plugin-background-mode', channelDescription: 'cordova-plugin-background-moden notification', allowClose: false,