More GA integration
Theme and layout dimensions reporting added
This commit is contained in:
parent
d23f8e2c40
commit
13b2558620
@ -30,7 +30,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.util.ActivityController;
|
import org.robolectric.util.ActivityController;
|
||||||
import org.solovyev.android.CalculatorTestRunner;
|
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.BaseWizardActivity;
|
||||||
import org.solovyev.android.wizard.WizardUi;
|
import org.solovyev.android.wizard.WizardUi;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public class OnScreenCalculatorWizardStepTest {
|
|||||||
|
|
||||||
private void testShouldBeEqualsToIconState(boolean iconEnabled) throws IllegalAccessException {
|
private void testShouldBeEqualsToIconState(boolean iconEnabled) throws IllegalAccessException {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(Robolectric.application);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(Robolectric.application);
|
||||||
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(preferences, iconEnabled);
|
Preferences.OnscreenCalculator.showAppIcon.putPreference(preferences, iconEnabled);
|
||||||
createActivity();
|
createActivity();
|
||||||
setFragment();
|
setFragment();
|
||||||
assertEquals(iconEnabled, fragment.isOnscreenCalculatorEnabled());
|
assertEquals(iconEnabled, fragment.isOnscreenCalculatorEnabled());
|
||||||
|
@ -32,15 +32,15 @@ import org.junit.runner.RunWith;
|
|||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
import org.solovyev.android.CalculatorTestRunner;
|
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.junit.Assert.*;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
import static org.solovyev.android.calculator.CalculatorApplication.getPreferences;
|
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.Preferences.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_mobile;
|
||||||
import static org.solovyev.android.calculator.CalculatorPreferences.OnscreenCalculator.showAppIcon;
|
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.big_buttons;
|
||||||
import static org.solovyev.android.calculator.wizard.CalculatorLayout.optimized;
|
import static org.solovyev.android.calculator.wizard.CalculatorLayout.optimized;
|
||||||
import static org.solovyev.android.calculator.wizard.CalculatorMode.engineer;
|
import static org.solovyev.android.calculator.wizard.CalculatorMode.engineer;
|
||||||
@ -88,7 +88,7 @@ public class WizardStepTest {
|
|||||||
chooseLayout(optimized);
|
chooseLayout(optimized);
|
||||||
chooseMode(simple);
|
chooseMode(simple);
|
||||||
|
|
||||||
assertUiLayoutEquals(CalculatorPreferences.Gui.Layout.simple);
|
assertUiLayoutEquals(Preferences.Gui.Layout.simple);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -96,11 +96,11 @@ public class WizardStepTest {
|
|||||||
chooseLayout(big_buttons);
|
chooseLayout(big_buttons);
|
||||||
chooseMode(simple);
|
chooseMode(simple);
|
||||||
|
|
||||||
assertUiLayoutEquals(CalculatorPreferences.Gui.Layout.simple_mobile);
|
assertUiLayoutEquals(Preferences.Gui.Layout.simple_mobile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertUiLayoutEquals(CalculatorPreferences.Gui.Layout uiLayout) {
|
private void assertUiLayoutEquals(Preferences.Gui.Layout uiLayout) {
|
||||||
Assert.assertEquals(uiLayout, CalculatorPreferences.Gui.layout.getPreference(PreferenceManager.getDefaultSharedPreferences(Robolectric.application)));
|
Assert.assertEquals(uiLayout, Preferences.Gui.layout.getPreference(PreferenceManager.getDefaultSharedPreferences(Robolectric.application)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void chooseMode(CalculatorMode mode) {
|
private void chooseMode(CalculatorMode mode) {
|
||||||
@ -152,30 +152,30 @@ public class WizardStepTest {
|
|||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
@Test
|
@Test
|
||||||
public void testChooseLayoutFragmentArgs() throws Exception {
|
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));
|
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));
|
assertEquals(CalculatorLayout.big_buttons, choose_layout.getFragmentArgs().getSerializable(LAYOUT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
@Test
|
@Test
|
||||||
public void testChooseModeFragmentArgs() throws Exception {
|
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));
|
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));
|
assertEquals(CalculatorMode.simple, choose_mode.getFragmentArgs().getSerializable(MODE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
@Test
|
@Test
|
||||||
public void testOnscreenFragmentArgs() throws Exception {
|
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));
|
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));
|
assertFalse(on_screen_calculator.getFragmentArgs().getBoolean(ONSCREEN_CALCULATOR_ENABLED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,10 +68,10 @@ public class ActivityUi extends BaseUi {
|
|||||||
private boolean homeIcon = false;
|
private boolean homeIcon = false;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorPreferences.Gui.Theme theme;
|
private Preferences.Gui.Theme theme;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorPreferences.Gui.Layout layout;
|
private Preferences.Gui.Layout layout;
|
||||||
|
|
||||||
private int selectedNavigationIndex = 0;
|
private int selectedNavigationIndex = 0;
|
||||||
|
|
||||||
@ -95,10 +95,10 @@ public class ActivityUi extends BaseUi {
|
|||||||
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
|
|
||||||
this.theme = CalculatorPreferences.Gui.getTheme(preferences);
|
this.theme = Preferences.Gui.getTheme(preferences);
|
||||||
activity.setTheme(this.theme.getThemeId());
|
activity.setTheme(this.theme.getThemeId());
|
||||||
|
|
||||||
this.layout = CalculatorPreferences.Gui.getLayout(preferences);
|
this.layout = Preferences.Gui.getLayout(preferences);
|
||||||
|
|
||||||
activity.setContentView(layoutId);
|
activity.setContentView(layoutId);
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ public class ActivityUi extends BaseUi {
|
|||||||
public void onResume(@Nonnull Activity activity) {
|
public void onResume(@Nonnull Activity activity) {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(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)) {
|
if (!theme.equals(newTheme)) {
|
||||||
Activities.restartActivity(activity);
|
Activities.restartActivity(activity);
|
||||||
}
|
}
|
||||||
@ -253,12 +253,12 @@ public class ActivityUi extends BaseUi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public CalculatorPreferences.Gui.Theme getTheme() {
|
public Preferences.Gui.Theme getTheme() {
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public CalculatorPreferences.Gui.Layout getLayout() {
|
public Preferences.Gui.Layout getLayout() {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
|
|||||||
this.calculator.init();
|
this.calculator.init();
|
||||||
|
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
this.calculator.setCalculateOnFly(CalculatorPreferences.Calculations.calculateOnFly.getPreference(prefs));
|
this.calculator.setCalculateOnFly(Preferences.Calculations.calculateOnFly.getPreference(prefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -245,8 +245,8 @@ public class AndroidCalculator implements Calculator, CalculatorEventListener, S
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(@Nonnull SharedPreferences prefs, @Nonnull String key) {
|
public void onSharedPreferenceChanged(@Nonnull SharedPreferences prefs, @Nonnull String key) {
|
||||||
if (CalculatorPreferences.Calculations.calculateOnFly.getKey().equals(key)) {
|
if (Preferences.Calculations.calculateOnFly.getKey().equals(key)) {
|
||||||
this.calculator.setCalculateOnFly(CalculatorPreferences.Calculations.calculateOnFly.getPreference(prefs));
|
this.calculator.setCalculateOnFly(Preferences.Calculations.calculateOnFly.getPreference(prefs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public class AndroidCalculatorDisplayView extends AutoResizeTextView implements
|
|||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
if (fromApp) {
|
if (fromApp) {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
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()) {
|
if (!layout.isOptimized()) {
|
||||||
setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(R.dimen.cpp_display_text_size_mobile));
|
setTextSize(TypedValue.COMPLEX_UNIT_SP, getResources().getDimension(R.dimen.cpp_display_text_size_mobile));
|
||||||
|
@ -28,12 +28,11 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
import org.solovyev.android.view.VibratorContainer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.solovyev.android.view.VibratorContainer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
* Date: 11/18/12
|
* Date: 11/18/12
|
||||||
@ -58,6 +57,7 @@ public class AndroidCalculatorKeyboard implements CalculatorKeyboard {
|
|||||||
@Override
|
@Override
|
||||||
public void buttonPressed(@Nullable String text) {
|
public void buttonPressed(@Nullable String text) {
|
||||||
vibrate();
|
vibrate();
|
||||||
|
App.getGa().onButtonPressed(text);
|
||||||
calculatorKeyboard.buttonPressed(text);
|
calculatorKeyboard.buttonPressed(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,11 +60,11 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
|
|||||||
|
|
||||||
final Long currentTime = System.currentTimeMillis();
|
final Long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
if (force || (CalculatorPreferences.Calculations.showCalculationMessagesDialog.getPreference(prefs) && isTimeForCheck(currentTime, prefs))) {
|
if (force || (Preferences.Calculations.showCalculationMessagesDialog.getPreference(prefs) && isTimeForCheck(currentTime, prefs))) {
|
||||||
final NumeralBase preferredNumeralBase = CalculatorPreferences.Calculations.preferredNumeralBase.getPreference(prefs);
|
final NumeralBase preferredNumeralBase = Preferences.Calculations.preferredNumeralBase.getPreference(prefs);
|
||||||
final NumeralBase numeralBase = AndroidCalculatorEngine.Preferences.numeralBase.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 AngleUnit angleUnits = AndroidCalculatorEngine.Preferences.angleUnit.getPreference(prefs);
|
||||||
|
|
||||||
final List<FixableMessage> messages = new ArrayList<FixableMessage>(2);
|
final List<FixableMessage> messages = new ArrayList<FixableMessage>(2);
|
||||||
@ -78,12 +78,12 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
|
|||||||
|
|
||||||
FixableMessagesDialog.showDialog(messages, application, true);
|
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) {
|
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;
|
return currentTime - lastPreferredPreferencesCheckTime > PREFERRED_PREFS_INTERVAL_TIME;
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
|
|||||||
@Override
|
@Override
|
||||||
public void setPreferredAngleUnits() {
|
public void setPreferredAngleUnits() {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
|
||||||
setAngleUnits(CalculatorPreferences.Calculations.preferredAngleUnits.getPreference(preferences));
|
setAngleUnits(Preferences.Calculations.preferredAngleUnits.getPreference(preferences));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,7 +105,7 @@ public class AndroidCalculatorPreferenceService implements CalculatorPreferenceS
|
|||||||
@Override
|
@Override
|
||||||
public void setPreferredNumeralBase() {
|
public void setPreferredNumeralBase() {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(application);
|
||||||
setNumeralBase(CalculatorPreferences.Calculations.preferredNumeralBase.getPreference(preferences));
|
setNumeralBase(Preferences.Calculations.preferredNumeralBase.getPreference(preferences));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import org.solovyev.android.UiThreadExecutor;
|
import org.solovyev.android.UiThreadExecutor;
|
||||||
import org.solovyev.android.calculator.ga.Ga;
|
import org.solovyev.android.calculator.ga.Ga;
|
||||||
import org.solovyev.common.listeners.JEvent;
|
import org.solovyev.common.listeners.JEvent;
|
||||||
@ -73,6 +75,9 @@ public final class App {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private static CalculatorBroadcaster broadcaster;
|
private static CalculatorBroadcaster broadcaster;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private static SharedPreferences preferences;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static volatile Ga ga;
|
private static volatile Ga ga;
|
||||||
|
|
||||||
@ -102,9 +107,10 @@ public final class App {
|
|||||||
@Nullable ServiceLocator serviceLocator) {
|
@Nullable ServiceLocator serviceLocator) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
App.application = application;
|
App.application = application;
|
||||||
|
App.preferences = PreferenceManager.getDefaultSharedPreferences(application);
|
||||||
App.uiThreadExecutor = uiThreadExecutor;
|
App.uiThreadExecutor = uiThreadExecutor;
|
||||||
App.eventBus = eventBus;
|
App.eventBus = eventBus;
|
||||||
App.ga = new Ga(application, eventBus);
|
App.ga = new Ga(application, preferences, eventBus);
|
||||||
if (serviceLocator != null) {
|
if (serviceLocator != null) {
|
||||||
App.locator = serviceLocator;
|
App.locator = serviceLocator;
|
||||||
} else {
|
} else {
|
||||||
|
@ -52,8 +52,8 @@ import java.lang.reflect.Modifier;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.simple;
|
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple;
|
||||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.simple_mobile;
|
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.angleUnit;
|
||||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.numeralBase;
|
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);
|
private static final List<Integer> viewIds = new ArrayList<Integer>(200);
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorPreferences.Gui.Layout layout;
|
private Preferences.Gui.Layout layout;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorPreferences.Gui.Theme theme;
|
private Preferences.Gui.Theme theme;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private Vibrator vibrator;
|
private Vibrator vibrator;
|
||||||
@ -99,8 +99,8 @@ public abstract class BaseUi implements SharedPreferences.OnSharedPreferenceChan
|
|||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
|
|
||||||
vibrator = (Vibrator) activity.getSystemService(Activity.VIBRATOR_SERVICE);
|
vibrator = (Vibrator) activity.getSystemService(Activity.VIBRATOR_SERVICE);
|
||||||
layout = CalculatorPreferences.Gui.layout.getPreferenceNoError(preferences);
|
layout = Preferences.Gui.layout.getPreferenceNoError(preferences);
|
||||||
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
|
theme = Preferences.Gui.theme.getPreferenceNoError(preferences);
|
||||||
|
|
||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ import javax.annotation.Nullable;
|
|||||||
import static android.os.Build.VERSION_CODES.GINGERBREAD_MR1;
|
import static android.os.Build.VERSION_CODES.GINGERBREAD_MR1;
|
||||||
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
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.continueWizard;
|
||||||
import static org.solovyev.android.wizard.WizardUi.startWizard;
|
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) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
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 = CalculatorApplication.getInstance().createActivityHelper(layout.getLayoutId(), TAG);
|
||||||
activityUi.logDebug("onCreate");
|
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, CalculatorDisplayFragment.class, R.id.displayContainer, "display");
|
||||||
FragmentUtils.createFragment(this, CalculatorKeyboardFragment.class, R.id.keyboardContainer, "keyboard");
|
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) {
|
if (savedInstanceState == null) {
|
||||||
firstTimeInit(preferences, this);
|
firstTimeInit(preferences, this);
|
||||||
}
|
}
|
||||||
@ -154,16 +154,16 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void firstTimeInit(@Nonnull SharedPreferences preferences, @Nonnull Context context) {
|
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) {
|
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);
|
final int appVersion = Android.getAppVersionCode(context);
|
||||||
|
|
||||||
CalculatorPreferences.appVersion.putPreference(preferences, appVersion);
|
Preferences.appVersion.putPreference(preferences, appVersion);
|
||||||
|
|
||||||
if (!CalculatorApplication.isMonkeyRunner(context)) {
|
if (!CalculatorApplication.isMonkeyRunner(context)) {
|
||||||
|
|
||||||
@ -174,13 +174,13 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
continueWizard(wizards, wizard.getName(), context);
|
continueWizard(wizards, wizard.getName(), context);
|
||||||
dialogShown = true;
|
dialogShown = true;
|
||||||
} else {
|
} else {
|
||||||
if (Objects.areEqual(savedVersion, CalculatorPreferences.appVersion.getDefaultValue())) {
|
if (Objects.areEqual(savedVersion, Preferences.appVersion.getDefaultValue())) {
|
||||||
// new start
|
// new start
|
||||||
startWizard(wizards, context);
|
startWizard(wizards, context);
|
||||||
dialogShown = true;
|
dialogShown = true;
|
||||||
} else {
|
} else {
|
||||||
if (savedVersion < appVersion) {
|
if (savedVersion < appVersion) {
|
||||||
final boolean showReleaseNotes = CalculatorPreferences.Gui.showReleaseNotes.getPreference(preferences);
|
final boolean showReleaseNotes = Preferences.Gui.showReleaseNotes.getPreference(preferences);
|
||||||
if (showReleaseNotes) {
|
if (showReleaseNotes) {
|
||||||
final String releaseNotes = CalculatorReleaseNotesFragment.getReleaseNotes(context, savedVersion + 1);
|
final String releaseNotes = CalculatorReleaseNotesFragment.getReleaseNotes(context, savedVersion + 1);
|
||||||
if (!Strings.isEmpty(releaseNotes)) {
|
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!");
|
//Log.d(this.getClass().getName(), "Application was opened " + appOpenedCounter + " time!");
|
||||||
if (!dialogShown) {
|
if (!dialogShown) {
|
||||||
if (appOpenedCounter != null && appOpenedCounter > 100) {
|
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();
|
super.onResume();
|
||||||
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
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()) {
|
if (newLayout != activityUi.getLayout()) {
|
||||||
Activities.restartActivity(this);
|
Activities.restartActivity(this);
|
||||||
}
|
}
|
||||||
@ -280,11 +280,11 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) {
|
public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) {
|
||||||
if (CalculatorPreferences.Gui.usePrevAsBack.getKey().equals(key)) {
|
if (Preferences.Gui.usePrevAsBack.getKey().equals(key)) {
|
||||||
useBackAsPrev = CalculatorPreferences.Gui.usePrevAsBack.getPreference(preferences);
|
useBackAsPrev = Preferences.Gui.usePrevAsBack.getPreference(preferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CalculatorPreferences.Gui.autoOrientation.getKey().equals(key)) {
|
if (Preferences.Gui.autoOrientation.getKey().equals(key)) {
|
||||||
toggleOrientationChange(preferences);
|
toggleOrientationChange(preferences);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,7 +298,7 @@ public class CalculatorActivity extends SherlockFragmentActivity implements Shar
|
|||||||
|
|
||||||
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
|
private void toggleOrientationChange(@Nullable SharedPreferences preferences) {
|
||||||
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(this) : 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);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||||
} else {
|
} else {
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
@ -208,7 +208,7 @@ public final class CalculatorActivityLauncher implements CalculatorEventListener
|
|||||||
public static void showCalculationMessagesDialog(@Nonnull Context context, @Nonnull List<Message> messages) {
|
public static void showCalculationMessagesDialog(@Nonnull Context context, @Nonnull List<Message> messages) {
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
|
||||||
if (CalculatorPreferences.Calculations.showCalculationMessagesDialog.getPreference(prefs)) {
|
if (Preferences.Calculations.showCalculationMessagesDialog.getPreference(prefs)) {
|
||||||
FixableMessagesDialog.showDialogForMessages(messages, context, true);
|
FixableMessagesDialog.showDialogForMessages(messages, context, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class CalculatorActivityMobile extends CalculatorActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
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);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
}
|
}
|
||||||
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
CalculatorPreferences.setDefaultValues(preferences);
|
Preferences.setDefaultValues(preferences);
|
||||||
|
|
||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
@ -169,6 +169,11 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
|
|
||||||
super.onCreate();
|
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 AndroidCalculator calculator = new AndroidCalculator(this);
|
||||||
|
|
||||||
final EditorTextProcessor editorTextProcessor = new EditorTextProcessor();
|
final EditorTextProcessor editorTextProcessor = new EditorTextProcessor();
|
||||||
@ -221,7 +226,7 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setTheme(@Nonnull SharedPreferences preferences) {
|
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());
|
setTheme(theme.getThemeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,8 +295,8 @@ public class CalculatorApplication extends android.app.Application implements Sh
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
|
||||||
if (CalculatorPreferences.OnscreenCalculator.showAppIcon.getKey().equals(key)) {
|
if (Preferences.OnscreenCalculator.showAppIcon.getKey().equals(key)) {
|
||||||
boolean showAppIcon = CalculatorPreferences.OnscreenCalculator.showAppIcon.getPreference(prefs);
|
boolean showAppIcon = Preferences.OnscreenCalculator.showAppIcon.getPreference(prefs);
|
||||||
Android.toggleComponent(this, CalculatorOnscreenStartActivity.class, showAppIcon);
|
Android.toggleComponent(this, CalculatorOnscreenStartActivity.class, showAppIcon);
|
||||||
Locator.getInstance().getNotifier().showMessage(R.string.cpp_this_change_may_require_reboot, MessageType.info);
|
Locator.getInstance().getNotifier().showMessage(R.string.cpp_this_change_may_require_reboot, MessageType.info);
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ public final class CalculatorButtons {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void processButtons(@Nonnull CalculatorPreferences.Gui.Theme theme,
|
public static void processButtons(@Nonnull Preferences.Gui.Theme theme,
|
||||||
@Nonnull CalculatorPreferences.Gui.Layout layout,
|
@Nonnull Preferences.Gui.Layout layout,
|
||||||
@Nonnull View root) {
|
@Nonnull View root) {
|
||||||
if (!layout.isOptimized()) {
|
if (!layout.isOptimized()) {
|
||||||
|
|
||||||
@ -93,15 +93,15 @@ public final class CalculatorButtons {
|
|||||||
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
|
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
|
||||||
|
|
||||||
final boolean large = Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) &&
|
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 (!large) {
|
||||||
if (Views.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT
|
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);
|
final DragButton equalsButton = (DragButton) activity.findViewById(R.id.cpp_button_equals);
|
||||||
if (equalsButton != null) {
|
if (equalsButton != null) {
|
||||||
if (CalculatorPreferences.Gui.showEqualsButton.getPreference(preferences)) {
|
if (Preferences.Gui.showEqualsButton.getPreference(preferences)) {
|
||||||
equalsButton.setVisibility(View.VISIBLE);
|
equalsButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
equalsButton.setVisibility(View.GONE);
|
equalsButton.setVisibility(View.GONE);
|
||||||
|
@ -48,7 +48,7 @@ public class CalculatorDisplayFragment extends SherlockFragment {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
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()) {
|
if (!layout.isOptimized()) {
|
||||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_display_mobile, R.string.result);
|
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_display_mobile, R.string.result);
|
||||||
} else {
|
} else {
|
||||||
|
@ -76,7 +76,7 @@ public class CalculatorEditorFragment extends SherlockFragment {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
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()) {
|
if (!layout.isOptimized()) {
|
||||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_editor_mobile, R.string.editor);
|
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_editor_mobile, R.string.editor);
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,19 +28,14 @@ import android.preference.PreferenceManager;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockFragment;
|
import com.actionbarsherlock.app.SherlockFragment;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
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.NumeralBaseButtons.toggleNumericDigits;
|
||||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences;
|
import static org.solovyev.android.calculator.Preferences.Gui.hideNumeralBaseDigits;
|
||||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.angleUnit;
|
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.multiplicationSign;
|
||||||
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.numeralBase;
|
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 {
|
public class CalculatorKeyboardFragment extends SherlockFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private CalculatorPreferences.Gui.Theme theme;
|
private Preferences.Gui.Theme theme;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private FragmentUi fragmentHelper;
|
private FragmentUi fragmentHelper;
|
||||||
@ -63,7 +58,7 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
|
|||||||
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());
|
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()) {
|
if (!layout.isOptimized()) {
|
||||||
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_keyboard_mobile);
|
fragmentHelper = CalculatorApplication.getInstance().createFragmentHelper(R.layout.cpp_app_keyboard_mobile);
|
||||||
} else {
|
} else {
|
||||||
@ -74,7 +69,7 @@ public class CalculatorKeyboardFragment extends SherlockFragment implements Shar
|
|||||||
|
|
||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
theme = CalculatorPreferences.Gui.theme.getPreferenceNoError(preferences);
|
theme = Preferences.Gui.theme.getPreferenceNoError(preferences);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class FixableMessagesDialog extends SherlockActivity {
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (doNotShowCalculationMessagesCheckbox.isChecked()) {
|
if (doNotShowCalculationMessagesCheckbox.isChecked()) {
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(FixableMessagesDialog.this);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(FixableMessagesDialog.this);
|
||||||
CalculatorPreferences.Calculations.showCalculationMessagesDialog.putPreference(prefs, false);
|
Preferences.Calculations.showCalculationMessagesDialog.putPreference(prefs, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
FixableMessagesDialog.this.finish();
|
FixableMessagesDialog.this.finish();
|
||||||
|
@ -31,7 +31,7 @@ import javax.annotation.Nonnull;
|
|||||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||||
|
|
||||||
import static jscl.NumeralBase.hex;
|
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;
|
import static org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences.numeralBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,15 +25,12 @@ package org.solovyev.android.calculator;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import jscl.AngleUnit;
|
import jscl.AngleUnit;
|
||||||
import jscl.NumeralBase;
|
import jscl.NumeralBase;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.R;
|
|
||||||
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.prefs.*;
|
import org.solovyev.android.prefs.*;
|
||||||
import org.solovyev.android.view.VibratorContainer;
|
import org.solovyev.android.view.VibratorContainer;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -46,9 +43,9 @@ import static org.solovyev.android.DeviceModel.samsung_galaxy_s_2;
|
|||||||
* Date: 4/20/12
|
* Date: 4/20/12
|
||||||
* Time: 12:42 PM
|
* Time: 12:42 PM
|
||||||
*/
|
*/
|
||||||
public final class CalculatorPreferences {
|
public final class Preferences {
|
||||||
|
|
||||||
private CalculatorPreferences() {
|
private Preferences() {
|
||||||
throw new AssertionError();
|
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 class Gui {
|
||||||
|
|
||||||
public static final Preference<Theme> theme = StringPreference.ofEnum("org.solovyev.android.calculator.CalculatorActivity_calc_theme", Theme.metro_blue_theme, Theme.class);
|
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.showAppIcon);
|
||||||
applyDefaultPreference(preferences, OnscreenCalculator.startOnBoot);
|
applyDefaultPreference(preferences, OnscreenCalculator.startOnBoot);
|
||||||
|
|
||||||
|
applyDefaultPreference(preferences, Ga.initialReportDone);
|
||||||
|
|
||||||
|
|
||||||
// renew value after each application start
|
// renew value after each application start
|
||||||
Calculations.showCalculationMessagesDialog.putDefault(preferences);
|
Calculations.showCalculationMessagesDialog.putDefault(preferences);
|
@ -1,19 +1,27 @@
|
|||||||
package org.solovyev.android.calculator.ga;
|
package org.solovyev.android.calculator.ga;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import com.google.android.gms.analytics.GoogleAnalytics;
|
import com.google.android.gms.analytics.GoogleAnalytics;
|
||||||
|
import com.google.android.gms.analytics.HitBuilders;
|
||||||
import com.google.android.gms.analytics.Tracker;
|
import com.google.android.gms.analytics.Tracker;
|
||||||
|
import org.solovyev.android.calculator.Preferences;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.common.listeners.JEvent;
|
import org.solovyev.common.listeners.JEvent;
|
||||||
import org.solovyev.common.listeners.JEventListener;
|
import org.solovyev.common.listeners.JEventListener;
|
||||||
import org.solovyev.common.listeners.JEventListeners;
|
import org.solovyev.common.listeners.JEventListeners;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.PrintStream;
|
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
|
@Nonnull
|
||||||
private final GoogleAnalytics analytics;
|
private final GoogleAnalytics analytics;
|
||||||
@ -21,9 +29,10 @@ public final class Ga {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private final Tracker tracker;
|
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);
|
analytics = GoogleAnalytics.getInstance(context);
|
||||||
tracker = analytics.newTracker(R.xml.ga);
|
tracker = analytics.newTracker(R.xml.ga);
|
||||||
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -38,6 +47,14 @@ public final class Ga {
|
|||||||
return "";
|
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
|
@Nonnull
|
||||||
public GoogleAnalytics getAnalytics() {
|
public GoogleAnalytics getAnalytics() {
|
||||||
return analytics;
|
return analytics;
|
||||||
@ -47,4 +64,30 @@ public final class Ga {
|
|||||||
public Tracker getTracker() {
|
public Tracker getTracker() {
|
||||||
return tracker;
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
|
|||||||
super.onViewCreated(root, savedInstanceState);
|
super.onViewCreated(root, savedInstanceState);
|
||||||
|
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
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);
|
fragmentHelper.onViewCreated(this, root);
|
||||||
|
|
||||||
@ -377,8 +377,8 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
|
public void onClick(@Nonnull MenuItem data, @Nonnull Context context) {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(CalculatorApplication.getInstance());
|
||||||
final Boolean showDatetime = CalculatorPreferences.History.showDatetime.getPreference(preferences);
|
final Boolean showDatetime = Preferences.History.showDatetime.getPreference(preferences);
|
||||||
CalculatorPreferences.History.showDatetime.putPreference(preferences, !showDatetime);
|
Preferences.History.showDatetime.putPreference(preferences, !showDatetime);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -432,8 +432,8 @@ public abstract class AbstractCalculatorHistoryFragment extends SherlockListFrag
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||||
if (CalculatorPreferences.History.showDatetime.isSameKey(key)) {
|
if (Preferences.History.showDatetime.isSameKey(key)) {
|
||||||
getAdapter().setShowDatetime(CalculatorPreferences.History.showDatetime.getPreference(preferences));
|
getAdapter().setShowDatetime(Preferences.History.showDatetime.getPreference(preferences));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
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.Locator;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public class CalculatorHistoryFragment extends AbstractCalculatorHistoryFragment
|
|||||||
@Override
|
@Override
|
||||||
protected List<CalculatorHistoryState> getHistoryItems() {
|
protected List<CalculatorHistoryState> getHistoryItems() {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
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);
|
final List<CalculatorHistoryState> historyStates = Locator.getInstance().getHistory().getStates(showIntermediateCalculations);
|
||||||
return new ArrayList<CalculatorHistoryState>(historyStates);
|
return new ArrayList<CalculatorHistoryState>(historyStates);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import android.preference.PreferenceManager;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
import org.solovyev.android.calculator.Preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -47,7 +47,7 @@ public final class CalculatorOnscreenBroadcastReceiver extends BroadcastReceiver
|
|||||||
@Nonnull Intent intent) {
|
@Nonnull Intent intent) {
|
||||||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
if (CalculatorPreferences.OnscreenCalculator.startOnBoot.getPreferenceNoError(preferences)) {
|
if (Preferences.OnscreenCalculator.startOnBoot.getPreferenceNoError(preferences)) {
|
||||||
CalculatorOnscreenService.showNotification(context);
|
CalculatorOnscreenService.showNotification(context);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,7 +30,7 @@ import jscl.math.Generic;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
import org.solovyev.android.calculator.Preferences;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
|||||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
|
||||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||||
|
|
||||||
onSharedPreferenceChanged(preferences, CalculatorPreferences.Graph.plotImag.getKey());
|
onSharedPreferenceChanged(preferences, Preferences.Graph.plotImag.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -194,8 +194,8 @@ public class AndroidCalculatorPlotter implements CalculatorPlotter, SharedPrefer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
public void onSharedPreferenceChanged(SharedPreferences preferences, String key) {
|
||||||
if (CalculatorPreferences.Graph.plotImag.getKey().equals(key)) {
|
if (Preferences.Graph.plotImag.getKey().equals(key)) {
|
||||||
setPlotImag(CalculatorPreferences.Graph.plotImag.getPreference(preferences));
|
setPlotImag(Preferences.Graph.plotImag.getPreference(preferences));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import org.solovyev.android.calculator.text.TextProcessorEditorResult;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
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;
|
import static org.solovyev.android.calculator.view.TextHighlighter.WHITE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,13 +24,13 @@ package org.solovyev.android.calculator.wizard;
|
|||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
import org.solovyev.android.calculator.Preferences;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator;
|
import static org.solovyev.android.calculator.Preferences.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_mobile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -42,14 +42,14 @@ enum CalculatorLayout {
|
|||||||
big_buttons(R.string.cpp_wizard_layout_big_buttons) {
|
big_buttons(R.string.cpp_wizard_layout_big_buttons) {
|
||||||
@Override
|
@Override
|
||||||
protected void apply(@Nonnull SharedPreferences preferences) {
|
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) {
|
optimized(R.string.cpp_wizard_layout_optimized) {
|
||||||
@Override
|
@Override
|
||||||
protected void apply(@Nonnull SharedPreferences preferences) {
|
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
|
@Nonnull
|
||||||
static CalculatorLayout fromGuiLayout(@Nonnull CalculatorPreferences.Gui.Layout layout) {
|
static CalculatorLayout fromGuiLayout(@Nonnull Preferences.Gui.Layout layout) {
|
||||||
if (layout.isOptimized()) {
|
if (layout.isOptimized()) {
|
||||||
return optimized;
|
return optimized;
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,14 +25,14 @@ package org.solovyev.android.calculator.wizard;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import jscl.AngleUnit;
|
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.R;
|
||||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator;
|
import static org.solovyev.android.calculator.Preferences.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_mobile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -44,13 +44,13 @@ enum CalculatorMode {
|
|||||||
simple(R.string.cpp_wizard_mode_simple) {
|
simple(R.string.cpp_wizard_mode_simple) {
|
||||||
@Override
|
@Override
|
||||||
protected void apply(@Nonnull SharedPreferences preferences) {
|
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()) {
|
if (layout.isOptimized()) {
|
||||||
CalculatorPreferences.Gui.layout.putPreference(preferences, CalculatorPreferences.Gui.Layout.simple);
|
Preferences.Gui.layout.putPreference(preferences, Preferences.Gui.Layout.simple);
|
||||||
} else {
|
} 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.angleUnit.putPreference(preferences, AngleUnit.deg);
|
||||||
AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, false);
|
AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, false);
|
||||||
AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, true);
|
AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, true);
|
||||||
@ -60,13 +60,13 @@ enum CalculatorMode {
|
|||||||
engineer(R.string.cpp_wizard_mode_engineer) {
|
engineer(R.string.cpp_wizard_mode_engineer) {
|
||||||
@Override
|
@Override
|
||||||
protected void apply(@Nonnull SharedPreferences preferences) {
|
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()) {
|
if (layout.isOptimized()) {
|
||||||
CalculatorPreferences.Gui.layout.putPreference(preferences, main_calculator);
|
Preferences.Gui.layout.putPreference(preferences, main_calculator);
|
||||||
} else {
|
} 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.angleUnit.putPreference(preferences, AngleUnit.rad);
|
||||||
AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, true);
|
AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, true);
|
||||||
AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, false);
|
AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, false);
|
||||||
@ -91,7 +91,7 @@ enum CalculatorMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
static CalculatorMode fromGuiLayout(@Nonnull CalculatorPreferences.Gui.Layout layout) {
|
static CalculatorMode fromGuiLayout(@Nonnull Preferences.Gui.Layout layout) {
|
||||||
switch (layout) {
|
switch (layout) {
|
||||||
case main_calculator:
|
case main_calculator:
|
||||||
case main_cellphone:
|
case main_cellphone:
|
||||||
|
@ -27,7 +27,7 @@ import android.os.Bundle;
|
|||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import org.solovyev.android.calculator.App;
|
import org.solovyev.android.calculator.App;
|
||||||
import org.solovyev.android.Views;
|
import org.solovyev.android.Views;
|
||||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
import org.solovyev.android.calculator.Preferences;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -62,7 +62,7 @@ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
|
|||||||
@Override
|
@Override
|
||||||
public Bundle getFragmentArgs() {
|
public Bundle getFragmentArgs() {
|
||||||
final Bundle bundle = new Bundle();
|
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;
|
return bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
|
|||||||
@Override
|
@Override
|
||||||
public Bundle getFragmentArgs() {
|
public Bundle getFragmentArgs() {
|
||||||
final Bundle bundle = new Bundle();
|
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;
|
return bundle;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -97,7 +97,7 @@ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
|
|||||||
public boolean onNext(@Nonnull Fragment f) {
|
public boolean onNext(@Nonnull Fragment f) {
|
||||||
final OnScreenCalculatorWizardStep fragment = (OnScreenCalculatorWizardStep) f;
|
final OnScreenCalculatorWizardStep fragment = (OnScreenCalculatorWizardStep) f;
|
||||||
|
|
||||||
CalculatorPreferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), fragment.isOnscreenCalculatorEnabled());
|
Preferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), fragment.isOnscreenCalculatorEnabled());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
|
|||||||
@Override
|
@Override
|
||||||
public Bundle getFragmentArgs() {
|
public Bundle getFragmentArgs() {
|
||||||
final Bundle bundle = new Bundle();
|
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;
|
return bundle;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -29,7 +29,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
import org.solovyev.android.calculator.CalculatorPreferences;
|
import org.solovyev.android.calculator.Preferences;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -68,7 +68,7 @@ public class OnScreenCalculatorWizardStep extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (onscreenCalculatorEnabled == null) {
|
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() {
|
public Boolean isOnscreenCalculatorEnabled() {
|
||||||
boolean enabled = CalculatorPreferences.OnscreenCalculator.showAppIcon.getDefaultValue();
|
boolean enabled = Preferences.OnscreenCalculator.showAppIcon.getDefaultValue();
|
||||||
|
|
||||||
if (onscreenCalculatorCheckbox != null) {
|
if (onscreenCalculatorCheckbox != null) {
|
||||||
enabled = onscreenCalculatorCheckbox.isChecked();
|
enabled = onscreenCalculatorCheckbox.isChecked();
|
||||||
|
Loading…
Reference in New Issue
Block a user