diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index 34e1156ae7..d2a06c5c12 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -121,6 +121,14 @@ + + + + + + \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java index 49bf50b726..a1cdd49744 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java @@ -6,6 +6,7 @@ import android.content.Intent; import info.nightscout.androidaps.ListenerService; import info.nightscout.androidaps.NWPreferences; import info.nightscout.androidaps.actions.bolus.BolusActivity; +import info.nightscout.androidaps.actions.bolus.GridActivity; /** * Created by adrian on 08/02/17. @@ -21,7 +22,7 @@ final class ActionsDefinitions { "Fillpreset 1", "Fillpreset 2", "Fillpreset 3", - "005"}; + "006"}; public static void doAction(int position, Context ctx) { @@ -52,6 +53,11 @@ final class ActionsDefinitions { case 6: ListenerService.initiateAction(ctx, "fillpreset 3"); break; + case 7: + intent = new Intent(ctx, GridActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + ctx.startActivity(intent); + break; } } diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java new file mode 100644 index 0000000000..1e50854683 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java @@ -0,0 +1,71 @@ +package info.nightscout.androidaps.actions.bolus; + + +import android.app.Activity; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Color; +import android.os.Bundle; +import android.support.wearable.view.DotsPageIndicator; +import android.support.wearable.view.GridPagerAdapter; +import android.support.wearable.view.GridViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import info.nightscout.androidaps.R; + +/** + * Created by adrian on 09/02/17. + */ + + +public class GridActivity extends Activity { + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.grid_layout); + final Resources res = getResources(); + final GridViewPager pager = (GridViewPager) findViewById(R.id.pager); + + pager.setAdapter(new MyGridViewPagerAdapter()); + DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator); + dotsPageIndicator.setPager(pager); + } + + private class MyGridViewPagerAdapter extends GridPagerAdapter { + @Override + public int getColumnCount(int arg0) { + return 3; + } + + @Override + public int getRowCount() { + return 1; + } + + @Override + public Object instantiateItem(ViewGroup container, int row, int col) { + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.grid_view_pager_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("label: " + col); + 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; + } + } +} \ No newline at end of file diff --git a/wear/src/main/res/layout/grid_layout.xml b/wear/src/main/res/layout/grid_layout.xml new file mode 100644 index 0000000000..2b37f71cae --- /dev/null +++ b/wear/src/main/res/layout/grid_layout.xml @@ -0,0 +1,19 @@ + + + + + + + + + \ No newline at end of file diff --git a/wear/src/main/res/layout/grid_view_pager_item.xml b/wear/src/main/res/layout/grid_view_pager_item.xml new file mode 100644 index 0000000000..2979dc00cb --- /dev/null +++ b/wear/src/main/res/layout/grid_view_pager_item.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + +