diff --git a/.gitignore b/.gitignore index 0235c648c..562d57523 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.idea /src/windows.old /src/windows/Microsoft.Toolkit.Uwp.Notifications.* /src/windows/**/.vs diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b6e25a3c..6526019c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ Changelog --------- +#### Version 0.9.4 (27.11.2020) +- Add namespace to provider authority to prevent crashes on Android. #### Version 0.9.3 (09.05.2019) - Add namespace to provider authority to prevent crashes on Android. diff --git a/README.md b/README.md index f342f24f5..c8be78ad3 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,12 @@ __Known issues__ Please report bugs or missing features! +## Installation + +To install the latest version: + + $ cordova plugin add https://github.com/hamzayanni/cordova-plugin-local-notifications.git + ## Basics @@ -514,14 +520,6 @@ See the sample app for how to use them. | clearAll | isPresent | getScheduledIds | getTriggered | setDefaults | | cancel | isScheduled | getTriggeredIds | addActions | on | - -## Installation - -To install the latest version: - - $ cordova plugin add https://github.com/Steffaan/cordova-plugin-local-notifications.git - - ## License This software is released under the [Apache 2.0 License][apache2_license]. diff --git a/src/android/notification/Manager.java b/src/android/notification/Manager.java index 0e1e2fdbc..0eb956607 100644 --- a/src/android/notification/Manager.java +++ b/src/android/notification/Manager.java @@ -57,6 +57,7 @@ import static de.appplant.cordova.plugin.notification.Notification.PREF_KEY_ID; import static de.appplant.cordova.plugin.notification.Notification.Type.TRIGGERED; import de.appplant.cordova.plugin.notification.Options; +import de.appplant.cordova.plugin.notification.util.AssetUtil; /** * Central way to access all or single local notifications set by specific @@ -72,6 +73,9 @@ public final class Manager { // The application context private Context context; + // Asset util instance + private final AssetUtil assets; + /** * Constructor * @@ -80,6 +84,7 @@ public final class Manager { private Manager(Context context) { this.context = context; //createDefaultChannel(); + assets = AssetUtil.getInstance(context); } /** @@ -113,7 +118,7 @@ public Notification schedule (Request request, Class receiver) { return toast; } - /** + /** * TODO: temporary */ @SuppressLint("WrongConstant") @@ -126,8 +131,10 @@ public void createChannel(Options options) { NotificationChannel channel = mgr.getNotificationChannel(options.getChannel()); - if (channel != null) - return; + if (channel != null) { + channel = null; + mgr.deleteNotificationChannel(options.getChannel()); + } switch (options.getPrio()) { case PRIORITY_MIN: @@ -149,28 +156,26 @@ public void createChannel(Options options) { channel = new NotificationChannel( options.getChannel(), options.getChannelDescription(), importance); - if(!options.isSilent() && importance > IMPORTANCE_DEFAULT) channel.setBypassDnd(true); - if(!options.isWithoutLights()) channel.enableLights(true); - if(options.isWithVibration()) { - channel.enableVibration(true); - } else { - channel.setVibrationPattern(new long[]{ 0 }); - channel.enableVibration(true); - } - channel.setLightColor(options.getLedColor()); + if(!options.isSilent() && importance > IMPORTANCE_DEFAULT) channel.setBypassDnd(true); + if(!options.isWithoutLights()) channel.enableLights(true); + if(options.isWithVibration()) { + channel.enableVibration(true); + } else { + channel.setVibrationPattern(new long[]{ 0 }); + channel.enableVibration(true); + } + channel.setLightColor(options.getLedColor()); if(options.isWithoutSound()) { - channel.setSound(null, null); - } else { - AudioAttributes audioAttributes = new AudioAttributes.Builder() + channel.setSound(null, null); + } else { + AudioAttributes audioAttributes = new AudioAttributes.Builder() .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) .setUsage(AudioAttributes.USAGE_NOTIFICATION).build(); - - if(options.isWithDefaultSound()) { - channel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), audioAttributes); - } else { - channel.setSound(options.getSound(), audioAttributes); - } - } + + SharedPreferences sharedpreferences = this.context.getSharedPreferences("ADHAN", Context.MODE_PRIVATE); + String sound = sharedpreferences.getString("sound", "file://assets/audio/adhan_makkah.wav"); + channel.setSound(assets.parse(sound), audioAttributes); + } mgr.createNotificationChannel(channel); }