Android Open Source - FRCAndroidWidget F R C Preferences






From Project

Back to project page FRCAndroidWidget.

License

The source code is released under:

GNU General Public License

If you think the Android project FRCAndroidWidget 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

/*
 * French Revolutionary Calendar Android Widget
 * Copyright (C) 2011 - 2014 Carmen Alvarez
 * //w w w .j av  a2  s .  c om
 * This program 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.
 * 
 * This program 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 ca.rmen.android.frccommon.prefs;

import java.util.Locale;

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

import ca.rmen.lfrc.FrenchRevolutionaryCalendar.CalculationMethod;

/**
 * Preference names and values used by this app.
 *
 * @author calvarez
 */
public class FRCPreferences {

    public static final String PREF_METHOD = "setting_method";
    static final String PREF_DETAILED_VIEW = "setting_detailed_view";
    public static final String PREF_LANGUAGE = "setting_language";
    public static final String PREF_CUSTOM_COLOR = "setting_custom_color";
    public static final String PREF_CUSTOM_COLOR_ENABLED = "setting_custom_color_enabled";
    public static final String PREF_ANDROID_WEAR = "setting_android_wear";
    private static final int FREQUENCY_MINUTES = 86400;
    public static final int FREQUENCY_DAYS = 86400000;

    private static FRCPreferences me = null;

    private final SharedPreferences sharedPrefs;

    public static enum DetailedView {
        NONE, TIME, DAY_OF_YEAR
    }

    public synchronized static FRCPreferences getInstance(Context context) {
        if (me == null) me = new FRCPreferences(context);
        return me;
    }

    private FRCPreferences(Context context) {
        sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    }

    public Locale getLocale() {
        String language = sharedPrefs.getString(PREF_LANGUAGE, "fr");
        return new Locale(language);
    }

    public boolean isCustomColorEnabled() {
        return sharedPrefs.getBoolean(PREF_CUSTOM_COLOR_ENABLED, false);
    }
    
    public int getColor() {
        return sharedPrefs.getInt(PREF_CUSTOM_COLOR, -1);
    }

    public CalculationMethod getCalculationMethod() {
        String methodPrefStr = sharedPrefs.getString(PREF_METHOD, "0");
        int calculationMethodInt = Integer.parseInt(methodPrefStr);
        return CalculationMethod.values()[calculationMethodInt];
    }

    public int getUpdateFrequency() {
        DetailedView detailedView = getDetailedView();
        final int frequency;
        if (detailedView == DetailedView.TIME) frequency = FREQUENCY_MINUTES;
        else frequency = FREQUENCY_DAYS;
        return frequency;
    }

    public DetailedView getDetailedView() {
        String detailedViewValue = sharedPrefs.getString(PREF_DETAILED_VIEW, DetailedView.DAY_OF_YEAR.name().toLowerCase(Locale.US));
        return DetailedView.valueOf(detailedViewValue.toUpperCase(Locale.US));
    }

    public boolean getAndroidWearEnabled() {
        return sharedPrefs.getBoolean(PREF_ANDROID_WEAR, false);
    }
}




Java Source Code List

ca.rmen.android.frccommon.Constants.java
ca.rmen.android.frccommon.FRCAboutActivity.java
ca.rmen.android.frccommon.FRCDateUtils.java
ca.rmen.android.frccommon.prefs.FRCPreferenceActivity.java
ca.rmen.android.frccommon.prefs.FRCPreferences.java
ca.rmen.android.frcwear.FRCAndroidWearService.java
ca.rmen.android.frcwear.FRCBootCompletedBroadcastReceiver.java
ca.rmen.android.frcwear.FRCWearCommHelper.java
ca.rmen.android.frcwear.FRCWearPreferenceListener.java
ca.rmen.android.frcwear.FRCWearPreferenceListener.java
ca.rmen.android.frcwear.FRCWearScheduler.java
ca.rmen.android.frcwidget.FRCAppWidgetManager.java
ca.rmen.android.frcwidget.FRCAppWidgetProvider.java
ca.rmen.android.frcwidget.FRCPopupActivity.java
ca.rmen.android.frcwidget.FRCWidgetScheduler.java
ca.rmen.android.frcwidget.render.FRCAppWidgetRendererFactory.java
ca.rmen.android.frcwidget.render.FRCAppWidgetRenderer.java
ca.rmen.android.frcwidget.render.FRCMinimalistAppWidgetRenderer.java
ca.rmen.android.frcwidget.render.FRCRenderApi13.java
ca.rmen.android.frcwidget.render.FRCRenderApi16.java
ca.rmen.android.frcwidget.render.FRCRender.java
ca.rmen.android.frcwidget.render.FRCScrollAppWidgetRenderParams.java
ca.rmen.android.frcwidget.render.FRCScrollAppWidgetRenderer.java
ca.rmen.android.frcwidget.render.Font.java
ca.rmen.android.frenchcalendar.FrenchCalendarAppWidgetMinimalist.java
ca.rmen.android.frenchcalendar.FrenchCalendarAppWidgetNarrow.java
ca.rmen.android.frenchcalendar.FrenchCalendarAppWidgetWide.java
ca.rmen.android.frenchcalendar.common.WearCommConstants.java
ca.rmen.android.frenchcalendar.wearable.app.notif.NotificationService.java