wear all watchfaces active
This commit is contained in:
parent
d8f4de8b22
commit
58d2c87870
|
@ -13,6 +13,21 @@
|
|||
<meta-data
|
||||
android:name="com.google.android.gms.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
|
||||
android:name="info.nightscout.androidaps.Home"
|
||||
android:allowEmbedded="true"
|
||||
|
@ -41,20 +56,6 @@
|
|||
</intent-filter>
|
||||
</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
|
||||
android:name="info.nightscout.androidaps.CircleWatchface"
|
||||
android:allowEmbedded="true"
|
||||
|
|
|
@ -58,6 +58,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
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;
|
||||
|
@ -253,7 +255,20 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
|
||||
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 {
|
||||
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());
|
||||
|
@ -388,4 +403,31 @@ protected abstract void setColorDark();
|
|||
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 String sgvString = "999";
|
||||
private String rawString = "x | x | x";
|
||||
private String statusString = "no status";
|
||||
|
||||
|
||||
private int batteryLevel = 0;
|
||||
|
@ -155,12 +155,10 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
|||
textView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
textView = (TextView) myLayout.findViewById(R.id.rawString);
|
||||
if (sharedPrefs.getBoolean("showRaw", false)||
|
||||
(sharedPrefs.getBoolean("showRawNoise", true) && getSgvString().equals("???"))
|
||||
) {
|
||||
textView = (TextView) myLayout.findViewById(R.id.statusString);
|
||||
if (sharedPrefs.getBoolean("showExternalStatus", true)) {
|
||||
textView.setVisibility(View.VISIBLE);
|
||||
textView.setText(getRawString());
|
||||
textView.setText(getStatusString());
|
||||
textView.setTextColor(getTextColor());
|
||||
|
||||
} else {
|
||||
|
@ -453,12 +451,12 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
|||
this.sgvString = sgvString;
|
||||
}
|
||||
|
||||
String getRawString() {
|
||||
return rawString;
|
||||
String getStatusString() {
|
||||
return statusString;
|
||||
}
|
||||
|
||||
void setRawString(String rawString) {
|
||||
this.rawString = rawString;
|
||||
void setStatusString(String statusString) {
|
||||
this.statusString = statusString;
|
||||
}
|
||||
|
||||
public String getDelta() {
|
||||
|
@ -527,7 +525,6 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
|||
Log.d("CircleWatchface", "sgv level : " + getSgvLevel());
|
||||
setSgvString(dataMap.getString("sgvString"));
|
||||
Log.d("CircleWatchface", "sgv string : " + getSgvString());
|
||||
setRawString(dataMap.getString("rawString"));
|
||||
setDelta(dataMap.getString("delta"));
|
||||
setDatetime(dataMap.getDouble("timestamp"));
|
||||
addToWatchSet(dataMap);
|
||||
|
@ -543,6 +540,17 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
|
|||
prepareDrawTime();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
android:text="999"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<TextView android:id="@+id/rawString"
|
||||
<TextView android:id="@+id/statusString"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="x | x | x"
|
||||
android:text="no status"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="-5dp" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue