wear menu restructuring and status
This commit is contained in:
parent
4dcbbd3df2
commit
dc476a6600
11 changed files with 185 additions and 87 deletions
|
@ -57,6 +57,7 @@ public class ActionStringHandler {
|
||||||
String[] act = actionstring.split("\\s+");
|
String[] act = actionstring.split("\\s+");
|
||||||
|
|
||||||
if ("fillpreset".equals(act[0])) {
|
if ("fillpreset".equals(act[0])) {
|
||||||
|
///////////////////////////////////// PRIME/FILL
|
||||||
double amount = 0d;
|
double amount = 0d;
|
||||||
if ("1".equals(act[1])) {
|
if ("1".equals(act[1])) {
|
||||||
amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button1", "0.3"))));
|
amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button1", "0.3"))));
|
||||||
|
@ -74,6 +75,27 @@ public class ActionStringHandler {
|
||||||
|
|
||||||
rAction += "fill " + insulinAfterConstraints;
|
rAction += "fill " + insulinAfterConstraints;
|
||||||
|
|
||||||
|
} else if ("status".equals(act[0])) {
|
||||||
|
///////////////////////////////////// STATUS
|
||||||
|
rTitle = "STATUS";
|
||||||
|
rAction = "statusmessage";
|
||||||
|
//TODO: add meaningfull status
|
||||||
|
|
||||||
|
if("general".equals(act[1])){
|
||||||
|
rMessage = "Today is going to be a good day!";
|
||||||
|
} else if("pump".equals(act[1])){
|
||||||
|
rTitle += " PUMP";
|
||||||
|
rMessage = "I'm feeling pumped!";
|
||||||
|
} else if("loop".equals(act[1])){
|
||||||
|
rTitle += " LOOP";
|
||||||
|
rMessage = "A loop di loop di loop!";
|
||||||
|
|
||||||
|
} else if("targets".equals(act[1])){
|
||||||
|
rTitle += " TARGETS";
|
||||||
|
rMessage = "Always on target!";
|
||||||
|
}
|
||||||
|
rMessage += "\n\n\nTODO:\nAdd some meaningful status.";
|
||||||
|
|
||||||
} else if ("wizard".equals(act[0])) {
|
} else if ("wizard".equals(act[0])) {
|
||||||
Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]);
|
Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]);
|
||||||
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbsBeforeConstraints);
|
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbsBeforeConstraints);
|
||||||
|
|
|
@ -99,27 +99,28 @@
|
||||||
android:label="@string/label_xdrip_activity">
|
android:label="@string/label_xdrip_activity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".actions.ActionsListActivity"
|
android:name=".actions.MainMenuActivity"
|
||||||
android:label="@string/label_actions_activity">
|
android:label="@string/label_actions_activity">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".actions.wizard.WizardActivity"
|
android:name=".actions.wizard.WizardActivity"
|
||||||
android:label="Wizard">
|
android:label="Wizard">
|
||||||
<intent-filter>
|
</activity>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<activity
|
||||||
|
android:name=".actions.FillMenuActivity"
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
android:label="Fillmenu">
|
||||||
</intent-filter>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".actions.StatusMenuActivity"
|
||||||
|
android:label="Status">
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
|
@ -39,7 +39,7 @@ import com.ustwo.clockwise.common.WatchShape;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.actions.ActionsListActivity;
|
import info.nightscout.androidaps.actions.MainMenuActivity;
|
||||||
import lecho.lib.hellocharts.view.LineChartView;
|
import lecho.lib.hellocharts.view.LineChartView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,7 +162,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
||||||
y >= mSgv.getTop() &&
|
y >= mSgv.getTop() &&
|
||||||
y <= mSgv.getBottom()){
|
y <= mSgv.getBottom()){
|
||||||
if (eventTime - sgvTapTime < 800){
|
if (eventTime - sgvTapTime < 800){
|
||||||
Intent intent = new Intent(this, ActionsListActivity.class);
|
Intent intent = new Intent(this, MainMenuActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import info.nightscout.androidaps.actions.ActionsListActivity;
|
import info.nightscout.androidaps.actions.MainMenuActivity;
|
||||||
|
|
||||||
|
|
||||||
public class CircleWatchface extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public class CircleWatchface extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
@ -717,7 +717,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
y >= mSgv.getTop() &&
|
y >= mSgv.getTop() &&
|
||||||
y <= mSgv.getBottom()){
|
y <= mSgv.getBottom()){
|
||||||
if (eventTime - sgvTapTime < 800){
|
if (eventTime - sgvTapTime < 800){
|
||||||
Intent intent = new Intent(this, ActionsListActivity.class);
|
Intent intent = new Intent(this, MainMenuActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import android.view.LayoutInflater;
|
||||||
|
|
||||||
import com.ustwo.clockwise.common.WatchMode;
|
import com.ustwo.clockwise.common.WatchMode;
|
||||||
|
|
||||||
import info.nightscout.androidaps.actions.ActionsListActivity;
|
import info.nightscout.androidaps.actions.MainMenuActivity;
|
||||||
|
|
||||||
public class Home extends BaseWatchFace {
|
public class Home extends BaseWatchFace {
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class Home extends BaseWatchFace {
|
||||||
y >= mSgv.getTop() &&
|
y >= mSgv.getTop() &&
|
||||||
y <= mSgv.getBottom()){
|
y <= mSgv.getBottom()){
|
||||||
if (eventTime - sgvTapTime < 800){
|
if (eventTime - sgvTapTime < 800){
|
||||||
Intent intent = new Intent(this, ActionsListActivity.class);
|
Intent intent = new Intent(this, MainMenuActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import android.view.LayoutInflater;
|
||||||
|
|
||||||
import com.ustwo.clockwise.common.WatchMode;
|
import com.ustwo.clockwise.common.WatchMode;
|
||||||
|
|
||||||
import info.nightscout.androidaps.actions.ActionsListActivity;
|
import info.nightscout.androidaps.actions.MainMenuActivity;
|
||||||
|
|
||||||
public class LargeHome extends BaseWatchFace {
|
public class LargeHome extends BaseWatchFace {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class LargeHome extends BaseWatchFace {
|
||||||
y >= mSgv.getTop() &&
|
y >= mSgv.getTop() &&
|
||||||
y <= mSgv.getBottom()){
|
y <= mSgv.getBottom()){
|
||||||
if (eventTime - sgvTapTime < 800){
|
if (eventTime - sgvTapTime < 800){
|
||||||
Intent intent = new Intent(this, ActionsListActivity.class);
|
Intent intent = new Intent(this, MainMenuActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
package info.nightscout.androidaps.actions;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.ListenerService;
|
|
||||||
import info.nightscout.androidaps.NWPreferences;
|
|
||||||
import info.nightscout.androidaps.actions.wizard.WizardActivity;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by adrian on 08/02/17.
|
|
||||||
*/
|
|
||||||
|
|
||||||
final class ActionsDefinitions {
|
|
||||||
|
|
||||||
private static final String[] ACTION_NAMES = {
|
|
||||||
"Temp Target",
|
|
||||||
"Wizard",
|
|
||||||
"Settings",
|
|
||||||
"Resend Data",
|
|
||||||
"Fillpreset 1",
|
|
||||||
"Fillpreset 2",
|
|
||||||
"Fillpreset 3",
|
|
||||||
"009"};
|
|
||||||
|
|
||||||
|
|
||||||
public static void doAction(int position, Context ctx) {
|
|
||||||
|
|
||||||
Intent intent;
|
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
intent = new Intent(ctx, WizardActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
ctx.startActivity(intent);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
intent = new Intent(ctx, NWPreferences.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
ctx.startActivity(intent);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
ListenerService.requestData(ctx);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
ListenerService.initiateAction(ctx, "fillpreset 1");
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
ListenerService.initiateAction(ctx, "fillpreset 2");
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
ListenerService.initiateAction(ctx, "fillpreset 3");
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String[] getActionNames() {
|
|
||||||
//posibility for later i18n
|
|
||||||
return ACTION_NAMES;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package info.nightscout.androidaps.actions;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.ListenerService;
|
||||||
|
import info.nightscout.androidaps.NWPreferences;
|
||||||
|
import info.nightscout.androidaps.actions.utils.MenuListActivity;
|
||||||
|
import info.nightscout.androidaps.actions.wizard.WizardActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 09/02/17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class FillMenuActivity extends MenuListActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getElements() {
|
||||||
|
return new String[] {
|
||||||
|
"Preset 1",
|
||||||
|
"Preset 2",
|
||||||
|
"Preset 3"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doAction(int position) {
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
ListenerService.initiateAction(this, "fillpreset 1");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ListenerService.initiateAction(this, "fillpreset 2");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ListenerService.initiateAction(this, "fillpreset 3");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package info.nightscout.androidaps.actions;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.ListenerService;
|
||||||
|
import info.nightscout.androidaps.NWPreferences;
|
||||||
|
import info.nightscout.androidaps.actions.utils.MenuListActivity;
|
||||||
|
import info.nightscout.androidaps.actions.wizard.WizardActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 09/02/17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MainMenuActivity extends MenuListActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getElements() {
|
||||||
|
return new String[] {
|
||||||
|
"TTarget",
|
||||||
|
"Wizard",
|
||||||
|
"Settings",
|
||||||
|
"Re-Sync",
|
||||||
|
"Status",
|
||||||
|
"Prime/Fill"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doAction(int position) {
|
||||||
|
|
||||||
|
Intent intent;
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
intent = new Intent(this, WizardActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
this.startActivity(intent);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
intent = new Intent(this, NWPreferences.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
this.startActivity(intent);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
ListenerService.requestData(this);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
intent = new Intent(this, StatusMenuActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
this.startActivity(intent);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
intent = new Intent(this, FillMenuActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
this.startActivity(intent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package info.nightscout.androidaps.actions;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.ListenerService;
|
||||||
|
import info.nightscout.androidaps.actions.utils.MenuListActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 09/02/17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class StatusMenuActivity extends MenuListActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getElements() {
|
||||||
|
return new String[] {
|
||||||
|
"General",
|
||||||
|
"Pump",
|
||||||
|
"Loop",
|
||||||
|
"Targets"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doAction(int position) {
|
||||||
|
switch (position) {
|
||||||
|
case 0:
|
||||||
|
ListenerService.initiateAction(this, "status general");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
ListenerService.initiateAction(this, "status pump");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ListenerService.initiateAction(this, "status loop");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
ListenerService.initiateAction(this, "status targets");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.actions;
|
package info.nightscout.androidaps.actions.utils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -15,10 +15,14 @@ import info.nightscout.androidaps.R;
|
||||||
* Created by adrian on 08/02/17.
|
* Created by adrian on 08/02/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ActionsListActivity extends Activity
|
public abstract class MenuListActivity extends Activity
|
||||||
implements WearableListView.ClickListener {
|
implements WearableListView.ClickListener {
|
||||||
|
|
||||||
String[] elements = ActionsDefinitions.getActionNames();
|
String[] elements = getElements();
|
||||||
|
|
||||||
|
protected abstract String[] getElements();
|
||||||
|
|
||||||
|
protected abstract void doAction(int position);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -40,7 +44,7 @@ public class ActionsListActivity extends Activity
|
||||||
@Override
|
@Override
|
||||||
public void onClick(WearableListView.ViewHolder v) {
|
public void onClick(WearableListView.ViewHolder v) {
|
||||||
Integer tag = (Integer) v.itemView.getTag();
|
Integer tag = (Integer) v.itemView.getTag();
|
||||||
ActionsDefinitions.doAction(tag, this);
|
doAction(tag);
|
||||||
//ActionsDefinitions.doAction(v.getAdapterPosition(), this);
|
//ActionsDefinitions.doAction(v.getAdapterPosition(), this);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
Loading…
Reference in a new issue