Inclusion of the new watch face "AAPSv2" which: 1) has larger text, 2) shows COB, 3) allows to choose between showing phone battery level (AAPS) or rig battery level (OpenAPS) via watch Settings menu.

Most changes are either minor or are completely new files. The largest changes were to the WatchUpdaterService.java, which required several new blocks of code in order to expose COB, IOB, and current temp basal independently of the main status string.
This commit is contained in:
Andrew Warrington 2017-11-05 21:41:50 +01:00
parent 5ad564e0e3
commit d70860bd97
9 changed files with 918 additions and 4 deletions

View file

@ -37,7 +37,10 @@ import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Wear.ActionStringHandler;
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
@ -242,9 +245,39 @@ public class WatchUpdaterService extends WearableListenerService implements
} else if (lastBG.value < lowLine) {
sgvLevel = -1;
}
DataMap dataMap = new DataMap();
int battery = getBatteryLevel(getApplicationContext());
//IOB
MainApp.getConfigBuilder().updateTotalIOBTreatments();
MainApp.getConfigBuilder().updateTotalIOBTempBasals();
final IobTotal bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments().round();
final IobTotal basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals().round();
String iobText = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
if (mPrefs.getBoolean("wear_detailediob", true)) {
iobText = DecimalFormatter.to2Decimal(bolusIob.iob) + "|"
+ DecimalFormatter.to2Decimal(basalIob.basaliob);
}
//COB
String cobText = "0g";
AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(System.currentTimeMillis());
if (autosensData != null) {
cobText = (int) autosensData.cob + "g";
}
//battery
int phoneBattery = getBatteryLevel(getApplicationContext());
String rigBattery = NSDeviceStatus.getInstance().getUploaderStatus().trim();
//Temp basal
String temp_basal = "-.--U/h";
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
if (activeTemp != null) {
temp_basal= activeTemp.toStringShort();
}
DataMap dataMap = new DataMap();
dataMap.putString("sgvString", lastBG.valueToUnitsToString(units));
dataMap.putDouble("timestamp", lastBG.date);
if (glucoseStatus == null) {
@ -256,12 +289,16 @@ public class WatchUpdaterService extends WearableListenerService implements
dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units));
dataMap.putString("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units));
}
dataMap.putString("battery", "" + battery);
dataMap.putLong("sgvLevel", sgvLevel);
dataMap.putInt("batteryLevel", (battery >= 30) ? 1 : 0);
dataMap.putString("battery", "" + phoneBattery);
dataMap.putString("rigBattery", rigBattery);
dataMap.putInt("batteryLevel", (phoneBattery >= 30) ? 1 : 0);
dataMap.putDouble("sgvDouble", lastBG.value);
dataMap.putDouble("high", highLine);
dataMap.putDouble("low", lowLine);
dataMap.putString("cob", "" + cobText);
dataMap.putString("iob", "" + iobText);
dataMap.putString("tempBasal", "" + temp_basal);
return dataMap;
}

View file

@ -34,6 +34,7 @@
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
<service
android:name=".watchfaces.NOChart"
android:allowEmbedded="true"
@ -52,6 +53,7 @@
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
<service
android:name=".watchfaces.Home"
android:allowEmbedded="true"
@ -70,6 +72,26 @@
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
<service
android:name=".watchfaces.Home2"
android:allowEmbedded="true"
android:label="AAPSv2"
android:permission="android.permission.BIND_WALLPAPER">
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/watch_face" />
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="@drawable/watchface_graph_2" />
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
<service
android:name=".watchfaces.LargeHome"
android:allowEmbedded="true"

View file

@ -0,0 +1,418 @@
package info.nightscout.androidaps.watchfaces;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.support.wearable.view.WatchViewStub;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.android.gms.wearable.DataMap;
import com.ustwo.clockwise.common.WatchMode;
import com.ustwo.clockwise.wearable.WatchFace;
import com.ustwo.clockwise.common.WatchFaceTime;
import com.ustwo.clockwise.common.WatchShape;
import java.util.ArrayList;
import java.util.Date;
import info.nightscout.androidaps.data.BasalWatchData;
import info.nightscout.androidaps.data.BgWatchData;
import info.nightscout.androidaps.data.ListenerService;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.TempWatchData;
import lecho.lib.hellocharts.view.LineChartView;
/**
* Created by emmablack on 12/29/14.
* Updated by andrew-warrington on 11/04/17.
*/
public abstract class BaseWatchFace2 extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
public final static IntentFilter INTENT_FILTER;
public static final long[] vibratePattern = {0,400,300,400,300,400};
public TextView mTime, mSgv, mDirection, mTimestamp, mUploaderBattery, mDelta, mStatus, mIOB, mCOB;
public RelativeLayout mRelativeLayout;
public LinearLayout mLinearLayout, mLinearLayout2;
public long sgvLevel = 0;
public int batteryLevel = 1;
public int ageLevel = 1;
public int highColor = Color.YELLOW;
public int lowColor = Color.RED;
public int midColor = Color.WHITE;
public int gridColor = Color.WHITE;
public int basalBackgroundColor = Color.BLUE;
public int basalCenterColor = Color.BLUE;
public boolean lowResMode = false;
public int pointSize = 2;
public boolean layoutSet = false;
//public int missed_readings_alert_id = 818;
public BgGraphBuilder bgGraphBuilder;
public LineChartView chart;
public double datetime;
public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
public PowerManager.WakeLock wakeLock;
// related endTime manual layout
public View layoutView;
private final Point displaySize = new Point();
private int specW, specH;
private LocalBroadcastManager localBroadcastManager;
private MessageReceiver messageReceiver;
protected SharedPreferences sharedPrefs;
private String avgDelta = "";
private String delta = "";
private String sgvString = "--";
//private String batteryString = "--%"; --- replaced with local variable
//private String IOB = "--U"; --- not used
//private String COB = "--g"; --- not used
@Override
public void onCreate() {
super.onCreate();
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
display.getSize(displaySize);
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clock");
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x,
View.MeasureSpec.EXACTLY);
specH = View.MeasureSpec.makeMeasureSpec(displaySize.y,
View.MeasureSpec.EXACTLY);
sharedPrefs = PreferenceManager
.getDefaultSharedPreferences(this);
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
}
@Override
protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) {
super.onLayout(shape, screenBounds, screenInsets);
layoutView.onApplyWindowInsets(screenInsets);
}
public void performViewSetup() {
final WatchViewStub stub = (WatchViewStub) layoutView.findViewById(R.id.watch_view_stub);
IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
messageReceiver = new MessageReceiver();
localBroadcastManager = LocalBroadcastManager.getInstance(this);
localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(WatchViewStub stub) {
mTime = (TextView) stub.findViewById(R.id.watch_time);
mSgv = (TextView) stub.findViewById(R.id.sgv);
mDirection = (TextView) stub.findViewById(R.id.direction);
mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
mIOB = (TextView) stub.findViewById(R.id.iobView);
mCOB = (TextView) stub.findViewById(R.id.cobView);
mStatus = (TextView) stub.findViewById(R.id.tmpBasal);
mUploaderBattery = (TextView) stub.findViewById(R.id.uploader_battery);
mDelta = (TextView) stub.findViewById(R.id.delta);
mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
mLinearLayout = (LinearLayout) stub.findViewById(R.id.secondary_layout);
mLinearLayout2 = (LinearLayout) stub.findViewById(R.id.tertiary_layout);
chart = (LineChartView) stub.findViewById(R.id.chart);
layoutSet = true;
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
}
});
ListenerService.requestData(this);
wakeLock.acquire(50);
}
public int ageLevel() {
if(timeSince() <= (1000 * 60 * 12)) {
return 1;
} else {
return 0;
}
}
public double timeSince() {
return System.currentTimeMillis() - datetime;
}
public String readingAge(boolean shortString) {
if (datetime == 0) { return "--' ago"; }
int minutesAgo = (int) Math.floor(timeSince()/(1000*60));
//if (minutesAgo == 1) {
// return minutesAgo + "' ago";
//}
return minutesAgo + "' ago";
}
@Override
public void onDestroy() {
if(localBroadcastManager != null && messageReceiver != null){
localBroadcastManager.unregisterReceiver(messageReceiver);}
if (sharedPrefs != null){
sharedPrefs.unregisterOnSharedPreferenceChangeListener(this);
}
super.onDestroy();
}
static {
INTENT_FILTER = new IntentFilter();
INTENT_FILTER.addAction(Intent.ACTION_TIME_TICK);
INTENT_FILTER.addAction(Intent.ACTION_TIMEZONE_CHANGED);
INTENT_FILTER.addAction(Intent.ACTION_TIME_CHANGED);
}
@Override
protected void onDraw(Canvas canvas) {
if(layoutSet) {
this.mRelativeLayout.draw(canvas);
Log.d("onDraw", "draw");
}
}
@Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
wakeLock.acquire(50);
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace2.this);
mTime.setText(timeFormat.format(System.currentTimeMillis()));
mTimestamp.setText(readingAge(true));
if(ageLevel()<=0) {
mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} else {
mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
missedReadingAlert();
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
}
}
public class MessageReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
//data
Bundle bundle = intent.getBundleExtra("data");
if (layoutSet && bundle != null) {
DataMap dataMap = DataMap.fromBundle(bundle);
wakeLock.acquire(50);
sgvLevel = dataMap.getLong("sgvLevel");
batteryLevel = dataMap.getInt("batteryLevel");
datetime = dataMap.getDouble("timestamp");
sgvString = dataMap.getString("sgvString");
mSgv.setText(dataMap.getString("sgvString"));
mIOB.setText(dataMap.getString("iob"));
mCOB.setText(dataMap.getString("cob"));
String batteryString;
if (Boolean.valueOf(sharedPrefs.getString("battery_choice","true"))) {
batteryString = dataMap.getString("battery") + "%";
} else {
batteryString = dataMap.getString("rigBattery");
}
mUploaderBattery.setText("" + batteryString);
if(ageLevel()<=0) {
mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} else {
mSgv.setPaintFlags(mSgv.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
}
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace2.this);
mTime.setText(timeFormat.format(System.currentTimeMillis()));
mDirection.setText(dataMap.getString("slopeArrow"));
avgDelta = dataMap.getString("avgDelta");
delta = dataMap.getString("delta");
mDelta.setText(delta);
boolean showAvgDelta = sharedPrefs.getBoolean("showAvgDelta", true);
if(showAvgDelta){
mDelta.append(" " + avgDelta);
}
if (mTimestamp != null && mStatus != null) {
mTimestamp.setText(readingAge(true));
mStatus.setVisibility(View.VISIBLE);
mStatus.setText("" + dataMap.getString("tempBasal"));
}
if (chart != null) {
addToWatchSet(dataMap);
setupCharts();
}
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
invalidate();
setColor();
}
//basals and temps
bundle = intent.getBundleExtra("basals");
if (layoutSet && bundle != null) {
DataMap dataMap = DataMap.fromBundle(bundle);
wakeLock.acquire(500);
loadBasalsAndTemps(dataMap);
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
invalidate();
setColor();
}
}
}
public void setColor() {
if(lowResMode){
setColorLowRes();
} else if (sharedPrefs.getBoolean("dark", true)) {
setColorDark();
} else {
setColorBright();
}
}
protected void onWatchModeChanged(WatchMode watchMode) {
if(lowResMode ^ isLowRes(watchMode)){ //if there was a change in lowResMode
lowResMode = isLowRes(watchMode);
setColor();
} else if (! sharedPrefs.getBoolean("dark", true)){
//in bright mode: different colours if active:
setColor();
}
}
private boolean isLowRes(WatchMode watchMode) {
return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN) || (watchMode == WatchMode.LOW_BIT_BURN_IN);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){
setColor();
if(layoutSet){
mRelativeLayout.measure(specW, specH);
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
mRelativeLayout.getMeasuredHeight());
}
invalidate();
}
protected abstract void setColorDark();
protected abstract void setColorBright();
protected abstract void setColorLowRes();
public void missedReadingAlert() {
int minutes_since = (int) Math.floor(timeSince()/(1000*60));
if(minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) {
ListenerService.requestData(this); // attempt endTime recover missing data
}
}
public void addToWatchSet(DataMap dataMap) {
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
bgDataList = new ArrayList<BgWatchData>();
for (DataMap entry : entries) {
double sgv = entry.getDouble("sgvDouble");
double high = entry.getDouble("high");
double low = entry.getDouble("low");
double timestamp = entry.getDouble("timestamp");
bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
}
} else {
double sgv = dataMap.getDouble("sgvDouble");
double high = dataMap.getDouble("high");
double low = dataMap.getDouble("low");
double timestamp = dataMap.getDouble("timestamp");
final int size = bgDataList.size();
if (size > 0) {
if (bgDataList.get(size - 1).timestamp == timestamp)
return; // Ignore duplicates.
}
bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
}
for (int i = 0; i < bgDataList.size(); i++) {
if (bgDataList.get(i).timestamp < (System.currentTimeMillis() - (1000 * 60 * 60 * 5))) {
bgDataList.remove(i); //Get rid of anything more than 5 hours old
break;
}
}
}
public void setupCharts() {
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
if (lowResMode) {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe);
} else {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe);
}
chart.setLineChartData(bgGraphBuilder.lineData());
chart.setViewportCalculationEnabled(true);
chart.setMaximumViewport(chart.getMaximumViewport());
} else {
ListenerService.requestData(this);
}
}
private void loadBasalsAndTemps(DataMap dataMap) {
ArrayList<DataMap> temps = dataMap.getDataMapArrayList("temps");
if (temps != null) {
tempWatchDataList = new ArrayList<>();
for (DataMap temp : temps) {
TempWatchData twd = new TempWatchData();
twd.startTime = temp.getLong("starttime");
twd.startBasal = temp.getDouble("startBasal");
twd.endTime = temp.getLong("endtime");
twd.endBasal = temp.getDouble("endbasal");
twd.amount = temp.getDouble("amount");
tempWatchDataList.add(twd);
}
}
ArrayList<DataMap> basals = dataMap.getDataMapArrayList("basals");
if (basals != null) {
basalWatchDataList = new ArrayList<>();
for (DataMap basal : basals) {
BasalWatchData bwd = new BasalWatchData();
bwd.startTime = basal.getLong("starttime");
bwd.endTime = basal.getLong("endtime");
bwd.amount = basal.getDouble("amount");
basalWatchDataList.add(bwd);
}
}
}
}

View file

@ -0,0 +1,180 @@
package info.nightscout.androidaps.watchfaces;
import android.content.Intent;
import android.graphics.Color;
import android.support.v4.content.ContextCompat;
import android.support.wearable.watchface.WatchFaceStyle;
import android.view.LayoutInflater;
import com.ustwo.clockwise.common.WatchMode;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
public class Home2 extends BaseWatchFace2 {
private long chartTapTime = 0;
private long sgvTapTime = 0;
@Override
public void onCreate() {
super.onCreate();
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
layoutView = inflater.inflate(R.layout.activity_home_2, null);
performViewSetup();
}
@Override
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
int extra = mSgv!=null?(mSgv.getRight() - mSgv.getLeft())/2:0;
if (tapType == TAP_TYPE_TAP&&
x >=chart.getLeft() &&
x <= chart.getRight()&&
y >= chart.getTop() &&
y <= chart.getBottom()){
if (eventTime - chartTapTime < 800){
changeChartTimeframe();
}
chartTapTime = eventTime;
} else if (tapType == TAP_TYPE_TAP&&
x + extra >=mSgv.getLeft() &&
x - extra <= mSgv.getRight()&&
y >= mSgv.getTop() &&
y <= mSgv.getBottom()){
if (eventTime - sgvTapTime < 800){
Intent intent = new Intent(this, MainMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
sgvTapTime = eventTime;
}
}
private void changeChartTimeframe() {
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
timeframe = (timeframe%5) + 1;
sharedPrefs.edit().putString("chart_timeframe", "" + timeframe).commit();
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build();
}
protected void setColorDark() {
mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView));
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
if (sgvLevel == 1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
} else if (sgvLevel == 0) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
} else if (sgvLevel == -1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
}
if (ageLevel == 1) {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
} else {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld));
}
if (batteryLevel == 1) {
mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBattery));
} else {
mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBatteryEmpty));
}
mStatus.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mStatus_home));
if (chart != null) {
highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor);
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor);
midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
gridColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor);
basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark);
basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light);
pointSize = 2;
setupCharts();
}
}
protected void setColorLowRes() {
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
// mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp));
if (chart != null) {
highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
gridColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor);
basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark_lowres);
basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light_lowres);
pointSize = 2;
setupCharts();
}
}
protected void setColorBright() {
if (getCurrentWatchMode() == WatchMode.INTERACTIVE) {
mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_stripe_background));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background));
if (sgvLevel == 1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
} else if (sgvLevel == 0) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
} else if (sgvLevel == -1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
}
if (ageLevel == 1) {
mTimestamp.setTextColor(Color.WHITE);
} else {
mTimestamp.setTextColor(Color.RED);
}
if (batteryLevel == 1) {
mUploaderBattery.setTextColor(Color.WHITE);
} else {
mUploaderBattery.setTextColor(Color.RED);
}
mStatus.setTextColor(Color.WHITE);
mTime.setTextColor(Color.BLACK);
if (chart != null) {
highColor = ContextCompat.getColor(getApplicationContext(), R.color.light_highColor);
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor);
midColor = ContextCompat.getColor(getApplicationContext(), R.color.light_midColor);
gridColor = ContextCompat.getColor(getApplicationContext(), R.color.light_gridColor);
basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light);
basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark);
pointSize = 2;
setupCharts();
}
} else {
setColorDark();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View 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_home"
app:roundLayout="@layout/round_activity_home_2"
tools:context=".watchfaces.Home"
tools:deviceIds="wear"/>

View file

@ -0,0 +1,228 @@
<?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_round"
android:background="@color/black"
android:id="@+id/main_layout">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textAlignment="center"
android:weightSum="1">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:paddingTop="15dp"
android:weightSum="1"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_marginTop="-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|bottom"
android:gravity="bottom|right"
android:paddingRight="5dp"
android:layout_marginBottom="-2dp"
android:paddingTop="-2dp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:weightSum="1"
android:textAlignment="center"
android:baselineAligned="false"
android:layout_gravity="center_horizontal">
<TextView
android:id="@+id/direction"
android:textSize="30sp"
android:text="--"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textAlignment="center"
android:layout_gravity="center_horizontal|bottom"
android:gravity="center_horizontal|bottom"
android:layout_marginBottom="-5dp"
android:layout_marginTop="-2dp"
android:textStyle="bold" />
<TextView
android:id="@+id/timestamp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center_horizontal|bottom"
android:text="--' ago"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/light_grey"
android:id="@+id/secondary_layout"
android:padding="1dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:layout_gravity="center_horizontal">
<TextView
android:id="@+id/delta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="delta"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/uploader_battery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:text="--%"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tmpBasal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10sp"
android:text="-.--U/h"
android:textAlignment="center"
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/tertiary_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black"
android:orientation="vertical"
android:padding="1dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:textAlignment="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:baselineAligned="false"
android:gravity="center_horizontal"
android:orientation="vertical"
android:textAlignment="center">
<TextView
android:id="@+id/cob_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Carb"
android:textColor="#FFFFFF"
android:textSize="10sp"
android:textStyle="bold" />
<TextView
android:id="@+id/cobView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="--g"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/watch_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-3dp"
android:layout_marginTop="-2dp"
android:paddingLeft="20sp"
android:text="12:00"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="30sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="18sp"
android:textAlignment="center">
<TextView
android:id="@+id/iob_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="IOB"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textSize="10sp"
android:textStyle="bold" />
<TextView
android:id="@+id/iobView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="--U"
android:textColor="#FFFFFF"
android:textSize="14sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_gravity="bottom"
android:gravity="center_horizontal|top" />
</LinearLayout>
</RelativeLayout>

View file

@ -20,7 +20,15 @@
<item>5</item>
</string-array>
<string-array name="battery_choice">
<item>Phone</item>
<item>Rig</item>
</string-array>
<string-array name="battery_choice_values">
<item>true</item>
<item>false</item>
</string-array>
<string-array name="input_design">
<item>Default</item>
@ -38,6 +46,7 @@
<string name="label_xdrip">AAPS</string>
<string name="label_xdrip2">AAPSv2</string>
<string name="label_xdrip_large">AAPS(Large)</string>
<string name="label_xdrip_big_chart">AAPS(BigChart)</string>
<string name="label_xdrip_no_chart">AAPS(NoChart)</string>

View file

@ -26,6 +26,14 @@
android:summary="Input Design"
android:title="Input Design" />
<ListPreference
android:defaultValue="true"
android:entries="@array/battery_choice"
android:entryValues="@array/battery_choice_values"
android:key="battery_choice"
android:summary="Battery Display"
android:title="Battery Display" />
<CheckBoxPreference
android:defaultValue="true"
android:key="showExternalStatus"