Merge pull request #523 from MilosKozak/watchfacesandrew

wear timestamps long
This commit is contained in:
AdrianLxM 2017-12-04 20:29:30 +01:00 committed by GitHub
commit acf9d2199b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 47 additions and 42 deletions

View file

@ -308,7 +308,7 @@ public class NSDeviceStatus {
return Html.fromHtml(string.toString());
}
public static double getOpenApsTimestamp() {
public static long getOpenApsTimestamp() {
if (deviceStatusOpenAPSData.clockSuggested != 0) {
return deviceStatusOpenAPSData.clockSuggested;

View file

@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
@ -122,11 +123,6 @@ public class WatchUpdaterService extends WearableListenerService implements
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
double timestamp = 0;
if (intent != null) {
timestamp = intent.getDoubleExtra("timestamp", 0);
}
String action = null;
if (intent != null) {
action = intent.getAction();
@ -247,7 +243,7 @@ public class WatchUpdaterService extends WearableListenerService implements
DataMap dataMap = new DataMap();
dataMap.putString("sgvString", lastBG.valueToUnitsToString(units));
dataMap.putDouble("timestamp", lastBG.date);
dataMap.putLong("timestamp", lastBG.date);
if (glucoseStatus == null) {
dataMap.putString("slopeArrow", "");
dataMap.putString("delta", "--");
@ -481,7 +477,7 @@ public class WatchUpdaterService extends WearableListenerService implements
if (googleApiClient.isConnected()) {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(OPEN_SETTINGS_PATH);
//unique content
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putString("openSettings", "openSettings");
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);
@ -494,7 +490,7 @@ public class WatchUpdaterService extends WearableListenerService implements
if (googleApiClient.isConnected()) {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(BOLUS_PROGRESS_PATH);
//unique content
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putString("bolusProgress", "bolusProgress");
dataMapRequest.getDataMap().putString("progressstatus", status);
dataMapRequest.getDataMap().putInt("progresspercent", progresspercent);
@ -509,7 +505,7 @@ public class WatchUpdaterService extends WearableListenerService implements
if (googleApiClient.isConnected()) {
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(ACTION_CONFIRMATION_REQUEST_PATH);
//unique content
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putString("actionConfirmationRequest", "actionConfirmationRequest");
dataMapRequest.getDataMap().putString("title", title);
dataMapRequest.getDataMap().putString("message", message);
@ -551,8 +547,16 @@ public class WatchUpdaterService extends WearableListenerService implements
int phoneBattery = getBatteryLevel(getApplicationContext());
String rigBattery = NSDeviceStatus.getInstance().getUploaderStatus().trim();
long openApsStatus = -1;
//OpenAPS status
Double openApsStatus = NSDeviceStatus.getOpenApsTimestamp();
if(Config.APS){
//we are AndroidAPS
openApsStatus = LoopPlugin.lastRun != null && LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.getTime(): -1;
} else {
//NSClient or remote
openApsStatus = NSDeviceStatus.getOpenApsTimestamp();
}
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_STATUS_PATH);
//unique content
@ -564,7 +568,7 @@ public class WatchUpdaterService extends WearableListenerService implements
dataMapRequest.getDataMap().putString("tempBasal", tempBasal);
dataMapRequest.getDataMap().putString("battery", "" + phoneBattery);
dataMapRequest.getDataMap().putString("rigBattery", rigBattery);
dataMapRequest.getDataMap().putDouble("openApsStatus", openApsStatus);
dataMapRequest.getDataMap().putLong("openApsStatus", openApsStatus);
dataMapRequest.getDataMap().putString("bgi", bgiString);
dataMapRequest.getDataMap().putBoolean("showBgi", mPrefs.getBoolean("wear_showbgi", false));
dataMapRequest.getDataMap().putInt("batteryLevel", (phoneBattery >= 30) ? 1 : 0);
@ -582,7 +586,7 @@ public class WatchUpdaterService extends WearableListenerService implements
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_PREFERENCES_PATH);
//unique content
dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putLong("timestamp", System.currentTimeMillis());
dataMapRequest.getDataMap().putBoolean("wearcontrol", wearcontrol);
PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest();
Wearable.DataApi.putDataItem(googleApiClient, putDataRequest);

View file

@ -7,9 +7,9 @@ public class BgWatchData implements Comparable<BgWatchData>{
public double sgv;
public double high;
public double low;
public double timestamp;
public long timestamp;
public BgWatchData(double aSgv, double aHigh, double aLow, double aTimestamp) {
public BgWatchData(double aSgv, double aHigh, double aLow, long aTimestamp) {
this.sgv = aSgv;
this.high = aHigh;
this.low = aLow;

View file

@ -69,7 +69,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
public boolean layoutSet = false;
public BgGraphBuilder bgGraphBuilder;
public LineChartView chart;
public double datetime;
public long datetime;
public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
@ -281,7 +281,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
wakeLock.acquire(50);
sgvLevel = dataMap.getLong("sgvLevel");
batteryLevel = dataMap.getInt("batteryLevel");
datetime = dataMap.getDouble("timestamp");
datetime = dataMap.getLong("timestamp");
rawString = dataMap.getString("rawString");
sgvString = dataMap.getString("sgvString");
batteryString = dataMap.getString("battery");
@ -604,14 +604,14 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
double sgv = entry.getDouble("sgvDouble");
double high = entry.getDouble("high");
double low = entry.getDouble("low");
double timestamp = entry.getDouble("timestamp");
long timestamp = entry.getLong("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");
long timestamp = dataMap.getLong("timestamp");
final int size = bgDataList.size();
if (size > 0) {

View file

@ -50,7 +50,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
public final static IntentFilter INTENT_FILTER;
public static final long[] vibratePattern = {0,400,300,400,300,400};
public TextView mTime, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mMonth, isAAPSv2, mHighLight, mLowLight;
public double datetime;
public long datetime;
public RelativeLayout mRelativeLayout;
public LinearLayout mLinearLayout, mLinearLayout2, mDate;
public long sgvLevel = 0;
@ -85,7 +85,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
public boolean detailedIOB = false;
public boolean showBGI = false;
public Double openApsStatus;
public long openApsStatus;
public String externalStatusString = "no status";
public String sSgv = "---";
public String sDirection = "--";
@ -213,6 +213,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
@Override
protected void onDraw(Canvas canvas) {
if (layoutSet) {
setupCharts();
this.mRelativeLayout.draw(canvas);
Log.d("onDraw", "draw");
}
@ -241,7 +242,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
DataMap dataMap = DataMap.fromBundle(bundle);
wakeLock.acquire(50);
sgvLevel = dataMap.getLong("sgvLevel");
datetime = dataMap.getDouble("timestamp");
datetime = dataMap.getLong("timestamp");
sSgv = dataMap.getString("sgvString");
sDirection = dataMap.getString("slopeArrow");
sDelta = dataMap.getString("delta");
@ -268,7 +269,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
showBGI = dataMap.getBoolean("showBgi");
externalStatusString = dataMap.getString("externalStatusString");
batteryLevel = dataMap.getInt("batteryLevel");
openApsStatus = dataMap.getDouble("openApsStatus");
openApsStatus = dataMap.getLong("openApsStatus");
}
setDataFields();
@ -453,7 +454,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
if (mLoop != null) {
if (sharedPrefs.getBoolean("showExternalStatus", true)) {
mLoop.setVisibility(View.VISIBLE);
if (openApsStatus != null) {
if (openApsStatus != -1) {
int mins = (int) ((System.currentTimeMillis() - openApsStatus) / 1000 / 60);
mLoop.setText(mins + "'");
if (mins > 14) {
@ -557,14 +558,14 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
double sgv = entry.getDouble("sgvDouble");
double high = entry.getDouble("high");
double low = entry.getDouble("low");
double timestamp = entry.getDouble("timestamp");
long timestamp = entry.getLong("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");
long timestamp = dataMap.getLong("timestamp");
final int size = bgDataList.size();
if (size > 0) {

View file

@ -30,8 +30,8 @@ public class BgGraphBuilder {
private ArrayList<BasalWatchData> basalWatchDataList;
public List<TempWatchData> tempWatchDataList;
private int timespan;
public double end_time;
public double start_time;
public long end_time;
public long start_time;
public double fuzzyTimeDenom = (1000 * 60 * 1);
public Context context;
public double highMark;
@ -47,7 +47,7 @@ public class BgGraphBuilder {
public int basalBackgroundColor;
public boolean singleLine = false;
private double endHour;
private long endHour;
private List<PointValue> inRangeValues = new ArrayList<PointValue>();
private List<PointValue> highValues = new ArrayList<PointValue>();
private List<PointValue> lowValues = new ArrayList<PointValue>();
@ -316,8 +316,8 @@ public class BgGraphBuilder {
GregorianCalendar today = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
SimpleDateFormat timeFormat = new SimpleDateFormat(is24? "HH" : "h a");
timeFormat.setTimeZone(TimeZone.getDefault());
double start_hour = today.getTime().getTime();
double timeNow = System.currentTimeMillis();
long start_hour = today.getTime().getTime();
long timeNow = System.currentTimeMillis();
for (int l = 0; l <= 24; l++) {
if ((start_hour + (60000 * 60 * (l))) < timeNow) {
if ((start_hour + (60000 * 60 * (l + 1))) >= timeNow) {
@ -332,7 +332,7 @@ public class BgGraphBuilder {
//Add whole hours endTime the axis (as long as they are more than 15 mins away from the current time)
for (int l = 0; l <= 24; l++) {
double timestamp = endHour - (60000 * 60 * l);
long timestamp = endHour - (60000 * 60 * l);
if((timestamp - timeNow < 0) && (timestamp > start_time)) {
if(Math.abs(timestamp - timeNow) > (1000 * 60 * 8 * timespan)){
xAxisValues.add(new AxisValue(fuzz(timestamp), (timeFormat.format(timestamp)).toCharArray()));
@ -350,7 +350,7 @@ public class BgGraphBuilder {
return xAxis;
}
public float fuzz(double value) {
return (float) Math.round(value / fuzzyTimeDenom);
public float fuzz(long value) {
return (float) Math.round(value / fuzzyTimeDenom);
}
}

View file

@ -73,7 +73,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
private int batteryLevel = 0;
private double datetime = 0;
private long datetime = 0;
private String direction = "";
private String delta = "";
private String avgDelta = "";
@ -433,11 +433,11 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
}
private synchronized double getDatetime() {
private synchronized long getDatetime() {
return datetime;
}
private synchronized void setDatetime(double datetime) {
private synchronized void setDatetime(long datetime) {
this.datetime = datetime;
}
@ -534,7 +534,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
Log.d("CircleWatchface", "sgv string : " + getSgvString());
setDelta(dataMap.getString("delta"));
setAvgDelta(dataMap.getString("avgDelta"));
setDatetime(dataMap.getDouble("timestamp"));
setDatetime(dataMap.getLong("timestamp"));
addToWatchSet(dataMap);
@ -576,7 +576,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
double sgv = dataMap.getDouble("sgvDouble");
double high = dataMap.getDouble("high");
double low = dataMap.getDouble("low");
double timestamp = dataMap.getDouble("timestamp");
long timestamp = dataMap.getLong("timestamp");
bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
} else if (!sharedPrefs.getBoolean("animation", false)) {
// don't load history at once if animations are set (less resource consumption)
@ -586,7 +586,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
double sgv = entry.getDouble("sgvDouble");
double high = entry.getDouble("high");
double low = entry.getDouble("low");
double timestamp = entry.getDouble("timestamp");
long timestamp = entry.getLong("timestamp");
bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
}
} else

View file

@ -59,7 +59,7 @@ public class NOChart extends WatchFace implements SharedPreferences.OnSharedPref
public int ageLevel = 1;
public boolean lowResMode = false;
public boolean layoutSet = false;
public double datetime;
public long datetime;
public ArrayList<BgWatchData> bgDataList = new ArrayList<>();
public ArrayList<TempWatchData> tempWatchDataList = new ArrayList<>();
public ArrayList<BasalWatchData> basalWatchDataList = new ArrayList<>();
@ -252,7 +252,7 @@ public class NOChart extends WatchFace implements SharedPreferences.OnSharedPref
wakeLock.acquire(50);
sgvLevel = dataMap.getLong("sgvLevel");
batteryLevel = dataMap.getInt("batteryLevel");
datetime = dataMap.getDouble("timestamp");
datetime = dataMap.getLong("timestamp");
sgvString = dataMap.getString("sgvString");
mSgv.setText(dataMap.getString("sgvString"));