Android Open Source - turbo-editor Preference Helper






From Project

Back to project page turbo-editor.

License

The source code is released under:

GNU General Public License

If you think the Android project turbo-editor listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright (C) 2014 Vlad Mihalachi//from  w ww  .j  av  a2s  .  co m
 *
 * This file is part of Turbo Editor.
 *
 * Turbo Editor is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Turbo Editor is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package sharedcode.turboeditor.preferences;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Environment;
import android.preference.PreferenceManager;

public final class PreferenceHelper {

    public static final String SD_CARD_ROOT = Environment.getExternalStorageDirectory().getAbsolutePath();

    private PreferenceHelper() {
    }

    // Getter Methods

    private static SharedPreferences getPrefs(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context);
    }

    private static SharedPreferences.Editor getEditor(Context context) {
        return getPrefs(context).edit();
    }

    public static boolean getUseMonospace(Context context) {
        return getPrefs(context).getBoolean("use_monospace", false);
    }

    public static boolean getLineNumbers(Context context) {
        return getPrefs(context).getBoolean("editor_line_numbers", true);
    }

    public static boolean getSyntaxHighlight(Context context) {
        return getPrefs(context).getBoolean("editor_syntax_highlight", false);
    }

    public static boolean getWrapContent(Context context) {
        return getPrefs(context).getBoolean("editor_wrap_content", true);
    }

    public static boolean getLightTheme(Context context) {
        return getPrefs(context).getBoolean("light_theme", false);
    }

    public static boolean getSuggestionActive(Context context) {
        return getPrefs(context).getBoolean("suggestion_active", false);
    }

    public static boolean getAutoEncoding(Context context) {
        return getPrefs(context).getBoolean("autoencoding", true);
    }

    public static boolean getSendErrorReports(Context context) {
        return getPrefs(context).getBoolean("send_error_reports", true);
    }

    public static String getEncoding(Context context) {
        return getPrefs(context).getString("editor_encoding", "UTF-8");
    }

    public static int getFontSize(Context context) {
        return getPrefs(context).getInt("font_size", 16);
    }

    public static String getWorkingFolder(Context context) {
        return getPrefs(context).getString("working_folder", SD_CARD_ROOT);
    }

    public static String[] getSavedPaths(Context context) {
        return getPrefs(context).getString("savedPaths", "").split(",");
    }

    public static boolean getPageSystemButtonsPopupShown(Context context) {
        return getPrefs(context).getBoolean("page_system_button_popup_shown", false);
    }

    public static boolean getAutoSave(Context context) {
        return getPrefs(context).getBoolean("auto_save", false);
    }

    public static boolean getReadOnly(Context context) {
        return getPrefs(context).getBoolean("read_only", false);
    }

    public static boolean getIgnoreBackButton(Context context) {
        return getPrefs(context).getBoolean("ignore_back_button", false);
    }

    public static boolean getSplitText(Context context) {
        return getPrefs(context).getBoolean("page_system_active", true);
    }

    public static boolean hasDonated(Context context) {
        return getPrefs(context).getBoolean("has_donated", false);
    }
    // Setter methods

    public static void setUseMonospace(Context context, boolean value) {
        getEditor(context).putBoolean("use_monospace", value).commit();
    }

    public static void setLineNumbers(Context context, boolean value) {
        getEditor(context).putBoolean("editor_line_numbers", value).commit();
    }

    public static void setSyntaxHighlight(Context context, boolean value) {
        getEditor(context).putBoolean("editor_syntax_highlight", value).commit();
    }

    public static void setWrapContent(Context context, boolean value) {
        getEditor(context).putBoolean("editor_wrap_content", value).commit();
    }

    public static void setAutoencoding(Context context, boolean value) {
        getEditor(context).putBoolean("autoencoding", value).commit();
    }

    public static void setFontSize(Context context, int value) {
        getEditor(context).putInt("font_size", value).commit();
    }

    public static void setWorkingFolder(Context context, String value) {
        getEditor(context).putString("working_folder", value).commit();
    }

    public static void setSavedPaths(Context context, StringBuilder stringBuilder) {
        getEditor(context).putString("savedPaths", stringBuilder.toString()).commit();
    }

    public static void setPageSystemButtonsPopupShown(Context context, boolean value) {
        getEditor(context).putBoolean("page_system_button_popup_shown", value).commit();
    }

    public static void setReadOnly(Context context, boolean value) {
        getEditor(context).putBoolean("read_only", value).commit();
    }

    public static void setHasDonated(Context context, boolean value) {
        getEditor(context).putBoolean("has_donated", value).commit();
    }

    public static void setLightTheme(Context context, boolean value) {
        getEditor(context).putBoolean("light_theme", value).commit();
    }

    public static void setSuggestionsActive(Context context, boolean value) {
        getEditor(context).putBoolean("suggestion_active", value).commit();
    }

    public static void setAutoSave(Context context, boolean value) {
        getEditor(context).putBoolean("auto_save", value).commit();
    }

    public static void setIgnoreBackButton(Context context, boolean value) {
        getEditor(context).putBoolean("ignore_back_button", value).commit();
    }

    public static void setSplitText(Context context, boolean value) {
        getEditor(context).putBoolean("page_system_active", value).commit();
    }

    public static void setSendErrorReport(Context context, boolean value) {
        getEditor(context).putBoolean("ignore_back_button", value).commit();
    }

    public static void setEncoding(Context context, String value) {
        getEditor(context).putString("editor_encoding", value).commit();
    }
}




Java Source Code List

com.faizmalkani.floatingactionbutton.BuildConfig.java
com.faizmalkani.floatingactionbutton.BuildConfig.java
com.faizmalkani.floatingactionbutton.DirectionScrollListener.java
com.faizmalkani.floatingactionbutton.FloatingActionButton.java
com.maskyn.fileeditor.AdsHelper.java
com.maskyn.fileeditor.ApplicationTest.java
com.maskyn.fileeditor.HomeActivity.java
com.maskyn.fileeditorpro.ApplicationTest.java
com.maskyn.fileeditorpro.HomeActivity.java
org.sufficientlysecure.rootcommands.Mount.java
org.sufficientlysecure.rootcommands.Remounter.java
org.sufficientlysecure.rootcommands.RootCommands.java
org.sufficientlysecure.rootcommands.Shell.java
org.sufficientlysecure.rootcommands.SystemCommands.java
org.sufficientlysecure.rootcommands.Toolbox.java
org.sufficientlysecure.rootcommands.command.Command.java
org.sufficientlysecure.rootcommands.command.ExecutableCommand.java
org.sufficientlysecure.rootcommands.command.SimpleCommand.java
org.sufficientlysecure.rootcommands.command.SimpleExecutableCommand.java
org.sufficientlysecure.rootcommands.util.BrokenBusyboxException.java
org.sufficientlysecure.rootcommands.util.Log.java
org.sufficientlysecure.rootcommands.util.RootAccessDeniedException.java
org.sufficientlysecure.rootcommands.util.UnsupportedArchitectureException.java
org.sufficientlysecure.rootcommands.util.Utils.java
sharedcode.turboeditor.ApplicationTest.java
sharedcode.turboeditor.activity.MainActivity.java
sharedcode.turboeditor.activity.SelectFileActivity.java
sharedcode.turboeditor.adapter.AdapterDetailedList.java
sharedcode.turboeditor.adapter.AdapterDrawer.java
sharedcode.turboeditor.adapter.AdapterTwoItem.java
sharedcode.turboeditor.application.MyApp.java
sharedcode.turboeditor.dialogfragment.AboutDialog.java
sharedcode.turboeditor.dialogfragment.ChangelogDialog.java
sharedcode.turboeditor.dialogfragment.EditTextDialog.java
sharedcode.turboeditor.dialogfragment.EncodingDialog.java
sharedcode.turboeditor.dialogfragment.FileInfoDialog.java
sharedcode.turboeditor.dialogfragment.FindTextDialog.java
sharedcode.turboeditor.dialogfragment.NewFileDetailsDialog.java
sharedcode.turboeditor.dialogfragment.NumberPickerDialog.java
sharedcode.turboeditor.dialogfragment.SaveFileDialog.java
sharedcode.turboeditor.iab.DonationAdapter.java
sharedcode.turboeditor.iab.DonationFragment.java
sharedcode.turboeditor.iab.DonationItems.java
sharedcode.turboeditor.iab.Donation.java
sharedcode.turboeditor.iab.utils.Base64DecoderException.java
sharedcode.turboeditor.iab.utils.Base64.java
sharedcode.turboeditor.iab.utils.IabException.java
sharedcode.turboeditor.iab.utils.IabHelper.java
sharedcode.turboeditor.iab.utils.IabResult.java
sharedcode.turboeditor.iab.utils.Inventory.java
sharedcode.turboeditor.iab.utils.Purchase.java
sharedcode.turboeditor.iab.utils.Security.java
sharedcode.turboeditor.iab.utils.SkuDetails.java
sharedcode.turboeditor.preferences.PreferenceHelper.java
sharedcode.turboeditor.preferences.SettingsFragment.java
sharedcode.turboeditor.root.LinuxShell.java
sharedcode.turboeditor.root.RootUtils.java
sharedcode.turboeditor.task.SaveFileTask.java
sharedcode.turboeditor.texteditor.EditTextPadding.java
sharedcode.turboeditor.texteditor.FileUtils.java
sharedcode.turboeditor.texteditor.LineUtils.java
sharedcode.turboeditor.texteditor.PageSystemButtons.java
sharedcode.turboeditor.texteditor.PageSystem.java
sharedcode.turboeditor.texteditor.Patterns.java
sharedcode.turboeditor.texteditor.SearchResult.java
sharedcode.turboeditor.util.AccessStorageApi.java
sharedcode.turboeditor.util.AlphanumComparator.java
sharedcode.turboeditor.util.AnimationUtils.java
sharedcode.turboeditor.util.AppInfoHelper.java
sharedcode.turboeditor.util.Build.java
sharedcode.turboeditor.util.Device.java
sharedcode.turboeditor.util.EventBusEvents.java
sharedcode.turboeditor.util.IHomeActivity.java
sharedcode.turboeditor.util.MimeTypes.java
sharedcode.turboeditor.util.PixelDipConverter.java
sharedcode.turboeditor.util.ProCheckUtils.java
sharedcode.turboeditor.util.ThemeUtils.java
sharedcode.turboeditor.util.ToastUtils.java
sharedcode.turboeditor.util.ViewUtils.java
sharedcode.turboeditor.util.systemui.SystemUiHelperImplHC.java
sharedcode.turboeditor.util.systemui.SystemUiHelperImplICS.java
sharedcode.turboeditor.util.systemui.SystemUiHelperImplJB.java
sharedcode.turboeditor.util.systemui.SystemUiHelperImplKK.java
sharedcode.turboeditor.util.systemui.SystemUiHelper.java
sharedcode.turboeditor.views.CustomDrawerLayout.java
sharedcode.turboeditor.views.DialogHelper.java
sharedcode.turboeditor.views.GoodScrollView.java