package net.somethingdreadful.MAL;

import android.content.Context;

import org.holoeverywhere.preference.PreferenceManager;
import org.holoeverywhere.preference.SharedPreferences;

import java.util.Locale;

public class PrefManager {
    private static SharedPreferences prefs;
    private static SharedPreferences.Editor prefeditor;
    private static Context context;


    public PrefManager(Context mContext) {
        context = mContext;
        prefs = PreferenceManager.getDefaultSharedPreferences(context);
        prefeditor = prefs.edit();
    }

    /**
     * Returns the custom share text.
     *
     * @return String The custom share text that the app should use.
     * @see DetailView
     */
    public String getCustomShareText() {
        return prefs.getString("customShareText", context.getString(R.string.preference_default_customShareText));
    }

    /**
     * Returns if we should use a Listview.
     *
     * @return boolean If true the app will use a Listview
     * @see IGF
     */
    public boolean getTraditionalListEnabled() {
        return prefs.getBoolean("traditionalList", false);
    }

    /**
     * Returns if the app should use Volumes instead of Chapters.
     *
     * @return boolean If it is true the app will use Volumes
     * @see IGF
     */
    public boolean getUseSecondaryAmountsEnabled() {
        return prefs.getBoolean("displayVolumes", false);
    }

    /**
     * Returns if auto synchronisation is enabled.
     *
     * @return boolean This returns true when auto synchronisation is enabled
     * @see Settings
     */
    public boolean getSyncEnabled() {
        return prefs.getBoolean("synchronisation", false);
    }

    /**
     * Returns the auto synchronisation interval.
     *
     * @return int The auto synchronisation interval in seconds
     * @see Settings
     */
    public int getSyncTime() { //Home, get the auto-sync interval
        return Integer.parseInt(prefs.getString("synchronisation_time", "60"));
    }

    /**
     * Returns the locale of the language that this app should use.
     *
     * @return Locale The locale of the language that the app should use
     * @see Theme
     */
    public Locale getLocale() {
        String localeName = prefs.getString("locale", Locale.getDefault().toString());
        Locale locale;
        if (localeName.equals("pt-br"))
            locale = new Locale("pt", "PT");
        else if (localeName.equals("pt-pt"))
            locale = new Locale("pt", "BR");
        else
            locale = new Locale(localeName);
        return locale;
    }

    /**
     * Returns if the app should synchronise the Anime/Manga records.
     *
     * @return boolean If all the records should be synced
     * @see Home
     */
    public boolean getForceSync() {
        return prefs.getBoolean("ForceSync", false);
    }

    /**
     * Returns if the app automatically should hide the card if it is empty.
     *
     * @return boolean If it should be hidden
     * @see ProfileActivity
     */
    public boolean getHideAnimeManga() { //profile activity, if the card is empty setting
        return prefs.getBoolean("a_mhide", false);
    }

    /**
     * Returns if the app should disable the coloured text and use black.
     *
     * @return boolean If it should be black
     * @see ProfileActivity
     */
    public boolean getTextColor() { //profile activity, if the textcolors are turned off
        return prefs.getBoolean("text_colours", false);
    }

    /**
     * Returns if the app should hide the anime stats in all profiles.
     *
     * @return boolean If it should be hidden
     * @see ProfileActivity
     */
    public boolean getHideAnime() { //profile activity, if the setting force hide is turned on
        return prefs.getBoolean("A_hide", false); //anime card
    }

    /**
     * Returns if the app should hide the manga stats in all profiles.
     *
     * @return boolean If it should be hidden
     * @see ProfileActivity
     */
    public boolean getHideManga() {//profile activity, if the setting force hide is turned on
        return prefs.getBoolean("M_hide", false); //manga card
    }

    /**
     * Set the force synchronisation, if true all the records will be synchronised.
     *
     * @param force This will determine if all the records should be synchronised
     * @see FirstTimeInit
     * @see Home
     */
    public void setForceSync(boolean force) {
        prefeditor.putBoolean("ForceSync", force);
    }

    /**
     * Commit all the changed made.
     */
    public void commitChanges() {
        prefeditor.commit();
    }

    /**
     * Returns the default list that will open on start.
     *
     * @return int The number of the list that should get loaded.
     * @see Home
     */
    public int getDefaultList() {
        return Integer.parseInt(prefs.getString("defList", "1"));
    }
}

@@ -1878,43 +1878,8 @@
 () %7B
- //Home, get the auto-sync interval
 %0A   
@@ -2806,32 +2806,368 @@
  false);%0A    %7D%0A%0A
+    /**%0A     * Set the force synchronisation, if true all the records will be synchronised.%0A     *%0A     * @param force This will determine if all the records should be synchronised%0A     * @see FirstTimeInit%0A     * @see Home%0A     */%0A    public void setForceSync(boolean force) %7B%0A        prefeditor.putBoolean(%22ForceSync%22, force);%0A    %7D%0A%0A
     /**%0A     * R
@@ -3368,57 +3368,8 @@
 () %7B
- //profile activity, if the card is empty setting
 %0A   
@@ -3632,61 +3632,8 @@
 () %7B
- //profile activity, if the textcolors are turned off
 %0A   
@@ -3899,67 +3899,8 @@
 () %7B
- //profile activity, if the setting force hide is turned on
 %0A   
@@ -3949,21 +3949,8 @@
 se);
- //anime card
 %0A   
@@ -4160,66 +4160,8 @@
 () %7B
-//profile activity, if the setting force hide is turned on
 %0A   
@@ -4210,21 +4210,8 @@
 se);
- //manga card
 %0A   
@@ -4233,199 +4233,130 @@
   * 
-S
+R
 et
+urns
  the 
-force synchronisation, if true all the records will be synchronised.%0A     *%0A     * @param force This will determine if all the records should be synchronised%0A     * @see FirstTimeInit
+default list that will open on start.%0A     *%0A     * @return int The number of the list that should get loaded.
 %0A   
@@ -4392,39 +4392,27 @@
 lic 
-void setForceSync(boolean force
+int getDefaultList(
 ) %7B%0A
@@ -4423,48 +4423,63 @@
     
-p
 re
-feditor.putBoolean(%22ForceSync%22, force
+turn Integer.parseInt(prefs.getString(%22defList%22, %221%22)
 );%0A 
@@ -4608,277 +4608,7 @@
    %7D
-%0A%0A    /**%0A     * Returns the default list that will open on start.%0A     *%0A     * @return int The number of the list that should get loaded.%0A     * @see Home%0A     */%0A    public int getDefaultList() %7B%0A        return Integer.parseInt(prefs.getString(%22defList%22, %221%22));%0A    %7D
 %0A%7D%0A

Fix indents & remove notes & reorder (PrefManager)