commit
e51954cec3
|
@ -4,8 +4,14 @@ import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
@ -15,17 +21,25 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
||||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
|
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfilePlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -157,14 +171,9 @@ public class ActionStringHandler {
|
||||||
rMessage = getPumpStatus();
|
rMessage = getPumpStatus();
|
||||||
} else if ("loop".equals(act[1])) {
|
} else if ("loop".equals(act[1])) {
|
||||||
rTitle += " LOOP";
|
rTitle += " LOOP";
|
||||||
rMessage = getLoopStatus();
|
rMessage = "TARGETS:\n" + getTargetsStatus();
|
||||||
|
rMessage += "\n\n" + getLoopStatus();
|
||||||
} else if ("targets".equals(act[1])) {
|
rMessage += "\n\nOAPS RESULT:\n" + getOAPSResultStatus();;
|
||||||
rTitle += " TARGETS";
|
|
||||||
rMessage = getTargetsStatus();
|
|
||||||
} else if ("oapsresult".equals(act[1])) {
|
|
||||||
rTitle += " OAPS RESULT";
|
|
||||||
rMessage = getOAPSResultStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ("wizard".equals(act[0])) {
|
} else if ("wizard".equals(act[0])) {
|
||||||
|
@ -256,6 +265,58 @@ public class ActionStringHandler {
|
||||||
rAction = actionstring;
|
rAction = actionstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if("tddstats".equals(act[0])){
|
||||||
|
Object activePump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
PumpInterface dana = (PumpInterface) MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||||
|
PumpInterface danaV2 = (PumpInterface) MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||||
|
PumpInterface danaKorean = (PumpInterface) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||||
|
|
||||||
|
|
||||||
|
if((dana == null || dana != activePump) &&
|
||||||
|
(danaV2 == null || danaV2 != activePump) &&
|
||||||
|
(danaKorean == null || danaKorean != activePump)
|
||||||
|
){
|
||||||
|
sendError("Pump does not support TDDs!");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// check if DB up to date
|
||||||
|
List<DanaRHistoryRecord> dummies = new LinkedList<DanaRHistoryRecord>();
|
||||||
|
List<DanaRHistoryRecord> historyList = getTDDList(dummies);
|
||||||
|
|
||||||
|
if(isOldData(historyList)){
|
||||||
|
rTitle = "TDD";
|
||||||
|
rAction = "statusmessage";
|
||||||
|
rMessage = "OLD DATA - ";
|
||||||
|
|
||||||
|
//if pump is not busy: try to fetch data
|
||||||
|
final PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
if (pump.isBusy()) {
|
||||||
|
rMessage += MainApp.instance().getString(R.string.pumpbusy);
|
||||||
|
} else {
|
||||||
|
rMessage += "trying to fetch data from pump.";
|
||||||
|
Handler handler = new Handler(handlerThread.getLooper());
|
||||||
|
handler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
((DanaRInterface)pump).loadHistory(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
List<DanaRHistoryRecord> dummies = new LinkedList<DanaRHistoryRecord>();
|
||||||
|
List<DanaRHistoryRecord> historyList = getTDDList(dummies);
|
||||||
|
if(isOldData(historyList)){
|
||||||
|
sendStatusmessage("TDD", "TDD: Still old data! Cannot load from pump.");
|
||||||
|
} else {
|
||||||
|
sendStatusmessage("TDD", generateTDDMessage(historyList, dummies));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// if up to date: prepare, send (check if CPP is activated -> add CPP stats)
|
||||||
|
rTitle = "TDD";
|
||||||
|
rAction = "statusmessage";
|
||||||
|
rMessage = generateTDDMessage(historyList, dummies);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else return;
|
else return;
|
||||||
|
|
||||||
|
@ -266,6 +327,98 @@ public class ActionStringHandler {
|
||||||
lastConfirmActionString = rAction;
|
lastConfirmActionString = rAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String generateTDDMessage(List<DanaRHistoryRecord> historyList, List<DanaRHistoryRecord> dummies) {
|
||||||
|
|
||||||
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
|
String message = "";
|
||||||
|
|
||||||
|
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
boolean isCPP = (cpp!= null && cpp.isEnabled(PluginBase.PROFILE));
|
||||||
|
double refTDD = 100;
|
||||||
|
if(isCPP) refTDD = cpp.baseBasalSum()*2;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
double sum = 0d;
|
||||||
|
double weighted03 = 0d;
|
||||||
|
double weighted05 = 0d;
|
||||||
|
double weighted07 = 0d;
|
||||||
|
|
||||||
|
Collections.reverse(historyList);
|
||||||
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
|
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||||
|
if (i == 0) {
|
||||||
|
weighted03 = tdd;
|
||||||
|
weighted05 = tdd;
|
||||||
|
weighted07 = tdd;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
weighted07 = (weighted07 * 0.3 + tdd * 0.7);
|
||||||
|
weighted05 = (weighted05 * 0.5 + tdd * 0.5);
|
||||||
|
weighted03 = (weighted03 * 0.7 + tdd * 0.3);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
message += "weighted:\n";
|
||||||
|
message += "0.3: " + DecimalFormatter.to2Decimal(weighted03) + "U " + (isCPP?(DecimalFormatter.to0Decimal(100*weighted03/refTDD) + "%"):"") + "\n";
|
||||||
|
message += "0.5: " + DecimalFormatter.to2Decimal(weighted05) + "U " + (isCPP?(DecimalFormatter.to0Decimal(100*weighted05/refTDD) + "%"):"") + "\n";
|
||||||
|
message += "0.7: " + DecimalFormatter.to2Decimal(weighted07) + "U " + (isCPP?(DecimalFormatter.to0Decimal(100*weighted07/refTDD) + "%"):"") + "\n";
|
||||||
|
message += "\n";
|
||||||
|
|
||||||
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
if (pump != null && pump instanceof DanaRPlugin) {
|
||||||
|
double tdd = DanaRPump.getInstance().dailyTotalUnits;
|
||||||
|
message += "Today: " + DecimalFormatter.to2Decimal(tdd) + "U " + (isCPP?(DecimalFormatter.to0Decimal(100*tdd/refTDD) + "%"):"") + "\n";
|
||||||
|
message += "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//add TDDs:
|
||||||
|
Collections.reverse(historyList);
|
||||||
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
|
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||||
|
message += df.format(new Date(record.recordDate)) + " " + DecimalFormatter.to2Decimal(tdd) +"U " + (isCPP?(DecimalFormatter.to0Decimal(100*tdd/refTDD) + "%"):"") + (dummies.contains(record)?"x":"") +"\n";
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isOldData(List<DanaRHistoryRecord> historyList) {
|
||||||
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
|
return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).recordDate)).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static List<DanaRHistoryRecord> getTDDList(List<DanaRHistoryRecord> returnDummies) {
|
||||||
|
List<DanaRHistoryRecord> historyList = MainApp.getDbHelper().getDanaRHistoryRecordsByType(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
|
||||||
|
//only use newest 10
|
||||||
|
historyList = historyList.subList(0, Math.min(10, historyList.size()));
|
||||||
|
|
||||||
|
//fill single gaps
|
||||||
|
List<DanaRHistoryRecord> dummies = (returnDummies!=null)?returnDummies:(new LinkedList());
|
||||||
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
|
for(int i = 0; i < historyList.size()-1; i++){
|
||||||
|
DanaRHistoryRecord elem1 = historyList.get(i);
|
||||||
|
DanaRHistoryRecord elem2 = historyList.get(i+1);
|
||||||
|
|
||||||
|
if (!df.format(new Date(elem1.recordDate)).equals(df.format(new Date(elem2.recordDate + 25*60*60*1000)))){
|
||||||
|
DanaRHistoryRecord dummy = new DanaRHistoryRecord();
|
||||||
|
dummy.recordDate = elem1.recordDate - 24*60*60*1000;
|
||||||
|
dummy.recordDailyBasal = elem1.recordDailyBasal/2;
|
||||||
|
dummy.recordDailyBolus = elem1.recordDailyBolus/2;
|
||||||
|
dummies.add(dummy);
|
||||||
|
elem1.recordDailyBasal /= 2;
|
||||||
|
elem1.recordDailyBolus /= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
historyList.addAll(dummies);
|
||||||
|
Collections.sort(historyList, new Comparator<DanaRHistoryRecord>() {
|
||||||
|
@Override
|
||||||
|
public int compare(DanaRHistoryRecord lhs, DanaRHistoryRecord rhs) {
|
||||||
|
return (int) (rhs.recordDate-lhs.recordDate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return historyList;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private static String getPumpStatus() {
|
private static String getPumpStatus() {
|
||||||
return MainApp.getConfigBuilder().shortStatus(false);
|
return MainApp.getConfigBuilder().shortStatus(false);
|
||||||
|
@ -506,6 +659,13 @@ public class ActionStringHandler {
|
||||||
lastBolusWizard = null;
|
lastBolusWizard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private synchronized static void sendStatusmessage(String title, String message) {
|
||||||
|
WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(title, message, "statusmessage");
|
||||||
|
lastSentTimestamp = System.currentTimeMillis();
|
||||||
|
lastConfirmActionString = null;
|
||||||
|
lastBolusWizard = null;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized static void expectNotificationAction(String message, int id) {
|
public synchronized static void expectNotificationAction(String message, int id) {
|
||||||
String actionstring = "dismissoverviewnotification " + id;
|
String actionstring = "dismissoverviewnotification " + id;
|
||||||
WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("DISMISS", message, actionstring);
|
WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("DISMISS", message, actionstring);
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
||||||
|
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
isMGDL = sp.getBoolean("units_mgdl", true);
|
isMGDL = sp.getBoolean("units_mgdl", true);
|
||||||
isSingleTarget = sp.getBoolean("singletarget", false);
|
isSingleTarget = sp.getBoolean("singletarget", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,23 +23,17 @@ public class FillMenuActivity extends MenuListActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doAction(int position) {
|
protected void doAction(String action) {
|
||||||
switch (position) {
|
if ("Preset 1".equals(action)) {
|
||||||
case 0:
|
|
||||||
ListenerService.initiateAction(this, "fillpreset 1");
|
ListenerService.initiateAction(this, "fillpreset 1");
|
||||||
break;
|
} else if ("Preset 2".equals(action)) {
|
||||||
case 1:
|
|
||||||
ListenerService.initiateAction(this, "fillpreset 2");
|
ListenerService.initiateAction(this, "fillpreset 2");
|
||||||
break;
|
} else if ("Preset 3".equals(action)) {
|
||||||
case 2:
|
|
||||||
ListenerService.initiateAction(this, "fillpreset 3");
|
ListenerService.initiateAction(this, "fillpreset 3");
|
||||||
break;
|
} else if ("Free amount".equals(action)) {
|
||||||
case 3:
|
|
||||||
Intent intent = new Intent(this, FillActivity.class);
|
Intent intent = new Intent(this, FillActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
this.startActivity(intent);
|
this.startActivity(intent);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.data.ListenerService;
|
import info.nightscout.androidaps.data.ListenerService;
|
||||||
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
||||||
|
@ -39,74 +41,50 @@ public class MainMenuActivity extends MenuListActivity {
|
||||||
|
|
||||||
|
|
||||||
boolean showPrimeFill = sp.getBoolean("primefill", false);
|
boolean showPrimeFill = sp.getBoolean("primefill", false);
|
||||||
return new String[] {
|
boolean showWizard = sp.getBoolean("showWizard", true);
|
||||||
"TempT",
|
|
||||||
"Bolus",
|
Vector<String> menuitems = new Vector<String>();
|
||||||
"Wizard",
|
menuitems.add("TempT");
|
||||||
"Settings",
|
menuitems.add("Bolus");
|
||||||
"Re-Sync",
|
if(showWizard) menuitems.add("Wizard");
|
||||||
"Status",
|
menuitems.add("Settings");
|
||||||
showPrimeFill?"Prime/Fill":""};
|
menuitems.add("Status");
|
||||||
|
if (showPrimeFill) menuitems.add("Prime/Fill");
|
||||||
|
|
||||||
|
return menuitems.toArray(new String[menuitems.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doAction(int position) {
|
protected void doAction(String action) {
|
||||||
|
|
||||||
Intent intent;
|
Intent intent;
|
||||||
|
|
||||||
if(!BuildConfig.WEAR_CONTROL) {
|
if ("Settings".equals(action)) {
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
intent = new Intent(this, AAPSPreferences.class);
|
intent = new Intent(this, AAPSPreferences.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
this.startActivity(intent);
|
this.startActivity(intent);
|
||||||
break;
|
} else if ("Re-Sync".equals(action)) {
|
||||||
case 1:
|
|
||||||
ListenerService.requestData(this);
|
ListenerService.requestData(this);
|
||||||
break;
|
} else if ("TempT".equals(action)) {
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
intent = new Intent(this, TempTargetActivity.class);
|
intent = new Intent(this, TempTargetActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
this.startActivity(intent);
|
this.startActivity(intent);
|
||||||
break;
|
} else if ("Bolus".equals(action)) {
|
||||||
case 1:
|
|
||||||
intent = new Intent(this, BolusActivity.class);
|
intent = new Intent(this, BolusActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
this.startActivity(intent);
|
this.startActivity(intent);
|
||||||
break;
|
} else if ("Wizard".equals(action)) {
|
||||||
case 2:
|
|
||||||
intent = new Intent(this, WizardActivity.class);
|
intent = new Intent(this, WizardActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
this.startActivity(intent);
|
this.startActivity(intent);
|
||||||
break;
|
} else if ("Status".equals(action)) {
|
||||||
case 3:
|
|
||||||
intent = new Intent(this, AAPSPreferences.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
this.startActivity(intent);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
ListenerService.requestData(this);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
intent = new Intent(this, StatusMenuActivity.class);
|
intent = new Intent(this, StatusMenuActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
this.startActivity(intent);
|
this.startActivity(intent);
|
||||||
break;
|
} else if ("Prime/Fill".equals(action)) {
|
||||||
case 6:
|
|
||||||
boolean showPrimeFill = sp.getBoolean("primefill", false);
|
|
||||||
if(showPrimeFill) {
|
|
||||||
intent = new Intent(this, FillMenuActivity.class);
|
intent = new Intent(this, FillMenuActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
this.startActivity(intent);
|
this.startActivity(intent);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
package info.nightscout.androidaps.interaction.menus;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.ListenerService;
|
|
||||||
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
|
||||||
import info.nightscout.androidaps.interaction.actions.BolusActivity;
|
|
||||||
import info.nightscout.androidaps.interaction.actions.TempTargetActivity;
|
|
||||||
import info.nightscout.androidaps.interaction.actions.WizardActivity;
|
|
||||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by adrian on 09/02/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class MainMenuRestrictedActivity extends MenuListActivity {
|
|
||||||
|
|
||||||
SharedPreferences sp;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
sp = PreferenceManager.getDefaultSharedPreferences(this);
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
ListenerService.requestData(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String[] getElements() {
|
|
||||||
return new String[] {
|
|
||||||
"Settings",
|
|
||||||
"Re-Sync"};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doAction(int position) {
|
|
||||||
|
|
||||||
Intent intent;
|
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
intent = new Intent(this, AAPSPreferences.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
this.startActivity(intent);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
ListenerService.requestData(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,32 +14,22 @@ public class StatusMenuActivity extends MenuListActivity {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"Pump",
|
"Pump",
|
||||||
"Loop",
|
"Loop",
|
||||||
"Targets",
|
|
||||||
"CPP",
|
"CPP",
|
||||||
"OAPS Result"};
|
"TDD"};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doAction(int position) {
|
protected void doAction(String action) {
|
||||||
switch (position) {
|
if ("Pump".equals(action)) {
|
||||||
|
|
||||||
case 0:
|
|
||||||
ListenerService.initiateAction(this, "status pump");
|
ListenerService.initiateAction(this, "status pump");
|
||||||
break;
|
} else if ("Loop".equals(action)) {
|
||||||
case 1:
|
|
||||||
ListenerService.initiateAction(this, "status loop");
|
ListenerService.initiateAction(this, "status loop");
|
||||||
break;
|
} else if ("CPP".equals(action)) {
|
||||||
case 2:
|
|
||||||
ListenerService.initiateAction(this, "status targets");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
ListenerService.initiateAction(this, "opencpp");
|
ListenerService.initiateAction(this, "opencpp");
|
||||||
break;
|
} else if ("TDD".equals(action)) {
|
||||||
case 4:
|
ListenerService.initiateAction(this, "tddstats");
|
||||||
ListenerService.initiateAction(this, "status oapsresult");
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public abstract class MenuListActivity extends Activity
|
||||||
|
|
||||||
protected abstract String[] getElements();
|
protected abstract String[] getElements();
|
||||||
|
|
||||||
protected abstract void doAction(int position);
|
protected abstract void doAction(String position);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause(){
|
protected void onPause(){
|
||||||
|
@ -50,7 +50,7 @@ public abstract class MenuListActivity extends Activity
|
||||||
// WearableListView click listener
|
// WearableListView click listener
|
||||||
@Override
|
@Override
|
||||||
public void onClick(WearableListView.ViewHolder v) {
|
public void onClick(WearableListView.ViewHolder v) {
|
||||||
Integer tag = (Integer) v.itemView.getTag();
|
String tag = (String) v.itemView.getTag();
|
||||||
doAction(tag);
|
doAction(tag);
|
||||||
//ActionsDefinitions.doAction(v.getAdapterPosition(), this);
|
//ActionsDefinitions.doAction(v.getAdapterPosition(), this);
|
||||||
finish();
|
finish();
|
||||||
|
@ -105,7 +105,7 @@ public abstract class MenuListActivity extends Activity
|
||||||
// replace text contents
|
// replace text contents
|
||||||
view.setText(mDataset[position]);
|
view.setText(mDataset[position]);
|
||||||
// replace list item's metadata
|
// replace list item's metadata
|
||||||
holder.itemView.setTag(position);
|
holder.itemView.setTag(mDataset[position]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the size of your dataset
|
// Return the size of your dataset
|
||||||
|
|
|
@ -121,6 +121,13 @@
|
||||||
app:wear_iconOff="@drawable/settings_off"
|
app:wear_iconOff="@drawable/settings_off"
|
||||||
app:wear_iconOn="@drawable/settings_on"/>
|
app:wear_iconOn="@drawable/settings_on"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="showWizard"
|
||||||
|
android:summary="Wizard from watch possible"
|
||||||
|
android:title="Wizard in Menu"
|
||||||
|
app:wear_iconOff="@drawable/settings_off"
|
||||||
|
app:wear_iconOn="@drawable/settings_on"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="primefill"
|
android:key="primefill"
|
||||||
|
@ -129,7 +136,7 @@
|
||||||
app:wear_iconOff="@drawable/settings_off"
|
app:wear_iconOff="@drawable/settings_off"
|
||||||
app:wear_iconOn="@drawable/settings_on"/>
|
app:wear_iconOn="@drawable/settings_on"/>
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="true"
|
||||||
android:key="singletarget"
|
android:key="singletarget"
|
||||||
android:summary="Single temp-target instead of a range."
|
android:summary="Single temp-target instead of a range."
|
||||||
android:title="Single Target"
|
android:title="Single Target"
|
||||||
|
|
Loading…
Reference in a new issue