From dc7a27b018dff8c38db26397eb8934ab59a5ca2e Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 30 Nov 2021 21:02:10 +0100 Subject: [PATCH 1/7] Wear set focus for rotary input --- .../interaction/AAPSPreferences.java | 1 + .../interaction/ConfigurationActivity.java | 1 + .../interaction/actions/BolusActivity.java | 20 ++++++++++++++++++- .../interaction/actions/CPPActivity.java | 16 +++++++++++++++ .../interaction/actions/ECarbActivity.java | 16 +++++++++++++++ .../interaction/actions/FillActivity.java | 1 + .../actions/TempTargetActivity.java | 16 +++++++++++++++ .../interaction/actions/WizardActivity.java | 16 +++++++++++++++ .../interaction/menus/FillMenuActivity.java | 18 ++++++++++------- .../interaction/utils/PlusMinusEditText.java | 18 ++++++++++++++++- .../main/res/layout/actions_list_activity.xml | 1 + 11 files changed, 115 insertions(+), 9 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java b/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java index 39dda741fd..ccdaeff7dc 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java @@ -17,6 +17,7 @@ public class AAPSPreferences extends WearPreferenceActivity { ViewGroup view = (ViewGroup)getWindow().getDecorView(); removeBackgroundRecursively(view); view.setBackground(getResources().getDrawable(R.drawable.settings_background)); + view.requestFocus(); } @Override diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.java index d1d8d71cc5..8348dfcb22 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/ConfigurationActivity.java @@ -22,6 +22,7 @@ public class ConfigurationActivity extends WearPreferenceActivity { ViewGroup view = (ViewGroup) getWindow().getDecorView(); removeBackgroundRecursively(view); view.setBackground(getResources().getDrawable(R.drawable.settings_background)); + view.requestFocus(); } @Override diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java index dad9a46df9..4b4986b5e2 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -6,12 +6,15 @@ import android.os.Bundle; import android.support.wearable.view.DotsPageIndicator; import android.support.wearable.view.GridPagerAdapter; import android.support.wearable.view.GridViewPager; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.List; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.ListenerService; @@ -38,8 +41,22 @@ public class BolusActivity extends ViewSelectorActivity { pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); - } + pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + } + @Override + public void onPageSelected(int row, int column) { + View view = pager.getChildAt(column); + view.requestFocus(); + } + + @Override + public void onPageScrollStateChanged(int state) { + } + }); + } @Override protected void onPause() { @@ -71,6 +88,7 @@ public class BolusActivity extends ViewSelectorActivity { 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 if (col == 1) { final View view = getInflatedPlusMinusView(container); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java index e47b40293c..e1da75e567 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java @@ -53,6 +53,21 @@ public class CPPActivity extends ViewSelectorActivity { pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); + pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + } + + @Override + public void onPageSelected(int row, int column) { + View view = pager.getChildAt(column); + view.requestFocus(); + } + + @Override + public void onPageScrollStateChanged(int state) { + } + }); } @@ -86,6 +101,7 @@ public class CPPActivity extends ViewSelectorActivity { editTimeshift = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 23d, 1d, new DecimalFormat("0"), true, true); setLabelToPlusMinusView(view, getString(R.string.action_timeshift)); container.addView(view); + view.requestFocus(); return view; } else if (col == 1) { final View view = getInflatedPlusMinusView(container); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java index 09b68ed704..3d2ff7d3f8 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java @@ -40,6 +40,21 @@ public class ECarbActivity extends ViewSelectorActivity { pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); + pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + } + + @Override + public void onPageSelected(int row, int column) { + View view = pager.getChildAt(column); + view.requestFocus(); + } + + @Override + public void onPageScrollStateChanged(int state) { + } + }); } @@ -73,6 +88,7 @@ public class ECarbActivity extends ViewSelectorActivity { editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), true); setLabelToPlusMinusView(view, getString(R.string.action_carbs)); container.addView(view); + view.requestFocus(); return view; } else if(col == 1){ final View view = getInflatedPlusMinusView(container); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java index 2f3770f464..e17c8bb724 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java @@ -70,6 +70,7 @@ public class FillActivity extends ViewSelectorActivity { 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 { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java index 6bc562c139..430b82fd5d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java @@ -48,6 +48,21 @@ public class TempTargetActivity extends ViewSelectorActivity { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); isMGDL = sp.getBoolean("units_mgdl", true); isSingleTarget = sp.getBoolean("singletarget", true); + pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + } + + @Override + public void onPageSelected(int row, int column) { + View view = pager.getChildAt(column); + view.requestFocus(); + } + + @Override + public void onPageScrollStateChanged(int state) { + } + }); } @@ -84,6 +99,7 @@ public class TempTargetActivity extends ViewSelectorActivity { } setLabelToPlusMinusView(view, getString(R.string.action_duration)); container.addView(view); + view.requestFocus(); return view; } else if (col == 1) { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java index 265eec49bb..f376bb954a 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java @@ -45,6 +45,21 @@ public class WizardActivity extends ViewSelectorActivity { dotsPageIndicator.setPager(pager); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); hasPercentage = sp.getBoolean("wizardpercentage", false); + pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + } + + @Override + public void onPageSelected(int row, int column) { + View view = pager.getChildAt(column); + view.requestFocus(); + } + + @Override + public void onPageScrollStateChanged(int state) { + } + }); } @@ -80,6 +95,7 @@ public class WizardActivity extends ViewSelectorActivity { } setLabelToPlusMinusView(view, getString(R.string.action_carbs)); container.addView(view); + view.requestFocus(); return view; } else if (col == 1 && hasPercentage) { final View view = getInflatedPlusMinusView(container); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java index 68368e4b48..fc3613c227 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java @@ -2,6 +2,9 @@ package info.nightscout.androidaps.interaction.menus; import android.content.Intent; +import java.util.ArrayList; +import java.util.List; + import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.interaction.actions.FillActivity; @@ -14,13 +17,14 @@ import info.nightscout.androidaps.interaction.utils.MenuListActivity; public class FillMenuActivity extends MenuListActivity { @Override - protected String[] getElements() { - return new String[]{ - getString(R.string.action_preset_1), - getString(R.string.action_preset_2), - getString(R.string.action_preset_3), - getString(R.string.action_free_amount) - }; + protected List getElements() { + List menuitems = new ArrayList<>(); + menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.action_preset_1))); + menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.action_preset_2))); + menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.action_preset_3))); + menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.action_free_amount))); + + return menuitems; } @Override diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java index f6c4046488..54780c83ac 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java @@ -3,6 +3,7 @@ package info.nightscout.androidaps.interaction.utils; import android.os.Handler; import android.os.Looper; import android.os.Message; +import android.support.wearable.input.RotaryEncoder; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; @@ -19,7 +20,7 @@ import java.util.concurrent.TimeUnit; * Created by mike on 28.06.2016. */ public class PlusMinusEditText implements View.OnKeyListener, - View.OnTouchListener, View.OnClickListener { + View.OnTouchListener, View.OnClickListener, View.OnGenericMotionListener { Integer editTextID; public TextView editText; @@ -104,6 +105,7 @@ public class PlusMinusEditText implements View.OnKeyListener, plusImage.setOnTouchListener(this); plusImage.setOnKeyListener(this); plusImage.setOnClickListener(this); + editText.setOnGenericMotionListener(this); updateEditText(); } @@ -207,4 +209,18 @@ public class PlusMinusEditText implements View.OnKeyListener, return false; } + @Override + public boolean onGenericMotion(View v, MotionEvent ev) { + if (ev.getAction() == MotionEvent.ACTION_SCROLL && RotaryEncoder.isFromRotaryEncoder(ev)) { + float delta = -RotaryEncoder.getRotaryAxisValue(ev); + if (delta > 0) { + inc(1); + } else { + dec(1); + } + return true; + } + return false; + } + } diff --git a/wear/src/main/res/layout/actions_list_activity.xml b/wear/src/main/res/layout/actions_list_activity.xml index 1779f1b4ab..d9086a813c 100644 --- a/wear/src/main/res/layout/actions_list_activity.xml +++ b/wear/src/main/res/layout/actions_list_activity.xml @@ -15,6 +15,7 @@ android:id="@+id/wearable_list" android:layout_height="match_parent" android:layout_width="match_parent"> + From 5ae7346123feca6db4dd8d1b7dcdad4d3635c8a5 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Tue, 30 Nov 2021 21:02:49 +0100 Subject: [PATCH 2/7] Wear add menu icons and animation --- .../interaction/actions/BolusActivity.java | 3 - .../interaction/menus/MainMenuActivity.java | 29 ++++--- .../interaction/menus/StatusMenuActivity.java | 17 ++-- .../interaction/utils/MenuListActivity.java | 82 +++++++++++++++---- wear/src/main/res/drawable/ic_canula.xml | 9 ++ .../res/drawable/ic_loop_closed_white.xml | 9 ++ wear/src/main/res/drawable/ic_settings.xml | 9 ++ wear/src/main/res/drawable/ic_status.xml | 9 ++ wear/src/main/res/drawable/ic_sync.xml | 9 ++ wear/src/main/res/drawable/ic_temptarget.xml | 9 ++ wear/src/main/res/layout-v26/list_item.xml | 13 ++- wear/src/main/res/layout/list_item.xml | 15 ++-- 12 files changed, 165 insertions(+), 48 deletions(-) create mode 100644 wear/src/main/res/drawable/ic_canula.xml create mode 100644 wear/src/main/res/drawable/ic_loop_closed_white.xml create mode 100644 wear/src/main/res/drawable/ic_settings.xml create mode 100644 wear/src/main/res/drawable/ic_status.xml create mode 100644 wear/src/main/res/drawable/ic_sync.xml create mode 100644 wear/src/main/res/drawable/ic_temptarget.xml diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java index 4b4986b5e2..fc5c252839 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -6,15 +6,12 @@ import android.os.Bundle; import android.support.wearable.view.DotsPageIndicator; import android.support.wearable.view.GridPagerAdapter; import android.support.wearable.view.GridViewPager; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.List; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.ListenerService; diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java index f72887b54e..a7b43444b8 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java @@ -5,6 +5,8 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; +import java.util.ArrayList; +import java.util.List; import java.util.Vector; import info.nightscout.androidaps.R; @@ -32,29 +34,30 @@ public class MainMenuActivity extends MenuListActivity { } @Override - protected String[] getElements() { + protected List getElements() { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); + List menuitems = new ArrayList<>(); if (!sharedPreferences.getBoolean("wearcontrol", false)) { - return new String[]{ - getString(R.string.menu_settings), - getString(R.string.menu_resync)}; + menuitems.add(new MenuElement(R.drawable.ic_settings, getString(R.string.menu_settings))); + menuitems.add(new MenuElement(R.drawable.ic_sync, getString(R.string.menu_resync))); + + return menuitems; } boolean showPrimeFill = sp.getBoolean("primefill", false); boolean showWizard = sp.getBoolean("showWizard", true); - Vector menuitems = new Vector(); - menuitems.add(getString(R.string.menu_tempt)); - if (showWizard) menuitems.add(getString(R.string.menu_wizard)); - menuitems.add(getString(R.string.menu_ecarb)); - menuitems.add(getString(R.string.menu_bolus)); - menuitems.add(getString(R.string.menu_settings)); - menuitems.add(getString(R.string.menu_status)); - if (showPrimeFill) menuitems.add(getString(R.string.menu_prime_fill)); + menuitems.add(new MenuElement(R.drawable.ic_temptarget, getString(R.string.menu_tempt))); + if (showWizard) menuitems.add(new MenuElement(R.drawable.ic_cob_iob, getString(R.string.menu_wizard))); + menuitems.add(new MenuElement(R.drawable.ic_carbs, getString(R.string.menu_ecarb))); + menuitems.add(new MenuElement(R.drawable.ic_ins, getString(R.string.menu_bolus))); + menuitems.add(new MenuElement(R.drawable.ic_settings, getString(R.string.menu_settings))); + menuitems.add(new MenuElement(R.drawable.ic_status, getString(R.string.menu_status))); + if (showPrimeFill) menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.menu_prime_fill))); - return menuitems.toArray(new String[menuitems.size()]); + return menuitems; } @Override diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java index 1133392a9a..73ffb8b019 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java @@ -1,5 +1,8 @@ package info.nightscout.androidaps.interaction.menus; +import java.util.ArrayList; +import java.util.List; + import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.interaction.utils.MenuListActivity; @@ -11,14 +14,14 @@ import info.nightscout.androidaps.interaction.utils.MenuListActivity; public class StatusMenuActivity extends MenuListActivity { @Override - protected String[] getElements() { - return new String[] { - getString(R.string.status_pump), - getString(R.string.status_loop), - getString(R.string.status_cpp), - getString(R.string.status_tdd)}; - + protected List getElements() { + List menuitems = new ArrayList<>(); + menuitems.add(new MenuElement(R.drawable.ic_status, getString(R.string.status_pump))); + menuitems.add(new MenuElement(R.drawable.ic_loop_closed_white, getString(R.string.status_loop))); + menuitems.add(new MenuElement(R.drawable.ic_status, getString(R.string.status_cpp))); + menuitems.add(new MenuElement(R.drawable.ic_iob_detailed, getString(R.string.status_tdd))); + return menuitems; } @Override diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java index af606db583..98583cf2cb 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java @@ -7,8 +7,12 @@ import android.support.wearable.view.WearableListView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.TextView; +import java.util.List; + import info.nightscout.androidaps.R; /** @@ -18,9 +22,9 @@ import info.nightscout.androidaps.R; public abstract class MenuListActivity extends Activity implements WearableListView.ClickListener { - String[] elements; + List elements; - protected abstract String[] getElements(); + protected abstract List getElements(); protected abstract void doAction(String position); @@ -41,7 +45,7 @@ public abstract class MenuListActivity extends Activity findViewById(R.id.wearable_list); // Assign an adapter to the list - listView.setAdapter(new Adapter(this, elements)); + listView.setAdapter(new MenuAdapter(this, elements)); // Set a click listener listView.setClickListener(this); @@ -61,20 +65,20 @@ public abstract class MenuListActivity extends Activity } - private static final class Adapter extends WearableListView.Adapter { - private final String[] mDataset; + private class MenuAdapter extends WearableListView.Adapter { + private final List mDataset; private final Context mContext; private final LayoutInflater mInflater; // Provide a suitable constructor (depends on the kind of dataset) - public Adapter(Context context, String[] dataset) { + public MenuAdapter(Context context, List dataset) { mContext = context; mInflater = LayoutInflater.from(context); mDataset = dataset; } // Provide a reference to the type of views you're using - public static class ItemViewHolder extends WearableListView.ViewHolder { + public class ItemViewHolder extends WearableListView.ViewHolder { private final TextView textView; public ItemViewHolder(View itemView) { @@ -90,7 +94,8 @@ public abstract class MenuListActivity extends Activity public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { // Inflate our custom layout for list items - return new ItemViewHolder(mInflater.inflate(R.layout.list_item, null)); + WearableListView.ViewHolder viewHolder = new WearableListView.ViewHolder(new MenuItemView(mContext)); + return viewHolder; } // Replace the contents of a list item @@ -100,21 +105,68 @@ public abstract class MenuListActivity extends Activity public void onBindViewHolder(WearableListView.ViewHolder holder, int position) { // retrieve the text view - ItemViewHolder itemHolder = (ItemViewHolder) holder; - TextView view = itemHolder.textView; - // replace text contents - view.setText(mDataset[position]); + MenuItemView menuItemView = (MenuItemView) holder.itemView; + final MenuElement item = mDataset.get(position); + TextView textView = menuItemView.findViewById(R.id.actionitem); + textView.setText(item.actionitem); + + final ImageView imageView = menuItemView.findViewById(R.id.actionicon); + imageView.setImageResource(item.actionicon); + // replace list item's metadata - holder.itemView.setTag(mDataset[position]); + holder.itemView.setTag(item.actionitem); } // Return the size of your dataset // (invoked by the WearableListView's layout manager) @Override public int getItemCount() { - return mDataset.length; + return mDataset.size(); } } + public final class MenuItemView extends FrameLayout implements WearableListView.OnCenterProximityListener { -} \ No newline at end of file + final ImageView image; + final TextView text; + final float scale = 0.8f; + final float alpha = 0.8f; + + public MenuItemView(Context context) { + super(context); + View.inflate(context, R.layout.list_item, this); + image = findViewById(R.id.actionicon); + text = findViewById(R.id.actionitem); + image.setScaleX(scale); + image.setScaleX(scale); + image.setAlpha(alpha); + text.setScaleX(scale); + text.setScaleX(scale); + text.setAlpha(alpha); + } + + @Override + public void onCenterPosition(boolean b) { + // Animation to be ran when the view becomes the centered one + image.animate().scaleX(1f).scaleY(1f).alpha(1); + text.animate().scaleX(1f).scaleY(1f).alpha(1); + } + + @Override + public void onNonCenterPosition(boolean b) { + //Animation to be ran when the view is not the centered one anymore + image.animate().scaleX(scale).scaleY(scale).alpha(alpha); + text.animate().scaleX(scale).scaleY(scale).alpha(alpha); + } + } + + protected class MenuElement { + public MenuElement(int actionicon, String actionitem) { + this.actionicon = actionicon; + this.actionitem = actionitem; + } + public int actionicon; + public String actionitem; + } + +} diff --git a/wear/src/main/res/drawable/ic_canula.xml b/wear/src/main/res/drawable/ic_canula.xml new file mode 100644 index 0000000000..8d20fa6864 --- /dev/null +++ b/wear/src/main/res/drawable/ic_canula.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/drawable/ic_loop_closed_white.xml b/wear/src/main/res/drawable/ic_loop_closed_white.xml new file mode 100644 index 0000000000..586e889a8d --- /dev/null +++ b/wear/src/main/res/drawable/ic_loop_closed_white.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/drawable/ic_settings.xml b/wear/src/main/res/drawable/ic_settings.xml new file mode 100644 index 0000000000..b833ab6c7c --- /dev/null +++ b/wear/src/main/res/drawable/ic_settings.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/drawable/ic_status.xml b/wear/src/main/res/drawable/ic_status.xml new file mode 100644 index 0000000000..53cfc991f7 --- /dev/null +++ b/wear/src/main/res/drawable/ic_status.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/drawable/ic_sync.xml b/wear/src/main/res/drawable/ic_sync.xml new file mode 100644 index 0000000000..749430d0b6 --- /dev/null +++ b/wear/src/main/res/drawable/ic_sync.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/drawable/ic_temptarget.xml b/wear/src/main/res/drawable/ic_temptarget.xml new file mode 100644 index 0000000000..5a1ed84c65 --- /dev/null +++ b/wear/src/main/res/drawable/ic_temptarget.xml @@ -0,0 +1,9 @@ + + + diff --git a/wear/src/main/res/layout-v26/list_item.xml b/wear/src/main/res/layout-v26/list_item.xml index 8084d832e6..aee08c036b 100644 --- a/wear/src/main/res/layout-v26/list_item.xml +++ b/wear/src/main/res/layout-v26/list_item.xml @@ -3,21 +3,28 @@ android:gravity="center_vertical" android:layout_width="match_parent" android:layout_height="80dp"> + diff --git a/wear/src/main/res/layout/list_item.xml b/wear/src/main/res/layout/list_item.xml index a6193efc3e..62bcf96129 100644 --- a/wear/src/main/res/layout/list_item.xml +++ b/wear/src/main/res/layout/list_item.xml @@ -3,22 +3,23 @@ android:gravity="center_vertical" android:layout_width="match_parent" android:layout_height="80dp"> - + android:src="@drawable/circle"/> + android:textSize="30sp" + android:text="list item"/> From 8ae63eff296430a03cd8e3ce540abafb5a66aea9 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 1 Dec 2021 14:16:00 +0100 Subject: [PATCH 3/7] Fix wear page indicator --- .../androidaps/interaction/actions/BolusActivity.java | 6 ++++-- .../androidaps/interaction/actions/CPPActivity.java | 6 ++++-- .../androidaps/interaction/actions/ECarbActivity.java | 6 ++++-- .../androidaps/interaction/actions/TempTargetActivity.java | 6 ++++-- .../androidaps/interaction/actions/WizardActivity.java | 6 ++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java index fc5c252839..4382f8d323 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -41,16 +41,18 @@ public class BolusActivity extends ViewSelectorActivity { pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels, + columnOffsetPixels); } - @Override public void onPageSelected(int row, int column) { + dotsPageIndicator.onPageSelected(row, column); View view = pager.getChildAt(column); view.requestFocus(); } - @Override public void onPageScrollStateChanged(int state) { + dotsPageIndicator.onPageScrollStateChanged(state); } }); } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java index e1da75e567..a2cc5f2b4d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java @@ -56,16 +56,18 @@ public class CPPActivity extends ViewSelectorActivity { pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels, + columnOffsetPixels); } - @Override public void onPageSelected(int row, int column) { + dotsPageIndicator.onPageSelected(row, column); View view = pager.getChildAt(column); view.requestFocus(); } - @Override public void onPageScrollStateChanged(int state) { + dotsPageIndicator.onPageScrollStateChanged(state); } }); } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java index 3d2ff7d3f8..33835ff01f 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java @@ -43,16 +43,18 @@ public class ECarbActivity extends ViewSelectorActivity { pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels, + columnOffsetPixels); } - @Override public void onPageSelected(int row, int column) { + dotsPageIndicator.onPageSelected(row, column); View view = pager.getChildAt(column); view.requestFocus(); } - @Override public void onPageScrollStateChanged(int state) { + dotsPageIndicator.onPageScrollStateChanged(state); } }); } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java index 430b82fd5d..17515ad282 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java @@ -51,16 +51,18 @@ public class TempTargetActivity extends ViewSelectorActivity { pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels, + columnOffsetPixels); } - @Override public void onPageSelected(int row, int column) { + dotsPageIndicator.onPageSelected(row, column); View view = pager.getChildAt(column); view.requestFocus(); } - @Override public void onPageScrollStateChanged(int state) { + dotsPageIndicator.onPageScrollStateChanged(state); } }); } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java index f376bb954a..6ab4f3375c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java @@ -48,16 +48,18 @@ public class WizardActivity extends ViewSelectorActivity { pager.setOnPageChangeListener(new GridViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int row, int column, float rowOffset, float columnOffset, int rowOffsetPixels, int columnOffsetPixels) { + dotsPageIndicator.onPageScrolled(row, column, rowOffset, columnOffset, rowOffsetPixels, + columnOffsetPixels); } - @Override public void onPageSelected(int row, int column) { + dotsPageIndicator.onPageSelected(row, column); View view = pager.getChildAt(column); view.requestFocus(); } - @Override public void onPageScrollStateChanged(int state) { + dotsPageIndicator.onPageScrollStateChanged(state); } }); } From e8e0aa75e2e43d004e9d7705972e74117015cda1 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 1 Dec 2021 14:20:10 +0100 Subject: [PATCH 4/7] Wear improve menu icons --- .../interaction/menus/MainMenuActivity.java | 4 ++-- wear/src/main/res/drawable/ic_calculator.xml | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 wear/src/main/res/drawable/ic_calculator.xml diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java index a7b43444b8..a37d612627 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java @@ -50,9 +50,9 @@ public class MainMenuActivity extends MenuListActivity { boolean showWizard = sp.getBoolean("showWizard", true); menuitems.add(new MenuElement(R.drawable.ic_temptarget, getString(R.string.menu_tempt))); - if (showWizard) menuitems.add(new MenuElement(R.drawable.ic_cob_iob, getString(R.string.menu_wizard))); + if (showWizard) menuitems.add(new MenuElement(R.drawable.ic_calculator, getString(R.string.menu_wizard))); menuitems.add(new MenuElement(R.drawable.ic_carbs, getString(R.string.menu_ecarb))); - menuitems.add(new MenuElement(R.drawable.ic_ins, getString(R.string.menu_bolus))); + menuitems.add(new MenuElement(R.drawable.ic_cob_iob, getString(R.string.menu_bolus))); menuitems.add(new MenuElement(R.drawable.ic_settings, getString(R.string.menu_settings))); menuitems.add(new MenuElement(R.drawable.ic_status, getString(R.string.menu_status))); if (showPrimeFill) menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.menu_prime_fill))); diff --git a/wear/src/main/res/drawable/ic_calculator.xml b/wear/src/main/res/drawable/ic_calculator.xml new file mode 100644 index 0000000000..2538ed034b --- /dev/null +++ b/wear/src/main/res/drawable/ic_calculator.xml @@ -0,0 +1,14 @@ + + + + + + + + + From d7caa39ff383f46d1f53d78787d8003919c99ab8 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 1 Dec 2021 15:28:25 +0100 Subject: [PATCH 5/7] Wear improve menu navigation --- .../androidaps/interaction/actions/AcceptActivity.java | 2 +- .../androidaps/interaction/actions/BolusActivity.java | 2 +- .../androidaps/interaction/actions/CPPActivity.java | 2 +- .../androidaps/interaction/actions/ECarbActivity.java | 2 +- .../androidaps/interaction/actions/FillActivity.java | 2 +- .../interaction/actions/TempTargetActivity.java | 2 +- .../androidaps/interaction/actions/WizardActivity.java | 2 +- .../androidaps/interaction/utils/MenuListActivity.java | 9 +-------- 8 files changed, 8 insertions(+), 15 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java index 6a5b9b5f9a..5000b47577 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java @@ -99,7 +99,7 @@ public class AcceptActivity extends ViewSelectorActivity { @Override public void onClick(View v) { ListenerService.confirmAction(AcceptActivity.this, actionstring); - finish(); + finishAffinity(); } }); container.addView(view); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java index 4382f8d323..27b812459c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -113,7 +113,7 @@ public class BolusActivity extends ViewSelectorActivity { String actionstring = "bolus " + SafeParse.stringToDouble(editInsulin.editText.getText().toString()) + " " + SafeParse.stringToInt(editCarbs.editText.getText().toString()); ListenerService.initiateAction(BolusActivity.this, actionstring); - finish(); + finishAffinity(); } }); container.addView(view); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java index a2cc5f2b4d..e0525048a7 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java @@ -129,7 +129,7 @@ public class CPPActivity extends ViewSelectorActivity { String actionstring = "cppset " + SafeParse.stringToInt(editTimeshift.editText.getText().toString()) + " " + SafeParse.stringToInt(editPercentage.editText.getText().toString()); ListenerService.initiateAction(CPPActivity.this, actionstring); - finish(); + finishAffinity(); } }); container.addView(view); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java index 33835ff01f..8954a312da 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java @@ -127,7 +127,7 @@ public class ECarbActivity extends ViewSelectorActivity { + " " + SafeParse.stringToInt(editStartTime.editText.getText().toString()) + " " + SafeParse.stringToInt(editDuration.editText.getText().toString()); ListenerService.initiateAction(ECarbActivity.this, actionstring); - finish(); + finishAffinity(); } }); container.addView(view); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java index e17c8bb724..f10f0ec192 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java @@ -85,7 +85,7 @@ public class FillActivity extends ViewSelectorActivity { String actionstring = "fill " + SafeParse.stringToDouble(editInsulin.editText.getText().toString()); ListenerService.initiateAction(FillActivity.this, actionstring); - finish(); + finishAffinity(); } }); container.addView(view); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java index 17515ad282..10018af882 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java @@ -162,7 +162,7 @@ public class TempTargetActivity extends ViewSelectorActivity { + " " + (isSingleTarget ? SafeParse.stringToDouble(lowRange.editText.getText().toString()) : SafeParse.stringToDouble(highRange.editText.getText().toString())); ListenerService.initiateAction(TempTargetActivity.this, actionstring); - finish(); + finishAffinity(); } }); container.addView(view); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java index 6ab4f3375c..d58f2ab387 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java @@ -129,7 +129,7 @@ public class WizardActivity extends ViewSelectorActivity { String actionstring = "wizard2 " + SafeParse.stringToInt(editCarbs.editText.getText().toString()) + " " + percentage; ListenerService.initiateAction(WizardActivity.this, actionstring); - finish(); + finishAffinity(); } }); container.addView(view); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java index 98583cf2cb..e9302f8b23 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java @@ -28,12 +28,6 @@ public abstract class MenuListActivity extends Activity protected abstract void doAction(String position); - @Override - protected void onPause(){ - super.onPause(); - finish(); - } - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -56,8 +50,7 @@ public abstract class MenuListActivity extends Activity public void onClick(WearableListView.ViewHolder v) { String tag = (String) v.itemView.getTag(); doAction(tag); - //ActionsDefinitions.doAction(v.getAdapterPosition(), this); - finish(); + } @Override From bc05eaa30934c7483215620c013e318f96097b87 Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Wed, 1 Dec 2021 21:13:10 +0100 Subject: [PATCH 6/7] Wear add title to grid layout --- .../androidaps/interaction/actions/AcceptActivity.java | 3 +-- .../androidaps/interaction/actions/BolusActivity.java | 7 +++++-- .../androidaps/interaction/actions/CPPActivity.java | 7 +++++-- .../androidaps/interaction/actions/ECarbActivity.java | 7 +++++-- .../androidaps/interaction/actions/FillActivity.java | 7 +++++-- .../androidaps/interaction/actions/TempTargetActivity.java | 6 ++++-- .../androidaps/interaction/actions/WizardActivity.java | 7 +++++-- wear/src/main/res/layout/grid_layout.xml | 7 +++++++ 8 files changed, 37 insertions(+), 14 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java index 5000b47577..91cffa4b3e 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/AcceptActivity.java @@ -50,9 +50,8 @@ public class AcceptActivity extends ViewSelectorActivity { } setContentView(R.layout.grid_layout); - final Resources res = getResources(); - final GridViewPager pager = findViewById(R.id.pager); + final GridViewPager pager = findViewById(R.id.pager); pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java index 27b812459c..6faec96119 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -10,6 +10,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.TextView; import java.text.DecimalFormat; @@ -32,9 +33,11 @@ public class BolusActivity extends ViewSelectorActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid_layout); - final Resources res = getResources(); - final GridViewPager pager = findViewById(R.id.pager); + final TextView title = findViewById(R.id.title); + title.setText(getString(R.string.menu_bolus)); + + final GridViewPager pager = findViewById(R.id.pager); pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java index e0525048a7..3851843b16 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/CPPActivity.java @@ -10,6 +10,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.TextView; import java.text.DecimalFormat; @@ -47,9 +48,11 @@ public class CPPActivity extends ViewSelectorActivity { if (timeshift < 0) timeshift += 24; setContentView(R.layout.grid_layout); - final Resources res = getResources(); - final GridViewPager pager = findViewById(R.id.pager); + + final TextView title = findViewById(R.id.title); + title.setText(getString(R.string.status_cpp)); + final GridViewPager pager = findViewById(R.id.pager); pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java index 8954a312da..1495624bac 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ECarbActivity.java @@ -10,6 +10,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.TextView; import java.text.DecimalFormat; @@ -34,9 +35,11 @@ public class ECarbActivity extends ViewSelectorActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid_layout); - final Resources res = getResources(); - final GridViewPager pager = findViewById(R.id.pager); + final TextView title = findViewById(R.id.title); + title.setText(getString(R.string.menu_ecarb)); + + final GridViewPager pager = findViewById(R.id.pager); pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java index f10f0ec192..b141cd053a 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java @@ -10,6 +10,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.TextView; import java.text.DecimalFormat; @@ -31,9 +32,11 @@ public class FillActivity extends ViewSelectorActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid_layout); - final Resources res = getResources(); - final GridViewPager pager = findViewById(R.id.pager); + final TextView title = findViewById(R.id.title); + title.setText(getString(R.string.menu_prime_fill)); + + final GridViewPager pager = findViewById(R.id.pager); pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java index 10018af882..6893b0af32 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java @@ -38,9 +38,11 @@ public class TempTargetActivity extends ViewSelectorActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid_layout); - final Resources res = getResources(); - final GridViewPager pager = findViewById(R.id.pager); + final TextView title = findViewById(R.id.title); + title.setText(getString(R.string.menu_tempt)); + + final GridViewPager pager = findViewById(R.id.pager); pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java index d58f2ab387..80ea09f64f 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java @@ -12,6 +12,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; +import android.widget.TextView; import java.text.DecimalFormat; @@ -37,9 +38,11 @@ public class WizardActivity extends ViewSelectorActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.grid_layout); - final Resources res = getResources(); - final GridViewPager pager = findViewById(R.id.pager); + final TextView title = findViewById(R.id.title); + title.setText(getString(R.string.menu_wizard)); + + final GridViewPager pager = findViewById(R.id.pager); pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); diff --git a/wear/src/main/res/layout/grid_layout.xml b/wear/src/main/res/layout/grid_layout.xml index 2b37f71cae..02731fd35e 100644 --- a/wear/src/main/res/layout/grid_layout.xml +++ b/wear/src/main/res/layout/grid_layout.xml @@ -3,6 +3,13 @@ android:layout_width="match_parent" android:layout_height="match_parent" > + + Date: Mon, 6 Dec 2021 20:45:29 +0100 Subject: [PATCH 7/7] Wear improve action menu --- .../interaction/menus/FillMenuActivity.java | 21 +- .../interaction/menus/MainMenuActivity.java | 31 ++- .../interaction/menus/StatusMenuActivity.java | 20 +- .../interaction/utils/MenuListActivity.java | 186 ++++++++---------- .../utils/WearableListItemLayout.java | 54 ----- wear/src/main/res/drawable/ic_bolus.xml | 13 ++ wear/src/main/res/drawable/ic_calculator.xml | 24 +-- wear/src/main/res/drawable/ic_canula.xml | 17 +- wear/src/main/res/drawable/ic_e_carbs.xml | 13 ++ wear/src/main/res/drawable/ic_loop_closed.xml | 12 ++ wear/src/main/res/drawable/ic_settings.xml | 13 +- wear/src/main/res/drawable/ic_sync.xml | 13 +- wear/src/main/res/drawable/ic_tdd.xml | 13 ++ wear/src/main/res/drawable/ic_temptarget.xml | 17 +- .../main/res/drawable/menu_item_layout_bg.xml | 11 ++ wear/src/main/res/layout-v26/list_item.xml | 49 +++-- .../main/res/layout/actions_list_activity.xml | 41 ++-- wear/src/main/res/layout/grid_layout.xml | 2 +- wear/src/main/res/layout/list_item.xml | 54 ++--- 19 files changed, 314 insertions(+), 290 deletions(-) delete mode 100644 wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java create mode 100644 wear/src/main/res/drawable/ic_bolus.xml create mode 100644 wear/src/main/res/drawable/ic_e_carbs.xml create mode 100644 wear/src/main/res/drawable/ic_loop_closed.xml create mode 100644 wear/src/main/res/drawable/ic_tdd.xml create mode 100644 wear/src/main/res/drawable/menu_item_layout_bg.xml diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java index fc3613c227..92f557268f 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java @@ -1,6 +1,7 @@ package info.nightscout.androidaps.interaction.menus; import android.content.Intent; +import android.os.Bundle; import java.util.ArrayList; import java.util.List; @@ -17,14 +18,20 @@ import info.nightscout.androidaps.interaction.utils.MenuListActivity; public class FillMenuActivity extends MenuListActivity { @Override - protected List getElements() { - List menuitems = new ArrayList<>(); - menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.action_preset_1))); - menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.action_preset_2))); - menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.action_preset_3))); - menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.action_free_amount))); + protected void onCreate(Bundle savedInstanceState) { + setTitle(R.string.menu_prime_fill); + super.onCreate(savedInstanceState); + } - return menuitems; + @Override + protected List getElements() { + List menuItems = new ArrayList<>(); + menuItems.add(new MenuItem(R.drawable.ic_canula, getString(R.string.action_preset_1))); + menuItems.add(new MenuItem(R.drawable.ic_canula, getString(R.string.action_preset_2))); + menuItems.add(new MenuItem(R.drawable.ic_canula, getString(R.string.action_preset_3))); + menuItems.add(new MenuItem(R.drawable.ic_canula, getString(R.string.action_free_amount))); + + return menuItems; } @Override diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java index a37d612627..b0180cf017 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java @@ -7,7 +7,6 @@ import android.preference.PreferenceManager; import java.util.ArrayList; import java.util.List; -import java.util.Vector; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.ListenerService; @@ -29,35 +28,35 @@ public class MainMenuActivity extends MenuListActivity { @Override protected void onCreate(Bundle savedInstanceState) { sp = PreferenceManager.getDefaultSharedPreferences(this); + setTitle(R.string.label_actions_activity); super.onCreate(savedInstanceState); ListenerService.requestData(this); } @Override - protected List getElements() { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); + protected List getElements() { - List menuitems = new ArrayList<>(); - if (!sharedPreferences.getBoolean("wearcontrol", false)) { - menuitems.add(new MenuElement(R.drawable.ic_settings, getString(R.string.menu_settings))); - menuitems.add(new MenuElement(R.drawable.ic_sync, getString(R.string.menu_resync))); + List menuItems = new ArrayList<>(); + if (!sp.getBoolean("wearcontrol", false)) { + menuItems.add(new MenuItem(R.drawable.ic_settings, getString(R.string.menu_settings))); + menuItems.add(new MenuItem(R.drawable.ic_sync, getString(R.string.menu_resync))); - return menuitems; + return menuItems; } boolean showPrimeFill = sp.getBoolean("primefill", false); boolean showWizard = sp.getBoolean("showWizard", true); - menuitems.add(new MenuElement(R.drawable.ic_temptarget, getString(R.string.menu_tempt))); - if (showWizard) menuitems.add(new MenuElement(R.drawable.ic_calculator, getString(R.string.menu_wizard))); - menuitems.add(new MenuElement(R.drawable.ic_carbs, getString(R.string.menu_ecarb))); - menuitems.add(new MenuElement(R.drawable.ic_cob_iob, getString(R.string.menu_bolus))); - menuitems.add(new MenuElement(R.drawable.ic_settings, getString(R.string.menu_settings))); - menuitems.add(new MenuElement(R.drawable.ic_status, getString(R.string.menu_status))); - if (showPrimeFill) menuitems.add(new MenuElement(R.drawable.ic_canula, getString(R.string.menu_prime_fill))); + 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_bolus))); + 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))); + if (showPrimeFill) menuItems.add(new MenuItem(R.drawable.ic_canula, getString(R.string.menu_prime_fill))); - return menuitems; + return menuItems; } @Override diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java index 73ffb8b019..8861e45ed6 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.interaction.menus; +import android.os.Bundle; + import java.util.ArrayList; import java.util.List; @@ -14,12 +16,18 @@ import info.nightscout.androidaps.interaction.utils.MenuListActivity; public class StatusMenuActivity extends MenuListActivity { @Override - protected List getElements() { - List menuitems = new ArrayList<>(); - menuitems.add(new MenuElement(R.drawable.ic_status, getString(R.string.status_pump))); - menuitems.add(new MenuElement(R.drawable.ic_loop_closed_white, getString(R.string.status_loop))); - menuitems.add(new MenuElement(R.drawable.ic_status, getString(R.string.status_cpp))); - menuitems.add(new MenuElement(R.drawable.ic_iob_detailed, getString(R.string.status_tdd))); + protected void onCreate(Bundle savedInstanceState) { + setTitle(R.string.menu_status); + super.onCreate(savedInstanceState); + } + + @Override + protected List getElements() { + List menuitems = new ArrayList<>(); + menuitems.add(new MenuItem(R.drawable.ic_status, getString(R.string.status_pump))); + menuitems.add(new MenuItem(R.drawable.ic_loop_closed, getString(R.string.status_loop))); + menuitems.add(new MenuItem(R.drawable.ic_status, getString(R.string.status_cpp))); + menuitems.add(new MenuItem(R.drawable.ic_tdd, getString(R.string.status_tdd))); return menuitems; } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java index e9302f8b23..c9184a61f0 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java @@ -1,16 +1,18 @@ package info.nightscout.androidaps.interaction.utils; import android.app.Activity; -import android.content.Context; import android.os.Bundle; -import android.support.wearable.view.WearableListView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.RelativeLayout; import android.widget.TextView; +import androidx.recyclerview.widget.RecyclerView; +import androidx.wear.widget.WearableLinearLayoutManager; +import androidx.wear.widget.WearableRecyclerView; + import java.util.List; import info.nightscout.androidaps.R; @@ -19,147 +21,113 @@ import info.nightscout.androidaps.R; * Created by adrian on 08/02/17. */ -public abstract class MenuListActivity extends Activity - implements WearableListView.ClickListener { - - List elements; - - protected abstract List getElements(); - +public abstract class MenuListActivity extends Activity { + List elements; + protected abstract List getElements(); protected abstract void doAction(String position); + public interface AdapterCallback{ + void onItemClicked(MenuAdapter.ItemViewHolder v); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - elements = getElements(); setContentView(R.layout.actions_list_activity); + TextView titleView = findViewById(R.id.title); + titleView.setText(getTitle()); - // Get the list component from the layout of the activity - WearableListView listView = - findViewById(R.id.wearable_list); - - // Assign an adapter to the list - listView.setAdapter(new MenuAdapter(this, elements)); - - // Set a click listener - listView.setClickListener(this); + elements = getElements(); + CustomScrollingLayoutCallback customScrollingLayoutCallback = new CustomScrollingLayoutCallback(); + WearableLinearLayoutManager layoutManager = new WearableLinearLayoutManager(this); + if (this.getResources().getConfiguration().isScreenRound()) { + layoutManager.setLayoutCallback(customScrollingLayoutCallback); + } + WearableRecyclerView listView = findViewById(R.id.action_list); + listView.setHasFixedSize(true); + listView.setEdgeItemsCenteringEnabled(true); + listView.setLayoutManager(layoutManager); + listView.setAdapter(new MenuAdapter(elements, v -> { + String tag = (String) v.itemView.getTag(); + doAction(tag); + })); } - // WearableListView click listener - @Override - public void onClick(WearableListView.ViewHolder v) { - String tag = (String) v.itemView.getTag(); - doAction(tag); + private class MenuAdapter extends RecyclerView.Adapter { + private final List mDataset; + private AdapterCallback callback; - } - - @Override - public void onTopEmptyRegionClick() { - } - - - private class MenuAdapter extends WearableListView.Adapter { - private final List mDataset; - private final Context mContext; - private final LayoutInflater mInflater; - - // Provide a suitable constructor (depends on the kind of dataset) - public MenuAdapter(Context context, List dataset) { - mContext = context; - mInflater = LayoutInflater.from(context); + public MenuAdapter(List dataset, AdapterCallback callback) { mDataset = dataset; + this.callback = callback; } - // Provide a reference to the type of views you're using - public class ItemViewHolder extends WearableListView.ViewHolder { - private final TextView textView; + public class ItemViewHolder extends RecyclerView.ViewHolder { + protected final RelativeLayout menuContainer; + protected final TextView actionItem; + protected final ImageView actionIcon; public ItemViewHolder(View itemView) { super(itemView); - // find the text view within the custom item's layout - textView = itemView.findViewById(R.id.actionitem); + menuContainer = itemView.findViewById(R.id.menu_container); + actionItem = itemView.findViewById(R.id.menuItemText); + actionIcon = itemView.findViewById(R.id.menuItemIcon); } } - // Create new views for list items - // (invoked by the WearableListView's layout manager) @Override - public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, - int viewType) { - // Inflate our custom layout for list items - WearableListView.ViewHolder viewHolder = new WearableListView.ViewHolder(new MenuItemView(mContext)); - return viewHolder; + public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false); + ItemViewHolder recyclerViewHolder = new ItemViewHolder(view); + + return recyclerViewHolder; } - // Replace the contents of a list item - // Instead of creating new views, the list tries to recycle existing ones - // (invoked by the WearableListView's layout manager) @Override - public void onBindViewHolder(WearableListView.ViewHolder holder, - int position) { - // retrieve the text view - MenuItemView menuItemView = (MenuItemView) holder.itemView; - final MenuElement item = mDataset.get(position); - TextView textView = menuItemView.findViewById(R.id.actionitem); - textView.setText(item.actionitem); - - final ImageView imageView = menuItemView.findViewById(R.id.actionicon); - imageView.setImageResource(item.actionicon); - - // replace list item's metadata - holder.itemView.setTag(item.actionitem); + public void onBindViewHolder(ItemViewHolder holder, final int position) { + MenuItem item = mDataset.get(position); + holder.actionItem.setText(item.actionItem); + holder.actionIcon.setImageResource(item.actionIcon); + holder.itemView.setTag(item.actionItem); + holder.menuContainer.setOnClickListener(v -> { + callback.onItemClicked(holder); + }); } - // Return the size of your dataset - // (invoked by the WearableListView's layout manager) @Override public int getItemCount() { return mDataset.size(); } } - public final class MenuItemView extends FrameLayout implements WearableListView.OnCenterProximityListener { - - final ImageView image; - final TextView text; - final float scale = 0.8f; - final float alpha = 0.8f; - - public MenuItemView(Context context) { - super(context); - View.inflate(context, R.layout.list_item, this); - image = findViewById(R.id.actionicon); - text = findViewById(R.id.actionitem); - image.setScaleX(scale); - image.setScaleX(scale); - image.setAlpha(alpha); - text.setScaleX(scale); - text.setScaleX(scale); - text.setAlpha(alpha); - } - - @Override - public void onCenterPosition(boolean b) { - // Animation to be ran when the view becomes the centered one - image.animate().scaleX(1f).scaleY(1f).alpha(1); - text.animate().scaleX(1f).scaleY(1f).alpha(1); - } - - @Override - public void onNonCenterPosition(boolean b) { - //Animation to be ran when the view is not the centered one anymore - image.animate().scaleX(scale).scaleY(scale).alpha(alpha); - text.animate().scaleX(scale).scaleY(scale).alpha(alpha); + protected class MenuItem { + public MenuItem(int actionIcon, String actionItem) { + this.actionIcon = actionIcon; + this.actionItem = actionItem; } + public int actionIcon; + public String actionItem; } - protected class MenuElement { - public MenuElement(int actionicon, String actionitem) { - this.actionicon = actionicon; - this.actionitem = actionitem; + public class CustomScrollingLayoutCallback extends WearableLinearLayoutManager.LayoutCallback { + // How much should we scale the icon at most. + private static final float MAX_ICON_PROGRESS = 0.65f; + private float progressToCenter; + + @Override + public void onLayoutFinished(View child, RecyclerView parent) { + // Figure out % progress from top to bottom + float centerOffset = ((float) child.getHeight() / 2.0f) / (float) parent.getHeight(); + float yRelativeToCenterOffset = (child.getY() / parent.getHeight()) + centerOffset; + + // Normalize for center + progressToCenter = Math.abs(0.5f - yRelativeToCenterOffset); + // Adjust to the maximum scale + progressToCenter = Math.min(progressToCenter, MAX_ICON_PROGRESS); + + child.setScaleX(1 - progressToCenter); + child.setScaleY(1 - progressToCenter); } - public int actionicon; - public String actionitem; } } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java deleted file mode 100644 index d135536e22..0000000000 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java +++ /dev/null @@ -1,54 +0,0 @@ -package info.nightscout.androidaps.interaction.utils; - -import android.content.Context; -import android.support.wearable.view.WearableListView; -import android.util.AttributeSet; -import android.widget.LinearLayout; -import android.widget.TextView; - -import info.nightscout.androidaps.R; - -/** - * Created by adrian on 08/02/17. - */ - -public class WearableListItemLayout extends LinearLayout - implements WearableListView.OnCenterProximityListener { - - //private ImageView mCircle; - private TextView mName; - - private final float mFadedTextAlpha; - - public WearableListItemLayout(Context context) { - this(context, null); - } - - public WearableListItemLayout(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public WearableListItemLayout(Context context, AttributeSet attrs, - int defStyle) { - super(context, attrs, defStyle); - - mFadedTextAlpha = 40 / 100f; - } - - // Get references to the icon and text in the item layout definition - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - mName = findViewById(R.id.actionitem); - } - - @Override - public void onCenterPosition(boolean animate) { - mName.setAlpha(1f); - } - - @Override - public void onNonCenterPosition(boolean animate) { - mName.setAlpha(mFadedTextAlpha); - } -} diff --git a/wear/src/main/res/drawable/ic_bolus.xml b/wear/src/main/res/drawable/ic_bolus.xml new file mode 100644 index 0000000000..1daf871f0c --- /dev/null +++ b/wear/src/main/res/drawable/ic_bolus.xml @@ -0,0 +1,13 @@ + + + + diff --git a/wear/src/main/res/drawable/ic_calculator.xml b/wear/src/main/res/drawable/ic_calculator.xml index 2538ed034b..a147eaac56 100644 --- a/wear/src/main/res/drawable/ic_calculator.xml +++ b/wear/src/main/res/drawable/ic_calculator.xml @@ -1,14 +1,16 @@ - - - - - - - - + android:viewportHeight="30" + android:viewportWidth="30"> + + + + + + + + diff --git a/wear/src/main/res/drawable/ic_canula.xml b/wear/src/main/res/drawable/ic_canula.xml index 8d20fa6864..29e1e43d9b 100644 --- a/wear/src/main/res/drawable/ic_canula.xml +++ b/wear/src/main/res/drawable/ic_canula.xml @@ -1,9 +1,12 @@ - + android:height="48dp" + android:width="48dp" + android:viewportHeight="30" + android:viewportWidth="30"> + + diff --git a/wear/src/main/res/drawable/ic_e_carbs.xml b/wear/src/main/res/drawable/ic_e_carbs.xml new file mode 100644 index 0000000000..047623e21e --- /dev/null +++ b/wear/src/main/res/drawable/ic_e_carbs.xml @@ -0,0 +1,13 @@ + + + + diff --git a/wear/src/main/res/drawable/ic_loop_closed.xml b/wear/src/main/res/drawable/ic_loop_closed.xml new file mode 100644 index 0000000000..68d6690445 --- /dev/null +++ b/wear/src/main/res/drawable/ic_loop_closed.xml @@ -0,0 +1,12 @@ + + + + diff --git a/wear/src/main/res/drawable/ic_settings.xml b/wear/src/main/res/drawable/ic_settings.xml index b833ab6c7c..30858cc88a 100644 --- a/wear/src/main/res/drawable/ic_settings.xml +++ b/wear/src/main/res/drawable/ic_settings.xml @@ -1,9 +1,12 @@ + android:height="48dp" + android:width="48dp" + android:viewportHeight="30" + android:viewportWidth="30"> + + android:pathData="M 22.14 15.94 c 0.04 -0.3 0.06 -0.61 0.06 -0.94 c 0 -0.32 -0.02 -0.64 -0.07 -0.94 l 2.03 -1.58 c 0.18 -0.14 0.23 -0.41 0.12 -0.61 l -1.92 -3.32 c -0.12 -0.22 -0.37 -0.29 -0.59 -0.22 l -2.39 0.96 c -0.5 -0.38 -1.03 -0.7 -1.62 -0.94 L 17.4 5.81 c -0.04 -0.24 -0.24 -0.41 -0.48 -0.41 h -3.84 c -0.24 0 -0.43 0.17 -0.47 0.41 L 12.25 8.35 C 11.66 8.59 11.12 8.92 10.63 9.29 L 8.24 8.33 c -0.22 -0.08 -0.47 0 -0.59 0.22 L 5.74 11.87 C 5.62 12.08 5.66 12.34 5.86 12.48 l 2.03 1.58 C 7.84 14.36 7.8 14.69 7.8 15 s 0.02 0.64 0.07 0.94 l -2.03 1.58 c -0.18 0.14 -0.23 0.41 -0.12 0.61 l 1.92 3.32 c 0.12 0.22 0.37 0.29 0.59 0.22 l 2.39 -0.96 c 0.5 0.38 1.03 0.7 1.62 0.94 l 0.36 2.54 c 0.05 0.24 0.24 0.41 0.48 0.41 h 3.84 c 0.24 0 0.44 -0.17 0.47 -0.41 l 0.36 -2.54 c 0.59 -0.24 1.13 -0.56 1.62 -0.94 l 2.39 0.96 c 0.22 0.08 0.47 0 0.59 -0.22 l 1.92 -3.32 c 0.12 -0.22 0.07 -0.47 -0.12 -0.61 L 22.14 15.94 z M 15 18.6 c -1.98 0 -3.6 -1.62 -3.6 -3.6 s 1.62 -3.6 3.6 -3.6 s 3.6 1.62 3.6 3.6 S 16.98 18.6 15 18.6 z"/> diff --git a/wear/src/main/res/drawable/ic_sync.xml b/wear/src/main/res/drawable/ic_sync.xml index 749430d0b6..5eacdb9105 100644 --- a/wear/src/main/res/drawable/ic_sync.xml +++ b/wear/src/main/res/drawable/ic_sync.xml @@ -1,9 +1,12 @@ + android:height="48dp" + android:width="48dp" + android:viewportHeight="30" + android:viewportWidth="30"> + + android:pathData="m 16 10.101 l 0.01 0.001 a 4.978 4.978 0 0 1 2.526 1.362 a 5.005 5.005 0 0 1 1.363 2.528 a 5.061 5.061 0 0 1 -0.001 2.016 a 4.976 4.976 0 0 1 -1.363 2.527 l 1.414 1.414 a 7.014 7.014 0 0 0 1.908 -3.54 a 6.98 6.98 0 0 0 0 -2.819 a 6.957 6.957 0 0 0 -1.907 -3.539 a 6.97 6.97 0 0 0 -2.223 -1.5 a 6.921 6.921 0 0 0 -1.315 -0.408 c -0.137 -0.028 -0.275 -0.043 -0.412 -0.063 V 5 L 12 9 l 4 4 V 10.101 z m -7.45 7.623 c 0.174 0.412 0.392 0.812 0.646 1.19 c 0.249 0.37 0.537 0.718 0.854 1.034 a 7.036 7.036 0 0 0 2.224 1.501 c 0.425 0.18 0.868 0.317 1.315 0.408 c 0.167 0.034 0.338 0.056 0.508 0.078 v 2.944 l 4 -4 l -4 -4 v 3.03 c -0.035 -0.006 -0.072 -0.003 -0.107 -0.011 a 4.978 4.978 0 0 1 -2.526 -1.362 a 4.994 4.994 0 0 1 0.001 -7.071 L 10.051 10.05 a 7.01 7.01 0 0 0 -1.5 2.224 A 6.974 6.974 0 0 0 8 15 a 6.997 6.997 0 0 0 0.55 2.724 z"/> diff --git a/wear/src/main/res/drawable/ic_tdd.xml b/wear/src/main/res/drawable/ic_tdd.xml new file mode 100644 index 0000000000..02d751c7bb --- /dev/null +++ b/wear/src/main/res/drawable/ic_tdd.xml @@ -0,0 +1,13 @@ + + + + diff --git a/wear/src/main/res/drawable/ic_temptarget.xml b/wear/src/main/res/drawable/ic_temptarget.xml index 5a1ed84c65..d1078f4d92 100644 --- a/wear/src/main/res/drawable/ic_temptarget.xml +++ b/wear/src/main/res/drawable/ic_temptarget.xml @@ -1,9 +1,12 @@ - + android:height="48dp" + android:width="48dp" + android:viewportHeight="30" + android:viewportWidth="30"> + + diff --git a/wear/src/main/res/drawable/menu_item_layout_bg.xml b/wear/src/main/res/drawable/menu_item_layout_bg.xml new file mode 100644 index 0000000000..9421db0f25 --- /dev/null +++ b/wear/src/main/res/drawable/menu_item_layout_bg.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/wear/src/main/res/layout-v26/list_item.xml b/wear/src/main/res/layout-v26/list_item.xml index aee08c036b..b40327f8a2 100644 --- a/wear/src/main/res/layout-v26/list_item.xml +++ b/wear/src/main/res/layout-v26/list_item.xml @@ -1,30 +1,37 @@ - + android:layout_height="wrap_content" + android:paddingBottom="8dp" + android:paddingTop="8dp" + android:background="@drawable/menu_item_layout_bg"> + + android:id="@+id/menuItemIcon" + android:layout_width="35dp" + android:layout_height="35dp" + android:layout_alignParentStart="true" + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:layout_marginStart="10dp" + android:src="@drawable/circle" /> + - + android:textStyle="bold" /> + diff --git a/wear/src/main/res/layout/actions_list_activity.xml b/wear/src/main/res/layout/actions_list_activity.xml index d9086a813c..c989dbbf33 100644 --- a/wear/src/main/res/layout/actions_list_activity.xml +++ b/wear/src/main/res/layout/actions_list_activity.xml @@ -1,22 +1,27 @@ - + - + android:layout_height="match_parent" + android:scrollbars="vertical" > + + - - - - - + + diff --git a/wear/src/main/res/layout/grid_layout.xml b/wear/src/main/res/layout/grid_layout.xml index 02731fd35e..7d0c41d95d 100644 --- a/wear/src/main/res/layout/grid_layout.xml +++ b/wear/src/main/res/layout/grid_layout.xml @@ -6,7 +6,7 @@ diff --git a/wear/src/main/res/layout/list_item.xml b/wear/src/main/res/layout/list_item.xml index 62bcf96129..538ff220f6 100644 --- a/wear/src/main/res/layout/list_item.xml +++ b/wear/src/main/res/layout/list_item.xml @@ -1,25 +1,33 @@ - - - - + android:layout_height="wrap_content" + android:paddingBottom="8dp" + android:paddingTop="8dp" + android:background="@drawable/menu_item_layout_bg"> + + + + +