<commit_before>package com.bkromhout.minerva.prefs;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.bkromhout.minerva.Minerva;
import com.bkromhout.minerva.R;
import com.bkromhout.minerva.activities.MainActivity;

/**
 * Preferences class for general/miscellaneous preferences.
 */
public class DefaultPrefs {
    // Key strings.
    private final static String CURR_FRAG = "CURR_FRAG";
    private final static String CURR_LIST_SEL = "CURR_LIST_UNIQUE_SEL";

    public final static String LIB_DIR = Minerva.getAppCtx().getString(R.string.key_lib_dir);
    private final static String LIB_AUTO_IMPORT = Minerva.getAppCtx().getString(R.string.key_auto_import);
    private final static String LAST_IMPORT_SUCCESS_TIME = "LAST_IMPORT_SUCCESS_TIME";
    private final static String FIRST_IMPORT_TRIGGERED = "FIRST_IMPORT_TRIGGERED";

    /**
     * Static instance.
     */
    private static DefaultPrefs INSTANCE = null;
    /**
     * Shared Preferences.
     */
    private SharedPreferences prefs;

    // No public construction allowed.
    private DefaultPrefs() {
        // Get shared preferences.
        this.prefs = PreferenceManager.getDefaultSharedPreferences(Minerva.getAppCtx());

    }

    /**
     * Get an instance.
     * @return {@link DefaultPrefs}.
     */
    public static DefaultPrefs get() {
        if (INSTANCE == null) INSTANCE = new DefaultPrefs();
        return INSTANCE;
    }

    /**
     * Get the int which specifies the fragment that is currently being shown in {@link
     * MainActivity}.
     * @param defValue The default value to return if nothing is set.
     * @return Frag int.
     */
    public int getCurrFrag(int defValue) {
        return prefs.getInt(CURR_FRAG, defValue);
    }

    /**
     * Put the int which specifies the fragment that is currently being shown in {@link
     * MainActivity}.
     * @param currFrag Frag int.
     */
    public void putCurrFrag(int currFrag) {
        prefs.edit().putInt(CURR_FRAG, currFrag).apply();
    }

    /**
     * Get the a string which uniquely identifies the list that was last shown in the list fragment.
     * @param defValue The default value to return if nothing is set.
     * @return The list selector string.
     */
    public String getCurrListSel(String defValue) {
        return prefs.getString(CURR_LIST_SEL, defValue);
    }

    /**
     * Put the a string which uniquely identifies the list that was last shown in the list fragment.
     * @param currListSel Unique list selector string.
     */
    public void putCurrListSel(String currListSel) {
        prefs.edit().putString(CURR_LIST_SEL, currListSel).apply();
    }

    /**<commit_msg>Code style<commit_after>package com.bkromhout.minerva.prefs;

import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.bkromhout.minerva.Minerva;
import com.bkromhout.minerva.R;
import com.bkromhout.minerva.activities.MainActivity;

/**
 * Preferences class for general/miscellaneous preferences.
 */
public class DefaultPrefs {
    // Key strings.
    private final static String CURR_FRAG = "CURR_FRAG";
    private final static String CURR_LIST_SEL = "CURR_LIST_UNIQUE_SEL";

    public final static String LIB_DIR = Minerva.getAppCtx().getString(R.string.key_lib_dir);
    private final static String LIB_AUTO_IMPORT = Minerva.getAppCtx().getString(R.string.key_auto_import);
    private final static String LAST_IMPORT_SUCCESS_TIME = "LAST_IMPORT_SUCCESS_TIME";
    private final static String FIRST_IMPORT_TRIGGERED = "FIRST_IMPORT_TRIGGERED";

    /**
     * Static instance.
     */
    private static DefaultPrefs INSTANCE = null;
    /**
     * Shared Preferences.
     */
    private SharedPreferences prefs;

    // No public construction allowed.
    private DefaultPrefs() {
        // Get shared preferences.
        this.prefs = PreferenceManager.getDefaultSharedPreferences(Minerva.getAppCtx());
    }

    /**
     * Get an instance.
     * @return {@link DefaultPrefs}.
     */
    public static DefaultPrefs get() {
        if (INSTANCE == null) INSTANCE = new DefaultPrefs();
        return INSTANCE;
    }

    /**
     * Get the int which specifies the fragment that is currently being shown in {@link MainActivity}.
     * @param defValue The default value to return if nothing is set.
     * @return Frag int.
     */
    public int getCurrFrag(int defValue) {
        return prefs.getInt(CURR_FRAG, defValue);
    }

    /**
     * Put the int which specifies the fragment that is currently being shown in {@link MainActivity}.
     * @param currFrag Frag int.
     */
    public void putCurrFrag(int currFrag) {
        prefs.edit().putInt(CURR_FRAG, currFrag).apply();
    }

    /**
     * Get the a string which uniquely identifies the list that was last shown in the list fragment.
     * @param defValue The default value to return if nothing is set.
     * @return The list selector string.
     */
    public String getCurrListSel(String defValue) {
        return prefs.getString(CURR_LIST_SEL, defValue);
    }

    /**
     * Put the a string which uniquely identifies the list that was last shown in the list fragment.
     * @param currListSel Unique list selector string.
     */
    public void putCurrListSel(String currListSel) {
        prefs.edit().putString(CURR_LIST_SEL, currListSel).apply();
    }

    /**
{'fraction_non_alphanumeric': 0.08872458410351201, 'fraction_numerical': 0.0, 'mean_word_length': 3.0170749814402376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1217442', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1601, 'n_words': 459}