/*  Copyright (C) 2015-2017 Andreas Shimokawa, Carsten Pfeiffer, Uwe Hermann

    This file is part of Gadgetbridge.

    Gadgetbridge is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published
    by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Gadgetbridge is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.miband;

import android.content.Context;

import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertLevel;

public class VibrationProfile {
    public static final Context CONTEXT = GBApplication.getContext();
    public static final String ID_STACCATO = CONTEXT.getString(R.string.p_staccato);
    public static final String ID_SHORT = CONTEXT.getString(R.string.p_short);
    public static final String ID_MEDIUM = CONTEXT.getString(R.string.p_medium);
    public static final String ID_LONG = CONTEXT.getString(R.string.p_long);
    public static final String ID_WATERDROP = CONTEXT.getString(R.string.p_waterdrop);
    public static final String ID_RING = CONTEXT.getString(R.string.p_ring);
    public static final String ID_ALARM_CLOCK = CONTEXT.getString(R.string.p_alarm_clock);

    public static VibrationProfile getProfile(String id, short repeat) {
        if (ID_STACCATO.equals(id)) {
            return new VibrationProfile(id, new int[]{100, 0}, repeat);
        }
        if (ID_SHORT.equals(id)) {
            return new VibrationProfile(id, new int[]{200, 200}, repeat);
        }
        if (ID_LONG.equals(id)) {
            return new VibrationProfile(id, new int[]{500, 1000}, repeat);
        }
        if (ID_WATERDROP.equals(id)) {
            return new VibrationProfile(id, new int[]{100, 1500}, repeat);
        }
        if (ID_RING.equals(id)) {
            return new VibrationProfile(id, new int[]{300, 200, 600, 2000}, repeat);
        }
        if (ID_ALARM_CLOCK.equals(id)) {
            return new VibrationProfile(id, new int[]{30, 35, 30, 35, 30, 35, 30, 800}, repeat);
        }
        // medium
        return new VibrationProfile(id, new int[]{300, 600}, repeat);
    }

    private final String id;

    private final int[] onOffSequence;
    private final short repeat;
    private int alertLevel = AlertLevel.MildAlert.getId();

    /**
     * Creates a new profile instance.
     *
     * @param id            the ID, used as preference key.
     * @param onOffSequence a sequence of alternating on and off durations, in milliseconds
     * @param repeat        how often the sequence shall be repeated
     */
    public VibrationProfile(String id, int[] onOffSequence, short repeat) {
        this.id = id;
        this.repeat = repeat;
        this.onOffSequence = onOffSequence;
    }

    public String getId() {
        return id;
    }

    public int[] getOnOffSequence() {
        return onOffSequence;
    }

    public short getRepeat() {
        return repeat;
    }

    public void setAlertLevel(int alertLevel) {
        this.alertLevel = alertLevel;
    }

    public int getAlertLevel() {
        return alertLevel;
    }
}

@@ -1145,84 +1145,358 @@
 nal 
-Context CONTEXT = GBApplication.getContext();%0A    public static final String
+String ID_STACCATO;%0A    public static final String ID_SHORT;%0A    public static final String ID_MEDIUM;%0A    public static final String ID_LONG;%0A    public static final String ID_WATERDROP;%0A    public static final String ID_RING;%0A    public static final String ID_ALARM_CLOCK;%0A%0A    static %7B%0A        Context CONTEXT = GBApplication.getContext();%0A       
  ID_
@@ -1554,34 +1554,11 @@
     
-public static final String
+   
  ID_
@@ -1610,34 +1610,11 @@
     
-public static final String
+   
  ID_
@@ -1668,34 +1668,11 @@
     
-public static final String
+   
  ID_
@@ -1722,34 +1722,11 @@
     
-public static final String
+   
  ID_
@@ -1786,34 +1786,11 @@
     
-public static final String
+   
  ID_
@@ -1840,34 +1840,11 @@
     
-public static final String
+   
  ID_
@@ -1899,16 +1899,22 @@
 _clock);
+%0A    %7D
 %0A%0A    pu

Fix static context leak