Cancel ongoing notification when plugin is disabled.

This commit is contained in:
Johannes Mockenhaupt 2017-11-22 11:44:20 +01:00
parent 62527ab33b
commit e28e5685f6
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

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