Wear disable logs

This commit is contained in:
Andries Smit 2022-01-06 21:11:42 +01:00
parent 6e5d14d470
commit b8c2693d67

View file

@ -62,7 +62,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
@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();
@ -109,15 +108,14 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
private LocalBroadcastManager localBroadcastManager; private LocalBroadcastManager localBroadcastManager;
private MessageReceiver messageReceiver; private MessageReceiver messageReceiver;
private BroadcastReceiver batteryReceiver; private BroadcastReceiver batteryReceiver;
protected boolean isCharging = false; private int colorDarkHigh;
int colorDarkHigh; private int colorDarkMid;
int colorDarkMid; private int colorDarkLow;
int colorDarkLow; private java.text.DateFormat timeFormat;
java.text.DateFormat timeFormat;
@Override @Override
public void onCreate() { public void onCreate() {
Log.i(TAG, "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();
@ -148,16 +146,16 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
private void setupBatteryReceiver() { private void setupBatteryReceiver() {
String setting = sharedPrefs.getString("simplify_ui", "off"); String setting = sharedPrefs.getString("simplify_ui", "off");
Log.i(TAG, "setupBatteryReceiver: " + setting); //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"); //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: "); //Log.i(TAG, "Battery BroadcastReceiver.onReceive: ");
setDataFields(); setDataFields();
invalidate(); invalidate();
} }
@ -168,82 +166,73 @@ 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: "); //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();
} }
public void performViewSetup() { public void performViewSetup() {
final WatchViewStub stub = layoutView.findViewById(R.id.watch_view_stub); final WatchViewStub layoutStub = layoutView.findViewById(R.id.watch_view_stub);
IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND); IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND);
messageReceiver = new MessageReceiver(); messageReceiver = new MessageReceiver();
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); layoutStub.setOnLayoutInflatedListener((WatchViewStub stub) -> {
final int colorDarkMid = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); mTime = stub.findViewById(R.id.watch_time);
final int colorDarkDark = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor); mHour = stub.findViewById(R.id.hour);
mMinute = stub.findViewById(R.id.minute);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { mTimePeriod = stub.findViewById(R.id.timePeriod);
@Override mDay = stub.findViewById(R.id.day);
public void onLayoutInflated(WatchViewStub stub) { mDayName = stub.findViewById(R.id.dayname);
mTime = stub.findViewById(R.id.watch_time); mMonth = stub.findViewById(R.id.month);
mHour = stub.findViewById(R.id.hour); mDate = stub.findViewById(R.id.date_time);
mMinute = stub.findViewById(R.id.minute); mLoop = stub.findViewById(R.id.loop);
mTimePeriod = stub.findViewById(R.id.timePeriod); mSgv = stub.findViewById(R.id.sgv);
mDay = stub.findViewById(R.id.day); mDirection = stub.findViewById(R.id.direction);
mDayName = stub.findViewById(R.id.dayname); mTimestamp = stub.findViewById(R.id.timestamp);
mMonth = stub.findViewById(R.id.month); mIOB1 = stub.findViewById(R.id.iob_text);
mDate = stub.findViewById(R.id.date_time); mIOB2 = stub.findViewById(R.id.iobView);
mLoop = stub.findViewById(R.id.loop); mCOB1 = stub.findViewById(R.id.cob_text);
mSgv = stub.findViewById(R.id.sgv); mCOB2 = stub.findViewById(R.id.cobView);
mDirection = stub.findViewById(R.id.direction); mBgi = stub.findViewById(R.id.bgiView);
mTimestamp = stub.findViewById(R.id.timestamp); mStatus = stub.findViewById(R.id.externaltstatus);
mIOB1 = stub.findViewById(R.id.iob_text); mBasalRate = stub.findViewById(R.id.tmpBasal);
mIOB2 = stub.findViewById(R.id.iobView); mUploaderBattery = stub.findViewById(R.id.uploader_battery);
mCOB1 = stub.findViewById(R.id.cob_text); mRigBattery = stub.findViewById(R.id.rig_battery);
mCOB2 = stub.findViewById(R.id.cobView); mDelta = stub.findViewById(R.id.delta);
mBgi = stub.findViewById(R.id.bgiView); mAvgDelta = stub.findViewById(R.id.avgdelta);
mStatus = stub.findViewById(R.id.externaltstatus); isAAPSv2 = stub.findViewById(R.id.AAPSv2);
mBasalRate = stub.findViewById(R.id.tmpBasal); mHighLight = stub.findViewById(R.id.highLight);
mUploaderBattery = stub.findViewById(R.id.uploader_battery); mLowLight = stub.findViewById(R.id.lowLight);
mRigBattery = stub.findViewById(R.id.rig_battery); mRelativeLayout = stub.findViewById(R.id.main_layout);
mDelta = stub.findViewById(R.id.delta); mLinearLayout = stub.findViewById(R.id.secondary_layout);
mAvgDelta = stub.findViewById(R.id.avgdelta); mLinearLayout2 = stub.findViewById(R.id.tertiary_layout);
isAAPSv2 = stub.findViewById(R.id.AAPSv2); mGlucoseDial = stub.findViewById(R.id.glucose_dial);
mHighLight = stub.findViewById(R.id.highLight); mDeltaGauge = stub.findViewById(R.id.delta_pointer);
mLowLight = stub.findViewById(R.id.lowLight); mHourHand = stub.findViewById(R.id.hour_hand);
mRelativeLayout = stub.findViewById(R.id.main_layout); mMinuteHand = stub.findViewById(R.id.minute_hand);
mLinearLayout = stub.findViewById(R.id.secondary_layout); mChartTap = stub.findViewById(R.id.chart_zoom_tap);
mLinearLayout2 = stub.findViewById(R.id.tertiary_layout); mMainMenuTap = stub.findViewById(R.id.main_menu_tap);
mGlucoseDial = stub.findViewById(R.id.glucose_dial); chart = stub.findViewById(R.id.chart);
mDeltaGauge = stub.findViewById(R.id.delta_pointer); mSimpleUi = stub.findViewById(R.id.simple_ui);
mHourHand = stub.findViewById(R.id.hour_hand); mSimpleSvg = stub.findViewById(R.id.simple_sgv);
mMinuteHand = stub.findViewById(R.id.minute_hand); mSimpleDirection = stub.findViewById(R.id.simple_direction);
mChartTap = stub.findViewById(R.id.chart_zoom_tap); mSimpleTime = stub.findViewById(R.id.simple_watch_time);
mMainMenuTap = stub.findViewById(R.id.main_menu_tap); layoutSet = true;
chart = stub.findViewById(R.id.chart); setDataFields();
mSimpleUi = stub.findViewById(R.id.simple_ui); setColor();
mSimpleSvg = stub.findViewById(R.id.simple_sgv); });
mSimpleDirection = stub.findViewById(R.id.simple_direction);
mSimpleTime = stub.findViewById(R.id.simple_watch_time);
layoutSet = true;
setDataFields();
setColor();
}
}
);
wakeLock.acquire(50); wakeLock.acquire(50);
} }
public int ageLevel() { public int ageLevel() {
if (timeSince() <= (1000 * 60 * 12)) { if (timeSince() <= (1000 * 60 * 12)) {
return 1; return 1;
} else {
return 0;
} }
return 0;
} }
public double timeSince() { public double timeSince() {
@ -283,7 +272,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
Log.i(TAG, "onDraw: "); //Log.i(TAG, "onDraw: ");
if (layoutSet) { if (layoutSet) {
setupCharts(); setupCharts();
@ -294,15 +283,15 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y); mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
} }
mRelativeLayout.draw(canvas); mRelativeLayout.draw(canvas);
Log.d("onDraw", "draw"); //Log.d("onDraw", "draw");
} }
} }
@Override @Override
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) { protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
Log.i(TAG, "onTimeChanged: "); // Log.i(TAG, "onTimeChanged: ");
if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) { if (layoutSet && (newTime.hasHourChanged(oldTime) || newTime.hasMinuteChanged(oldTime))) {
Log.i(TAG, "onTimeChanged: time changed"); //Log.i(TAG, "onTimeChanged: time changed");
PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50); PowerManager.WakeLock wl = wearUtil.getWakeLock("readingPrefs", 50);
setDataFields(); setDataFields();
@ -550,7 +539,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
mSimpleDirection.setText(rawData.sDirection+"\uFE0E"); mSimpleDirection.setText(rawData.sDirection+"\uFE0E");
mSimpleTime.setText(timeFormat.format(System.currentTimeMillis())); mSimpleTime.setText(timeFormat.format(System.currentTimeMillis()));
return true; return true;
} }
@ -638,7 +626,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
protected void onWatchModeChanged(WatchMode watchMode) { protected void onWatchModeChanged(WatchMode watchMode) {
Log.i(TAG, "onWatchModeChanged: " + 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);
@ -669,7 +657,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: "); //Log.i(TAG, "onSharedPreferenceChanged: ");
setupBatteryReceiver(); setupBatteryReceiver();
if ("delta_granularity".equals(key)) { if ("delta_granularity".equals(key)) {
ListenerService.requestData(this); ListenerService.requestData(this);
@ -716,7 +704,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: "); //Log.i(TAG, "Data MessageReceiver.onReceive: ");
if (layoutSet) { if (layoutSet) {
final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock); final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock);