wear menu restructuring and status

This commit is contained in:
AdrianLxM 2017-02-09 17:40:26 +01:00
parent 4dcbbd3df2
commit dc476a6600
11 changed files with 185 additions and 87 deletions

View file

@ -57,6 +57,7 @@ public class ActionStringHandler {
String[] act = actionstring.split("\\s+");
if ("fillpreset".equals(act[0])) {
///////////////////////////////////// PRIME/FILL
double amount = 0d;
if ("1".equals(act[1])) {
amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button1", "0.3"))));
@ -74,6 +75,27 @@ public class ActionStringHandler {
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])) {
Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]);
Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbsBeforeConstraints);

View file

@ -99,27 +99,28 @@
android:label="@string/label_xdrip_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".actions.ActionsListActivity"
android:name=".actions.MainMenuActivity"
android:label="@string/label_actions_activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".actions.wizard.WizardActivity"
android:label="Wizard">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".actions.FillMenuActivity"
android:label="Fillmenu">
</activity>
<activity
android:name=".actions.StatusMenuActivity"
android:label="Status">
</activity>
</application>
</manifest>

View file

@ -39,7 +39,7 @@ import com.ustwo.clockwise.common.WatchShape;
import java.util.ArrayList;
import java.util.Date;
import info.nightscout.androidaps.actions.ActionsListActivity;
import info.nightscout.androidaps.actions.MainMenuActivity;
import lecho.lib.hellocharts.view.LineChartView;
/**
@ -162,7 +162,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
y >= mSgv.getTop() &&
y <= mSgv.getBottom()){
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);
startActivity(intent);
}

View file

@ -36,7 +36,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.TreeSet;
import info.nightscout.androidaps.actions.ActionsListActivity;
import info.nightscout.androidaps.actions.MainMenuActivity;
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.getBottom()){
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);
startActivity(intent);
}

View file

@ -8,7 +8,7 @@ import android.view.LayoutInflater;
import com.ustwo.clockwise.common.WatchMode;
import info.nightscout.androidaps.actions.ActionsListActivity;
import info.nightscout.androidaps.actions.MainMenuActivity;
public class Home extends BaseWatchFace {
@ -43,7 +43,7 @@ public class Home extends BaseWatchFace {
y >= mSgv.getTop() &&
y <= mSgv.getBottom()){
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);
startActivity(intent);
}

View file

@ -8,7 +8,7 @@ import android.view.LayoutInflater;
import com.ustwo.clockwise.common.WatchMode;
import info.nightscout.androidaps.actions.ActionsListActivity;
import info.nightscout.androidaps.actions.MainMenuActivity;
public class LargeHome extends BaseWatchFace {
@ -33,7 +33,7 @@ public class LargeHome extends BaseWatchFace {
y >= mSgv.getTop() &&
y <= mSgv.getBottom()){
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);
startActivity(intent);
}

View file

@ -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;
}
}

View file

@ -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;
}
}
}

View file

@ -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;
}
}
}

View file

@ -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;
}
}
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.actions;
package info.nightscout.androidaps.actions.utils;
import android.app.Activity;
import android.content.Context;
@ -15,10 +15,14 @@ import info.nightscout.androidaps.R;
* Created by adrian on 08/02/17.
*/
public class ActionsListActivity extends Activity
public abstract class MenuListActivity extends Activity
implements WearableListView.ClickListener {
String[] elements = ActionsDefinitions.getActionNames();
String[] elements = getElements();
protected abstract String[] getElements();
protected abstract void doAction(int position);
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -40,7 +44,7 @@ public class ActionsListActivity extends Activity
@Override
public void onClick(WearableListView.ViewHolder v) {
Integer tag = (Integer) v.itemView.getTag();
ActionsDefinitions.doAction(tag, this);
doAction(tag);
//ActionsDefinitions.doAction(v.getAdapterPosition(), this);
finish();
}