Haptic feedback default value
This commit is contained in:
parent
ac411a549f
commit
577fac76f8
@ -1,174 +1,183 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.AndroidUtils;
|
import org.solovyev.android.AndroidUtils;
|
||||||
import org.solovyev.android.calculator.math.MathType;
|
import org.solovyev.android.calculator.math.MathType;
|
||||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||||
import org.solovyev.android.calculator.plot.GraphLineColor;
|
import org.solovyev.android.calculator.plot.GraphLineColor;
|
||||||
import org.solovyev.android.prefs.BooleanPreference;
|
import org.solovyev.android.prefs.BooleanPreference;
|
||||||
import org.solovyev.android.prefs.IntegerPreference;
|
import org.solovyev.android.prefs.IntegerPreference;
|
||||||
import org.solovyev.android.prefs.Preference;
|
import org.solovyev.android.prefs.Preference;
|
||||||
import org.solovyev.android.prefs.StringPreference;
|
import org.solovyev.android.prefs.StringPreference;
|
||||||
|
import org.solovyev.android.view.VibratorContainer;
|
||||||
import java.text.DecimalFormatSymbols;
|
|
||||||
import java.util.Locale;
|
import java.text.DecimalFormatSymbols;
|
||||||
|
import java.util.Locale;
|
||||||
/**
|
|
||||||
* User: serso
|
/**
|
||||||
* Date: 4/20/12
|
* User: serso
|
||||||
* Time: 12:42 PM
|
* Date: 4/20/12
|
||||||
*/
|
* Time: 12:42 PM
|
||||||
public final class CalculatorPreferences {
|
*/
|
||||||
|
public final class CalculatorPreferences {
|
||||||
private CalculatorPreferences() {
|
|
||||||
throw new AssertionError();
|
private CalculatorPreferences() {
|
||||||
}
|
throw new AssertionError();
|
||||||
|
}
|
||||||
public static final Preference<Integer> appVersion = new IntegerPreference("application.version", -1);
|
|
||||||
public static final Preference<Integer> appOpenedCounter = new IntegerPreference("app_opened_counter", 0);
|
public static final Preference<Integer> appVersion = new IntegerPreference("application.version", -1);
|
||||||
|
public static final Preference<Integer> appOpenedCounter = new IntegerPreference("app_opened_counter", 0);
|
||||||
public static class Gui {
|
|
||||||
|
public static class Gui {
|
||||||
public static final Preference<Theme> theme = StringPreference.newInstance("org.solovyev.android.calculator.CalculatorActivity_calc_theme", Theme.metro_blue_theme, Theme.class);
|
|
||||||
public static final Preference<Layout> layout = StringPreference.newInstance("org.solovyev.android.calculator.CalculatorActivity_calc_layout", Layout.main_calculator, Layout.class);
|
public static final Preference<Theme> theme = StringPreference.newInstance("org.solovyev.android.calculator.CalculatorActivity_calc_theme", Theme.metro_blue_theme, Theme.class);
|
||||||
public static final Preference<Boolean> feedbackWindowShown = new BooleanPreference("feedback_window_shown", false);
|
public static final Preference<Layout> layout = StringPreference.newInstance("org.solovyev.android.calculator.CalculatorActivity_calc_layout", Layout.main_calculator, Layout.class);
|
||||||
public static final Preference<Boolean> notesppAnnounceShown = new BooleanPreference("notespp_announce_shown", false);
|
public static final Preference<Boolean> feedbackWindowShown = new BooleanPreference("feedback_window_shown", false);
|
||||||
public static final Preference<Boolean> showReleaseNotes = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_show_release_notes", true);
|
public static final Preference<Boolean> notesppAnnounceShown = new BooleanPreference("notespp_announce_shown", false);
|
||||||
public static final Preference<Boolean> usePrevAsBack = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false);
|
public static final Preference<Boolean> showReleaseNotes = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_show_release_notes", true);
|
||||||
public static final Preference<Boolean> showEqualsButton = new BooleanPreference("showEqualsButton", true);
|
public static final Preference<Boolean> usePrevAsBack = new BooleanPreference("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false);
|
||||||
public static final Preference<Boolean> autoOrientation = new BooleanPreference("autoOrientation", true);
|
public static final Preference<Boolean> showEqualsButton = new BooleanPreference("showEqualsButton", true);
|
||||||
public static final Preference<Boolean> hideNumeralBaseDigits = new BooleanPreference("hideNumeralBaseDigits", true);
|
public static final Preference<Boolean> autoOrientation = new BooleanPreference("autoOrientation", true);
|
||||||
|
public static final Preference<Boolean> hideNumeralBaseDigits = new BooleanPreference("hideNumeralBaseDigits", true);
|
||||||
@NotNull
|
|
||||||
public static Theme getTheme(@NotNull SharedPreferences preferences) {
|
@NotNull
|
||||||
return theme.getPreferenceNoError(preferences);
|
public static Theme getTheme(@NotNull SharedPreferences preferences) {
|
||||||
}
|
return theme.getPreferenceNoError(preferences);
|
||||||
|
}
|
||||||
@NotNull
|
|
||||||
public static Layout getLayout(@NotNull SharedPreferences preferences) {
|
@NotNull
|
||||||
return layout.getPreferenceNoError(preferences);
|
public static Layout getLayout(@NotNull SharedPreferences preferences) {
|
||||||
}
|
return layout.getPreferenceNoError(preferences);
|
||||||
|
}
|
||||||
public static enum Theme {
|
|
||||||
|
public static enum Theme {
|
||||||
default_theme(ThemeType.other, R.style.default_theme),
|
|
||||||
violet_theme(ThemeType.other, R.style.violet_theme),
|
default_theme(ThemeType.other, R.style.default_theme),
|
||||||
light_blue_theme(ThemeType.other, R.style.light_blue_theme),
|
violet_theme(ThemeType.other, R.style.violet_theme),
|
||||||
metro_blue_theme(ThemeType.metro, R.style.metro_blue_theme),
|
light_blue_theme(ThemeType.other, R.style.light_blue_theme),
|
||||||
metro_purple_theme(ThemeType.metro, R.style.metro_purple_theme),
|
metro_blue_theme(ThemeType.metro, R.style.metro_blue_theme),
|
||||||
metro_green_theme(ThemeType.metro, R.style.metro_green_theme);
|
metro_purple_theme(ThemeType.metro, R.style.metro_purple_theme),
|
||||||
|
metro_green_theme(ThemeType.metro, R.style.metro_green_theme);
|
||||||
@NotNull
|
|
||||||
private final ThemeType themeType;
|
@NotNull
|
||||||
|
private final ThemeType themeType;
|
||||||
@NotNull
|
|
||||||
private final Integer themeId;
|
@NotNull
|
||||||
|
private final Integer themeId;
|
||||||
Theme(@NotNull ThemeType themeType, Integer themeId) {
|
|
||||||
this.themeType = themeType;
|
Theme(@NotNull ThemeType themeType, Integer themeId) {
|
||||||
this.themeId = themeId;
|
this.themeType = themeType;
|
||||||
}
|
this.themeId = themeId;
|
||||||
|
}
|
||||||
@NotNull
|
|
||||||
public ThemeType getThemeType() {
|
@NotNull
|
||||||
return themeType;
|
public ThemeType getThemeType() {
|
||||||
}
|
return themeType;
|
||||||
|
}
|
||||||
@NotNull
|
|
||||||
public Integer getThemeId() {
|
@NotNull
|
||||||
return themeId;
|
public Integer getThemeId() {
|
||||||
}
|
return themeId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static enum ThemeType {
|
|
||||||
metro,
|
public static enum ThemeType {
|
||||||
other
|
metro,
|
||||||
}
|
other
|
||||||
|
}
|
||||||
public static enum Layout {
|
|
||||||
main_calculator(R.layout.main_calculator),
|
public static enum Layout {
|
||||||
|
main_calculator(R.layout.main_calculator),
|
||||||
// not used anymore
|
|
||||||
@Deprecated
|
// not used anymore
|
||||||
main_cellphone(R.layout.main_calculator),
|
@Deprecated
|
||||||
|
main_cellphone(R.layout.main_calculator),
|
||||||
simple(R.layout.main_calculator);
|
|
||||||
|
simple(R.layout.main_calculator);
|
||||||
private final int layoutId;
|
|
||||||
|
private final int layoutId;
|
||||||
Layout(int layoutId) {
|
|
||||||
this.layoutId = layoutId;
|
Layout(int layoutId) {
|
||||||
}
|
this.layoutId = layoutId;
|
||||||
|
}
|
||||||
public int getLayoutId() {
|
|
||||||
return layoutId;
|
public int getLayoutId() {
|
||||||
}
|
return layoutId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public static class Graph {
|
|
||||||
public static final Preference<Boolean> interpolate = new BooleanPreference("graph_interpolate", true);
|
public static class Graph {
|
||||||
public static final Preference<GraphLineColor> lineColorReal = StringPreference.newInstance("graph_line_color_real", GraphLineColor.white, GraphLineColor.class);
|
public static final Preference<Boolean> interpolate = new BooleanPreference("graph_interpolate", true);
|
||||||
public static final Preference<GraphLineColor> lineColorImag = StringPreference.newInstance("graph_line_color_imag", GraphLineColor.blue, GraphLineColor.class);
|
public static final Preference<GraphLineColor> lineColorReal = StringPreference.newInstance("graph_line_color_real", GraphLineColor.white, GraphLineColor.class);
|
||||||
}
|
public static final Preference<GraphLineColor> lineColorImag = StringPreference.newInstance("graph_line_color_imag", GraphLineColor.blue, GraphLineColor.class);
|
||||||
|
}
|
||||||
|
|
||||||
static void setDefaultValues(@NotNull SharedPreferences preferences) {
|
|
||||||
if (!AndroidCalculatorEngine.Preferences.groupingSeparator.isSet(preferences)) {
|
static void setDefaultValues(@NotNull SharedPreferences preferences) {
|
||||||
final Locale locale = Locale.getDefault();
|
if (!AndroidCalculatorEngine.Preferences.groupingSeparator.isSet(preferences)) {
|
||||||
if (locale != null) {
|
final Locale locale = Locale.getDefault();
|
||||||
final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale);
|
if (locale != null) {
|
||||||
int index = MathType.grouping_separator.getTokens().indexOf(String.valueOf(decimalFormatSymbols.getGroupingSeparator()));
|
final DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale);
|
||||||
final String groupingSeparator;
|
int index = MathType.grouping_separator.getTokens().indexOf(String.valueOf(decimalFormatSymbols.getGroupingSeparator()));
|
||||||
if (index >= 0) {
|
final String groupingSeparator;
|
||||||
groupingSeparator = MathType.grouping_separator.getTokens().get(index);
|
if (index >= 0) {
|
||||||
} else {
|
groupingSeparator = MathType.grouping_separator.getTokens().get(index);
|
||||||
groupingSeparator = " ";
|
} else {
|
||||||
}
|
groupingSeparator = " ";
|
||||||
|
}
|
||||||
AndroidCalculatorEngine.Preferences.groupingSeparator.putPreference(preferences, groupingSeparator);
|
|
||||||
}
|
AndroidCalculatorEngine.Preferences.groupingSeparator.putPreference(preferences, groupingSeparator);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!AndroidCalculatorEngine.Preferences.angleUnit.isSet(preferences)) {
|
|
||||||
AndroidCalculatorEngine.Preferences.angleUnit.putDefault(preferences);
|
if (!AndroidCalculatorEngine.Preferences.angleUnit.isSet(preferences)) {
|
||||||
}
|
AndroidCalculatorEngine.Preferences.angleUnit.putDefault(preferences);
|
||||||
|
}
|
||||||
if (!AndroidCalculatorEngine.Preferences.numeralBase.isSet(preferences)) {
|
|
||||||
AndroidCalculatorEngine.Preferences.numeralBase.putDefault(preferences);
|
if (!AndroidCalculatorEngine.Preferences.numeralBase.isSet(preferences)) {
|
||||||
}
|
AndroidCalculatorEngine.Preferences.numeralBase.putDefault(preferences);
|
||||||
|
}
|
||||||
if (!AndroidCalculatorEngine.Preferences.multiplicationSign.isSet(preferences)) {
|
|
||||||
if ( AndroidUtils.isPhoneModel(AndroidUtils.PhoneModel.samsung_galaxy_s) || AndroidUtils.isPhoneModel(AndroidUtils.PhoneModel.samsung_galaxy_s_2) ) {
|
if (!AndroidCalculatorEngine.Preferences.multiplicationSign.isSet(preferences)) {
|
||||||
// workaround ofr samsung galaxy s phones
|
if ( AndroidUtils.isPhoneModel(AndroidUtils.PhoneModel.samsung_galaxy_s) || AndroidUtils.isPhoneModel(AndroidUtils.PhoneModel.samsung_galaxy_s_2) ) {
|
||||||
AndroidCalculatorEngine.Preferences.multiplicationSign.putPreference(preferences, "*");
|
// workaround ofr samsung galaxy s phones
|
||||||
}
|
AndroidCalculatorEngine.Preferences.multiplicationSign.putPreference(preferences, "*");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
applyDefaultPreference(preferences, Gui.theme);
|
|
||||||
applyDefaultPreference(preferences, Gui.layout);
|
applyDefaultPreference(preferences, Gui.theme);
|
||||||
if ( Gui.layout.getPreference(preferences) == Gui.Layout.main_cellphone ) {
|
applyDefaultPreference(preferences, Gui.layout);
|
||||||
Gui.layout.putDefault(preferences);
|
if ( Gui.layout.getPreference(preferences) == Gui.Layout.main_cellphone ) {
|
||||||
}
|
Gui.layout.putDefault(preferences);
|
||||||
applyDefaultPreference(preferences, Gui.feedbackWindowShown);
|
}
|
||||||
applyDefaultPreference(preferences, Gui.notesppAnnounceShown);
|
applyDefaultPreference(preferences, Gui.feedbackWindowShown);
|
||||||
applyDefaultPreference(preferences, Gui.showReleaseNotes);
|
applyDefaultPreference(preferences, Gui.notesppAnnounceShown);
|
||||||
applyDefaultPreference(preferences, Gui.usePrevAsBack);
|
applyDefaultPreference(preferences, Gui.showReleaseNotes);
|
||||||
applyDefaultPreference(preferences, Gui.showEqualsButton);
|
applyDefaultPreference(preferences, Gui.usePrevAsBack);
|
||||||
applyDefaultPreference(preferences, Gui.autoOrientation);
|
applyDefaultPreference(preferences, Gui.showEqualsButton);
|
||||||
applyDefaultPreference(preferences, Gui.hideNumeralBaseDigits);
|
applyDefaultPreference(preferences, Gui.autoOrientation);
|
||||||
|
applyDefaultPreference(preferences, Gui.hideNumeralBaseDigits);
|
||||||
applyDefaultPreference(preferences, Graph.interpolate);
|
|
||||||
applyDefaultPreference(preferences, Graph.lineColorImag);
|
applyDefaultPreference(preferences, Graph.interpolate);
|
||||||
applyDefaultPreference(preferences, Graph.lineColorReal);
|
applyDefaultPreference(preferences, Graph.lineColorImag);
|
||||||
|
applyDefaultPreference(preferences, Graph.lineColorReal);
|
||||||
}
|
|
||||||
|
if ( !VibratorContainer.Preferences.hapticFeedbackEnabled.isSet(preferences) ) {
|
||||||
private static void applyDefaultPreference(@NotNull SharedPreferences preferences, @NotNull Preference<?> preference) {
|
VibratorContainer.Preferences.hapticFeedbackEnabled.putPreference(preferences, true);
|
||||||
if (!preference.isSet(preferences)) {
|
}
|
||||||
preference.putDefault(preferences);
|
|
||||||
}
|
if ( !VibratorContainer.Preferences.hapticFeedbackDuration.isSet(preferences) ) {
|
||||||
}
|
VibratorContainer.Preferences.hapticFeedbackDuration.putPreference(preferences, 60L);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void applyDefaultPreference(@NotNull SharedPreferences preferences, @NotNull Preference<?> preference) {
|
||||||
|
if (!preference.isSet(preferences)) {
|
||||||
|
preference.putDefault(preferences);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user