// Path: Android/mobile/src/main/java/fi/iki/murgo/irssinotifier/Server.java
// public enum ServerTarget {
//     SaveSettings,
//     Test,
//     FetchData,
//     Authenticate,
//     Message,
//     WipeSettings,
//     GetNonce,
//     License,
// }


import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import fi.iki.murgo.irssinotifier.Server.ServerTarget;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import com.google.firebase.iid.FirebaseInstanceId;
    public String getAuthToken() {
        return sharedPreferences.getString(AUTH_TOKEN_KEY, null);
    }

    public boolean setAuthToken(String token) {
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(AUTH_TOKEN_KEY, token);
        editor.putBoolean(SETTINGS_SENT_KEY, false);
        return editor.commit();
    }

    public boolean settingsNeedSending() {
        return !sharedPreferences.getBoolean(SETTINGS_SENT_KEY, false);
    }

    public ServerResponse sendSettings(Server server) throws IOException {
        HashMap<String, String> map = new HashMap<String, String>();

        if (getGcmRegistrationId() == null) {
            throw new IllegalStateException();
        }

        map.put("RegistrationId", getGcmRegistrationId());
        ServerTarget target;

        if (isNotificationsEnabled()) {
            map.put(DEVICE_NAME_KEY, android.os.Build.MODEL);
            map.put(ENABLED_KEY, "1");
            target = ServerTarget.SaveSettings;
        } else {
// Path: Android/mobile/src/main/java/fi/iki/murgo/irssinotifier/Server.java
// public enum ServerTarget {
//     SaveSettings,
//     Test,
//     FetchData,
//     Authenticate,
//     Message,
//     WipeSettings,
//     GetNonce,
//     License,
// }


// Path: Android/mobile/src/main/java/fi/iki/murgo/irssinotifier/Preferences.java
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import fi.iki.murgo.irssinotifier.Server.ServerTarget;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.util.Log;
import com.google.firebase.iid.FirebaseInstanceId;

    public String getAuthToken() {
        return sharedPreferences.getString(AUTH_TOKEN_KEY, null);
    }

    public boolean setAuthToken(String token) {
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(AUTH_TOKEN_KEY, token);
        editor.putBoolean(SETTINGS_SENT_KEY, false);
        return editor.commit();
    }

    public boolean settingsNeedSending() {
        return !sharedPreferences.getBoolean(SETTINGS_SENT_KEY, false);
    }

    public ServerResponse sendSettings(Server server) throws IOException {
        HashMap<String, String> map = new HashMap<String, String>();

        if (getGcmRegistrationId() == null) {
            throw new IllegalStateException();
        }

        map.put("RegistrationId", getGcmRegistrationId());
        ServerTarget target;

        if (isNotificationsEnabled()) {
            map.put(DEVICE_NAME_KEY, android.os.Build.MODEL);
            map.put(ENABLED_KEY, "1");
            target = ServerTarget.SaveSettings;
        } else {
            target = ServerTarget.WipeSettings;