wear menu mockup
This commit is contained in:
parent
d2d0d4b51a
commit
6556ddda37
11 changed files with 256 additions and 15 deletions
|
@ -86,6 +86,15 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="info.nightscout.androidaps.actions.ActionsListActivity"
|
||||||
|
android:label="@string/label_actions_activity" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
package info.nightscout.androidaps.actions;
|
||||||
|
|
||||||
|
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.TextView;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 08/02/17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ActionsListActivity extends Activity
|
||||||
|
implements WearableListView.ClickListener {
|
||||||
|
|
||||||
|
// Sample dataset for the list
|
||||||
|
String[] elements = { "Temp Target", "Bolus", "Settings"};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.actions_list_activity);
|
||||||
|
|
||||||
|
// Get the list component from the layout of the activity
|
||||||
|
WearableListView listView =
|
||||||
|
(WearableListView) findViewById(R.id.wearable_list);
|
||||||
|
|
||||||
|
// Assign an adapter to the list
|
||||||
|
listView.setAdapter(new Adapter(this, elements));
|
||||||
|
|
||||||
|
// Set a click listener
|
||||||
|
listView.setClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// WearableListView click listener
|
||||||
|
@Override
|
||||||
|
public void onClick(WearableListView.ViewHolder v) {
|
||||||
|
Integer tag = (Integer) v.itemView.getTag();
|
||||||
|
// use this data to complete some action ...
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTopEmptyRegionClick() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static final class Adapter extends WearableListView.Adapter {
|
||||||
|
private String[] 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) {
|
||||||
|
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 {
|
||||||
|
private TextView textView;
|
||||||
|
public ItemViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
// find the text view within the custom item's layout
|
||||||
|
textView = (TextView) itemView.findViewById(R.id.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
return new ItemViewHolder(mInflater.inflate(R.layout.list_item, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
ItemViewHolder itemHolder = (ItemViewHolder) holder;
|
||||||
|
TextView view = itemHolder.textView;
|
||||||
|
// replace text contents
|
||||||
|
view.setText(mDataset[position]);
|
||||||
|
// replace list item's metadata
|
||||||
|
holder.itemView.setTag(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the size of your dataset
|
||||||
|
// (invoked by the WearableListView's layout manager)
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mDataset.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
package info.nightscout.androidaps.actions;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
|
import android.support.wearable.view.WearableListView;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
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;
|
||||||
|
private final int mFadedCircleColor;
|
||||||
|
private final int mChosenCircleColor;
|
||||||
|
|
||||||
|
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;
|
||||||
|
mFadedCircleColor = getResources().getColor(R.color.grey);
|
||||||
|
mChosenCircleColor = getResources().getColor(R.color.blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get references to the icon and text in the item layout definition
|
||||||
|
@Override
|
||||||
|
protected void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
|
// These are defined in the layout file for list items
|
||||||
|
// (see next section)
|
||||||
|
mCircle = (ImageView) findViewById(R.id.circle);
|
||||||
|
mName = (TextView) findViewById(R.id.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCenterPosition(boolean animate) {
|
||||||
|
mName.setAlpha(1f);
|
||||||
|
((GradientDrawable) mCircle.getDrawable()).setColor(mChosenCircleColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNonCenterPosition(boolean animate) {
|
||||||
|
((GradientDrawable) mCircle.getDrawable()).setColor(mFadedCircleColor);
|
||||||
|
mName.setAlpha(mFadedTextAlpha);
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
BIN
wear/src/main/res/drawable/nslogo_background.png
Normal file
BIN
wear/src/main/res/drawable/nslogo_background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
6
wear/src/main/res/drawable/wl_circle.xml
Normal file
6
wear/src/main/res/drawable/wl_circle.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<solid android:color="@color/wl_gray"/>
|
||||||
|
</shape>
|
21
wear/src/main/res/layout/actions_list_activity.xml
Normal file
21
wear/src/main/res/layout/actions_list_activity.xml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<android.support.wearable.view.BoxInsetLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:background="@drawable/nslogo_background"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_width="match_parent">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/frame_layout"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
app:layout_box="left|bottom|right">
|
||||||
|
|
||||||
|
<android.support.wearable.view.WearableListView
|
||||||
|
android:id="@+id/wearable_list"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_width="match_parent">
|
||||||
|
</android.support.wearable.view.WearableListView>
|
||||||
|
</FrameLayout>
|
||||||
|
</android.support.wearable.view.BoxInsetLayout>
|
||||||
|
|
23
wear/src/main/res/layout/list_item.xml
Normal file
23
wear/src/main/res/layout/list_item.xml
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<info.nightscout.androidaps.actions.WearableListItemLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="80dp">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/circle"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:src="@drawable/wl_circle"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/name"
|
||||||
|
android:gravity="center_vertical|left"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fontFamily="sans-serif-condensed-light"
|
||||||
|
android:lineSpacingExtra="-4sp"
|
||||||
|
android:textColor="@color/dark_statusView"
|
||||||
|
android:textSize="32sp"/>
|
||||||
|
</info.nightscout.androidaps.actions.WearableListItemLayout>
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
|
<color name="wl_blue">#2878ff</color>
|
||||||
|
<color name="wl_gray">#c1c1c1</color>
|
||||||
|
<color name="text_color">#434343</color>
|
||||||
|
|
||||||
<!-- light colors -->
|
<!-- light colors -->
|
||||||
<color name="light_bigchart_time">@color/black</color>
|
<color name="light_bigchart_time">@color/black</color>
|
||||||
<color name="light_bigchart_status">@color/black</color>
|
<color name="light_bigchart_status">@color/black</color>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="app_name">AAPS Prefs.</string>
|
<string name="app_name">AAPS Prefs.</string>
|
||||||
|
<string name="label_actions_activity">AAPS Actions</string>
|
||||||
|
|
||||||
<string-array name="chart_timeframe">
|
<string-array name="chart_timeframe">
|
||||||
<item>1 hour</item>
|
<item>1 hour</item>
|
||||||
|
|
|
@ -43,13 +43,6 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/jni" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/jni" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/rs" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/rs" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/shaders" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/fullDebug/shaders" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/full/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/res" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/res" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/resources" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/resources" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/assets" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/assets" type="java-test-resource" />
|
||||||
|
@ -58,6 +51,13 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/jni" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/jni" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/rs" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/rs" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/shaders" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/testFullDebug/shaders" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/full/debug" isTestSource="true" generated="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/full/debug" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/full/debug" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/full/res" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/full/res" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/full/resources" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/full/resources" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/full/assets" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/full/assets" type="java-resource" />
|
||||||
|
@ -66,14 +66,6 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/full/jni" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/full/jni" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/full/rs" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/full/rs" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/full/shaders" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/full/shaders" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/res" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/assets" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/aidl" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/jni" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/rs" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/shaders" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/res" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/res" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/resources" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/resources" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/assets" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/assets" type="java-test-resource" />
|
||||||
|
@ -82,6 +74,14 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/jni" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/jni" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/rs" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/rs" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/shaders" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/shaders" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/res" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/resources" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/assets" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/aidl" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/jni" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/rs" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/shaders" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||||
|
|
Loading…
Reference in a new issue