wear avgDelta on all watchfaces

This commit is contained in:
AdrianLxM 2016-11-22 04:07:47 +01:00
parent ef0e30b2b3
commit 8a466506fb
5 changed files with 40 additions and 36 deletions

View file

@ -429,12 +429,15 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
if (sgvLevel == 1) {
mSgv.setTextColor(Color.YELLOW);
mDelta.setTextColor(Color.YELLOW);
mAvgDelta.setTextColor(Color.YELLOW);
} else if (sgvLevel == 0) {
mSgv.setTextColor(Color.WHITE);
mDelta.setTextColor(Color.WHITE);
mAvgDelta.setTextColor(Color.WHITE);
} else if (sgvLevel == -1) {
mSgv.setTextColor(Color.RED);
mDelta.setTextColor(Color.RED);
mAvgDelta.setTextColor(Color.RED);
}
@ -466,12 +469,15 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
if (sgvLevel == 1) {
mSgv.setTextColor(ChartUtils.COLOR_ORANGE);
mDelta.setTextColor(ChartUtils.COLOR_ORANGE);
mAvgDelta.setTextColor(ChartUtils.COLOR_ORANGE);
} else if (sgvLevel == 0) {
mSgv.setTextColor(Color.BLACK);
mDelta.setTextColor(Color.BLACK);
mAvgDelta.setTextColor(Color.BLACK);
} else if (sgvLevel == -1) {
mSgv.setTextColor(Color.RED);
mDelta.setTextColor(Color.RED);
mAvgDelta.setTextColor(Color.RED);
}
if (ageLevel == 1) {
@ -496,12 +502,15 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
if (sgvLevel == 1) {
mSgv.setTextColor(Color.YELLOW);
mDelta.setTextColor(Color.YELLOW);
mAvgDelta.setTextColor(Color.YELLOW);
} else if (sgvLevel == 0) {
mSgv.setTextColor(Color.WHITE);
mDelta.setTextColor(Color.WHITE);
mAvgDelta.setTextColor(Color.WHITE);
} else if (sgvLevel == -1) {
mSgv.setTextColor(Color.RED);
mDelta.setTextColor(Color.RED);
mAvgDelta.setTextColor(Color.RED);
}
mTimestamp.setTextColor(Color.WHITE);
statusView.setTextColor(Color.WHITE);

View file

@ -41,7 +41,7 @@ import lecho.lib.hellocharts.view.LineChartView;
public abstract class BaseWatchFace 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, mRaw, mStatus;
public TextView mTime, mSgv, mDirection, mTimestamp, mUploaderBattery, mDelta, mStatus;
public RelativeLayout mRelativeLayout;
public LinearLayout mLinearLayout;
public long sgvLevel = 0;
@ -70,11 +70,12 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
private MessageReceiver messageReceiver;
protected SharedPreferences sharedPrefs;
// private String rawString = "000 | 000 | 000";
private String rawString = "";
private String batteryString = "--";
private String sgvString = "--";
private String externalStatusString = "no status";
private String avgDelta = "";
private String delta = "";
@Override
public void onCreate() {
@ -114,7 +115,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
mSgv = (TextView) stub.findViewById(R.id.sgv);
mDirection = (TextView) stub.findViewById(R.id.direction);
mTimestamp = (TextView) stub.findViewById(R.id.timestamp);
mRaw = (TextView) stub.findViewById(R.id.raw);
mStatus = (TextView) stub.findViewById(R.id.externaltstatus);
mUploaderBattery = (TextView) stub.findViewById(R.id.uploader_battery);
mDelta = (TextView) stub.findViewById(R.id.delta);
@ -211,7 +211,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
sgvLevel = dataMap.getLong("sgvLevel");
batteryLevel = dataMap.getInt("batteryLevel");
datetime = dataMap.getDouble("timestamp");
rawString = dataMap.getString("rawString");
sgvString = dataMap.getString("sgvString");
batteryString = dataMap.getString("battery");
mSgv.setText(dataMap.getString("sgvString"));
@ -225,10 +224,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
mTime.setText(timeFormat.format(System.currentTimeMillis()));
mDirection.setText(dataMap.getString("slopeArrow"));
avgDelta = dataMap.getString("avgDelta");
delta = dataMap.getString("delta");
showAgoRawBattStatus();
mDirection.setText(dataMap.getString("slopeArrow"));
mDelta.setText(dataMap.getString("delta"));
if (chart != null) {
addToWatchSet(dataMap);
@ -274,17 +276,21 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
private void showAgoRawBattStatus() {
if(mRaw == null || mTimestamp == null || mUploaderBattery == null|| mStatus == null){
boolean showAvgDelta = sharedPrefs.getBoolean("showAvgDelta", true);
mDelta.setText(delta);
if(showAvgDelta){
mDelta.append(" " + avgDelta);
}
if( mTimestamp == null || mUploaderBattery == null|| mStatus == null){
return;
}
boolean showRaw = sharedPrefs.getBoolean("showRaw", false)
|| (sharedPrefs.getBoolean("showRawNoise", true)
&& sgvString.equals("???"));
boolean showStatus = sharedPrefs.getBoolean("showExternalStatus", true);
if(showRaw || showStatus){
if(showStatus){
//use short forms
mTimestamp.setText(readingAge(true));
mUploaderBattery.setText("U: " + batteryString + "%");
@ -293,12 +299,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
mUploaderBattery.setText("Uploader: " + batteryString + "%");
}
if (showRaw) {
mRaw.setVisibility(View.VISIBLE);
mRaw.setText("R: " + rawString);
} else {
mRaw.setVisibility(View.GONE);
}
if (showStatus) {
mStatus.setVisibility(View.VISIBLE);
@ -337,11 +337,6 @@ protected abstract void setColorDark();
public void missedReadingAlert() {
int minutes_since = (int) Math.floor(timeSince()/(1000*60));
if(minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) {
/*NotificationCompat.Builder notification = new NotificationCompat.Builder(getApplicationContext())
.setContentTitle("Missed BG Readings")
.setVibrate(vibratePattern);
NotificationManager mNotifyMgr = (NotificationManager) getApplicationContext().getSystemService(getApplicationContext().NOTIFICATION_SERVICE);
mNotifyMgr.notify(missed_readings_alert_id, notification.build());*/
ListenerService.requestData(this); // attempt endTime recover missing data
}
}

View file

@ -70,6 +70,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
private double datetime = 0;
private String direction = "";
private String delta = "";
private String avgDelta = "";
public TreeSet<BgWatchData> bgDataList = new TreeSet<BgWatchData>();
private View layoutView;
@ -189,15 +190,13 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
textView.setTextColor(getTextColor());
if (sharedPrefs.getBoolean("showBigNumbers", false)) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
if (delta.endsWith(" mg/dl")) {
textView.setText(getDelta().substring(0, delta.length() - 6));
} else if (delta.endsWith(" mmol")) {
textView.setText(getDelta().substring(0, delta.length() - 5));
}
} else {
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
textView.setText(getDelta());
}
if(sharedPrefs.getBoolean("showAvgDelta", true)){
textView.append(" " + getAvgDelta());
}
} else {
//Also possible: View.INVISIBLE instead of View.GONE (no layout change)
textView.setVisibility(View.INVISIBLE);
@ -467,6 +466,12 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
this.delta = delta;
}
private String getAvgDelta() {
return avgDelta;
}
private void setAvgDelta(String avgDelta) {
this.avgDelta = avgDelta;
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
@ -526,6 +531,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh
setSgvString(dataMap.getString("sgvString"));
Log.d("CircleWatchface", "sgv string : " + getSgvString());
setDelta(dataMap.getString("delta"));
setAvgDelta(dataMap.getString("avgDelta"));
setDatetime(dataMap.getDouble("timestamp"));
addToWatchSet(dataMap);

View file

@ -45,7 +45,6 @@ public class Home extends BaseWatchFace {
} else {
mUploaderBattery.setTextColor(Color.RED);
}
mRaw.setTextColor(Color.BLACK);
mStatus.setTextColor(Color.BLACK);
if (chart != null) {
highColor = Color.YELLOW;
@ -89,7 +88,6 @@ public class Home extends BaseWatchFace {
} else {
mUploaderBattery.setTextColor(Color.RED);
}
mRaw.setTextColor(Color.WHITE);
mStatus.setTextColor(Color.WHITE);
mTime.setTextColor(Color.BLACK);
@ -117,7 +115,6 @@ public class Home extends BaseWatchFace {
mDirection.setTextColor(Color.RED);
mDelta.setTextColor(Color.RED);
}
mRaw.setTextColor(Color.BLACK);
mStatus.setTextColor(Color.BLACK);
mUploaderBattery.setTextColor(Color.BLACK);
mTimestamp.setTextColor(Color.BLACK);

View file

@ -46,7 +46,6 @@ public class LargeHome extends BaseWatchFace {
mUploaderBattery.setTextColor(Color.RED);
}
mRaw.setTextColor(Color.BLACK);
mStatus.setTextColor(Color.BLACK);
}
@ -83,7 +82,6 @@ public class LargeHome extends BaseWatchFace {
} else {
mUploaderBattery.setTextColor(Color.RED);
}
mRaw.setTextColor(Color.WHITE);
mStatus.setTextColor(Color.WHITE);
mTime.setTextColor(Color.BLACK);
} else {
@ -105,7 +103,6 @@ public class LargeHome extends BaseWatchFace {
mUploaderBattery.setTextColor(Color.BLACK);
mTimestamp.setTextColor(Color.BLACK);
mRaw.setTextColor(Color.BLACK);
mStatus.setTextColor(Color.BLACK);
mTime.setTextColor(Color.WHITE);
}