package com.averi.worldscribe.utilities;

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

/**
 * Created by mark on 21/06/16.
 */
public class AppPreferences {
    public static final String PREFERENCES_FILE_NAME = "com.averi.worldscribe";
    public static final String LAST_OPENED_WORLD = "lastOpenedWorld";
    public static final String WRITE_PERMISSION_PROMPT_IS_ENABLED = "permissionPromptIsEnabled";
    public static final String APP_THEME = "appTheme";
    public static final String NIGHT_MODE_IS_ENABLED = "nightModeIsEnabled";

    /**
     * Save the name of the World that was last opened, so that it can automatically be loaded the
     * next time the app is launched.
     * @param context The Context calling this method.
     * @param worldName The name of the last opened World.
     */
    public static void saveLastOpenedWorld(Context context, String worldName) {
        SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_FILE_NAME,
                Context.MODE_PRIVATE);
        preferences.edit().putString(AppPreferences.LAST_OPENED_WORLD, worldName).apply();
    }

    /**
     * Checks if Night Mode is enabled.
     * @param context The The Context calling this method.
     * @return True if Night Mode is enabled; false otherwise.
     */
    public static boolean nightModeIsEnabled(Context context) {
        SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_FILE_NAME,
                Context.MODE_PRIVATE);
        return preferences.getBoolean(NIGHT_MODE_IS_ENABLED, false);
    }
}

@@ -558,16 +558,92 @@
 nabled%22;
+%0A    public static final String DROPBOX_ACCESS_TOKEN = %22dropboxAccessToken%22;
 %0A%0A    /*
@@ -1659,11 +1659,582 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Checks if this app has access to the user's Dropbox account by seeing if an access token%0A     * for that account exists in preferences.%0A     * @param context The context calling this method%0A     * @return True if a Dropbox access token exists in SharedPreferences; false otherwise%0A     */%0A    public static boolean dropboxAccessTokenExists(Context context) %7B%0A        SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_FILE_NAME,%0A                Context.MODE_PRIVATE);%0A        return preferences.contains(DROPBOX_ACCESS_TOKEN);%0A    %7D
 %0A%7D%0A

Add Dropbox Access Token constant