wear better bolus layout
This commit is contained in:
parent
cb2319d1f2
commit
ef2654d3eb
5 changed files with 166 additions and 1 deletions
|
@ -121,6 +121,14 @@
|
|||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".actions.bolus.GridActivity"
|
||||
android:label="GridTest">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
19
wear/src/main/res/layout/grid_layout.xml
Normal file
19
wear/src/main/res/layout/grid_layout.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<android.support.wearable.view.GridViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:keepScreenOn="true" />
|
||||
|
||||
<android.support.wearable.view.DotsPageIndicator
|
||||
android:id="@+id/page_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|bottom">
|
||||
</android.support.wearable.view.DotsPageIndicator>
|
||||
|
||||
</FrameLayout>
|
61
wear/src/main/res/layout/grid_view_pager_item.xml
Normal file
61
wear/src/main/res/layout/grid_view_pager_item.xml
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/treatments_newtreatment_insulinamount_minus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_minus"
|
||||
android:tint="#ffffff" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center">
|
||||
<EditText
|
||||
android:id="@+id/treatments_newtreatment_insulinamount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:inputType="numberDecimal"
|
||||
android:minWidth="50dp"
|
||||
android:padding="10dp"
|
||||
android:text="112"
|
||||
android:cursorVisible="false"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="label"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center" />
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:id="@+id/treatments_newtreatment_insulinamount_plus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/circle"
|
||||
android:backgroundTint="#ffffff"
|
||||
android:src="@drawable/ic_action_add"
|
||||
android:tint="#ffffff" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
Loading…
Reference in a new issue