include bigchart watchface for very small watches
This commit is contained in:
parent
88ea215f66
commit
6a1b777bc3
|
@ -13,6 +13,7 @@ import android.graphics.Paint;
|
|||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Shader;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
|
@ -22,6 +23,7 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||
import android.support.wearable.view.WatchViewStub;
|
||||
import android.support.wearable.watchface.WatchFaceStyle;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -30,6 +32,7 @@ import android.view.WindowInsets;
|
|||
import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.wearable.DataMap;
|
||||
import com.ustwo.clockwise.wearable.WatchFace;
|
||||
|
@ -40,6 +43,7 @@ import com.ustwo.clockwise.common.WatchShape;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.data.BasalWatchData;
|
||||
import info.nightscout.androidaps.data.BgWatchData;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
|
@ -53,6 +57,7 @@ import lecho.lib.hellocharts.view.LineChartView;
|
|||
*/
|
||||
public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public final static IntentFilter INTENT_FILTER;
|
||||
public static final int SCREENSIZE_SMALL = 280;
|
||||
public TextView mTime, mSgv, mTimestamp, mDelta, mAvgDelta;
|
||||
public RelativeLayout mRelativeLayout;
|
||||
public long sgvLevel = 0;
|
||||
|
@ -108,7 +113,13 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
|||
.getDefaultSharedPreferences(this);
|
||||
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
layoutView = inflater.inflate(R.layout.activity_bigchart, null);
|
||||
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||
if(metrics.widthPixels < SCREENSIZE_SMALL || metrics.widthPixels < SCREENSIZE_SMALL){
|
||||
layoutView = inflater.inflate(R.layout.activity_bigchart_small, null);
|
||||
} else {
|
||||
layoutView = inflater.inflate(R.layout.activity_bigchart, null);
|
||||
|
||||
}
|
||||
performViewSetup();
|
||||
}
|
||||
|
||||
|
|
12
wear/src/main/res/layout/activity_bigchart_small.xml
Normal file
12
wear/src/main/res/layout/activity_bigchart_small.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.wearable.view.WatchViewStub
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/watch_view_stub"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:rectLayout="@layout/rect_activity_bigchart_small"
|
||||
app:roundLayout="@layout/round_activity_bigchart_small"
|
||||
tools:context=".watchfaces.Home"
|
||||
tools:deviceIds="wear"/>
|
108
wear/src/main/res/layout/rect_activity_bigchart_small.xml
Normal file
108
wear/src/main/res/layout/rect_activity_bigchart_small.xml
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
|
||||
android:background="@color/black"
|
||||
android:id="@+id/main_layout">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="-5dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="5dp"
|
||||
android:textAlignment="center">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/delta"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|center_horizontal|center"
|
||||
android:layout_marginRight="5dp"
|
||||
android:gravity="center_horizontal|bottom"
|
||||
android:text="---"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sgv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="---"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="34sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/avgdelta"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|center_horizontal|center"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:gravity="center_horizontal|bottom"
|
||||
android:text="---"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aps_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="E xU/h IOB: x (x+x)"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<lecho.lib.hellocharts.view.LineChartView
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/watch_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginRight="6dp"
|
||||
android:text="12:00"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="34sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timestamp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|center_horizontal|center"
|
||||
android:text="--'"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
108
wear/src/main/res/layout/round_activity_bigchart_small.xml
Normal file
108
wear/src/main/res/layout/round_activity_bigchart_small.xml
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" tools:context=".watchfaces.Home" tools:deviceIds="wear_square"
|
||||
android:background="@color/black"
|
||||
android:id="@+id/main_layout">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:paddingTop="5dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="-5dp"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/delta"
|
||||
android:textSize="30sp"
|
||||
android:text="---"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="center_horizontal|bottom"
|
||||
android:layout_marginRight="5dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sgv"
|
||||
android:textSize="41sp"
|
||||
android:text="---"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/avgdelta"
|
||||
android:textSize="30sp"
|
||||
android:text="---"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="bottom"
|
||||
android:gravity="center_horizontal|bottom"
|
||||
android:layout_marginLeft="5dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<lecho.lib.hellocharts.view.LineChartView
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aps_status"
|
||||
android:textSize="18sp"
|
||||
android:text="E xU/h IOB: x (x+x)"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:gravity="center_horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/watch_time"
|
||||
android:textSize="35sp"
|
||||
android:text="12:00"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginRight="6dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/timestamp"
|
||||
android:textSize="26sp"
|
||||
android:text="-- '"
|
||||
android:layout_width="wrap_content"
|
||||
android:textAlignment="center"
|
||||
android:textColor="#FFFFFF"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in a new issue