Wear: remove debug log

This commit is contained in:
Andries Smit 2022-01-10 09:28:57 +01:00
parent 5760bbe708
commit 6fd1594011

View file

@ -97,28 +97,24 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
// related endTime manual layout // related endTime manual layout
public View layoutView; public View layoutView;
public int specW, specH; public int specW, specH;
public boolean forceSquareCanvas = false; // Set to true by the Steampunk watch face. public boolean forceSquareCanvas = false; // Set to true by the Steampunk watch face.
public String sMinute = "0"; public String sMinute = "0";
public String sHour = "0"; public String sHour = "0";
protected SharedPreferences sharedPrefs; protected SharedPreferences sharedPrefs;
private LocalBroadcastManager localBroadcastManager; private LocalBroadcastManager localBroadcastManager;
private MessageReceiver messageReceiver; private MessageReceiver messageReceiver;
private BroadcastReceiver batteryReceiver; private BroadcastReceiver batteryReceiver;
private int colorDarkHigh; private int colorDarkHigh, colorDarkMid, colorDarkLow;
private int colorDarkMid;
private int colorDarkLow;
private java.text.DateFormat timeFormat; private java.text.DateFormat timeFormat;
private SimpleDateFormat sdfDay, sdfMonth, sdfHour, sdfPeriod, sdfDayName, sdfMinute; private SimpleDateFormat sdfDay, sdfMonth, sdfHour, sdfPeriod, sdfDayName, sdfMinute;
private final String TAG = "ASTAG";
private Paint mBackgroundPaint, mTimePaint, mSvgPaint, mDirectionPaint; private Paint mBackgroundPaint, mTimePaint, mSvgPaint, mDirectionPaint;
private Date mDateTime; private Date mDateTime;
private String mLastSvg = ""; private String mLastSvg = "", mLastDirection = "";
private String mLastDirection = "";
private float mYOffset = 0; private float mYOffset = 0;
private Intent mBatteryStatus;
@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();
@ -149,17 +145,16 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
private void setupBatteryReceiver() { private void setupBatteryReceiver() {
IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
mBatteryStatus = this.registerReceiver(null, iFilter);
String setting = sharedPrefs.getString("simplify_ui", "off"); String setting = sharedPrefs.getString("simplify_ui", "off");
Log.i(TAG, "setupBatteryReceiver: " + setting);
if (setting.equals("charging") || setting.equals("ambient_charging") && batteryReceiver == null) { 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();
} }
@ -212,7 +207,6 @@ 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();
@ -309,36 +303,24 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
@Override @Override
protected long getInteractiveModeUpdateRate() { protected long getInteractiveModeUpdateRate() {
// Only call onTimeChanged every 1 return 60 * 1000L; // Only call onTimeChanged every 60 seconds
return 60 * 1000L;
} }
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
Log.i(TAG, "onDraw: start ");
long sTime = System.nanoTime();
if (isSimpleUi()) { if (isSimpleUi()) {
onDrawSimpleUi(canvas); onDrawSimpleUi(canvas);
} else { } else {
if (layoutSet) { if (layoutSet) {
mRelativeLayout.measure(specW, specH); mRelativeLayout.measure(specW, specH);
if (forceSquareCanvas) { int y = forceSquareCanvas ? displaySize.x : displaySize.y; // Square Steampunk
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); // force a square for Steampunk watch face. mRelativeLayout.layout(0, 0, displaySize.x, y);
} else {
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
}
mRelativeLayout.draw(canvas); mRelativeLayout.draw(canvas);
} }
} }
long fTime = System.nanoTime();
float elapsedTime = (float) (fTime - sTime) / (1000 * 1000);
Log.i(TAG, "onDraw: end " + String.format("%.3f", elapsedTime) + "ms");
} }
protected void onDrawSimpleUi(Canvas canvas) { protected void onDrawSimpleUi(Canvas canvas) {
Log.i(TAG, "onDrawSimpleUi: ");
canvas.drawRect(0, 0, displaySize.x, displaySize.y, mBackgroundPaint); canvas.drawRect(0, 0, displaySize.x, displaySize.y, mBackgroundPaint);
float xHalf = displaySize.x / 2f; float xHalf = displaySize.x / 2f;
float yThird = displaySize.y / 3f; float yThird = displaySize.y / 3f;
@ -368,8 +350,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
int getBgColour(long level) { int getBgColour(long level) {
if (level == 1) { if (level == 1) {
return colorDarkHigh; return colorDarkHigh;
}
} if (level == 0) { if (level == 0) {
return colorDarkMid; return colorDarkMid;
} }
return colorDarkLow; return colorDarkLow;
@ -377,9 +359,7 @@ 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: called ");
if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) { if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
Log.i(TAG, "onTimeChanged: minute/hour changed");
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
mDateTime.setTime(now); mDateTime.setTime(now);
@ -394,9 +374,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
private boolean isCharging() { private boolean isCharging() {
IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); int status = mBatteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
Intent batteryStatus = this.registerReceiver(null, iFilter);
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
return status == BatteryManager.BATTERY_STATUS_CHARGING || return status == BatteryManager.BATTERY_STATUS_CHARGING ||
status == BatteryManager.BATTERY_STATUS_FULL; status == BatteryManager.BATTERY_STATUS_FULL;
} }
@ -412,14 +390,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
public void setDataFields() { public void setDataFields() {
Log.i(TAG, "setDataFields: ");
setDateAndTime(); 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);
mSgv.setVisibility(View.VISIBLE); mSgv.setVisibility(View.VISIBLE);
} else { } else {
// leave the textview there but invisible, as a height holder for the empty space above the white line // Leave the textview there but invisible, as a height holder for the empty space above the white line
mSgv.setVisibility(View.INVISIBLE); mSgv.setVisibility(View.INVISIBLE);
mSgv.setText(""); mSgv.setText("");
} }
@ -488,7 +465,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
mIOB1.setVisibility(View.GONE); mIOB1.setVisibility(View.GONE);
mIOB2.setVisibility(View.GONE); mIOB2.setVisibility(View.GONE);
} }
// deal with cases where there is only the value shown for IOB, and not the label // Deal with cases where there is only the value shown for IOB, and not the label
} else if (mIOB2 != null) { } else if (mIOB2 != null) {
if (sharedPrefs.getBoolean("show_iob", true)) { if (sharedPrefs.getBoolean("show_iob", true)) {
mIOB2.setVisibility(View.VISIBLE); mIOB2.setVisibility(View.VISIBLE);
@ -501,16 +478,14 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
mIOB2.setText(""); mIOB2.setText("");
} }
} }
if (mTimestamp != null) { if (mTimestamp != null) {
if (sharedPrefs.getBoolean("showAgo", true)) { if (sharedPrefs.getBoolean("showAgo", true)) {
if (isAAPSv2 != null) { if (isAAPSv2 != null) {
mTimestamp.setText(readingAge(true)); mTimestamp.setText(readingAge(true));
} else { } else {
if (sharedPrefs.getBoolean("showExternalStatus", true)) { boolean shortString = sharedPrefs.getBoolean("showExternalStatus", true);
mTimestamp.setText(readingAge(true)); mTimestamp.setText(readingAge(shortString));
} else {
mTimestamp.setText(readingAge(false));
}
} }
mTimestamp.setVisibility(View.VISIBLE); mTimestamp.setVisibility(View.VISIBLE);
} else { } else {
@ -570,8 +545,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
mStatus.setVisibility(View.GONE); mStatus.setVisibility(View.GONE);
} }
} }
Log.i(TAG,
"setDataFields: loop " + rawData.openApsStatus + " " + (System.currentTimeMillis() - rawData.openApsStatus));
if (mLoop != null) { if (mLoop != null) {
if (sharedPrefs.getBoolean("showExternalStatus", true)) { if (sharedPrefs.getBoolean("showExternalStatus", true)) {
mLoop.setVisibility(View.VISIBLE); mLoop.setVisibility(View.VISIBLE);
@ -600,7 +574,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
@Override @Override
protected void on24HourFormatChanged(boolean is24HourFormat) { protected void on24HourFormatChanged(boolean is24HourFormat) {
Log.i(TAG, "on24HourFormatChanged: ");
initFormats(); initFormats();
if (!isSimpleUi()) { if (!isSimpleUi()) {
setDataFields(); setDataFields();
@ -609,7 +582,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
public void setDateAndTime() { public void setDateAndTime() {
Log.i(TAG, "setDateAndTime: ");
if (mTime != null) { if (mTime != null) {
mTime.setText(timeFormat.format(mDateTime)); mTime.setText(timeFormat.format(mDateTime));
} }
@ -646,7 +618,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
public void setColor() { public void setColor() {
Log.i(TAG, "setColor: ");
dividerMatchesBg = sharedPrefs.getBoolean("match_divider", false); dividerMatchesBg = sharedPrefs.getBoolean("match_divider", false);
if (lowResMode) { if (lowResMode) {
setColorLowRes(); setColorLowRes();
@ -670,7 +641,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
protected void onWatchModeChanged(WatchMode watchMode) { protected void onWatchModeChanged(WatchMode watchMode) {
Log.i(TAG, "onWatchModeChanged: " + watchMode);
lowResMode = isLowRes(watchMode); lowResMode = isLowRes(watchMode);
if (isSimpleUi()) { if (isSimpleUi()) {
setSimpleUiAntiAlias(); setSimpleUiAntiAlias();
@ -693,30 +663,21 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
private boolean isSimpleUi() { private boolean isSimpleUi() {
String simplify = sharedPrefs.getString("simplify_ui", "off"); String simplify = sharedPrefs.getString("simplify_ui", "off");
Log.i(TAG, "isSimpleUi: " + simplify);
if (simplify.equals("off")) { if (simplify.equals("off")) {
Log.i(TAG, "isSimpleUi: off");
return false; return false;
} }
if ((simplify.equals("ambient") || simplify.equals("ambient_charging")) && getCurrentWatchMode() == WatchMode.AMBIENT) { if ((simplify.equals("ambient") || simplify.equals("ambient_charging")) && getCurrentWatchMode() == WatchMode.AMBIENT) {
Log.i(TAG, "isSimpleUi: abient");
return true; return true;
} }
if((simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging()){ return (simplify.equals("charging") || simplify.equals("ambient_charging")) && isCharging();
Log.i(TAG, "isSimpleUi: charging");
return true;
}
return false;
} }
@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);
} }
if (layoutSet) { if (layoutSet) {
setDataFields(); setDataFields();
} }
@ -730,11 +691,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
protected abstract void setColorLowRes(); protected abstract void setColorLowRes();
public void missedReadingAlert() { public void missedReadingAlert() {
Log.i(TAG, "missedReadingAlert: check");
int minutes_since = (int) Math.floor(timeSince() / (1000 * 60)); int minutes_since = (int) Math.floor(timeSince() / (1000 * 60));
if (rawData.datetime == 0 || minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) { if (rawData.datetime == 0 || minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) {
Log.i(TAG, "missedReadingAlert: do"); ListenerService.requestData(this); // Attempt endTime recover missing data
ListenerService.requestData(this); // attempt endTime recover missing data
} }
} }
@ -742,7 +701,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
if (isSimpleUi()) { if (isSimpleUi()) {
return; return;
} }
Log.i(TAG, "setupCharts: ");
if (rawData.bgDataList.size() > 0) { // Dont crash things just because we dont have values, people dont like crashy things if (rawData.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 (lowResMode) { if (lowResMode) {
@ -760,21 +718,16 @@ 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: ");
long sTime = System.nanoTime();
PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50);
final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock); final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock);
Log.i(TAG, "onReceive: data " + intent.getBundleExtra("data"));
if (chart != null && dataMap != null) { if (chart != null && dataMap != null) {
rawData.addToWatchSet(dataMap); rawData.addToWatchSet(dataMap);
setupCharts(); setupCharts();
} }
rawData.updateStatusFromMessage(intent, wakeLock); rawData.updateStatusFromMessage(intent, wakeLock);
rawData.updateBasalsFromMessage(intent, wakeLock); rawData.updateBasalsFromMessage(intent, wakeLock);
Log.i(TAG, "onReceive: status " + intent.getBundleExtra("status"));
Log.i(TAG, "onReceive: " + rawData.sSgv + " " + rawData.sDirection);
if (isSimpleUi()) { if (isSimpleUi()) {
if (needUpdate()) { if (needUpdate()) {
invalidate(); invalidate();
@ -785,9 +738,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
invalidate(); invalidate();
} }
wearUtil.releaseWakeLock(wl); wearUtil.releaseWakeLock(wl);
long fTime = System.nanoTime();
float elapsedTime = (float) (fTime - sTime) / (1000 * 1000);
Log.i(TAG, "onReceive: end " + String.format("%.3f", elapsedTime) + "ms");
} }
} }
@ -797,7 +747,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
mLastSvg = rawData.sSgv; mLastSvg = rawData.sSgv;
mLastDirection = rawData.sDirection; mLastDirection = rawData.sDirection;
Log.i(TAG, "needUpdate: ");
return true; return true;
} }