Always create Notification
This commit is contained in:
parent
1512064c53
commit
b2c46b67b6
|
@ -17,6 +17,8 @@ import androidx.core.app.TaskStackBuilder;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainActivity;
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -79,7 +81,8 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.pluginName(R.string.ongoingnotificaction)
|
.pluginName(R.string.ongoingnotificaction)
|
||||||
.enableByDefault(true)
|
.enableByDefault(true)
|
||||||
.alwaysEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
.alwaysEnabled(true)
|
||||||
|
.showInList(false)
|
||||||
.description(R.string.description_persistent_notification)
|
.description(R.string.description_persistent_notification)
|
||||||
);
|
);
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
@ -87,8 +90,8 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
|
createNotificationChannel(); // make sure channels exist before triggering updates through the bus
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
createNotificationChannel();
|
|
||||||
triggerNotificationUpdate();
|
triggerNotificationUpdate();
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
@ -112,18 +115,14 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void triggerNotificationUpdate() {
|
private void triggerNotificationUpdate() {
|
||||||
if (updateNotification() != null)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
MainApp.instance().startForegroundService(new Intent(MainApp.instance(), DummyService.class));
|
||||||
MainApp.instance().startForegroundService(new Intent(MainApp.instance(), DummyService.class));
|
else
|
||||||
else
|
MainApp.instance().startService(new Intent(MainApp.instance(), DummyService.class));
|
||||||
MainApp.instance().startService(new Intent(MainApp.instance(), DummyService.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
Notification updateNotification() {
|
Notification updateNotification() {
|
||||||
if (!isEnabled(PluginType.GENERAL)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String line1 = null;
|
String line1 = null;
|
||||||
String line2 = null;
|
String line2 = null;
|
||||||
String line3 = null;
|
String line3 = null;
|
||||||
|
|
Loading…
Reference in a new issue