Move vibrateHourly to BaseWatchFace
This commit is contained in:
parent
d220a903b0
commit
4eda29577c
|
@ -11,6 +11,7 @@ import android.graphics.Paint;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.Vibrator;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
import android.support.wearable.view.WatchViewStub;
|
import android.support.wearable.view.WatchViewStub;
|
||||||
|
@ -233,6 +234,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
setDataFields();
|
setDataFields();
|
||||||
setColor();
|
setColor();
|
||||||
missedReadingAlert();
|
missedReadingAlert();
|
||||||
|
checkVibrateHourly(oldTime,newTime);
|
||||||
|
|
||||||
mRelativeLayout.measure(specW, specH);
|
mRelativeLayout.measure(specW, specH);
|
||||||
if (forceSquareCanvas) {
|
if (forceSquareCanvas) {
|
||||||
|
@ -244,6 +246,16 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkVibrateHourly(WatchFaceTime oldTime, WatchFaceTime newTime){
|
||||||
|
Boolean hourlyVibratePref = sharedPrefs.getBoolean("vibrate_Hourly", false);
|
||||||
|
if (hourlyVibratePref && layoutSet && newTime.hasHourChanged(oldTime)) {
|
||||||
|
Log.i("hourlyVibratePref", "true --> " + newTime.toString());
|
||||||
|
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
|
||||||
|
long[] vibrationPattern = {0, 150, 125, 100};
|
||||||
|
vibrator.vibrate(vibrationPattern, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|
|
@ -170,28 +170,6 @@ public class DigitalStyle01 extends BaseWatchFace {
|
||||||
protected void setColorLowRes() {
|
protected void setColorLowRes() {
|
||||||
setColorDark();
|
setColorDark();
|
||||||
}
|
}
|
||||||
|
protected void setColorBright() { setColorDark(); /* getCurrentWatchMode() == WatchMode.AMBIENT or WatchMode.INTERACTIVE */}
|
||||||
protected void setColorBright() {
|
|
||||||
if (getCurrentWatchMode() == WatchMode.INTERACTIVE) {
|
|
||||||
setColorDark();
|
|
||||||
} else {
|
|
||||||
setColorDark();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onTimeChanged(WatchFaceTime oldTime, WatchFaceTime newTime) {
|
|
||||||
super.onTimeChanged(oldTime,newTime);
|
|
||||||
|
|
||||||
/* hourly vibration*/
|
|
||||||
Boolean hourlyVibratePref = sharedPrefs.getBoolean("vibrate_Hourly", false);
|
|
||||||
if (hourlyVibratePref && layoutSet && newTime.hasHourChanged(oldTime)) {
|
|
||||||
Log.i("hourlyVibratePref", "true --> " + newTime.toString());
|
|
||||||
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
|
|
||||||
long[] vibrationPattern = {0, 150, 125, 100};
|
|
||||||
vibrator.vibrate(vibrationPattern, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue