Merge pull request #503 from jotomo/disabling-ongoing-notification

Cancel ongoing notification when plugin is disabled.
This commit is contained in:
Milos Kozak 2017-11-22 19:36:28 +01:00 committed by GitHub
commit d3288da468
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,24 +95,27 @@ public class PersistentNotificationPlugin implements PluginBase {
@Override @Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
if (getType() == type) { if (getType() == type) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
enableDisableNotification(fragmentEnabled);
checkBusRegistration(); checkBusRegistration();
//updateNotification(); }
} }
} private void enableDisableNotification(boolean fragmentEnabled) {
private void updateNotification() {
if (!fragmentEnabled) { if (!fragmentEnabled) {
NotificationManager mNotificationManager = NotificationManager mNotificationManager =
(NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(ONGOING_NOTIFICATION_ID); mNotificationManager.cancel(ONGOING_NOTIFICATION_ID);
return; } else {
updateNotification();
}
} }
private void updateNotification() {
if (!fragmentEnabled) {
return;
}
String line1 = ctx.getString(R.string.noprofile); String line1 = ctx.getString(R.string.noprofile);