Move vibrateHourly to BaseWatchFace
This commit is contained in:
parent
d220a903b0
commit
4eda29577c
2 changed files with 13 additions and 23 deletions
|
@ -11,6 +11,7 @@ import android.graphics.Paint;
|
|||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import android.support.wearable.view.WatchViewStub;
|
||||
|
@ -233,6 +234,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
setDataFields();
|
||||
setColor();
|
||||
missedReadingAlert();
|
||||
checkVibrateHourly(oldTime,newTime);
|
||||
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
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 {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
|
|
@ -170,28 +170,6 @@ public class DigitalStyle01 extends BaseWatchFace {
|
|||
protected void setColorLowRes() {
|
||||
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