Merge remote-tracking branch 'origin/dev' into combo-scripter-v2
* origin/dev: Cancel ongoing notification when plugin is disabled. Fix typo in fragment name. Nitpicky symmetry. PersistentNotification unregister workaround. Make PumpEnactResult fluent. Minor code cleanup. # Conflicts: # app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java # app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java
This commit is contained in:
commit
1a8c0fcf52
3 changed files with 12 additions and 7 deletions
|
@ -95,25 +95,28 @@ 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 updateNotification() {
|
private void enableDisableNotification(boolean fragmentEnabled) {
|
||||||
|
|
||||||
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);
|
||||||
|
} else {
|
||||||
|
updateNotification();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateNotification() {
|
||||||
|
if (!fragmentEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String line1 = ctx.getString(R.string.noprofile);
|
String line1 = ctx.getString(R.string.noprofile);
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || MainApp.getConfigBuilder().getProfile() == null)
|
if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || MainApp.getConfigBuilder().getProfile() == null)
|
||||||
|
@ -194,11 +197,13 @@ public class PersistentNotificationPlugin implements PluginBase {
|
||||||
try {
|
try {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
// already registered
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
// already unregistered
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class VirtualPumpFragment extends SubscriberFragment {
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
try {
|
try {
|
||||||
View view = inflater.inflate(R.layout.vitualpump_fragment, container, false);
|
View view = inflater.inflate(R.layout.virtualpump_fragment, container, false);
|
||||||
basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate);
|
basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate);
|
||||||
tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal);
|
tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal);
|
||||||
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);
|
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);
|
||||||
|
|
Loading…
Reference in a new issue