wear all watchfaces active
This commit is contained in:
parent
d8f4de8b22
commit
58d2c87870
4 changed files with 80 additions and 29 deletions
|
@ -13,6 +13,21 @@
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.gms.version"
|
android:name="com.google.android.gms.version"
|
||||||
android:value="@integer/google_play_services_version" />
|
android:value="@integer/google_play_services_version" />
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name="info.nightscout.androidaps.BIGChart"
|
||||||
|
android:allowEmbedded="true"
|
||||||
|
android:label="@string/label_xdrip_big_chart"
|
||||||
|
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_bigchart" />
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.service.wallpaper.WallpaperService" />
|
||||||
|
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="info.nightscout.androidaps.Home"
|
android:name="info.nightscout.androidaps.Home"
|
||||||
android:allowEmbedded="true"
|
android:allowEmbedded="true"
|
||||||
|
@ -41,20 +56,6 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service
|
|
||||||
android:name="info.nightscout.androidaps.BIGChart"
|
|
||||||
android:allowEmbedded="true"
|
|
||||||
android:label="@string/label_xdrip_big_chart"
|
|
||||||
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_bigchart" />
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.service.wallpaper.WallpaperService" />
|
|
||||||
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
|
|
||||||
</intent-filter>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="info.nightscout.androidaps.CircleWatchface"
|
android:name="info.nightscout.androidaps.CircleWatchface"
|
||||||
android:allowEmbedded="true"
|
android:allowEmbedded="true"
|
||||||
|
|
|
@ -58,6 +58,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
public LineChartView chart;
|
public LineChartView chart;
|
||||||
public double datetime;
|
public double datetime;
|
||||||
public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
|
public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
|
||||||
|
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
|
||||||
|
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
|
||||||
public PowerManager.WakeLock wakeLock;
|
public PowerManager.WakeLock wakeLock;
|
||||||
// related endTime manual layout
|
// related endTime manual layout
|
||||||
public View layoutView;
|
public View layoutView;
|
||||||
|
@ -253,7 +255,20 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
invalidate();
|
invalidate();
|
||||||
setColor();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,9 +391,9 @@ protected abstract void setColorDark();
|
||||||
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
|
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"));
|
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
|
||||||
if (singleLine) {
|
if (singleLine) {
|
||||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, new ArrayList<TempWatchData>(), new ArrayList<BasalWatchData>(), pointSize, midColor, timeframe);
|
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, timeframe);
|
||||||
} else {
|
} else {
|
||||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, new ArrayList<TempWatchData>(), new ArrayList<BasalWatchData>(), pointSize, highColor, lowColor, midColor, timeframe);
|
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, timeframe);
|
||||||
}
|
}
|
||||||
|
|
||||||
chart.setLineChartData(bgGraphBuilder.lineData());
|
chart.setLineChartData(bgGraphBuilder.lineData());
|
||||||
|
@ -388,4 +403,31 @@ protected abstract void setColorDark();
|
||||||
ListenerService.requestData(this);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
|
|
||||||
private int sgvLevel = 0;
|
private int sgvLevel = 0;
|
||||||
private String sgvString = "999";
|
private String sgvString = "999";
|
||||||
private String rawString = "x | x | x";
|
private String statusString = "no status";
|
||||||
|
|
||||||
|
|
||||||
private int batteryLevel = 0;
|
private int batteryLevel = 0;
|
||||||
|
@ -155,12 +155,10 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
textView.setVisibility(View.INVISIBLE);
|
textView.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
textView = (TextView) myLayout.findViewById(R.id.rawString);
|
textView = (TextView) myLayout.findViewById(R.id.statusString);
|
||||||
if (sharedPrefs.getBoolean("showRaw", false)||
|
if (sharedPrefs.getBoolean("showExternalStatus", true)) {
|
||||||
(sharedPrefs.getBoolean("showRawNoise", true) && getSgvString().equals("???"))
|
|
||||||
) {
|
|
||||||
textView.setVisibility(View.VISIBLE);
|
textView.setVisibility(View.VISIBLE);
|
||||||
textView.setText(getRawString());
|
textView.setText(getStatusString());
|
||||||
textView.setTextColor(getTextColor());
|
textView.setTextColor(getTextColor());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -453,12 +451,12 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
this.sgvString = sgvString;
|
this.sgvString = sgvString;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getRawString() {
|
String getStatusString() {
|
||||||
return rawString;
|
return statusString;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRawString(String rawString) {
|
void setStatusString(String statusString) {
|
||||||
this.rawString = rawString;
|
this.statusString = statusString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDelta() {
|
public String getDelta() {
|
||||||
|
@ -527,7 +525,6 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
Log.d("CircleWatchface", "sgv level : " + getSgvLevel());
|
Log.d("CircleWatchface", "sgv level : " + getSgvLevel());
|
||||||
setSgvString(dataMap.getString("sgvString"));
|
setSgvString(dataMap.getString("sgvString"));
|
||||||
Log.d("CircleWatchface", "sgv string : " + getSgvString());
|
Log.d("CircleWatchface", "sgv string : " + getSgvString());
|
||||||
setRawString(dataMap.getString("rawString"));
|
|
||||||
setDelta(dataMap.getString("delta"));
|
setDelta(dataMap.getString("delta"));
|
||||||
setDatetime(dataMap.getDouble("timestamp"));
|
setDatetime(dataMap.getDouble("timestamp"));
|
||||||
addToWatchSet(dataMap);
|
addToWatchSet(dataMap);
|
||||||
|
@ -543,6 +540,17 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
||||||
prepareDrawTime();
|
prepareDrawTime();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
//status
|
||||||
|
bundle = intent.getBundleExtra("status");
|
||||||
|
if (bundle != null) {
|
||||||
|
DataMap dataMap = DataMap.fromBundle(bundle);
|
||||||
|
wakeLock.acquire(50);
|
||||||
|
setStatusString(dataMap.getString("externalStatusString"));
|
||||||
|
|
||||||
|
prepareLayout();
|
||||||
|
prepareDrawTime();
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
wakeLock.release();
|
wakeLock.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,13 @@
|
||||||
android:text="999"
|
android:text="999"
|
||||||
android:layout_gravity="center" />
|
android:layout_gravity="center" />
|
||||||
|
|
||||||
<TextView android:id="@+id/rawString"
|
<TextView android:id="@+id/statusString"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:text="x | x | x"
|
android:text="no status"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_marginTop="-5dp" />
|
android:layout_marginTop="-5dp" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue