wear menu simplification
This commit is contained in:
parent
26ebceb4d9
commit
387cfcccaf
8 changed files with 75 additions and 168 deletions
|
@ -157,14 +157,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])) {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class FillMenuActivity extends MenuListActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getElements() {
|
protected String[] getElements() {
|
||||||
return new String[] {
|
return new String[]{
|
||||||
"Preset 1",
|
"Preset 1",
|
||||||
"Preset 2",
|
"Preset 2",
|
||||||
"Preset 3",
|
"Preset 3",
|
||||||
|
@ -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,18 @@ public class StatusMenuActivity extends MenuListActivity {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"Pump",
|
"Pump",
|
||||||
"Loop",
|
"Loop",
|
||||||
"Targets",
|
"CPP"};
|
||||||
"CPP",
|
|
||||||
"OAPS Result"};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
|
||||||
case 4:
|
|
||||||
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…
Add table
Reference in a new issue