notify by SMS on new ProfileSwitch instead of profile
This commit is contained in:
parent
e6a606296d
commit
df3c226d5a
3 changed files with 16 additions and 16 deletions
|
@ -187,9 +187,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
final Object updateSync = new Object();
|
final Object updateSync = new Object();
|
||||||
|
|
||||||
public enum CHARTTYPE {PRE, BAS, IOB, COB, DEV, SEN}
|
public enum CHARTTYPE {PRE, BAS, IOB, COB, DEV, SEN};
|
||||||
|
|
||||||
;
|
|
||||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledUpdate = null;
|
private static ScheduledFuture<?> scheduledUpdate = null;
|
||||||
|
|
||||||
|
|
|
@ -120,19 +120,6 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
profile = new ProfileStore(newProfile.getData());
|
profile = new ProfileStore(newProfile.getData());
|
||||||
storeNSProfile();
|
storeNSProfile();
|
||||||
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
||||||
if (MainApp.getConfigBuilder().isProfileValid("storeNewProfile")) {
|
|
||||||
ConfigBuilderPlugin.getCommandQueue().setProfile(MainApp.getConfigBuilder().getProfile(), new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (result.enacted) {
|
|
||||||
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
|
||||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
|
||||||
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeNSProfile() {
|
private void storeNSProfile() {
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package info.nightscout.androidaps.queue.commands;
|
package info.nightscout.androidaps.queue.commands;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +16,7 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommandSetProfile extends Command {
|
public class CommandSetProfile extends Command {
|
||||||
Profile profile;
|
private Profile profile;
|
||||||
|
|
||||||
public CommandSetProfile(Profile profile, Callback callback) {
|
public CommandSetProfile(Profile profile, Callback callback) {
|
||||||
commandType = CommandType.BASALPROFILE;
|
commandType = CommandType.BASALPROFILE;
|
||||||
|
@ -24,6 +29,15 @@ public class CommandSetProfile extends Command {
|
||||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile);
|
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile);
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(r).run();
|
callback.result(r).run();
|
||||||
|
|
||||||
|
// Send SMS notification if ProfileSwitch is comming from NS
|
||||||
|
ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||||
|
if (r.enacted && profileSwitch.source == Source.NIGHTSCOUT) {
|
||||||
|
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
||||||
|
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||||
|
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue