More GA integration

Theme and layout dimensions reporting added
This commit is contained in:
serso 2015-01-26 13:48:03 +01:00
parent d23f8e2c40
commit 13b2558620
30 changed files with 182 additions and 130 deletions

View File

@ -30,7 +30,7 @@ import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.util.ActivityController;
import org.solovyev.android.CalculatorTestRunner;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.wizard.BaseWizardActivity;
import org.solovyev.android.wizard.WizardUi;
@ -100,7 +100,7 @@ public class OnScreenCalculatorWizardStepTest {
private void testShouldBeEqualsToIconState(boolean iconEnabled) throws IllegalAccessException {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(Robolectric.application);
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(preferences, iconEnabled);
Preferences.OnscreenCalculator.showAppIcon.putPreference(preferences, iconEnabled);
createActivity();
setFragment();
assertEquals(iconEnabled, fragment.isOnscreenCalculatorEnabled());

View File

@ -32,15 +32,15 @@ import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
import org.solovyev.android.CalculatorTestRunner;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Preferences;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.solovyev.android.calculator.CalculatorApplication.getPreferences;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator_mobile;
import static org.solovyev.android.calculator.CalculatorPreferences.OnscreenCalculator.showAppIcon;
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator;
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator_mobile;
import static org.solovyev.android.calculator.Preferences.OnscreenCalculator.showAppIcon;
import static org.solovyev.android.calculator.wizard.CalculatorLayout.big_buttons;
import static org.solovyev.android.calculator.wizard.CalculatorLayout.optimized;
import static org.solovyev.android.calculator.wizard.CalculatorMode.engineer;
@ -88,7 +88,7 @@ public class WizardStepTest {
chooseLayout(optimized);
chooseMode(simple);
assertUiLayoutEquals(CalculatorPreferences.Gui.Layout.simple);
assertUiLayoutEquals(Preferences.Gui.Layout.simple);
}
@Test
@ -96,11 +96,11 @@ public class WizardStepTest {
chooseLayout(big_buttons);
chooseMode(simple);
assertUiLayoutEquals(CalculatorPreferences.Gui.Layout.simple_mobile);
assertUiLayoutEquals(Preferences.Gui.Layout.simple_mobile);
}
private void assertUiLayoutEquals(CalculatorPreferences.Gui.Layout uiLayout) {
Assert.assertEquals(uiLayout, CalculatorPreferences.Gui.layout.getPreference(PreferenceManager.getDefaultSharedPreferences(Robolectric.application)));
private void assertUiLayoutEquals(Preferences.Gui.Layout uiLayout) {
Assert.assertEquals(uiLayout, Preferences.Gui.layout.getPreference(PreferenceManager.getDefaultSharedPreferences(Robolectric.application)));
}
private void chooseMode(CalculatorMode mode) {
@ -152,30 +152,30 @@ public class WizardStepTest {
@SuppressWarnings("ConstantConditions")
@Test
public void testChooseLayoutFragmentArgs() throws Exception {
CalculatorPreferences.Gui.layout.putPreference(getPreferences(), CalculatorPreferences.Gui.Layout.simple);
Preferences.Gui.layout.putPreference(getPreferences(), Preferences.Gui.Layout.simple);
assertEquals(CalculatorLayout.optimized, choose_layout.getFragmentArgs().getSerializable(LAYOUT));
CalculatorPreferences.Gui.layout.putPreference(getPreferences(), CalculatorPreferences.Gui.Layout.simple_mobile);
Preferences.Gui.layout.putPreference(getPreferences(), Preferences.Gui.Layout.simple_mobile);
assertEquals(CalculatorLayout.big_buttons, choose_layout.getFragmentArgs().getSerializable(LAYOUT));
}
@SuppressWarnings("ConstantConditions")
@Test
public void testChooseModeFragmentArgs() throws Exception {
CalculatorPreferences.Gui.layout.putPreference(getPreferences(), CalculatorPreferences.Gui.Layout.main_calculator);
Preferences.Gui.layout.putPreference(getPreferences(), Preferences.Gui.Layout.main_calculator);
assertEquals(CalculatorMode.engineer, choose_mode.getFragmentArgs().getSerializable(MODE));
CalculatorPreferences.Gui.layout.putPreference(getPreferences(), CalculatorPreferences.Gui.Layout.simple_mobile);
Preferences.Gui.layout.putPreference(getPreferences(), Preferences.Gui.Layout.simple_mobile);
assertEquals(CalculatorMode.simple, choose_mode.getFragmentArgs().getSerializable(MODE));
}
@SuppressWarnings("ConstantConditions")
@Test
public void testOnscreenFragmentArgs() throws Exception {
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), true);
Preferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), true);
assertTrue(on_screen_calculator.getFragmentArgs().getBoolean(ONSCREEN_CALCULATOR_ENABLED));
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), false);
Preferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), false);
assertFalse(on_screen_calculator.getFragmentArgs().getBoolean(ONSCREEN_CALCULATOR_ENABLED));
}
}

View File

@ -68,10 +68,10 @@ public class ActivityUi extends BaseUi {
private boolean homeIcon = false;
@Nonnull
private CalculatorPreferences.Gui.Theme theme;
private Preferences.Gui.Theme theme;
@Nonnull
private CalculatorPreferences.Gui.Layout layout;
private Preferences.Gui.Layout layout;
private int selectedNavigationIndex = 0;
@ -95,10 +95,10 @@ public class ActivityUi extends BaseUi {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
this.theme = CalculatorPreferences.Gui.getTheme(preferences);
this.theme = Preferences.Gui.getTheme(preferences);
activity.setTheme(this.theme.getThemeId());
this.layout = CalculatorPreferences.Gui.getLayout(preferences);
this.layout = Preferences.Gui.getLayout(preferences);
activity.setContentView(layoutId);
@ -157,7 +157,7 @@ public class ActivityUi extends BaseUi {
public void onResume(@Nonnull Activity activity) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
final CalculatorPreferences.Gui.Theme newTheme = CalculatorPreferences.Gui.theme.getPreference(preferences);
final Preferences.Gui.Theme newTheme = Preferences.Gui.theme.getPreference(preferences);
if (!theme.equals(newTheme)) {
Activities.restartActivity(activity);
}
@ -253,12 +253,12 @@ public class ActivityUi extends BaseUi {
}
@Nonnull
public CalculatorPreferences.Gui.Theme getTheme() {
public Preferences.Gui.Theme getTheme() {
return theme;
}
@Nonnull
public CalculatorPreferences.Gui.Layout getLayout() {
public Preferences.Gui.Layout getLayout() {
return layout;
}

View File

@ -144,7 +144,7 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
this.calculator.init();
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.calculator.setCalculateOnFly(CalculatorPreferences.Calculations.calculateOnFly.getPreference(prefs));
this.calculator.setCalculateOnFly(Preferences.Calculations.calculateOnFly.getPreference(prefs));
}
@Override
@ -245,8 +245,8 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
@Override
public void onSharedPreferenceChanged(@Nonnull SharedPreferences prefs, @Nonnull String key) {
if (CalculatorPreferences.Calculations.calculateOnFly.getKey().equals(key)) {
this.calculator.setCalculateOnFly(CalculatorPreferences.Calculations.calculateOnFly.getPreference(prefs));
if (Preferences.Calculations.calculateOnFly.getKey().equals(key)) {
this.calculator.setCalculateOnFly(Preferences.Calculations.calculateOnFly.getPreference(prefs));
}
}
}

View File

@ -195,7 +195,7 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
if (!initialized) {
if (fromApp) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.getLayout(preferences);
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(preferences);
if (!layout.isOptimized()) {
setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(R.dimen.cpp_display_text_size_mobile));

View File

@ -28,12 +28,11 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.os.Vibrator;
import android.preference.PreferenceManager;
import org.solovyev.android.view.VibratorContainer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.solovyev.android.view.VibratorContainer;
/**
* User: serso
* Date: 11/18/12
@ -58,6 +57,7 @@ public class AndroidCalculatorKeyboard implements CalculatorKeyboard {
@Override
public void buttonPressed(@Nullable String text) {
vibrate();
App.getGa().onButtonPressed(text);
calculatorKeyboard.buttonPressed(text);
}

View File

@ -60,11 +60,11 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
final Long currentTime = System.currentTimeMillis();
if (force || (CalculatorPreferences.Calculations.showCalculationMessagesDialog.getPreference(prefs) && isTimeForCheck(currentTime, prefs))) {
final NumeralBase preferredNumeralBase = CalculatorPreferences.Calculations.preferredNumeralBase.getPreference(prefs);
if (force || (Preferences.Calculations.showCalculationMessagesDialog.getPreference(prefs) && isTimeForCheck(currentTime, prefs))) {
final NumeralBase preferredNumeralBase = Preferences.Calculations.preferredNumeralBase.getPreference(prefs);
final NumeralBase numeralBase = AndroidCalculatorEngine.Preferences.numeralBase.getPreference(prefs);
final AngleUnit preferredAngleUnits = CalculatorPreferences.Calculations.preferredAngleUnits.getPreference(prefs);
final AngleUnit preferredAngleUnits = Preferences.Calculations.preferredAngleUnits.getPreference(prefs);
final AngleUnit angleUnits = AndroidCalculatorEngine.Preferences.angleUnit.getPreference(prefs);
final List<FixableMessage> messages = new ArrayList<FixableMessage>(2);
@ -78,12 +78,12 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
FixableMessagesDialog.showDialog(messages, application, true);
CalculatorPreferences.Calculations.lastPreferredPreferencesCheck.putPreference(prefs, currentTime);
Preferences.Calculations.lastPreferredPreferencesCheck.putPreference(prefs, currentTime);
}
}
private boolean isTimeForCheck(@Nonnull Long currentTime, @Nonnull SharedPreferences preferences) {
final Long lastPreferredPreferencesCheckTime = CalculatorPreferences.Calculations.lastPreferredPreferencesCheck.getPreference(preferences);
final Long lastPreferredPreferencesCheckTime = Preferences.Calculations.lastPreferredPreferencesCheck.getPreference(preferences);
return currentTime - lastPreferredPreferencesCheckTime > PREFERRED_PREFS_INTERVAL_TIME;
}
@ -91,7 +91,7 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
@Override
public void setPreferredAngleUnits() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
setAngleUnits(CalculatorPreferences.Calculations.preferredAngleUnits.getPreference(preferences));
setAngleUnits(Preferences.Calculations.preferredAngleUnits.getPreference(preferences));
}
@Override
@ -105,7 +105,7 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
@Override
public void setPreferredNumeralBase() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
setNumeralBase(CalculatorPreferences.Calculations.preferredNumeralBase.getPreference(preferences));
setNumeralBase(Preferences.Calculations.preferredNumeralBase.getPreference(preferences));
}
@Override

View File

@ -23,6 +23,8 @@
package org.solovyev.android.calculator;
import android.app.Application;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.solovyev.android.UiThreadExecutor;
import org.solovyev.android.calculator.ga.Ga;
import org.solovyev.common.listeners.JEvent;
@ -73,6 +75,9 @@ public final class App {
@Nonnull
private static CalculatorBroadcaster broadcaster;
@Nonnull
private static SharedPreferences preferences;
@Nonnull
private static volatile Ga ga;
@ -102,9 +107,10 @@ public final class App {
@Nullable ServiceLocator serviceLocator) {
if (!initialized) {
App.application = application;
App.preferences = PreferenceManager.getDefaultSharedPreferences(application);
App.uiThreadExecutor = uiThreadExecutor;
App.eventBus = eventBus;
App.ga = new Ga(application, eventBus);
App.ga = new Ga(application, preferences, eventBus);
if (serviceLocator != null) {
App.locator = serviceLocator;
} else {

View File

@ -52,8 +52,8 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.simple;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.simple_mobile;
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple;
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple_mobile;
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.angleUnit;
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.numeralBase;
@ -68,10 +68,10 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
private static final List<Integer> viewIds = new ArrayList<Integer>(200);
@Nonnull
private CalculatorPreferences.Gui.Layout layout;
private Preferences.Gui.Layout layout;
@Nonnull
private CalculatorPreferences.Gui.Theme theme;
private Preferences.Gui.Theme theme;
@Nullable
private Vibrator vibrator;
@ -99,8 +99,8 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
vibrator = (Vibrator) activity.getSystemService(Activity.VIBRATOR_SERVICE);
layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
layout = Preferences.Gui.layout.getPreferenceNoError(preferences);
theme = Preferences.Gui.theme.getPreferenceNoError(preferences);
preferences.registerOnSharedPreferenceChangeListener(this);

View File

@ -58,7 +58,7 @@ import javax.annotation.Nullable;
import static android.os.Build.VERSION_CODES.GINGERBREAD_MR1;
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.preventScreenFromFading;
import static org.solovyev.android.calculator.Preferences.Gui.preventScreenFromFading;
import static org.solovyev.android.wizard.WizardUi.continueWizard;
import static org.solovyev.android.wizard.WizardUi.startWizard;
@ -79,7 +79,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
public void onCreate(@Nullable Bundle savedInstanceState) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
final Preferences.Gui.Layout layout = Preferences.Gui.layout.getPreferenceNoError(preferences);
activityUi = CalculatorApplication.getInstance().createActivityHelper(layout.getLayoutId(), TAG);
activityUi.logDebug("onCreate");
@ -109,7 +109,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
FragmentUtils.createFragment(this, CalculatorDisplayFragment.class, R.id.displayContainer, "display");
FragmentUtils.createFragment(this, CalculatorKeyboardFragment.class, R.id.keyboardContainer, "keyboard");
this.useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
this.useBackAsPrev = Preferences.Gui.usePrevAsBack.getPreference(preferences);
if (savedInstanceState == null) {
firstTimeInit(preferences, this);
}
@ -154,16 +154,16 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
}
private static void firstTimeInit(@Nonnull SharedPreferences preferences, @Nonnull Context context) {
final Integer appOpenedCounter = CalculatorPreferences.appOpenedCounter.getPreference(preferences);
final Integer appOpenedCounter = Preferences.appOpenedCounter.getPreference(preferences);
if (appOpenedCounter != null) {
CalculatorPreferences.appOpenedCounter.putPreference(preferences, appOpenedCounter + 1);
Preferences.appOpenedCounter.putPreference(preferences, appOpenedCounter + 1);
}
final Integer savedVersion = CalculatorPreferences.appVersion.getPreference(preferences);
final Integer savedVersion = Preferences.appVersion.getPreference(preferences);
final int appVersion = Android.getAppVersionCode(context);
CalculatorPreferences.appVersion.putPreference(preferences, appVersion);
Preferences.appVersion.putPreference(preferences, appVersion);
if (!CalculatorApplication.isMonkeyRunner(context)) {
@ -174,13 +174,13 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
continueWizard(wizards, wizard.getName(), context);
dialogShown = true;
} else {
if (Objects.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) {
if (Objects.areEqual(savedVersion, Preferences.appVersion.getDefaultValue())) {
// new start
startWizard(wizards, context);
dialogShown = true;
} else {
if (savedVersion < appVersion) {
final boolean showReleaseNotes = CalculatorPreferences.Gui.showReleaseNotes.getPreference(preferences);
final boolean showReleaseNotes = Preferences.Gui.showReleaseNotes.getPreference(preferences);
if (showReleaseNotes) {
final String releaseNotes = CalculatorReleaseNotesFragment.getReleaseNotes(context, savedVersion + 1);
if (!Strings.isEmpty(releaseNotes)) {
@ -198,7 +198,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
//Log.d(this.getClass().getName(), "Application was opened " + appOpenedCounter + " time!");
if (!dialogShown) {
if (appOpenedCounter != null && appOpenedCounter > 100) {
dialogShown = showSpecialWindow(preferences, CalculatorPreferences.Gui.feedbackWindowShown, R.layout.feedback, R.id.feedbackText, context);
dialogShown = showSpecialWindow(preferences, Preferences.Gui.feedbackWindowShown, R.layout.feedback, R.id.feedbackText, context);
}
}
}
@ -254,7 +254,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
super.onResume();
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
final CalculatorPreferences.Gui.Layout newLayout = CalculatorPreferences.Gui.layout.getPreference(preferences);
final Preferences.Gui.Layout newLayout = Preferences.Gui.layout.getPreference(preferences);
if (newLayout != activityUi.getLayout()) {
Activities.restartActivity(this);
}
@ -280,11 +280,11 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) {
if (CalculatorPreferences.Gui.usePrevAsBack.getKey().equals(key)) {
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
if (Preferences.Gui.usePrevAsBack.getKey().equals(key)) {
useBackAsPrev = Preferences.Gui.usePrevAsBack.getPreference(preferences);
}
if (CalculatorPreferences.Gui.autoOrientation.getKey().equals(key)) {
if (Preferences.Gui.autoOrientation.getKey().equals(key)) {
toggleOrientationChange(preferences);
}
}
@ -298,7 +298,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : preferences;
if (CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
if (Preferences.Gui.autoOrientation.getPreference(preferences)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

View File

@ -208,7 +208,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
public static void showCalculationMessagesDialog(@Nonnull Context context, @Nonnull List<Message> messages) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (CalculatorPreferences.Calculations.showCalculationMessagesDialog.getPreference(prefs)) {
if (Preferences.Calculations.showCalculationMessagesDialog.getPreference(prefs)) {
FixableMessagesDialog.showDialogForMessages(messages, context, true);
}
}

View File

@ -38,7 +38,7 @@ public class CalculatorActivityMobile extends CalculatorActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
CalculatorPreferences.Gui.layout.putPreference(prefs, CalculatorPreferences.Gui.Layout.main_calculator_mobile);
Preferences.Gui.layout.putPreference(prefs, Preferences.Gui.Layout.main_calculator_mobile);
super.onCreate(savedInstanceState);

View File

@ -161,7 +161,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
}
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
CalculatorPreferences.setDefaultValues(preferences);
Preferences.setDefaultValues(preferences);
preferences.registerOnSharedPreferenceChangeListener(this);
@ -169,6 +169,11 @@ public class CalculatorApplication extends android.app.Application implements Sh
super.onCreate();
if (!Preferences.Ga.initialReportDone.getPreference(preferences)) {
App.getGa().reportInitially(preferences);
Preferences.Ga.initialReportDone.putPreference(preferences, true);
}
final AndroidCalculator calculator = new AndroidCalculator(this);
final EditorTextProcessor editorTextProcessor = new EditorTextProcessor();
@ -221,7 +226,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
}
private void setTheme(@Nonnull SharedPreferences preferences) {
final CalculatorPreferences.Gui.Theme theme = CalculatorPreferences.Gui.getTheme(preferences);
final Preferences.Gui.Theme theme = Preferences.Gui.getTheme(preferences);
setTheme(theme.getThemeId());
}
@ -290,8 +295,8 @@ public class CalculatorApplication extends android.app.Application implements Sh
@Override
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
if (CalculatorPreferences.OnscreenCalculator.showAppIcon.getKey().equals(key)) {
boolean showAppIcon = CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(prefs);
if (Preferences.OnscreenCalculator.showAppIcon.getKey().equals(key)) {
boolean showAppIcon = Preferences.OnscreenCalculator.showAppIcon.getPreference(prefs);
Android.toggleComponent(this, CalculatorOnscreenStartActivity.class, showAppIcon);
Locator.getInstance().getNotifier().showMessage(R.string.cpp_this_change_may_require_reboot, MessageType.info);
}

View File

@ -60,8 +60,8 @@ public final class CalculatorButtons {
}
public static void processButtons(@Nonnull CalculatorPreferences.Gui.Theme theme,
@Nonnull CalculatorPreferences.Gui.Layout layout,
public static void processButtons(@Nonnull Preferences.Gui.Theme theme,
@Nonnull Preferences.Gui.Layout layout,
@Nonnull View root) {
if (!layout.isOptimized()) {
@ -93,15 +93,15 @@ public final class CalculatorButtons {
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
final boolean large = Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) &&
CalculatorPreferences.Gui.getLayout(preferences).isOptimized();
Preferences.Gui.getLayout(preferences).isOptimized();
if (!large) {
if (Views.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT
|| !CalculatorPreferences.Gui.autoOrientation.getPreference(preferences)) {
|| !Preferences.Gui.autoOrientation.getPreference(preferences)) {
final DragButton equalsButton = (DragButton) activity.findViewById(R.id.cpp_button_equals);
if (equalsButton != null) {
if (CalculatorPreferences.Gui.showEqualsButton.getPreference(preferences)) {
if (Preferences.Gui.showEqualsButton.getPreference(preferences)) {
equalsButton.setVisibility(View.VISIBLE);
} else {
equalsButton.setVisibility(View.GONE);

View File

@ -48,7 +48,7 @@ public class CalculatorDisplayFragment extends SherlockFragment {
super.onCreate(savedInstanceState);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.getLayout(prefs);
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(prefs);
if (!layout.isOptimized()) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_display_mobile, R.string.result);
} else {

View File

@ -76,7 +76,7 @@ public class CalculatorEditorFragment extends SherlockFragment {
super.onCreate(savedInstanceState);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.getLayout(prefs);
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(prefs);
if (!layout.isOptimized()) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_editor_mobile, R.string.editor);
} else {

View File

@ -28,19 +28,14 @@ import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragment;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.hideNumeralBaseDigits;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.showEqualsButton;
import static org.solovyev.android.calculator.NumeralBaseButtons.toggleNumericDigits;
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences;
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.angleUnit;
import static org.solovyev.android.calculator.Preferences.Gui.hideNumeralBaseDigits;
import static org.solovyev.android.calculator.Preferences.Gui.showEqualsButton;
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.multiplicationSign;
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.numeralBase;
@ -52,7 +47,7 @@ import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Pref
public class CalculatorKeyboardFragment extends SherlockFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
@Nonnull
private CalculatorPreferences.Gui.Theme theme;
private Preferences.Gui.Theme theme;
@Nonnull
private FragmentUi fragmentHelper;
@ -63,7 +58,7 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.getLayout(preferences);
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(preferences);
if (!layout.isOptimized()) {
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_keyboard_mobile);
} else {
@ -74,7 +69,7 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
preferences.registerOnSharedPreferenceChangeListener(this);
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
theme = Preferences.Gui.theme.getPreferenceNoError(preferences);
}

View File

@ -87,7 +87,7 @@ public class FixableMessagesDialog extends SherlockActivity {
public void onClick(View v) {
if (doNotShowCalculationMessagesCheckbox.isChecked()) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(FixableMessagesDialog.this);
CalculatorPreferences.Calculations.showCalculationMessagesDialog.putPreference(prefs, false);
Preferences.Calculations.showCalculationMessagesDialog.putPreference(prefs, false);
}
FixableMessagesDialog.this.finish();

View File

@ -31,7 +31,7 @@ import javax.annotation.Nonnull;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import static jscl.NumeralBase.hex;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.hideNumeralBaseDigits;
import static org.solovyev.android.calculator.Preferences.Gui.hideNumeralBaseDigits;
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.numeralBase;
/**

View File

@ -25,15 +25,12 @@ package org.solovyev.android.calculator;
import android.content.SharedPreferences;
import jscl.AngleUnit;
import jscl.NumeralBase;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.prefs.*;
import org.solovyev.android.view.VibratorContainer;
import javax.annotation.Nonnull;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
@ -46,9 +43,9 @@ import static org.solovyev.android.DeviceModel.samsung_galaxy_s_2;
* Date: 4/20/12
* Time: 12:42 PM
*/
public final class CalculatorPreferences {
public final class Preferences {
private CalculatorPreferences() {
private Preferences() {
throw new AssertionError();
}
@ -71,6 +68,10 @@ public final class CalculatorPreferences {
}
public static class Ga {
public static final Preference<Boolean> initialReportDone = BooleanPreference.of("ga.initial_report_done", false);
}
public static class Gui {
public static final Preference<Theme> theme = StringPreference.ofEnum("org.solovyev.android.calculator.CalculatorActivity_calc_theme", Theme.metro_blue_theme, Theme.class);
@ -233,6 +234,8 @@ public final class CalculatorPreferences {
applyDefaultPreference(preferences, OnscreenCalculator.showAppIcon);
applyDefaultPreference(preferences, OnscreenCalculator.startOnBoot);
applyDefaultPreference(preferences, Ga.initialReportDone);
// renew value after each application start
Calculations.showCalculationMessagesDialog.putDefault(preferences);

View File

@ -1,19 +1,27 @@
package org.solovyev.android.calculator.ga;
import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.util.Log;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import org.solovyev.common.listeners.JEvent;
import org.solovyev.common.listeners.JEventListener;
import org.solovyev.common.listeners.JEventListeners;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
public final class Ga {
public final class Ga implements SharedPreferences.OnSharedPreferenceChangeListener {
private static final int LAYOUT = 1;
private static final int THEME = 2;
@Nonnull
private final GoogleAnalytics analytics;
@ -21,9 +29,10 @@ public final class Ga {
@Nonnull
private final Tracker tracker;
public Ga(@Nonnull Context context, @Nonnull JEventListeners<JEventListener<? extends JEvent>, JEvent> bus) {
public Ga(@Nonnull Context context, @Nonnull SharedPreferences preferences, @Nonnull JEventListeners<JEventListener<? extends JEvent>, JEvent> bus) {
analytics = GoogleAnalytics.getInstance(context);
tracker = analytics.newTracker(R.xml.ga);
preferences.registerOnSharedPreferenceChangeListener(this);
}
@Nonnull
@ -38,6 +47,14 @@ public final class Ga {
return "";
}
private void reportLayout(@Nonnull Preferences.Gui.Layout layout) {
tracker.send(new HitBuilders.EventBuilder().setCustomDimension(LAYOUT, layout.name()).build());
}
private void reportTheme(@Nonnull Preferences.Gui.Theme theme) {
tracker.send(new HitBuilders.EventBuilder().setCustomDimension(THEME, theme.name()).build());
}
@Nonnull
public GoogleAnalytics getAnalytics() {
return analytics;
@ -47,4 +64,30 @@ public final class Ga {
public Tracker getTracker() {
return tracker;
}
public void onButtonPressed(@Nullable String text) {
if (TextUtils.isEmpty(text)) {
return;
}
final HitBuilders.EventBuilder b = new HitBuilders.EventBuilder();
b.setCategory("ui");
b.setAction("click");
b.setLabel(text);
tracker.send(b.build());
}
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (TextUtils.equals(key, Preferences.Gui.layout.getKey())) {
reportLayout(Preferences.Gui.layout.getPreferenceNoError(preferences));
} else if (TextUtils.equals(key, Preferences.Gui.theme.getKey())) {
reportTheme(Preferences.Gui.theme.getPreferenceNoError(preferences));
}
}
public void reportInitially(@Nonnull SharedPreferences preferences) {
reportLayout(Preferences.Gui.layout.getPreferenceNoError(preferences));
reportTheme(Preferences.Gui.theme.getPreferenceNoError(preferences));
}
}

View File

@ -144,7 +144,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
super.onViewCreated(root, savedInstanceState);
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
final Boolean showDatetime = CalculatorPreferences.History.showDatetime.getPreference(preferences);
final Boolean showDatetime = Preferences.History.showDatetime.getPreference(preferences);
fragmentHelper.onViewCreated(this, root);
@ -377,8 +377,8 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
@Override
public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
final Boolean showDatetime = CalculatorPreferences.History.showDatetime.getPreference(preferences);
CalculatorPreferences.History.showDatetime.putPreference(preferences, !showDatetime);
final Boolean showDatetime = Preferences.History.showDatetime.getPreference(preferences);
Preferences.History.showDatetime.putPreference(preferences, !showDatetime);
}
},
@ -432,8 +432,8 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (CalculatorPreferences.History.showDatetime.isSameKey(key)) {
getAdapter().setShowDatetime(CalculatorPreferences.History.showDatetime.getPreference(preferences));
if (Preferences.History.showDatetime.isSameKey(key)) {
getAdapter().setShowDatetime(Preferences.History.showDatetime.getPreference(preferences));
}
}
}

View File

@ -26,7 +26,7 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.solovyev.android.calculator.CalculatorFragmentType;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.Locator;
import org.solovyev.android.calculator.R;
@ -55,7 +55,7 @@ public class CalculatorHistoryFragment extends AbstractCalculatorHistoryFragment
@Override
protected List<CalculatorHistoryState> getHistoryItems() {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
final boolean showIntermediateCalculations = CalculatorPreferences.History.showIntermediateCalculations.getPreference(preferences);
final boolean showIntermediateCalculations = Preferences.History.showIntermediateCalculations.getPreference(preferences);
final List<CalculatorHistoryState> historyStates = Locator.getInstance().getHistory().getStates(showIntermediateCalculations);
return new ArrayList<CalculatorHistoryState>(historyStates);
}

View File

@ -30,7 +30,7 @@ import android.preference.PreferenceManager;
import javax.annotation.Nonnull;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Preferences;
/**
* User: serso
@ -47,7 +47,7 @@ public final class CalculatorOnscreenBroadcastReceiver extends BroadcastReceiver
@Nonnull Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
if (CalculatorPreferences.OnscreenCalculator.startOnBoot.getPreferenceNoError(preferences)) {
if (Preferences.OnscreenCalculator.startOnBoot.getPreferenceNoError(preferences)) {
CalculatorOnscreenService.showNotification(context);
}
} else {

View File

@ -30,7 +30,7 @@ import jscl.math.Generic;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Preferences;
import java.util.List;
@ -51,7 +51,7 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
preferences.registerOnSharedPreferenceChangeListener(this);
onSharedPreferenceChanged(preferences, CalculatorPreferences.Graph.plotImag.getKey());
onSharedPreferenceChanged(preferences, Preferences.Graph.plotImag.getKey());
}
@Override
@ -194,8 +194,8 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
@Override
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
if (CalculatorPreferences.Graph.plotImag.getKey().equals(key)) {
setPlotImag(CalculatorPreferences.Graph.plotImag.getPreference(preferences));
if (Preferences.Graph.plotImag.getKey().equals(key)) {
setPlotImag(Preferences.Graph.plotImag.getPreference(preferences));
}
}
}

View File

@ -11,7 +11,7 @@ import org.solovyev.android.calculator.text.TextProcessorEditorResult;
import javax.annotation.Nonnull;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.colorDisplay;
import static org.solovyev.android.calculator.Preferences.Gui.colorDisplay;
import static org.solovyev.android.calculator.view.TextHighlighter.WHITE;
/**

View File

@ -24,13 +24,13 @@ package org.solovyev.android.calculator.wizard;
import android.content.SharedPreferences;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator_mobile;
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator;
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator_mobile;
/**
* User: serso
@ -42,14 +42,14 @@ enum CalculatorLayout {
big_buttons(R.string.cpp_wizard_layout_big_buttons) {
@Override
protected void apply(@Nonnull SharedPreferences preferences) {
CalculatorPreferences.Gui.layout.putPreference(preferences, main_calculator_mobile);
Preferences.Gui.layout.putPreference(preferences, main_calculator_mobile);
}
},
optimized(R.string.cpp_wizard_layout_optimized) {
@Override
protected void apply(@Nonnull SharedPreferences preferences) {
CalculatorPreferences.Gui.layout.putPreference(preferences, main_calculator);
Preferences.Gui.layout.putPreference(preferences, main_calculator);
}
};
@ -71,7 +71,7 @@ enum CalculatorLayout {
}
@Nonnull
static CalculatorLayout fromGuiLayout(@Nonnull CalculatorPreferences.Gui.Layout layout) {
static CalculatorLayout fromGuiLayout(@Nonnull Preferences.Gui.Layout layout) {
if (layout.isOptimized()) {
return optimized;
} else {

View File

@ -25,14 +25,14 @@ package org.solovyev.android.calculator.wizard;
import android.content.SharedPreferences;
import jscl.AngleUnit;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import javax.annotation.Nonnull;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator_mobile;
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator;
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator_mobile;
/**
* User: serso
@ -44,13 +44,13 @@ enum CalculatorMode {
simple(R.string.cpp_wizard_mode_simple) {
@Override
protected void apply(@Nonnull SharedPreferences preferences) {
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.layout.getPreference(preferences);
final Preferences.Gui.Layout layout = Preferences.Gui.layout.getPreference(preferences);
if (layout.isOptimized()) {
CalculatorPreferences.Gui.layout.putPreference(preferences, CalculatorPreferences.Gui.Layout.simple);
Preferences.Gui.layout.putPreference(preferences, Preferences.Gui.Layout.simple);
} else {
CalculatorPreferences.Gui.layout.putPreference(preferences, CalculatorPreferences.Gui.Layout.simple_mobile);
Preferences.Gui.layout.putPreference(preferences, Preferences.Gui.Layout.simple_mobile);
}
CalculatorPreferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.deg);
Preferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.deg);
AndroidCalculatorEngine.Preferences.angleUnit.putPreference(preferences, AngleUnit.deg);
AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, false);
AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, true);
@ -60,13 +60,13 @@ enum CalculatorMode {
engineer(R.string.cpp_wizard_mode_engineer) {
@Override
protected void apply(@Nonnull SharedPreferences preferences) {
final CalculatorPreferences.Gui.Layout layout = CalculatorPreferences.Gui.layout.getPreference(preferences);
final Preferences.Gui.Layout layout = Preferences.Gui.layout.getPreference(preferences);
if (layout.isOptimized()) {
CalculatorPreferences.Gui.layout.putPreference(preferences, main_calculator);
Preferences.Gui.layout.putPreference(preferences, main_calculator);
} else {
CalculatorPreferences.Gui.layout.putPreference(preferences, main_calculator_mobile);
Preferences.Gui.layout.putPreference(preferences, main_calculator_mobile);
}
CalculatorPreferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.rad);
Preferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.rad);
AndroidCalculatorEngine.Preferences.angleUnit.putPreference(preferences, AngleUnit.rad);
AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, true);
AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, false);
@ -91,7 +91,7 @@ enum CalculatorMode {
}
@Nonnull
static CalculatorMode fromGuiLayout(@Nonnull CalculatorPreferences.Gui.Layout layout) {
static CalculatorMode fromGuiLayout(@Nonnull Preferences.Gui.Layout layout) {
switch (layout) {
case main_calculator:
case main_cellphone:

View File

@ -27,7 +27,7 @@ import android.os.Bundle;
import android.support.v4.app.Fragment;
import org.solovyev.android.calculator.App;
import org.solovyev.android.Views;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull;
@ -62,7 +62,7 @@ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
@Override
public Bundle getFragmentArgs() {
final Bundle bundle = new Bundle();
bundle.putSerializable(LAYOUT, CalculatorLayout.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(getPreferences())));
bundle.putSerializable(LAYOUT, CalculatorLayout.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences())));
return bundle;
}
@ -87,7 +87,7 @@ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
@Override
public Bundle getFragmentArgs() {
final Bundle bundle = new Bundle();
bundle.putSerializable(MODE, CalculatorMode.fromGuiLayout(CalculatorPreferences.Gui.layout.getPreference(getPreferences())));
bundle.putSerializable(MODE, CalculatorMode.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences())));
return bundle;
}
},
@ -97,7 +97,7 @@ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
public boolean onNext(@Nonnull Fragment f) {
final OnScreenCalculatorWizardStep fragment = (OnScreenCalculatorWizardStep) f;
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), fragment.isOnscreenCalculatorEnabled());
Preferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), fragment.isOnscreenCalculatorEnabled());
return true;
}
@ -106,7 +106,7 @@ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
@Override
public Bundle getFragmentArgs() {
final Bundle bundle = new Bundle();
bundle.putSerializable(ONSCREEN_CALCULATOR_ENABLED, CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(getPreferences()));
bundle.putSerializable(ONSCREEN_CALCULATOR_ENABLED, Preferences.OnscreenCalculator.showAppIcon.getPreference(getPreferences()));
return bundle;
}
},

View File

@ -29,7 +29,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import org.solovyev.android.calculator.CalculatorPreferences;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
import javax.annotation.Nullable;
@ -68,7 +68,7 @@ public class OnScreenCalculatorWizardStep extends Fragment {
}
if (onscreenCalculatorEnabled == null) {
onscreenCalculatorEnabled = getArguments().getBoolean(ONSCREEN_CALCULATOR_ENABLED, CalculatorPreferences.OnscreenCalculator.showAppIcon.getDefaultValue());
onscreenCalculatorEnabled = getArguments().getBoolean(ONSCREEN_CALCULATOR_ENABLED, Preferences.OnscreenCalculator.showAppIcon.getDefaultValue());
}
}
@ -86,7 +86,7 @@ public class OnScreenCalculatorWizardStep extends Fragment {
}
public Boolean isOnscreenCalculatorEnabled() {
boolean enabled = CalculatorPreferences.OnscreenCalculator.showAppIcon.getDefaultValue();
boolean enabled = Preferences.OnscreenCalculator.showAppIcon.getDefaultValue();
if (onscreenCalculatorCheckbox != null) {
enabled = onscreenCalculatorCheckbox.isChecked();