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"/>