// Path: common/src/main/java/com/matejdro/wearvibrationcenter/common/AlarmCommand.java
// public class AlarmCommand implements Parcelable, InterruptionCommand {
//     private final String text;
//     private final long[] vibrationPattern;
//     private final byte[] backgroundBitmap;
//     private final byte[] icon;
//     private final int snoozeDuration;
//     private final boolean doNotVibrateInTheater;
//     private final boolean doNotVibrateOnCharger;
// 
//     public AlarmCommand(LiteAlarmCommand liteAlarmCommand, byte[] backgroundBitmap, byte[] icon) {
//         this(liteAlarmCommand.getText(),
//                 liteAlarmCommand.getVibrationPattern(),
//                 backgroundBitmap,
//                 icon,
//                 liteAlarmCommand.getSnoozeDuration(),
//                 liteAlarmCommand.shouldNotVibrateInTheater(),
//                 liteAlarmCommand.shouldNotVibrateOnCharger());
//     }
// 
//     public AlarmCommand(String text, long[] vibrationPattern, byte[] backgroundBitmap, byte[] icon, int snoozeDuration, boolean doNotVibrateInTheater, boolean doNotVibrateOnCharger) {
//         this.text = text;
//         this.vibrationPattern = vibrationPattern;
//         this.backgroundBitmap = backgroundBitmap;
//         this.icon = icon;
//         this.snoozeDuration = snoozeDuration;
//         this.doNotVibrateInTheater = doNotVibrateInTheater;
//         this.doNotVibrateOnCharger = doNotVibrateOnCharger;
//     }
// 
//     public String getText() {
//         return text;
//     }
// 
//     public byte[] getBackgroundBitmap() {
//         return backgroundBitmap;
//     }
// 
//     public boolean shouldNotVibrateInTheater() {
//         return doNotVibrateInTheater;
//     }
// 
//     public boolean shouldNotVibrateOnCharger() {
//         return doNotVibrateOnCharger;
//     }
// 
//     public byte[] getIcon() {
//         return icon;
//     }
// 
//     public long[] getVibrationPattern() {
//         return vibrationPattern;
//     }
// 
//     public int getSnoozeDuration() {
//         return snoozeDuration;
//     }
// 
//     @Override public int describeContents() {
//         return 0;
//     }
// 
//     @Override public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(this.text);
//         dest.writeLongArray(this.vibrationPattern);
//         dest.writeByteArray(this.backgroundBitmap);
//         dest.writeByteArray(this.icon);
//         dest.writeInt(this.snoozeDuration);
//         dest.writeByte(this.doNotVibrateInTheater ? (byte) 1 : (byte) 0);
//         dest.writeByte(this.doNotVibrateOnCharger ? (byte) 1 : (byte) 0);
//     }
// 
//     protected AlarmCommand(Parcel in) {
//         this.text = in.readString();
//         this.vibrationPattern = in.createLongArray();
//         this.backgroundBitmap = in.createByteArray();
//         this.icon = in.createByteArray();
//         this.snoozeDuration = in.readInt();
//         this.doNotVibrateInTheater = in.readByte() != 0;
//         this.doNotVibrateOnCharger = in.readByte() != 0;
//     }
// 
//     public static final Creator<AlarmCommand> CREATOR = new Creator<AlarmCommand>() {
//         @Override public AlarmCommand createFromParcel(Parcel source) {
//             return new AlarmCommand(source);
//         }
// 
//         @Override public AlarmCommand[] newArray(int size) {
//             return new AlarmCommand[size];
//         }
//     };
// }
// 
// Path: common/src/main/java/com/matejdro/wearvibrationcenter/preferences/GlobalSettings.java
// public class GlobalSettings {
//     public static final PreferenceDefinition<Boolean> ENABLE_VIBRATIONS = new SimplePreferenceDefinition<>("enable_vibrations", true);
//     public static final PreferenceDefinition<Integer> ALARM_TIMEOUT = new SimplePreferenceDefinition<>("alarm_timeout", 60);
//     public static final PreferenceDefinition<List<String>> MUTE_INTERVALS = new SimplePreferenceDefinition<>("mute_intervals", Arrays.asList("10", "20", "30", "60", "120"));
//     public static final EnumPreferenceDefinition<ZenModeChange> TIMED_MUTE_ZEN_CHANGE = new EnumPreferenceDefinition<>("timed_mute_zen", ZenModeChange.ALARMS);
//     public static final PreferenceDefinition<Integer> PROCESSING_DELAY = new SimplePreferenceDefinition<>("processing_delay", 2000);
// 
// 
// }


import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import androidx.annotation.NonNull;
import android.support.wearable.activity.ConfirmationActivity;
import android.support.wearable.activity.WearableActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.matejdro.wearutils.messages.ParcelPacker;
import com.matejdro.wearutils.miscutils.BitmapUtils;
import com.matejdro.wearutils.preferences.definition.Preferences;
import com.matejdro.wearvibrationcenter.common.AlarmCommand;
import com.matejdro.wearvibrationcenter.preferences.GlobalSettings;
import timber.log.Timber;
        }

        vibrator.cancel();
        vibrator.vibrate(alarmCommand.getVibrationPattern(), -1);
        mainThreadHandler.removeCallbacks(vibrationRestartRunnable);
        mainThreadHandler.postDelayed(vibrationRestartRunnable, vibrationTimeSum);
    }

    @Override
    protected void onResume() {
        restartVibrator();
        onAmbientStateChanged(isAmbient());
        resumed = true;

        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        resumed = false;
    }

    @Override
    protected void onStop() {
        super.onStop();

        if (!dismissed) {
            // Screen has turned off or some other app gained focus. Alarm must continue, let's try to restart ourselves.

// Path: common/src/main/java/com/matejdro/wearvibrationcenter/common/AlarmCommand.java
// public class AlarmCommand implements Parcelable, InterruptionCommand {
//     private final String text;
//     private final long[] vibrationPattern;
//     private final byte[] backgroundBitmap;
//     private final byte[] icon;
//     private final int snoozeDuration;
//     private final boolean doNotVibrateInTheater;
//     private final boolean doNotVibrateOnCharger;
// 
//     public AlarmCommand(LiteAlarmCommand liteAlarmCommand, byte[] backgroundBitmap, byte[] icon) {
//         this(liteAlarmCommand.getText(),
//                 liteAlarmCommand.getVibrationPattern(),
//                 backgroundBitmap,
//                 icon,
//                 liteAlarmCommand.getSnoozeDuration(),
//                 liteAlarmCommand.shouldNotVibrateInTheater(),
//                 liteAlarmCommand.shouldNotVibrateOnCharger());
//     }
// 
//     public AlarmCommand(String text, long[] vibrationPattern, byte[] backgroundBitmap, byte[] icon, int snoozeDuration, boolean doNotVibrateInTheater, boolean doNotVibrateOnCharger) {
//         this.text = text;
//         this.vibrationPattern = vibrationPattern;
//         this.backgroundBitmap = backgroundBitmap;
//         this.icon = icon;
//         this.snoozeDuration = snoozeDuration;
//         this.doNotVibrateInTheater = doNotVibrateInTheater;
//         this.doNotVibrateOnCharger = doNotVibrateOnCharger;
//     }
// 
//     public String getText() {
//         return text;
//     }
// 
//     public byte[] getBackgroundBitmap() {
//         return backgroundBitmap;
//     }
// 
//     public boolean shouldNotVibrateInTheater() {
//         return doNotVibrateInTheater;
//     }
// 
//     public boolean shouldNotVibrateOnCharger() {
//         return doNotVibrateOnCharger;
//     }
// 
//     public byte[] getIcon() {
//         return icon;
//     }
// 
//     public long[] getVibrationPattern() {
//         return vibrationPattern;
//     }
// 
//     public int getSnoozeDuration() {
//         return snoozeDuration;
//     }
// 
//     @Override public int describeContents() {
//         return 0;
//     }
// 
//     @Override public void writeToParcel(Parcel dest, int flags) {
//         dest.writeString(this.text);
//         dest.writeLongArray(this.vibrationPattern);
//         dest.writeByteArray(this.backgroundBitmap);
//         dest.writeByteArray(this.icon);
//         dest.writeInt(this.snoozeDuration);
//         dest.writeByte(this.doNotVibrateInTheater ? (byte) 1 : (byte) 0);
//         dest.writeByte(this.doNotVibrateOnCharger ? (byte) 1 : (byte) 0);
//     }
// 
//     protected AlarmCommand(Parcel in) {
//         this.text = in.readString();
//         this.vibrationPattern = in.createLongArray();
//         this.backgroundBitmap = in.createByteArray();
//         this.icon = in.createByteArray();
//         this.snoozeDuration = in.readInt();
//         this.doNotVibrateInTheater = in.readByte() != 0;
//         this.doNotVibrateOnCharger = in.readByte() != 0;
//     }
// 
//     public static final Creator<AlarmCommand> CREATOR = new Creator<AlarmCommand>() {
//         @Override public AlarmCommand createFromParcel(Parcel source) {
//             return new AlarmCommand(source);
//         }
// 
//         @Override public AlarmCommand[] newArray(int size) {
//             return new AlarmCommand[size];
//         }
//     };
// }
// 
// Path: common/src/main/java/com/matejdro/wearvibrationcenter/preferences/GlobalSettings.java
// public class GlobalSettings {
//     public static final PreferenceDefinition<Boolean> ENABLE_VIBRATIONS = new SimplePreferenceDefinition<>("enable_vibrations", true);
//     public static final PreferenceDefinition<Integer> ALARM_TIMEOUT = new SimplePreferenceDefinition<>("alarm_timeout", 60);
//     public static final PreferenceDefinition<List<String>> MUTE_INTERVALS = new SimplePreferenceDefinition<>("mute_intervals", Arrays.asList("10", "20", "30", "60", "120"));
//     public static final EnumPreferenceDefinition<ZenModeChange> TIMED_MUTE_ZEN_CHANGE = new EnumPreferenceDefinition<>("timed_mute_zen", ZenModeChange.ALARMS);
//     public static final PreferenceDefinition<Integer> PROCESSING_DELAY = new SimplePreferenceDefinition<>("processing_delay", 2000);
// 
// 
// }


// Path: wear/src/main/java/com/matejdro/wearvibrationcenter/AlarmActivity.java
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import androidx.annotation.NonNull;
import android.support.wearable.activity.ConfirmationActivity;
import android.support.wearable.activity.WearableActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import com.matejdro.wearutils.messages.ParcelPacker;
import com.matejdro.wearutils.miscutils.BitmapUtils;
import com.matejdro.wearutils.preferences.definition.Preferences;
import com.matejdro.wearvibrationcenter.common.AlarmCommand;
import com.matejdro.wearvibrationcenter.preferences.GlobalSettings;
import timber.log.Timber;

        }

        vibrator.cancel();
        vibrator.vibrate(alarmCommand.getVibrationPattern(), -1);
        mainThreadHandler.removeCallbacks(vibrationRestartRunnable);
        mainThreadHandler.postDelayed(vibrationRestartRunnable, vibrationTimeSum);
    }

    @Override
    protected void onResume() {
        restartVibrator();
        onAmbientStateChanged(isAmbient());
        resumed = true;

        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        resumed = false;
    }

    @Override
    protected void onStop() {
        super.onStop();

        if (!dismissed) {
            // Screen has turned off or some other app gained focus. Alarm must continue, let's try to restart ourselves.

            Intent restartIntent = new Intent(this, AlarmActivity.class);