package de.sopa.manager;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * David Schilling - davejs92@gmail.com
 */
public class SettingsService {

    SharedPreferences sharedPreferences;
    private static final String PREFS_NAME = "MyPrefsFile";
    private String MUTE = "mute";

    public SettingsService(Context context) {
        sharedPreferences = context.getSharedPreferences(PREFS_NAME, 0);
    }

    public boolean isFirstTime() {
        String my_first_time = "my_first_time";
        if(sharedPreferences.getBoolean(my_first_time, true)) {
            sharedPreferences.edit().putBoolean(my_first_time, false).apply();
            return true;
        }
        return false;
    }

    public boolean isMute(){
        return sharedPreferences.getBoolean(MUTE, false);
    }

    public void switchMute() {
        sharedPreferences.edit().putBoolean(MUTE, !sharedPreferences.getBoolean(MUTE, true)).apply();
    }
}

@@ -287,16 +287,29 @@
 private 
+static final 
 String M
@@ -321,16 +321,81 @@
  %22mute%22;
+%0A    private static final String MY_FIRST_TIME = %22MY_FIRST_TIME%22;
 %0A%0A    pu
@@ -553,56 +553,8 @@
 ) %7B%0A
-        String my_first_time = %22my_first_time%22;%0A
     
@@ -589,29 +589,29 @@
 Boolean(
-my_first_time
+MY_FIRST_TIME
 , true))
@@ -665,21 +665,21 @@
 ean(
-my_first_time
+MY_FIRST_TIME
 , fa
@@ -936,47 +936,15 @@
 E, !
-sharedPreferences.getBoolean(MUTE, true
+isMute(
 )).a

fix inconsistenct between mute state and button