diff --git a/MotoActions/src/com/moto/actions/actions/FlipToMute.java b/MotoActions/src/com/moto/actions/actions/FlipToMute.java index b226a27..8676ad1 100644 --- a/MotoActions/src/com/moto/actions/actions/FlipToMute.java +++ b/MotoActions/src/com/moto/actions/actions/FlipToMute.java @@ -25,6 +25,7 @@ import android.content.IntentFilter; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; +import android.os.Vibrator; import android.util.Log; import com.moto.actions.MotoActionsSettings; @@ -39,6 +40,7 @@ public class FlipToMute implements UpdatedStateNotifier { private final Sensor mFlatDown; private final Sensor mStow; + private boolean canVibrate = false; private boolean mIsEnabled; private boolean mIsFlatDown; private boolean mIsStowed; @@ -106,14 +108,25 @@ public class FlipToMute implements UpdatedStateNotifier { Log.d(TAG, "event: " + mIsFlatDown + " mIsStowed=" + mIsStowed); if (mIsFlatDown && mIsStowed) { + vibrate(); + canVibrate = true; mNotificationManager.setInterruptionFilter(NotificationManager.INTERRUPTION_FILTER_PRIORITY); Log.d(TAG, "Interrupt filter: Allow priority"); } else if (!mIsFlatDown) { + if (canVibrate) { + vibrate(); + canVibrate = false; + } mNotificationManager.setInterruptionFilter(mFilter); Log.d(TAG, "Interrupt filter: Restore"); } } + private void vibrate() { + Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE); + v.vibrate(250); + } + public class Receiver extends BroadcastReceiver { @Override