Wear: test optimisations always on
This commit is contained in:
parent
06c9920177
commit
4dd97e75ea
3 changed files with 71 additions and 21 deletions
|
@ -135,7 +135,7 @@ public class RawDisplayData {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateData(DataMap dataMap) {
|
private void updateData(DataMap dataMap) {
|
||||||
wearUtil.getWakeLock("readingPrefs", 50);
|
// wearUtil.getWakeLock("readingPrefs", 50);
|
||||||
sgvLevel = dataMap.getLong("sgvLevel");
|
sgvLevel = dataMap.getLong("sgvLevel");
|
||||||
datetime = dataMap.getLong("timestamp");
|
datetime = dataMap.getLong("timestamp");
|
||||||
sSgv = dataMap.getString("sgvString");
|
sSgv = dataMap.getString("sgvString");
|
||||||
|
@ -156,7 +156,7 @@ public class RawDisplayData {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStatus(DataMap dataMap) {
|
private void updateStatus(DataMap dataMap) {
|
||||||
wearUtil.getWakeLock("readingPrefs", 50);
|
// wearUtil.getWakeLock("readingPrefs", 50);
|
||||||
sBasalRate = dataMap.getString("currentBasal");
|
sBasalRate = dataMap.getString("currentBasal");
|
||||||
sUploaderBattery = dataMap.getString("battery");
|
sUploaderBattery = dataMap.getString("battery");
|
||||||
sRigBattery = dataMap.getString("rigBattery");
|
sRigBattery = dataMap.getString("rigBattery");
|
||||||
|
@ -183,7 +183,7 @@ public class RawDisplayData {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateBasals(DataMap dataMap) {
|
private void updateBasals(DataMap dataMap) {
|
||||||
wearUtil.getWakeLock("readingPrefs", 500);
|
// wearUtil.getWakeLock("readingPrefs", 500);
|
||||||
loadBasalsAndTemps(dataMap);
|
loadBasalsAndTemps(dataMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,12 +54,15 @@ import lecho.lib.hellocharts.view.LineChartView;
|
||||||
* Refactored by dlvoy on 2019-11-2019
|
* Refactored by dlvoy on 2019-11-2019
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class BaseWatchFace extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public abstract class BaseWatchFace extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@Inject WearUtil wearUtil;
|
@Inject WearUtil wearUtil;
|
||||||
@Inject Persistence persistence;
|
@Inject Persistence persistence;
|
||||||
|
|
||||||
public final static IntentFilter INTENT_FILTER;
|
public final static IntentFilter INTENT_FILTER;
|
||||||
|
public final static String TAG = "ASTAG-perf";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
INTENT_FILTER = new IntentFilter();
|
INTENT_FILTER = new IntentFilter();
|
||||||
|
@ -68,6 +71,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
INTENT_FILTER.addAction(Intent.ACTION_TIME_CHANGED);
|
INTENT_FILTER.addAction(Intent.ACTION_TIME_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String mLastSvg = "";
|
||||||
|
String mLastDirection = "";
|
||||||
|
|
||||||
public final Point displaySize = new Point();
|
public final Point displaySize = new Point();
|
||||||
public TextView mTime, mHour, mMinute, mTimePeriod, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mDayName, mMonth, isAAPSv2, mHighLight, mLowLight;
|
public TextView mTime, mHour, mMinute, mTimePeriod, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mDayName, mMonth, isAAPSv2, mHighLight, mLowLight;
|
||||||
public TextView mSimpleSvg, mSimpleDirection, mSimpleTime;
|
public TextView mSimpleSvg, mSimpleDirection, mSimpleTime;
|
||||||
|
@ -104,12 +110,23 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
private MessageReceiver messageReceiver;
|
private MessageReceiver messageReceiver;
|
||||||
private BroadcastReceiver batteryReceiver;
|
private BroadcastReceiver batteryReceiver;
|
||||||
protected boolean isCharging = false;
|
protected boolean isCharging = false;
|
||||||
|
int colorDarkHigh;
|
||||||
|
int colorDarkMid;
|
||||||
|
int colorDarkLow;
|
||||||
|
java.text.DateFormat timeFormat;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
|
Log.i(TAG, "onCreate: ");
|
||||||
// Not derived from DaggerService, do injection here
|
// Not derived from DaggerService, do injection here
|
||||||
AndroidInjection.inject(this);
|
AndroidInjection.inject(this);
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
|
colorDarkHigh = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor);
|
||||||
|
colorDarkMid = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
|
||||||
|
colorDarkLow = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor);
|
||||||
|
timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
|
||||||
|
|
||||||
rawData = new RawDisplayData(wearUtil);
|
rawData = new RawDisplayData(wearUtil);
|
||||||
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
||||||
display.getSize(displaySize);
|
display.getSize(displaySize);
|
||||||
|
@ -130,13 +147,17 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupBatteryReceiver() {
|
private void setupBatteryReceiver() {
|
||||||
if (sharedPrefs.getString("simplify_ui", "off") == "charching" && batteryReceiver == null) {
|
String setting = sharedPrefs.getString("simplify_ui", "off");
|
||||||
|
Log.i(TAG, "setupBatteryReceiver: " + setting);
|
||||||
|
if (setting.equals("charging") || setting.equals("ambient_charging") && batteryReceiver == null) {
|
||||||
|
Log.i(TAG, "setupBatteryReceiver: DONE");
|
||||||
IntentFilter intentBatteryFilter = new IntentFilter();
|
IntentFilter intentBatteryFilter = new IntentFilter();
|
||||||
intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING);
|
intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING);
|
||||||
intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING);
|
intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING);
|
||||||
batteryReceiver = new BroadcastReceiver() {
|
batteryReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
Log.i(TAG, "Battery BroadcastReceiver.onReceive: ");
|
||||||
setDataFields();
|
setDataFields();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
@ -147,6 +168,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) {
|
protected void onLayout(WatchShape shape, Rect screenBounds, WindowInsets screenInsets) {
|
||||||
|
Log.i(TAG, "onLayout: ");
|
||||||
super.onLayout(shape, screenBounds, screenInsets);
|
super.onLayout(shape, screenBounds, screenInsets);
|
||||||
layoutView.onApplyWindowInsets(screenInsets);
|
layoutView.onApplyWindowInsets(screenInsets);
|
||||||
bIsRound = screenInsets.isRound();
|
bIsRound = screenInsets.isRound();
|
||||||
|
@ -160,6 +182,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||||
localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
|
localBroadcastManager.registerReceiver(messageReceiver, messageFilter);
|
||||||
|
|
||||||
|
final int colorDarkHigh = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor);
|
||||||
|
final int colorDarkMid = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
|
||||||
|
final int colorDarkDark = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor);
|
||||||
|
|
||||||
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
|
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLayoutInflated(WatchViewStub stub) {
|
public void onLayoutInflated(WatchViewStub stub) {
|
||||||
|
@ -249,8 +275,15 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected long getInteractiveModeUpdateRate() {
|
||||||
|
// Only call onTimeChanged every 1
|
||||||
|
return 60 * 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
|
Log.i(TAG, "onDraw: ");
|
||||||
if (layoutSet) {
|
if (layoutSet) {
|
||||||
setupCharts();
|
setupCharts();
|
||||||
|
|
||||||
|
@ -267,8 +300,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
|
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
|
||||||
|
Log.i(TAG, "onTimeChanged: ");
|
||||||
if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
|
if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
|
||||||
wakeLock.acquire(50);
|
Log.i(TAG, "onTimeChanged: time changed");
|
||||||
|
// wakeLock.acquire(50);
|
||||||
|
|
||||||
setDataFields();
|
setDataFields();
|
||||||
setColor();
|
setColor();
|
||||||
|
@ -281,7 +316,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
} else {
|
} else {
|
||||||
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
|
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
|
||||||
}
|
}
|
||||||
invalidate();
|
// invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,10 +340,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
|
|
||||||
public void setDataFields() {
|
public void setDataFields() {
|
||||||
|
|
||||||
setDateAndTime();
|
|
||||||
if (setDataFieldsSimpleUi()) {
|
if (setDataFieldsSimpleUi()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setDateAndTime();
|
||||||
if (mSgv != null) {
|
if (mSgv != null) {
|
||||||
if (sharedPrefs.getBoolean("showBG", true)) {
|
if (sharedPrefs.getBoolean("showBG", true)) {
|
||||||
mSgv.setText(rawData.sSgv);
|
mSgv.setText(rawData.sSgv);
|
||||||
|
@ -500,20 +535,21 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
} else {
|
} else {
|
||||||
mSimpleSvg.setPaintFlags(mSimpleSvg.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
mSimpleSvg.setPaintFlags(mSimpleSvg.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawData.sgvLevel == 1) {
|
if (rawData.sgvLevel == 1) {
|
||||||
mSimpleSvg.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
|
mSimpleSvg.setTextColor(colorDarkHigh);
|
||||||
mSimpleDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor));
|
mSimpleDirection.setTextColor(colorDarkHigh);
|
||||||
} else if (rawData.sgvLevel == 0) {
|
} else if (rawData.sgvLevel == 0) {
|
||||||
mSimpleSvg.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
|
mSimpleSvg.setTextColor(colorDarkMid);
|
||||||
mSimpleDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
|
mSimpleDirection.setTextColor(colorDarkMid);
|
||||||
} else if (rawData.sgvLevel == -1) {
|
} else if (rawData.sgvLevel == -1) {
|
||||||
mSimpleSvg.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
|
mSimpleSvg.setTextColor(colorDarkLow);
|
||||||
mSimpleDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor));
|
mSimpleDirection.setTextColor(colorDarkLow);
|
||||||
}
|
}
|
||||||
|
|
||||||
mSimpleDirection.setText(rawData.sDirection+"\uFE0E");
|
mSimpleDirection.setText(rawData.sDirection+"\uFE0E");
|
||||||
|
|
||||||
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
|
|
||||||
mSimpleTime.setText(timeFormat.format(System.currentTimeMillis()));
|
mSimpleTime.setText(timeFormat.format(System.currentTimeMillis()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -601,6 +637,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onWatchModeChanged(WatchMode watchMode) {
|
protected void onWatchModeChanged(WatchMode watchMode) {
|
||||||
|
Log.i(TAG, "onWatchModeChanged: " + watchMode);
|
||||||
setDataFields();
|
setDataFields();
|
||||||
if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode
|
if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode
|
||||||
lowResMode = isLowRes(watchMode);
|
lowResMode = isLowRes(watchMode);
|
||||||
|
@ -620,10 +657,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
if (simplify.equals("off")) {
|
if (simplify.equals("off")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (simplify.equals("ambient") && getCurrentWatchMode() == WatchMode.AMBIENT) {
|
if ((simplify.equals("ambient") || simplify.equals("ambient_charging")) && getCurrentWatchMode() == WatchMode.AMBIENT) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (simplify.equals("charging") && isCharging()) {
|
if ((simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -631,6 +668,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||||
|
Log.i(TAG, "onSharedPreferenceChanged: ");
|
||||||
setupBatteryReceiver();
|
setupBatteryReceiver();
|
||||||
if ("delta_granularity".equals(key)) {
|
if ("delta_granularity".equals(key)) {
|
||||||
ListenerService.requestData(this);
|
ListenerService.requestData(this);
|
||||||
|
@ -677,6 +715,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
public class MessageReceiver extends BroadcastReceiver {
|
public class MessageReceiver extends BroadcastReceiver {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
Log.i(TAG, "Data MessageReceiver.onReceive: ");
|
||||||
|
|
||||||
if (layoutSet) {
|
if (layoutSet) {
|
||||||
final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock);
|
final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock);
|
||||||
|
@ -685,15 +724,15 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
setupCharts();
|
setupCharts();
|
||||||
}
|
}
|
||||||
rawData.updateStatusFromMessage(intent, wakeLock);
|
rawData.updateStatusFromMessage(intent, wakeLock);
|
||||||
|
rawData.updateBasalsFromMessage(intent, wakeLock);
|
||||||
|
}
|
||||||
|
if (!needUpdate()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setDataFields();
|
setDataFields();
|
||||||
setColor();
|
setColor();
|
||||||
|
|
||||||
if (layoutSet) {
|
|
||||||
rawData.updateBasalsFromMessage(intent, wakeLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
mRelativeLayout.measure(specW, specH);
|
mRelativeLayout.measure(specW, specH);
|
||||||
if (forceSquareCanvas) {
|
if (forceSquareCanvas) {
|
||||||
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face.
|
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face.
|
||||||
|
@ -704,4 +743,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean needUpdate() {
|
||||||
|
if (isSimpleUi() && mLastSvg.equals(rawData.sSgv) && mLastDirection.equals(rawData.sDirection)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
mLastSvg = rawData.sSgv;
|
||||||
|
mLastDirection = rawData.sDirection;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,12 +69,14 @@
|
||||||
<item>Off</item>
|
<item>Off</item>
|
||||||
<item>During Charging</item>
|
<item>During Charging</item>
|
||||||
<item>Always On Mode</item>
|
<item>Always On Mode</item>
|
||||||
|
<item>Always On and Charging</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="watchface_simplify_ui_values">
|
<string-array name="watchface_simplify_ui_values">
|
||||||
<item>off</item>
|
<item>off</item>
|
||||||
<item>charging</item>
|
<item>charging</item>
|
||||||
<item>ambient</item>
|
<item>ambient</item>
|
||||||
|
<item>ambient_charging</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue