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();
|
||||
} else if ("loop".equals(act[1])) {
|
||||
rTitle += " LOOP";
|
||||
rMessage = getLoopStatus();
|
||||
|
||||
} else if ("targets".equals(act[1])) {
|
||||
rTitle += " TARGETS";
|
||||
rMessage = getTargetsStatus();
|
||||
} else if ("oapsresult".equals(act[1])) {
|
||||
rTitle += " OAPS RESULT";
|
||||
rMessage = getOAPSResultStatus();
|
||||
rMessage = "TARGETS:\n" + getTargetsStatus();
|
||||
rMessage += "\n\n" + getLoopStatus();
|
||||
rMessage += "\n\nOAPS RESULT:\n" + getOAPSResultStatus();;
|
||||
}
|
||||
|
||||
} else if ("wizard".equals(act[0])) {
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
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
|
||||
protected String[] getElements() {
|
||||
return new String[] {
|
||||
return new String[]{
|
||||
"Preset 1",
|
||||
"Preset 2",
|
||||
"Preset 3",
|
||||
|
@ -23,23 +23,17 @@ public class FillMenuActivity extends MenuListActivity {
|
|||
}
|
||||
|
||||
@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;
|
||||
case 3:
|
||||
Intent intent = new Intent(this, FillActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
protected void doAction(String action) {
|
||||
if ("Preset 1".equals(action)) {
|
||||
ListenerService.initiateAction(this, "fillpreset 1");
|
||||
} else if ("Preset 2".equals(action)) {
|
||||
ListenerService.initiateAction(this, "fillpreset 2");
|
||||
} else if ("Preset 3".equals(action)) {
|
||||
ListenerService.initiateAction(this, "fillpreset 3");
|
||||
} else if ("Free amount".equals(action)) {
|
||||
Intent intent = new Intent(this, FillActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.content.SharedPreferences;
|
|||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
||||
|
@ -39,74 +41,50 @@ public class MainMenuActivity extends MenuListActivity {
|
|||
|
||||
|
||||
boolean showPrimeFill = sp.getBoolean("primefill", false);
|
||||
return new String[] {
|
||||
"TempT",
|
||||
"Bolus",
|
||||
"Wizard",
|
||||
"Settings",
|
||||
"Re-Sync",
|
||||
"Status",
|
||||
showPrimeFill?"Prime/Fill":""};
|
||||
boolean showWizard = sp.getBoolean("showWizard", true);
|
||||
|
||||
Vector<String> menuitems = new Vector<String>();
|
||||
menuitems.add("TempT");
|
||||
menuitems.add("Bolus");
|
||||
if(showWizard) menuitems.add("Wizard");
|
||||
menuitems.add("Settings");
|
||||
menuitems.add("Status");
|
||||
if (showPrimeFill) menuitems.add("Prime/Fill");
|
||||
|
||||
return menuitems.toArray(new String[menuitems.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAction(int position) {
|
||||
protected void doAction(String action) {
|
||||
|
||||
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;
|
||||
if ("Settings".equals(action)) {
|
||||
intent = new Intent(this, AAPSPreferences.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if ("Re-Sync".equals(action)) {
|
||||
ListenerService.requestData(this);
|
||||
} else if ("TempT".equals(action)) {
|
||||
intent = new Intent(this, TempTargetActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if ("Bolus".equals(action)) {
|
||||
intent = new Intent(this, BolusActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if ("Wizard".equals(action)) {
|
||||
intent = new Intent(this, WizardActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if ("Status".equals(action)) {
|
||||
intent = new Intent(this, StatusMenuActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if ("Prime/Fill".equals(action)) {
|
||||
intent = new Intent(this, FillMenuActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
switch (position) {
|
||||
case 0:
|
||||
intent = new Intent(this, TempTargetActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
case 1:
|
||||
intent = new Intent(this, BolusActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
case 2:
|
||||
intent = new Intent(this, WizardActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
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.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
case 6:
|
||||
boolean showPrimeFill = sp.getBoolean("primefill", false);
|
||||
if(showPrimeFill) {
|
||||
intent = new Intent(this, FillMenuActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
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[] {
|
||||
"Pump",
|
||||
"Loop",
|
||||
"Targets",
|
||||
"CPP",
|
||||
"OAPS Result"};
|
||||
"CPP"};
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAction(int position) {
|
||||
switch (position) {
|
||||
|
||||
case 0:
|
||||
ListenerService.initiateAction(this, "status pump");
|
||||
break;
|
||||
case 1:
|
||||
ListenerService.initiateAction(this, "status loop");
|
||||
break;
|
||||
case 2:
|
||||
ListenerService.initiateAction(this, "status targets");
|
||||
break;
|
||||
case 3:
|
||||
ListenerService.initiateAction(this, "opencpp");
|
||||
break;
|
||||
case 4:
|
||||
ListenerService.initiateAction(this, "status oapsresult");
|
||||
break;
|
||||
protected void doAction(String action) {
|
||||
if ("Pump".equals(action)) {
|
||||
ListenerService.initiateAction(this, "status pump");
|
||||
} else if ("Loop".equals(action)) {
|
||||
ListenerService.initiateAction(this, "status loop");
|
||||
} else if ("CPP".equals(action)) {
|
||||
ListenerService.initiateAction(this, "opencpp");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public abstract class MenuListActivity extends Activity
|
|||
|
||||
protected abstract String[] getElements();
|
||||
|
||||
protected abstract void doAction(int position);
|
||||
protected abstract void doAction(String position);
|
||||
|
||||
@Override
|
||||
protected void onPause(){
|
||||
|
@ -50,7 +50,7 @@ public abstract class MenuListActivity extends Activity
|
|||
// WearableListView click listener
|
||||
@Override
|
||||
public void onClick(WearableListView.ViewHolder v) {
|
||||
Integer tag = (Integer) v.itemView.getTag();
|
||||
String tag = (String) v.itemView.getTag();
|
||||
doAction(tag);
|
||||
//ActionsDefinitions.doAction(v.getAdapterPosition(), this);
|
||||
finish();
|
||||
|
@ -105,7 +105,7 @@ public abstract class MenuListActivity extends Activity
|
|||
// replace text contents
|
||||
view.setText(mDataset[position]);
|
||||
// replace list item's metadata
|
||||
holder.itemView.setTag(position);
|
||||
holder.itemView.setTag(mDataset[position]);
|
||||
}
|
||||
|
||||
// Return the size of your dataset
|
||||
|
|
|
@ -121,6 +121,13 @@
|
|||
app:wear_iconOff="@drawable/settings_off"
|
||||
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
|
||||
android:defaultValue="false"
|
||||
android:key="primefill"
|
||||
|
@ -129,7 +136,7 @@
|
|||
app:wear_iconOff="@drawable/settings_off"
|
||||
app:wear_iconOn="@drawable/settings_on"/>
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:defaultValue="true"
|
||||
android:key="singletarget"
|
||||
android:summary="Single temp-target instead of a range."
|
||||
android:title="Single Target"
|
||||
|
|
Loading…
Reference in a new issue