android滑动解锁的震动效果
在4.0的圆环滑动解锁中,我们点击下去的时候会有震动效果,因为这个空间设置的震动效果没有绑定设置中设置的触摸振动开关来取消振动效果,
所以如果我们需要根据设置中的触摸震动开关来开启和取消滑动解锁的震动效果,就需要做以下修改了。
在LockScreen.java类中的LockScreen方法中的
else if (mUnlockWidget instanceof MultiWaveView) {
MultiWaveView multiWaveView = (MultiWaveView) mUnlockWidget;
multiWaveView.setVibrateEnabled(Settings.System.getInt(mContext.getContentResolver(),//通过判断是否设置了触摸震动效果来设置解锁的震动。
Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) != 0);
MultiWaveViewMethods multiWaveViewMethods = new MultiWaveViewMethods(multiWaveView);
multiWaveView.setOnTriggerListener(multiWaveViewMethods);
mUnlockWidgetMethods = multiWaveViewMethods;
还要在这里加入
class MultiWaveViewMethods implements MultiWaveView.OnTriggerListener,
UnlockWidgetCommonMethods {
private final MultiWaveView mMultiWaveView;
private boolean mCameraDisabled;
MultiWaveViewMethods(MultiWaveView multiWaveView) {
mMultiWaveView = multiWaveView;
multiWaveView.setVibrateEnabled(Settings.System.getInt(mContext.getContentResolver(),
Settings.System.HAPTIC_FEEDBACK_ENABLED, 1) != 0);
final boolean cameraDisabled = mLockPatternUtils.getDevicePolicyManager()
.getCameraDisabled(null);
因为滑动解锁主要使用的就是MultiWaveView这个控件,而这个控件是有设置是否振动的属性。
补充:移动开发 , Android ,