wear setting for single temp target instead of range

This commit is contained in:
AdrianLxM 2017-04-30 20:20:04 +02:00
parent e201dea662
commit 37e00d33aa
2 changed files with 17 additions and 4 deletions

View file

@ -35,6 +35,7 @@ public class TempTargetActivity extends ViewSelectorActivity {
PlusMinusEditText highRange; PlusMinusEditText highRange;
PlusMinusEditText time; PlusMinusEditText time;
boolean isMGDL; boolean isMGDL;
boolean isSingleTarget;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -49,6 +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);
} }
@ -62,7 +64,7 @@ public class TempTargetActivity extends ViewSelectorActivity {
private class MyGridViewPagerAdapter extends GridPagerAdapter { private class MyGridViewPagerAdapter extends GridPagerAdapter {
@Override @Override
public int getColumnCount(int arg0) { public int getColumnCount(int arg0) {
return 4; return isSingleTarget?3:4;
} }
@Override @Override
@ -102,10 +104,14 @@ public class TempTargetActivity extends ViewSelectorActivity {
} }
lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false);
} }
setLabelToPlusMinusView(view, "low"); if(isSingleTarget){
setLabelToPlusMinusView(view, "target");
} else {
setLabelToPlusMinusView(view, "low");
}
container.addView(view); container.addView(view);
return view; return view;
} else if(col == 2){ } else if(col == 2 && ! isSingleTarget){
final View view = getInflatedPlusMinusView(container); final View view = getInflatedPlusMinusView(container);
if (isMGDL){ if (isMGDL){
double def = 100; double def = 100;
@ -138,7 +144,7 @@ public class TempTargetActivity extends ViewSelectorActivity {
+ " " + isMGDL + " " + isMGDL
+ " " + SafeParse.stringToInt(time.editText.getText().toString()) + " " + SafeParse.stringToInt(time.editText.getText().toString())
+ " " + SafeParse.stringToDouble(lowRange.editText.getText().toString()) + " " + SafeParse.stringToDouble(lowRange.editText.getText().toString())
+ " " + SafeParse.stringToDouble(highRange.editText.getText().toString()) + " " + (isSingleTarget?SafeParse.stringToDouble(lowRange.editText.getText().toString()):SafeParse.stringToDouble(highRange.editText.getText().toString()))
; ;
ListenerService.initiateAction(TempTargetActivity.this, actionstring); ListenerService.initiateAction(TempTargetActivity.this, actionstring);

View file

@ -128,4 +128,11 @@
android:title="Prime in Menu" android:title="Prime in Menu"
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="false"
android:key="singletarget"
android:summary="Single temp-target instead of a range."
android:title="Single Target"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
</PreferenceScreen> </PreferenceScreen>