Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c254e35c authored by James Lemieux's avatar James Lemieux
Browse files

Preview the vibration when it is enabled on an alarm

To give the user a sample of the expected behavior when
configuring an alarm.

Change-Id: Ie64f0260857d0e8681f97d4a5f0e3024e4a64cb3
parent e6672e6d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Vibrator;
import android.text.format.DateFormat;

import com.android.deskclock.LabelDialogFragment;
@@ -89,6 +90,15 @@ public final class AlarmTimeClickHandler {
            alarm.vibrate = newState;
            mAlarmUpdateHandler.asyncUpdateAlarm(alarm, false, true);
            LogUtils.d(TAG, "Updating vibrate state to " + newState);

            if (newState) {
                // Buzz the vibrator to preview the alarm firing behavior.
                final Context context = mFragment.getActivity();
                final Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
                if (v.hasVibrator()) {
                    v.vibrate(300);
                }
            }
        }
    }