wear allow multiple input layouts
This commit is contained in:
parent
05d40e4af0
commit
56e5fae27d
10 changed files with 295 additions and 26 deletions
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
|
|||
*/
|
||||
|
||||
|
||||
public class BolusActivity extends Activity {
|
||||
public class BolusActivity extends ViewSelectorActivity {
|
||||
|
||||
PlusMinusEditText editCarbs;
|
||||
PlusMinusEditText editInsulin;
|
||||
|
@ -65,25 +65,23 @@ public class BolusActivity extends Activity {
|
|||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("insulin");
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
double def = 0;
|
||||
if (editInsulin != null){
|
||||
def = SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
||||
}
|
||||
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false);
|
||||
setLabelToPlusMinusView(view, "insulin");
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 1){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("carbs");
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
double def = 0;
|
||||
if (editCarbs != null){
|
||||
def = SafeParse.stringToDouble(editCarbs.editText.getText().toString());
|
||||
}
|
||||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false);
|
||||
setLabelToPlusMinusView(view, "carbs");
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else {
|
||||
|
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
|
|||
*/
|
||||
|
||||
|
||||
public class FillActivity extends Activity {
|
||||
public class FillActivity extends ViewSelectorActivity {
|
||||
|
||||
PlusMinusEditText editInsulin;
|
||||
|
||||
|
@ -64,14 +64,13 @@ public class FillActivity extends Activity {
|
|||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("insulin");
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
double def = 0d;
|
||||
if (editInsulin != null){
|
||||
def = SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
||||
}
|
||||
editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false);
|
||||
setLabelToPlusMinusView(view, "insulin");
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else {
|
||||
|
|
|
@ -29,7 +29,7 @@ import static android.preference.PreferenceManager.getDefaultSharedPreferences;
|
|||
*/
|
||||
|
||||
|
||||
public class TempTargetActivity extends Activity {
|
||||
public class TempTargetActivity extends ViewSelectorActivity {
|
||||
|
||||
PlusMinusEditText lowRange;
|
||||
PlusMinusEditText highRange;
|
||||
|
@ -74,7 +74,7 @@ public class TempTargetActivity extends Activity {
|
|||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("duration");
|
||||
if (time == null) {
|
||||
|
@ -83,13 +83,12 @@ public class TempTargetActivity extends Activity {
|
|||
double def = SafeParse.stringToDouble(time.editText.getText().toString());
|
||||
time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 24 * 60d, 1d, new DecimalFormat("0"), false);
|
||||
}
|
||||
container.addView(view);
|
||||
setLabelToPlusMinusView(view, "duration");
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
||||
} else if(col == 1){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("low");
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
if (isMGDL){
|
||||
double def = 100;
|
||||
if (lowRange != null){
|
||||
|
@ -103,13 +102,11 @@ public class TempTargetActivity extends Activity {
|
|||
}
|
||||
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");
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 2){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("high");
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
if (isMGDL){
|
||||
double def = 100;
|
||||
if (highRange != null){
|
||||
|
@ -123,7 +120,7 @@ public class TempTargetActivity extends Activity {
|
|||
}
|
||||
highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false);
|
||||
}
|
||||
|
||||
setLabelToPlusMinusView(view, "high");
|
||||
container.addView(view);
|
||||
return view;
|
||||
}else {
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package info.nightscout.androidaps.interaction.actions;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
|
||||
/**
|
||||
* Created by adrian on 13/02/17.
|
||||
*/
|
||||
public class ViewSelectorActivity extends Activity {
|
||||
|
||||
|
||||
View getInflatedPlusMinusView(ViewGroup container) {
|
||||
SharedPreferences sharedPrefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(this);
|
||||
int design = Integer.parseInt(sharedPrefs.getString("input_design", "1"));
|
||||
|
||||
if (design == 2){
|
||||
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_quickrighty, container, false);
|
||||
} else if (design == 3) {
|
||||
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_quicklefty, container, false);
|
||||
} else if (design == 4) {
|
||||
//TODO: LadyViktoria: Add your design
|
||||
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
}
|
||||
|
||||
//default
|
||||
return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
}
|
||||
|
||||
void setLabelToPlusMinusView(View view, String labelText){
|
||||
SharedPreferences sharedPrefs = PreferenceManager
|
||||
.getDefaultSharedPreferences(this);
|
||||
int design = Integer.parseInt(sharedPrefs.getString("input_design", "1"));
|
||||
|
||||
if (design == 4){
|
||||
//TODO: LadyViktoria: Add your design label
|
||||
|
||||
} else {
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText(labelText);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.interaction.utils.SafeParse;
|
|||
*/
|
||||
|
||||
|
||||
public class WizardActivity extends Activity {
|
||||
public class WizardActivity extends ViewSelectorActivity {
|
||||
|
||||
PlusMinusEditText editCarbs;
|
||||
|
||||
|
@ -68,9 +68,7 @@ public class WizardActivity extends Activity {
|
|||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false);
|
||||
final TextView textView = (TextView) view.findViewById(R.id.label);
|
||||
textView.setText("carbs");
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
if (editCarbs == null) {
|
||||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 150d, 1d, new DecimalFormat("0"), false);
|
||||
} else {
|
||||
|
@ -78,6 +76,7 @@ public class WizardActivity extends Activity {
|
|||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false);
|
||||
|
||||
}
|
||||
setLabelToPlusMinusView(view, "carbs");
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 1){
|
||||
|
|
68
wear/src/main/res/layout/action_editplusminus_item_below.xml
Normal file
68
wear/src/main/res/layout/action_editplusminus_item_below.xml
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/amountfield"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:inputType="numberDecimal"
|
||||
android:minWidth="50dp"
|
||||
android:text="112"
|
||||
android:textSize="45sp"
|
||||
android:cursorVisible="false"
|
||||
android:gravity="center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="label"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/minusbutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_minus"
|
||||
android:tint="#ffffff" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/plusbutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_add"
|
||||
android:tint="#ffffff" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/plusbutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_add"
|
||||
android:tint="#ffffff" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
<EditText
|
||||
android:id="@+id/amountfield"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:inputType="numberDecimal"
|
||||
android:minWidth="100dp"
|
||||
android:paddingTop="10dp"
|
||||
android:text="112"
|
||||
android:textSize="45sp"
|
||||
android:cursorVisible="false"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="label"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/minusbutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_minus"
|
||||
android:tint="#ffffff" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
<EditText
|
||||
android:id="@+id/amountfield"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:inputType="numberDecimal"
|
||||
android:minWidth="100dp"
|
||||
android:paddingTop="10dp"
|
||||
android:text="112"
|
||||
android:textSize="45sp"
|
||||
android:cursorVisible="false"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="label"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center"
|
||||
android:textSize="25sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/minusbutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_minus"
|
||||
android:tint="#ffffff" />
|
||||
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/plusbutton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_add"
|
||||
android:tint="#ffffff" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -19,6 +19,26 @@
|
|||
<item>4</item>
|
||||
<item>5</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
|
||||
<string-array name="input_design">
|
||||
<item>Default</item>
|
||||
<item>Quick righty</item>
|
||||
<item>Quick lefty</item>
|
||||
<item>Modern Sparse</item>
|
||||
|
||||
</string-array>
|
||||
<string-array name="input_design_values">
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
|
||||
|
||||
<string name="title_activity_bolus">BolusActivity</string>
|
||||
<string name="hello_round">Hello Round World!</string>
|
||||
<string name="hello_square">Hello Square World!</string>
|
||||
|
|
|
@ -18,6 +18,14 @@
|
|||
app:wear_iconOff="@drawable/settings_off"
|
||||
app:wear_iconOn="@drawable/settings_on" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="1"
|
||||
android:entries="@array/input_design"
|
||||
android:entryValues="@array/input_design_values"
|
||||
android:key="input_design"
|
||||
android:summary="Input Design"
|
||||
android:title="Input Design" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="showExternalStatus"
|
||||
|
|
Loading…
Reference in a new issue