package com.marverenic.music.data.store;

import android.media.audiofx.Equalizer;
import android.util.Log;

import com.crashlytics.android.Crashlytics;

public class RemotePreferencesStore implements ReadOnlyPreferencesStore {

    private static final String TAG = "RemotePreferencesStore";

    private final boolean mShowFirstStart;
    private final boolean mAllowLogging;
    private final boolean mUseMobileNetwork;
    private final boolean mOpenNowPlayingOnNewQueue;
    private final boolean mEnableNowPlayingGestures;
    private final int mDefaultPage;
    private final int mPrimaryColor;
    private final int mBaseColor;
    private final int mEqualizerPresetId;
    private final boolean mEqualizerEnabled;
    private final String mEqualizerSettings;

    public RemotePreferencesStore(ReadOnlyPreferencesStore preferencesStore) {
        mShowFirstStart = preferencesStore.showFirstStart();
        mAllowLogging = preferencesStore.allowLogging();
        mUseMobileNetwork = preferencesStore.useMobileNetwork();
        mOpenNowPlayingOnNewQueue = preferencesStore.openNowPlayingOnNewQueue();
        mEnableNowPlayingGestures = preferencesStore.enableNowPlayingGestures();
        mDefaultPage = preferencesStore.getDefaultPage();
        mPrimaryColor = preferencesStore.getPrimaryColor();
        mBaseColor = preferencesStore.getBaseColor();
        mEqualizerPresetId = preferencesStore.getEqualizerPresetId();
        mEqualizerEnabled = preferencesStore.getEqualizerEnabled();
        mEqualizerSettings = preferencesStore.getEqualizerSettings().toString();
    }

    @Override
    public boolean showFirstStart() {
        return mShowFirstStart;
    }

    @Override
    public boolean allowLogging() {
        return mAllowLogging;
    }

    @Override
    public boolean useMobileNetwork() {
        return mUseMobileNetwork;
    }

    @Override
    public boolean openNowPlayingOnNewQueue() {
        return mOpenNowPlayingOnNewQueue;
    }

    @Override
    public boolean enableNowPlayingGestures() {
        return mEnableNowPlayingGestures;
    }

    @Override
    public int getDefaultPage() {
        return mDefaultPage;
    }

    @Override
    public int getPrimaryColor() {
        return mPrimaryColor;
    }

    @Override
    public int getBaseColor() {
        return mBaseColor;
    }

    @Override
    public int getEqualizerPresetId() {
        return mEqualizerPresetId;
    }

    @Override
    public boolean getEqualizerEnabled() {
        return mEqualizerEnabled;
    }

    @Override
    public Equalizer.Settings getEqualizerSettings() {
        if (mEqualizerSettings != null) {
            try {
                return new Equalizer.Settings(mEqualizerSettings);
            } catch (IllegalArgumentException e) {
                Log.e(TAG, "getEqualizerSettings: failed to parse equalizer settings", e);
                Crashlytics.logException(e);
            }
        }
        return null;
    }
}

@@ -75,16 +75,72 @@
 alizer;%0A
+import android.os.Parcel;%0Aimport android.os.Parcelable;%0A
 import a
@@ -273,16 +273,28 @@
 cesStore
+, Parcelable
  %7B%0A%0A    
@@ -1643,32 +1643,1711 @@
 tring();%0A    %7D%0A%0A
+    protected RemotePreferencesStore(Parcel in) %7B%0A        mShowFirstStart = in.readByte() != 0;%0A        mAllowLogging = in.readByte() != 0;%0A        mUseMobileNetwork = in.readByte() != 0;%0A        mOpenNowPlayingOnNewQueue = in.readByte() != 0;%0A        mEnableNowPlayingGestures = in.readByte() != 0;%0A        mDefaultPage = in.readInt();%0A        mPrimaryColor = in.readInt();%0A        mBaseColor = in.readInt();%0A        mEqualizerPresetId = in.readInt();%0A        mEqualizerEnabled = in.readByte() != 0;%0A        mEqualizerSettings = in.readString();%0A    %7D%0A%0A    @Override%0A    public void writeToParcel(Parcel dest, int flags) %7B%0A        dest.writeByte((byte) (mShowFirstStart ? 1 : 0));%0A        dest.writeByte((byte) (mAllowLogging ? 1 : 0));%0A        dest.writeByte((byte) (mUseMobileNetwork ? 1 : 0));%0A        dest.writeByte((byte) (mOpenNowPlayingOnNewQueue ? 1 : 0));%0A        dest.writeByte((byte) (mEnableNowPlayingGestures ? 1 : 0));%0A        dest.writeInt(mDefaultPage);%0A        dest.writeInt(mPrimaryColor);%0A        dest.writeInt(mBaseColor);%0A        dest.writeInt(mEqualizerPresetId);%0A        dest.writeByte((byte) (mEqualizerEnabled ? 1 : 0));%0A        dest.writeString(mEqualizerSettings);%0A    %7D%0A%0A    @Override%0A    public int describeContents() %7B%0A        return 0;%0A    %7D%0A%0A    public static final Creator%3CRemotePreferencesStore%3E CREATOR = new Creator%3CRemotePreferencesStore%3E() %7B%0A        @Override%0A        public RemotePreferencesStore createFromParcel(Parcel in) %7B%0A            return new RemotePreferencesStore(in);%0A        %7D%0A%0A        @Override%0A        public RemotePreferencesStore%5B%5D newArray(int size) %7B%0A            return new RemotePreferencesStore%5Bsize%5D;%0A        %7D%0A    %7D;%0A%0A
     @Override%0A  

Make RemotePreferencesStore parcelable