Wear disable logs
This commit is contained in:
parent
6e5d14d470
commit
b8c2693d67
1 changed files with 63 additions and 75 deletions
|
@ -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,27 +166,21 @@ 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);
|
|
||||||
final int colorDarkDark = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor);
|
|
||||||
|
|
||||||
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
|
|
||||||
@Override
|
|
||||||
public void onLayoutInflated(WatchViewStub stub) {
|
|
||||||
mTime = stub.findViewById(R.id.watch_time);
|
mTime = stub.findViewById(R.id.watch_time);
|
||||||
mHour = stub.findViewById(R.id.hour);
|
mHour = stub.findViewById(R.id.hour);
|
||||||
mMinute = stub.findViewById(R.id.minute);
|
mMinute = stub.findViewById(R.id.minute);
|
||||||
|
@ -232,18 +224,15 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
layoutSet = true;
|
layoutSet = true;
|
||||||
setDataFields();
|
setDataFields();
|
||||||
setColor();
|
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);
|
||||||
|
|
Loading…
Reference in a new issue