Wear: Add bolus activity for tile
This commit is contained in:
parent
b823a2f5a7
commit
38d4133df2
12 changed files with 148 additions and 32 deletions
|
@ -1,8 +1,9 @@
|
|||
<vector
|
||||
android:height="48dp"
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="48dp"
|
||||
android:viewportHeight="24"
|
||||
android:height="48dp"
|
||||
android:viewportWidth="24"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#67DFE8" android:pathData="M18.501,12.002l-0.428,0.564L8.179,5.064c-0.092,-0.07 -0.212,-0.09 -0.323,-0.055L5.115,5.89L1.571,3.501L4.755,6.36L4.647,9.243c-0.004,0.116 0.047,0.226 0.14,0.296l9.895,7.502l-0.428,0.564c-0.26,0.343 -0.193,0.832 0.15,1.092s0.832,0.193 1.092,-0.15l1.653,-2.18l2.219,1.683l-0.719,0.948c-0.26,0.343 -0.193,0.832 0.15,1.092c0.343,0.26 0.832,0.193 1.092,-0.15l2.379,-3.138c0.26,-0.343 0.193,-0.832 -0.15,-1.092c-0.343,-0.26 -0.832,-0.193 -1.092,0.15l-0.719,0.948l-2.219,-1.683l1.653,-2.18c0.26,-0.343 0.193,-0.832 -0.15,-1.092S18.762,11.659 18.501,12.002zM5.458,6.524l2.44,-0.783l9.748,7.39L17.26,13.64l-5.754,-4.362c-0.091,-0.069 -0.221,-0.053 -0.293,0.035L9.087,11.91l-0.67,-0.508l1.526,-1.833c0.002,-0.002 0.004,-0.005 0.006,-0.008c0.068,-0.09 0.054,-0.219 -0.033,-0.291c-0.09,-0.075 -0.224,-0.063 -0.299,0.027l-1.538,1.848l-0.769,-0.583l1.526,-1.833c0.002,-0.002 0.004,-0.005 0.006,-0.008c0.068,-0.09 0.054,-0.219 -0.033,-0.291c-0.09,-0.075 -0.224,-0.063 -0.299,0.027L6.97,10.305L6.201,9.721l1.526,-1.833C7.728,7.886 7.731,7.882 7.732,7.88c0.068,-0.09 0.054,-0.219 -0.033,-0.291C7.609,7.513 7.475,7.526 7.4,7.616L5.861,9.464L5.362,9.085L5.458,6.524z"/>
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#67DFE8"
|
||||
android:pathData="M18.501,12.002l-0.428,0.564L8.179,5.064c-0.092,-0.07 -0.212,-0.09 -0.323,-0.055L5.115,5.89L1.571,3.501L4.755,6.36L4.647,9.243c-0.004,0.116 0.047,0.226 0.14,0.296l9.895,7.502l-0.428,0.564c-0.26,0.343 -0.193,0.832 0.15,1.092s0.832,0.193 1.092,-0.15l1.653,-2.18l2.219,1.683l-0.719,0.948c-0.26,0.343 -0.193,0.832 0.15,1.092c0.343,0.26 0.832,0.193 1.092,-0.15l2.379,-3.138c0.26,-0.343 0.193,-0.832 -0.15,-1.092c-0.343,-0.26 -0.832,-0.193 -1.092,0.15l-0.719,0.948l-2.219,-1.683l1.653,-2.18c0.26,-0.343 0.193,-0.832 -0.15,-1.092S18.762,11.659 18.501,12.002zM5.458,6.524l2.44,-0.783l9.748,7.39L17.26,13.64l-5.754,-4.362c-0.091,-0.069 -0.221,-0.053 -0.293,0.035L9.087,11.91l-0.67,-0.508l1.526,-1.833c0.002,-0.002 0.004,-0.005 0.006,-0.008c0.068,-0.09 0.054,-0.219 -0.033,-0.291c-0.09,-0.075 -0.224,-0.063 -0.299,0.027l-1.538,1.848l-0.769,-0.583l1.526,-1.833c0.002,-0.002 0.004,-0.005 0.006,-0.008c0.068,-0.09 0.054,-0.219 -0.033,-0.291c-0.09,-0.075 -0.224,-0.063 -0.299,0.027L6.97,10.305L6.201,9.721l1.526,-1.833C7.728,7.886 7.731,7.882 7.732,7.88c0.068,-0.09 0.054,-0.219 -0.033,-0.291C7.609,7.513 7.475,7.526 7.4,7.616L5.861,9.464L5.362,9.085L5.458,6.524z" />
|
||||
</vector>
|
||||
|
|
|
@ -571,6 +571,10 @@
|
|||
android:name=".interaction.actions.TreatmentActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/menu_treatment" />
|
||||
<activity
|
||||
android:name=".interaction.actions.BolusActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/menu_bolus" />
|
||||
<activity
|
||||
android:name=".interaction.actions.CPPActivity"
|
||||
android:label="@string/status_cpp" />
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package info.nightscout.androidaps.interaction.actions;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.wearable.view.GridPagerAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
|
||||
import info.nightscout.shared.SafeParse;
|
||||
|
||||
public class BolusActivity extends ViewSelectorActivity {
|
||||
|
||||
PlusMinusEditText editInsulin;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setAdapter(new MyGridViewPagerAdapter());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
finish();
|
||||
}
|
||||
|
||||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||
@Override
|
||||
public int getColumnCount(int arg0) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if (col == 0) {
|
||||
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, getString(R.string.action_insulin));
|
||||
container.addView(view);
|
||||
view.requestFocus();
|
||||
return view;
|
||||
} else {
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
|
||||
confirmbutton.setOnClickListener((View v) -> {
|
||||
String actionstring = "bolus " + SafeParse.stringToDouble(editInsulin.editText.getText().toString())
|
||||
+ " 0"; // Zero carbs
|
||||
ListenerService.initiateAction(BolusActivity.this, actionstring);
|
||||
confirmAction(BolusActivity.this, R.string.action_bolus_confirmation);
|
||||
finishAffinity();
|
||||
});
|
||||
container.addView(view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup container, int row, int col, Object view) {
|
||||
container.removeView((View) view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -80,8 +80,8 @@ public class TreatmentActivity extends ViewSelectorActivity {
|
|||
// (you have to swipe past them anyways - but still)
|
||||
String actionstring = "bolus " + SafeParse.stringToDouble(editInsulin.editText.getText().toString())
|
||||
+ " " + SafeParse.stringToInt(editCarbs.editText.getText().toString());
|
||||
ListenerService.initiateAction(BolusActivity.this, actionstring);
|
||||
confirmAction(BolusActivity.this, R.string.action_bolus_confirmation);
|
||||
ListenerService.initiateAction(TreatmentActivity.this, actionstring);
|
||||
confirmAction(TreatmentActivity.this, R.string.action_treatment_confirmation);
|
||||
finishAffinity();
|
||||
});
|
||||
container.addView(view);
|
||||
|
|
|
@ -49,7 +49,7 @@ public class MainMenuActivity extends MenuListActivity {
|
|||
|
||||
if (showWizard) menuItems.add(new MenuItem(R.drawable.ic_calculator, getString(R.string.menu_wizard)));
|
||||
menuItems.add(new MenuItem(R.drawable.ic_e_carbs, getString(R.string.menu_ecarb)));
|
||||
menuItems.add(new MenuItem(R.drawable.ic_bolus, getString(R.string.menu_treatment)));
|
||||
menuItems.add(new MenuItem(R.drawable.ic_treatment, getString(R.string.menu_treatment)));
|
||||
menuItems.add(new MenuItem(R.drawable.ic_temptarget, getString(R.string.menu_tempt)));
|
||||
menuItems.add(new MenuItem(R.drawable.ic_settings, getString(R.string.menu_settings)));
|
||||
menuItems.add(new MenuItem(R.drawable.ic_status, getString(R.string.menu_status)));
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.tile
|
||||
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interaction.actions.BolusActivity
|
||||
import info.nightscout.androidaps.interaction.actions.TreatmentActivity
|
||||
import info.nightscout.androidaps.interaction.actions.ECarbActivity
|
||||
import info.nightscout.androidaps.interaction.actions.TempTargetActivity
|
||||
|
@ -21,8 +22,8 @@ object ActionSource : TileSource {
|
|||
),
|
||||
Action(
|
||||
id = 1,
|
||||
settingName = "bolus",
|
||||
nameRes = R.string.action_bolus,
|
||||
settingName = "treatment",
|
||||
nameRes = R.string.menu_treatment,
|
||||
iconRes = R.drawable.ic_bolus_carbs,
|
||||
activityClass = TreatmentActivity::class.java.getName(),
|
||||
background = false,
|
||||
|
@ -30,6 +31,15 @@ object ActionSource : TileSource {
|
|||
),
|
||||
Action(
|
||||
id = 2,
|
||||
settingName = "bolus",
|
||||
nameRes = R.string.action_bolus,
|
||||
iconRes = R.drawable.ic_bolus,
|
||||
activityClass = BolusActivity::class.java.getName(),
|
||||
background = false,
|
||||
actionString = "",
|
||||
),
|
||||
Action(
|
||||
id = 3,
|
||||
settingName = "carbs",
|
||||
nameRes = R.string.action_carbs,
|
||||
iconRes = R.drawable.ic_carbs_orange,
|
||||
|
@ -38,7 +48,7 @@ object ActionSource : TileSource {
|
|||
actionString = "",
|
||||
),
|
||||
Action(
|
||||
id = 3,
|
||||
id = 4,
|
||||
settingName = "temp_target",
|
||||
nameRes = R.string.menu_tempt,
|
||||
iconRes = R.drawable.ic_temptarget_flat,
|
||||
|
@ -52,7 +62,7 @@ object ActionSource : TileSource {
|
|||
override fun getDefaultConfig(): Map<String, String> {
|
||||
return mapOf(
|
||||
"tile_action_1" to "wizzard",
|
||||
"tile_action_2" to "bolus",
|
||||
"tile_action_2" to "treatment",
|
||||
"tile_action_3" to "carbs",
|
||||
"tile_action_4" to "temp_target"
|
||||
)
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
13
wear/src/main/res/drawable/ic_treatment.xml
Normal file
13
wear/src/main/res/drawable/ic_treatment.xml
Normal file
File diff suppressed because one or more lines are too long
|
@ -82,6 +82,7 @@
|
|||
<string-array name="tile_action_names">
|
||||
<item>@string/menu_wizard</item>
|
||||
<item>@string/menu_treatment</item>
|
||||
<item>@string/menu_bolus</item>
|
||||
<item>@string/menu_ecarb</item>
|
||||
<item>@string/menu_tempt</item>
|
||||
<item>@string/tile_none</item>
|
||||
|
@ -89,6 +90,7 @@
|
|||
|
||||
<string-array name="tile_action_values">
|
||||
<item>wizzard</item>
|
||||
<item>treatment</item>
|
||||
<item>bolus</item>
|
||||
<item>carbs</item>
|
||||
<item>temp_target</item>
|
||||
|
|
|
@ -75,7 +75,8 @@
|
|||
<string name="menu_tempt">TempT</string>
|
||||
<string name="menu_wizard">Wizard</string>
|
||||
<string name="menu_treatment">Treatment</string>
|
||||
<string name="menu_ecarb">eCarb</string>
|
||||
<string name="menu_bolus">Bolus</string>
|
||||
<string name="menu_ecarb">Carbs</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="menu_status">Status</string>
|
||||
<string name="menu_resync">Re-Sync</string>
|
||||
|
@ -86,6 +87,7 @@
|
|||
|
||||
<string name="action_duration">duration</string>
|
||||
<string name="action_tempt_confirmation">Temp Target Requested</string>
|
||||
<string name="action_treatment_confirmation">Treatment Requested</string>
|
||||
<string name="action_bolus_confirmation">Bolus Requested</string>
|
||||
<string name="action_wizard_confirmation">Updated Requested</string>
|
||||
<string name="action_fill_confirmation">Fill Requested</string>
|
||||
|
@ -95,10 +97,10 @@
|
|||
<string name="action_low" comment="In temp target menu, lower value from range">low</string>
|
||||
<string name="action_high" comment="In temp target menu, higher value from range">high</string>
|
||||
<string name="action_carbs">Carbs</string>
|
||||
<string name="action_percentage">percentage</string>
|
||||
<string name="action_start_min">start [min]</string>
|
||||
<string name="action_duration_h">duration [h]</string>
|
||||
<string name="action_insulin">insulin</string>
|
||||
<string name="action_percentage">Percentage</string>
|
||||
<string name="action_start_min">Start [min]</string>
|
||||
<string name="action_duration_h">Duration [h]</string>
|
||||
<string name="action_insulin">Insulin</string>
|
||||
<string name="action_preset_1">Preset 1</string>
|
||||
<string name="action_preset_2">Preset 2</string>
|
||||
<string name="action_preset_3">Preset 3</string>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<ListPreference
|
||||
android:key="tile_action_2"
|
||||
android:title="Action 2"
|
||||
android:defaultValue="bolus"
|
||||
android:defaultValue="treatment"
|
||||
android:entries="@array/tile_action_names"
|
||||
android:entryValues="@array/tile_action_values"/>
|
||||
|
||||
|
|
Loading…
Reference in a new issue