wear full status support and product flavour with/without controls on wear

This commit is contained in:
AdrianLxM 2017-02-13 01:55:35 +01:00
parent 6fcee9ea3f
commit e85e651c56
6 changed files with 143 additions and 21 deletions

View file

@ -97,10 +97,18 @@ android {
wear { wear {
dimension "wear" dimension "wear"
buildConfigField "boolean", "WEAR", "true" buildConfigField "boolean", "WEAR", "true"
buildConfigField "boolean", "WEAR_CONTROL", "false"
}
wearcontrol {
dimension "wear"
buildConfigField "boolean", "WEAR", "true"
buildConfigField "boolean", "WEAR_CONTROL", "true"
} }
nowear { nowear {
dimension "wear" dimension "wear"
buildConfigField "boolean", "WEAR", "false" buildConfigField "boolean", "WEAR", "false"
buildConfigField "boolean", "WEAR_CONTROL", "false"
} }
} }
} }
@ -115,7 +123,9 @@ allprojects {
} }
dependencies { dependencies {
wearWearApp project(path: ':wear', configuration: 'fullRelease') wearWearApp project(path: ':wear', configuration: 'restrictedRelease')
wearcontrolWearApp project(path: ':wear', configuration: 'fullRelease')
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') { compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') {
transitive = true; transitive = true;

View file

@ -20,6 +20,7 @@ import java.sql.SQLException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Date; import java.util.Date;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
@ -28,9 +29,11 @@ import info.nightscout.androidaps.data.GlucoseStatus;
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.TempTarget; import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog; import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Overview.QuickWizard; import info.nightscout.androidaps.plugins.Overview.QuickWizard;
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin; import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange; import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange;
@ -63,6 +66,9 @@ public class ActionStringHandler {
public synchronized static void handleInitiate(String actionstring){ public synchronized static void handleInitiate(String actionstring){
if(!BuildConfig.WEAR_CONTROL) return;
lastBolusWizard = null; lastBolusWizard = null;
String rTitle = "CONFIRM"; //TODO: i18n String rTitle = "CONFIRM"; //TODO: i18n
@ -164,11 +170,7 @@ public class ActionStringHandler {
////////////////////////////////////////////// STATUS ////////////////////////////////////////////// STATUS
rTitle = "STATUS"; rTitle = "STATUS";
rAction = "statusmessage"; rAction = "statusmessage";
//TODO: add meaningful status if("pump".equals(act[1])){
if("general".equals(act[1])){
rMessage = getGeneralStatus();
} else if("pump".equals(act[1])){
rTitle += " PUMP"; rTitle += " PUMP";
rMessage = getPumpStatus(); rMessage = getPumpStatus();
} else if("loop".equals(act[1])){ } else if("loop".equals(act[1])){
@ -179,7 +181,6 @@ public class ActionStringHandler {
rTitle += " TARGETS"; rTitle += " TARGETS";
rMessage = getTargetsStatus(); rMessage = getTargetsStatus();
} }
rMessage += "\n\n\nTODO:\nAdd some meaningful status.";
} else if ("wizard".equals(act[0])) { } else if ("wizard".equals(act[0])) {
////////////////////////////////////////////// WIZARD ////////////////////////////////////////////// WIZARD
@ -245,19 +246,40 @@ public class ActionStringHandler {
lastConfirmActionString = rAction; lastConfirmActionString = rAction;
} }
@NonNull
private static String getGeneralStatus() {
return "Today is going to be a good day!";
}
@NonNull @NonNull
private static String getPumpStatus() { private static String getPumpStatus() {
return "I'm feeling pumped!"; return MainApp.getConfigBuilder().shortStatus(false);
} }
@NonNull @NonNull
private static String getLoopStatus() { private static String getLoopStatus() {
return "A loop di loop di loop!"; String ret = "";
// decide if enabled/disabled closed/open; what Plugin as APS?
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
if(activeloop != null && activeloop.isEnabled(activeloop.getType())) {
if (MainApp.getConfigBuilder().isClosedModeEnabled()) {
ret += "CLOSED LOOP\n";
} else {
ret += "OPEN LOOP\n";
}
final APSInterface aps = MainApp.getConfigBuilder().getActiveAPS();
ret += "APS: " + ((aps==null)?"NO APS SELECTED!":((PluginBase) aps).getName());
if(activeloop.lastRun != null){
if(activeloop.lastRun.lastAPSRun != null)
ret += "\nLast Run: " + DateUtil.timeString(activeloop.lastRun.lastAPSRun);
if(activeloop.lastRun.lastEnact != null)
ret += "\nLast Enact: " + DateUtil.timeString(activeloop.lastRun.lastEnact);
}
} else {
ret += "LOOP DISABLED\n";
}
return ret;
} }
@NonNull @NonNull
@ -300,6 +322,9 @@ public class ActionStringHandler {
public synchronized static void handleConfirmation(String actionString){ public synchronized static void handleConfirmation(String actionString){
if(!BuildConfig.WEAR_CONTROL) return;
//Guard from old or duplicate confirmations //Guard from old or duplicate confirmations
if (lastConfirmActionString == null) return; if (lastConfirmActionString == null) return;
if (!lastConfirmActionString.equals(actionString)) return; if (!lastConfirmActionString.equals(actionString)) return;

View file

@ -30,6 +30,20 @@ android {
resValue "string", "label_xdrip_circle", "AAPS(Circle)" resValue "string", "label_xdrip_circle", "AAPS(Circle)"
resValue "string", "label_xdrip_activity", "AAPS Prefs." resValue "string", "label_xdrip_activity", "AAPS Prefs."
resValue "string", "app_settings", "AAPS Settings" resValue "string", "app_settings", "AAPS Settings"
buildConfigField "boolean", "WEAR_CONTROL", "true"
}
restricted {
applicationId = "info.nightscout.androidaps"
resValue "string", "label_xdrip", "AAPS"
resValue "string", "label_xdrip_large", "AAPS(Large)"
resValue "string", "label_xdrip_big_chart", "AAPS(BigChart)"
resValue "string", "label_xdrip_circle", "AAPS(Circle)"
resValue "string", "label_xdrip_activity", "AAPS Prefs."
resValue "string", "app_settings", "AAPS Settings"
buildConfigField "boolean", "WEAR_CONTROL", "false"
} }
} }
} }

View file

@ -5,6 +5,7 @@ import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
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;
import info.nightscout.androidaps.interaction.actions.BolusActivity; import info.nightscout.androidaps.interaction.actions.BolusActivity;
@ -30,8 +31,14 @@ public class MainMenuActivity extends MenuListActivity {
@Override @Override
protected String[] getElements() { protected String[] getElements() {
boolean showPrimeFill = sp.getBoolean("primefill", false); if(!BuildConfig.WEAR_CONTROL){
return new String[] {
"Settings",
"Re-Sync"};
}
boolean showPrimeFill = sp.getBoolean("primefill", false);
return new String[] { return new String[] {
"TempT", "TempT",
"Bolus", "Bolus",
@ -46,6 +53,22 @@ public class MainMenuActivity extends MenuListActivity {
protected void doAction(int position) { protected void doAction(int position) {
Intent intent; Intent intent;
if(!BuildConfig.WEAR_CONTROL) {
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;
}
return;
}
switch (position) { switch (position) {
case 0: case 0:
intent = new Intent(this, TempTargetActivity.class); intent = new Intent(this, TempTargetActivity.class);

View file

@ -0,0 +1,53 @@
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;
}
}
}

View file

@ -12,7 +12,6 @@ public class StatusMenuActivity extends MenuListActivity {
@Override @Override
protected String[] getElements() { protected String[] getElements() {
return new String[] { return new String[] {
"General",
"Pump", "Pump",
"Loop", "Loop",
"Targets"}; "Targets"};
@ -21,16 +20,14 @@ public class StatusMenuActivity extends MenuListActivity {
@Override @Override
protected void doAction(int position) { protected void doAction(int position) {
switch (position) { switch (position) {
case 0: case 0:
ListenerService.initiateAction(this, "status general");
break;
case 1:
ListenerService.initiateAction(this, "status pump"); ListenerService.initiateAction(this, "status pump");
break; break;
case 2: case 1:
ListenerService.initiateAction(this, "status loop"); ListenerService.initiateAction(this, "status loop");
break; break;
case 3: case 2:
ListenerService.initiateAction(this, "status targets"); ListenerService.initiateAction(this, "status targets");
break; break;
} }