From d6ea6c742f4526cf641109baded1a1f2050ab89f Mon Sep 17 00:00:00 2001 From: serso Date: Wed, 23 Mar 2016 00:15:03 +0100 Subject: [PATCH] Mode menu setting --- .../android/calculator/BaseActivity.java | 20 +++-- .../calculator/CalculatorActivity.java | 28 +++++-- .../android/calculator/Preferences.java | 70 +++++++----------- .../solovyev/android/calculator/ga/Ga.java | 10 +-- .../history/HistoryArrayAdapter.java | 73 ------------------- .../calculator/keyboard/BaseKeyboardUi.java | 11 ++- .../calculator/keyboard/KeyboardUi.java | 2 +- .../keyboard/PartialKeyboardUi.java | 2 +- .../preferences/PreferencesFragment.java | 6 +- .../calculator/wizard/CalculatorMode.java | 15 ++-- .../wizard/ChooseModeWizardStep.java | 2 +- .../layout/cpp_wizard_step_choose_layout.xml | 50 ------------- app/src/main/res/menu/main.xml | 14 ++++ app/src/main/res/values/arrays.xml | 10 +-- app/src/main/res/values/text_strings.xml | 2 + .../main/res/xml/preferences_appearance.xml | 5 +- 16 files changed, 105 insertions(+), 215 deletions(-) delete mode 100644 app/src/main/java/org/solovyev/android/calculator/history/HistoryArrayAdapter.java delete mode 100644 app/src/main/res/layout/cpp_wizard_step_choose_layout.xml diff --git a/app/src/main/java/org/solovyev/android/calculator/BaseActivity.java b/app/src/main/java/org/solovyev/android/calculator/BaseActivity.java index 6c59e238..f0251f9d 100644 --- a/app/src/main/java/org/solovyev/android/calculator/BaseActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/BaseActivity.java @@ -66,7 +66,7 @@ public class BaseActivity extends AppCompatActivity { @Nonnull private Preferences.Gui.Theme theme = Preferences.Gui.Theme.material_theme; @Nonnull - private Preferences.Gui.Layout layout = Preferences.Gui.Layout.main_calculator; + private Preferences.Gui.Mode mode = Preferences.Gui.Mode.engineer; @Nonnull private Language language = Languages.SYSTEM_LANGUAGE; @@ -96,6 +96,16 @@ public class BaseActivity extends AppCompatActivity { } } + @Nonnull + public Preferences.Gui.Theme getActivityTheme() { + return theme; + } + + @Nonnull + public Preferences.Gui.Mode getActivityMode() { + return mode; + } + public static void setFont(@Nonnull TextView view, @Nonnull Typeface newTypeface) { final Typeface oldTypeface = view.getTypeface(); if (oldTypeface == newTypeface) { @@ -105,9 +115,9 @@ public class BaseActivity extends AppCompatActivity { view.setTypeface(newTypeface, style); } - public boolean restartIfLayoutChanged() { - final Preferences.Gui.Layout newLayout = Preferences.Gui.layout.getPreference(preferences); - if (newLayout != layout) { + public boolean restartIfModeChanged() { + final Preferences.Gui.Mode newMode = Preferences.Gui.mode.getPreference(preferences); + if (newMode != mode) { App.restartActivity(this); return true; } @@ -188,7 +198,7 @@ public class BaseActivity extends AppCompatActivity { theme = Preferences.Gui.getTheme(preferences); setTheme(theme.getThemeFor(this)); - layout = Preferences.Gui.getLayout(preferences); + mode = Preferences.Gui.getMode(preferences); language = languages.getCurrent(); } diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java index 6ef0afd5..8560c886 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java +++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorActivity.java @@ -27,10 +27,7 @@ import android.os.Bundle; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v7.widget.Toolbar; -import android.view.KeyEvent; -import android.view.MenuItem; -import android.view.View; -import android.view.Window; +import android.view.*; import android.widget.FrameLayout; import butterknife.Bind; import butterknife.ButterKnife; @@ -97,6 +94,7 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference toolbar.inflateMenu(R.menu.main); toolbar.setOnMenuItemClickListener(this); + updateModeMenuItem(); useBackAsPrevious = Preferences.Gui.useBackAsPrevious.getPreference(preferences); if (savedInstanceState == null) { @@ -109,6 +107,12 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference preferredPreferences.check(this, false); } + private void updateModeMenuItem() { + final Menu menu = toolbar.getMenu(); + final MenuItem modeMenuItem = menu.findItem(R.id.menu_mode); + modeMenuItem.setTitle(getString(R.string.cpp_mode_status, getString(getActivityMode().menuName))); + } + @Override protected void inject(@Nonnull AppComponent component) { super.inject(component); @@ -128,7 +132,7 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference protected void onResume() { super.onResume(); launcher.setActivity(this); - if (restartIfLayoutChanged()) { + if (restartIfModeChanged()) { return; } @@ -156,12 +160,12 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference } @Override - public void onSharedPreferenceChanged(SharedPreferences preferences, @Nullable String key) { - if (Preferences.Gui.useBackAsPrevious.getKey().equals(key)) { + public void onSharedPreferenceChanged(SharedPreferences preferences, @Nonnull String key) { + if (Preferences.Gui.useBackAsPrevious.isSameKey(key)) { useBackAsPrevious = Preferences.Gui.useBackAsPrevious.getPreference(preferences); } - if (Preferences.Gui.rotateScreen.getKey().equals(key)) { + if (Preferences.Gui.rotateScreen.isSameKey(key)) { updateOrientation(); } } @@ -192,6 +196,14 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference case R.id.menu_about: launcher.showAbout(); return true; + case R.id.menu_mode_engineer: + Preferences.Gui.mode.putPreference(preferences, Preferences.Gui.Mode.engineer); + restartIfModeChanged(); + return true; + case R.id.menu_mode_simple: + Preferences.Gui.mode.putPreference(preferences, Preferences.Gui.Mode.simple); + restartIfModeChanged(); + return true; } return false; } diff --git a/app/src/main/java/org/solovyev/android/calculator/Preferences.java b/app/src/main/java/org/solovyev/android/calculator/Preferences.java index ce7acb4f..e78fffb7 100644 --- a/app/src/main/java/org/solovyev/android/calculator/Preferences.java +++ b/app/src/main/java/org/solovyev/android/calculator/Preferences.java @@ -29,14 +29,12 @@ import android.content.SharedPreferences; import android.content.res.TypedArray; import android.graphics.Color; import android.provider.Settings; -import android.support.annotation.ColorRes; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.annotation.StringRes; -import android.support.annotation.StyleRes; +import android.support.annotation.*; import android.support.v7.view.ContextThemeWrapper; +import android.text.TextUtils; import android.util.SparseArray; - +import jscl.AngleUnit; +import jscl.NumeralBase; import org.solovyev.android.Check; import org.solovyev.android.calculator.about.AboutActivity; import org.solovyev.android.calculator.functions.FunctionsActivity; @@ -47,23 +45,15 @@ import org.solovyev.android.calculator.operators.OperatorsActivity; import org.solovyev.android.calculator.preferences.PreferencesActivity; import org.solovyev.android.calculator.variables.VariablesActivity; import org.solovyev.android.calculator.wizard.WizardActivity; -import org.solovyev.android.prefs.BooleanPreference; -import org.solovyev.android.prefs.IntegerPreference; -import org.solovyev.android.prefs.NumberToStringPreference; -import org.solovyev.android.prefs.Preference; -import org.solovyev.android.prefs.StringPreference; +import org.solovyev.android.prefs.*; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.text.DecimalFormatSymbols; import java.util.EnumMap; import java.util.Locale; import java.util.Map; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import jscl.AngleUnit; -import jscl.NumeralBase; - import static org.solovyev.android.prefs.IntegerPreference.DEF_VALUE; public final class Preferences { @@ -87,17 +77,16 @@ public final class Preferences { } migratePreference(preferences, editor, Gui.keepScreenOn, Deleted.preventScreenFromFading); migratePreference(preferences, editor, Gui.theme, Deleted.theme); - migratePreference(preferences, editor, Gui.layout, Deleted.layout); migratePreference(preferences, editor, Gui.useBackAsPrevious, Deleted.usePrevAsBack); migratePreference(preferences, editor, Gui.showReleaseNotes, Deleted.showReleaseNotes); migratePreference(preferences, editor, Gui.rotateScreen, Deleted.autoOrientation); - final Gui.Layout layout = Deleted.layout.getPreference(preferences); - if (layout == Gui.Layout.main_cellphone) { - Gui.layout.putDefault(editor); - } else if (layout == Gui.Layout.main_calculator_mobile) { - Gui.layout.putPreference(editor, Gui.Layout.main_calculator); - } else if (layout == Gui.Layout.simple_mobile) { - Gui.layout.putPreference(editor, Gui.Layout.simple); + final String layout = Deleted.layout.getPreference(preferences); + if (TextUtils.equals(layout, "main_calculator")) { + Gui.mode.putPreference(editor, Gui.Mode.engineer); + } else if (TextUtils.equals(layout, "simple")) { + Gui.mode.putPreference(editor, Gui.Mode.simple); + } else if (!Gui.mode.isSet(preferences)) { + Gui.mode.putDefault(editor); } version.putDefault(editor); editor.apply(); @@ -140,7 +129,7 @@ public final class Preferences { Engine.Preferences.numeralBase.tryPutDefault(preferences, editor); Gui.theme.tryPutDefault(preferences, editor); - Gui.layout.tryPutDefault(preferences, editor); + Gui.mode.tryPutDefault(preferences, editor); Gui.showReleaseNotes.tryPutDefault(preferences, editor); Gui.useBackAsPrevious.tryPutDefault(preferences, editor); Gui.rotateScreen.tryPutDefault(preferences, editor); @@ -285,7 +274,7 @@ public final class Preferences { public static class Gui { public static final Preference theme = StringPreference.ofEnum("gui.theme", Theme.material_theme, Theme.class); - public static final Preference layout = StringPreference.ofEnum("gui.layout", Layout.simple, Layout.class); + public static final Preference mode = StringPreference.ofEnum("gui.mode", Mode.simple, Mode.class); public static final Preference language = StringPreference.of("gui.language", Languages.SYSTEM_LANGUAGE_CODE); public static final Preference showReleaseNotes = BooleanPreference.of("gui.showReleaseNotes", true); public static final Preference useBackAsPrevious = BooleanPreference.of("gui.useBackAsPrevious", false); @@ -299,8 +288,8 @@ public final class Preferences { } @Nonnull - public static Layout getLayout(@Nonnull SharedPreferences preferences) { - return layout.getPreferenceNoError(preferences); + public static Mode getMode(@Nonnull SharedPreferences preferences) { + return mode.getPreferenceNoError(preferences); } public enum Theme { @@ -393,25 +382,18 @@ public final class Preferences { } } - public enum Layout { - main_calculator(R.string.p_layout_calculator), - simple(R.string.p_layout_simple), - - // not used anymore - @Deprecated - main_cellphone(R.string.p_layout_simple), - // not used anymore - @Deprecated - main_calculator_mobile(R.string.p_layout_simple), - // not used anymore - @Deprecated - simple_mobile(R.string.p_layout_simple); + public enum Mode { + engineer(R.string.p_layout_calculator, R.string.cpp_wizard_mode_engineer), + simple(R.string.p_layout_simple, R.string.cpp_wizard_mode_simple); @StringRes public final int name; + @StringRes + public final int menuName; - Layout(@StringRes int name) { + Mode(@StringRes int name, @StringRes int menuName) { this.name = name; + this.menuName = menuName; } } @@ -438,7 +420,7 @@ public final class Preferences { static final Preference colorDisplay = BooleanPreference.of("org.solovyev.android.calculator.CalculatorModel_color_display", true); static final Preference preventScreenFromFading = BooleanPreference.of("preventScreenFromFading", true); static final Preference theme = StringPreference.ofEnum("org.solovyev.android.calculator.CalculatorActivity_calc_theme", Gui.Theme.material_theme, Gui.Theme.class); - static final Preference layout = StringPreference.ofEnum("org.solovyev.android.calculator.CalculatorActivity_calc_layout", Gui.Layout.simple, Gui.Layout.class); + static final StringPreference layout = StringPreference.of("org.solovyev.android.calculator.CalculatorActivity_calc_layout", "simple"); static final Preference showReleaseNotes = BooleanPreference.of("org.solovyev.android.calculator.CalculatorActivity_show_release_notes", true); static final Preference usePrevAsBack = BooleanPreference.of("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false); static final Preference showEqualsButton = BooleanPreference.of("showEqualsButton", true); diff --git a/app/src/main/java/org/solovyev/android/calculator/ga/Ga.java b/app/src/main/java/org/solovyev/android/calculator/ga/Ga.java index 3d5671b1..6ed83605 100644 --- a/app/src/main/java/org/solovyev/android/calculator/ga/Ga.java +++ b/app/src/main/java/org/solovyev/android/calculator/ga/Ga.java @@ -33,8 +33,8 @@ public final class Ga implements SharedPreferences.OnSharedPreferenceChangeListe preferences.registerOnSharedPreferenceChangeListener(this); } - private void reportLayout(@Nonnull Preferences.Gui.Layout layout) { - tracker.send(new HitBuilders.EventBuilder().setCustomDimension(LAYOUT, layout.name()).build()); + private void reportLayout(@Nonnull Preferences.Gui.Mode mode) { + tracker.send(new HitBuilders.EventBuilder().setCustomDimension(LAYOUT, mode.name()).build()); } private void reportTheme(@Nonnull Preferences.Gui.Theme theme) { @@ -60,15 +60,15 @@ public final class Ga implements SharedPreferences.OnSharedPreferenceChangeListe @Override public void onSharedPreferenceChanged(SharedPreferences preferences, String key) { - if (TextUtils.equals(key, Preferences.Gui.layout.getKey())) { - reportLayout(Preferences.Gui.layout.getPreferenceNoError(preferences)); + if (TextUtils.equals(key, Preferences.Gui.mode.getKey())) { + reportLayout(Preferences.Gui.mode.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)); + reportLayout(Preferences.Gui.mode.getPreferenceNoError(preferences)); reportTheme(Preferences.Gui.theme.getPreferenceNoError(preferences)); } diff --git a/app/src/main/java/org/solovyev/android/calculator/history/HistoryArrayAdapter.java b/app/src/main/java/org/solovyev/android/calculator/history/HistoryArrayAdapter.java deleted file mode 100644 index fee526ae..00000000 --- a/app/src/main/java/org/solovyev/android/calculator/history/HistoryArrayAdapter.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator.history; - -import android.content.Context; -import android.text.format.DateUtils; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.TextView; -import org.solovyev.android.calculator.R; -import org.solovyev.common.text.Strings; - -import javax.annotation.Nonnull; -import java.util.List; - -import static android.view.View.GONE; -import static android.view.View.VISIBLE; - -public class HistoryArrayAdapter extends ArrayAdapter { - - private static final int DATETIME_FORMAT = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_TIME; - - HistoryArrayAdapter(Context context, int resource, int textViewResourceId, @Nonnull List historyList) { - super(context, resource, textViewResourceId, historyList); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - final ViewGroup result = (ViewGroup) super.getView(position, convertView, parent); - - final HistoryState state = getItem(position); - - final TextView time = (TextView) result.findViewById(R.id.history_item_time); - time.setText(DateUtils.formatDateTime(getContext(), state.getTime(), DATETIME_FORMAT)); - - final TextView editor = (TextView) result.findViewById(R.id.history_item_value); - editor.setText(BaseHistoryFragment.getHistoryText(state)); - - final TextView commentView = (TextView) result.findViewById(R.id.history_item_comment); - if (commentView != null) { - final String comment = state.getComment(); - if (!Strings.isEmpty(comment)) { - commentView.setText(comment); - commentView.setVisibility(VISIBLE); - } else { - commentView.setText(null); - commentView.setVisibility(GONE); - } - } - return result; - } -} diff --git a/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseKeyboardUi.java b/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseKeyboardUi.java index bfa29323..96e9a444 100644 --- a/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseKeyboardUi.java +++ b/app/src/main/java/org/solovyev/android/calculator/keyboard/BaseKeyboardUi.java @@ -27,8 +27,7 @@ import java.util.List; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.view.HapticFeedbackConstants.*; import static org.solovyev.android.calculator.App.cast; -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.Preferences.Gui.Mode.simple; public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPreferenceChangeListener, View.OnClickListener { @@ -61,7 +60,7 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer PreferredPreferences preferredPreferences; protected int orientation = ORIENTATION_PORTRAIT; private int textSize; - private Preferences.Gui.Layout layout; + private Preferences.Gui.Mode mode; private final float textScale; public BaseKeyboardUi(@NonNull Application application) { @@ -92,7 +91,7 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer preferences.registerOnSharedPreferenceChangeListener(this); orientation = App.getScreenOrientation(activity); - layout = Preferences.Gui.layout.getPreferenceNoError(preferences); + mode = Preferences.Gui.mode.getPreferenceNoError(preferences); textSize = calculateTextSize(activity); } @@ -183,8 +182,8 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer } } - protected boolean isSimpleLayout() { - return layout == simple || layout == simple_mobile; + protected boolean isSimpleMode() { + return mode == simple; } protected final void onClick(@Nonnull View v, @Nonnull String s) { diff --git a/app/src/main/java/org/solovyev/android/calculator/keyboard/KeyboardUi.java b/app/src/main/java/org/solovyev/android/calculator/keyboard/KeyboardUi.java index f919f982..a71e717a 100644 --- a/app/src/main/java/org/solovyev/android/calculator/keyboard/KeyboardUi.java +++ b/app/src/main/java/org/solovyev/android/calculator/keyboard/KeyboardUi.java @@ -151,7 +151,7 @@ public class KeyboardUi extends BaseKeyboardUi { prepareButton(likeButton); prepareButton(memoryButton); - if (isSimpleLayout()) { + if (isSimpleMode()) { hideText(button1, down); hideText(button2, down); hideText(button3, down); diff --git a/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java b/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java index 42887091..e9889b76 100644 --- a/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java +++ b/app/src/main/java/org/solovyev/android/calculator/keyboard/PartialKeyboardUi.java @@ -61,7 +61,7 @@ public class PartialKeyboardUi extends BaseKeyboardUi { prepareButton(eraseButton, IMAGE_SCALE_ERASE); longClickEraser = EditorLongClickEraser.attachTo(eraseButton, keyboard.isVibrateOnKeypress(), editor, calculator); } - if(isSimpleLayout()) { + if(isSimpleMode()) { hideText(equalsButton, down); } } diff --git a/app/src/main/java/org/solovyev/android/calculator/preferences/PreferencesFragment.java b/app/src/main/java/org/solovyev/android/calculator/preferences/PreferencesFragment.java index c7471576..c40ae3f3 100644 --- a/app/src/main/java/org/solovyev/android/calculator/preferences/PreferencesFragment.java +++ b/app/src/main/java/org/solovyev/android/calculator/preferences/PreferencesFragment.java @@ -138,12 +138,12 @@ public class PreferencesFragment extends org.solovyev.android.material.preferenc if (preference != R.xml.preferences_appearance) { return; } - final ListPreference layout = (ListPreference) preferenceManager.findPreference(Preferences.Gui.layout.getKey()); - layout.setSummary(Preferences.Gui.getLayout(preferences).name); + final ListPreference layout = (ListPreference) preferenceManager.findPreference(Preferences.Gui.mode.getKey()); + layout.setSummary(Preferences.Gui.getMode(preferences).name); layout.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - layout.setSummary(Preferences.Gui.Layout.valueOf((String) newValue).name); + layout.setSummary(Preferences.Gui.Mode.valueOf((String) newValue).name); return true; } }); diff --git a/app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorMode.java b/app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorMode.java index 96192c91..c01196d9 100644 --- a/app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorMode.java +++ b/app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorMode.java @@ -29,8 +29,6 @@ import org.solovyev.android.calculator.Preferences; import javax.annotation.Nonnull; -import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator; - enum CalculatorMode { simple() { @@ -38,7 +36,7 @@ enum CalculatorMode { protected void apply(@Nonnull SharedPreferences preferences) { final SharedPreferences.Editor editor = preferences.edit(); - Preferences.Gui.layout.putPreference(editor, Preferences.Gui.Layout.simple); + Preferences.Gui.mode.putPreference(editor, Preferences.Gui.Mode.simple); Preferences.Calculations.preferredAngleUnits.putPreference(editor, AngleUnit.deg); Engine.Preferences.angleUnit.putPreference(editor, AngleUnit.deg); Engine.Preferences.Output.scientificNotation.putPreference(editor, false); @@ -53,7 +51,7 @@ enum CalculatorMode { protected void apply(@Nonnull SharedPreferences preferences) { final SharedPreferences.Editor editor = preferences.edit(); - Preferences.Gui.layout.putPreference(editor, main_calculator); + Preferences.Gui.mode.putPreference(editor, Preferences.Gui.Mode.engineer); Preferences.Calculations.preferredAngleUnits.putPreference(editor, AngleUnit.rad); Engine.Preferences.angleUnit.putPreference(editor, AngleUnit.rad); Engine.Preferences.Output.scientificNotation.putPreference(editor, true); @@ -69,14 +67,11 @@ enum CalculatorMode { } @Nonnull - static CalculatorMode fromGuiLayout(@Nonnull Preferences.Gui.Layout layout) { - switch (layout) { - case main_calculator: - case main_cellphone: - case main_calculator_mobile: + static CalculatorMode fromGuiLayout(@Nonnull Preferences.Gui.Mode mode) { + switch (mode) { + case engineer: return engineer; case simple: - case simple_mobile: return simple; default: return getDefaultMode(); diff --git a/app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java b/app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java index f517ea9b..eaa60c57 100644 --- a/app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java +++ b/app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java @@ -66,7 +66,7 @@ public class ChooseModeWizardStep extends WizardFragment implements AdapterView. public void onViewCreated(View root, Bundle savedInstanceState) { super.onViewCreated(root, savedInstanceState); - final CalculatorMode mode = CalculatorMode.fromGuiLayout(Preferences.Gui.layout.getPreference(preferences)); + final CalculatorMode mode = CalculatorMode.fromGuiLayout(Preferences.Gui.mode.getPreference(preferences)); final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_mode_spinner); spinner.setAdapter(WizardArrayAdapter.create(getActivity(), R.array.cpp_modes)); spinner.setSelection(mode == simple ? 0 : 1); diff --git a/app/src/main/res/layout/cpp_wizard_step_choose_layout.xml b/app/src/main/res/layout/cpp_wizard_step_choose_layout.xml deleted file mode 100644 index 2cb6716c..00000000 --- a/app/src/main/res/layout/cpp_wizard_step_choose_layout.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/menu/main.xml b/app/src/main/res/menu/main.xml index 29c8dc64..26c3105f 100644 --- a/app/src/main/res/menu/main.xml +++ b/app/src/main/res/menu/main.xml @@ -2,6 +2,20 @@ + + + + + + + "∙" - - @string/p_layout_calculator - @string/p_layout_simple + + @string/cpp_wizard_mode_engineer + @string/cpp_wizard_mode_simple - - main_calculator + + engineer simple diff --git a/app/src/main/res/values/text_strings.xml b/app/src/main/res/values/text_strings.xml index 1e084ba3..aea8a1af 100644 --- a/app/src/main/res/values/text_strings.xml +++ b/app/src/main/res/values/text_strings.xml @@ -241,4 +241,6 @@ Please enable \"%1$s\" permission in system settings Line width Line color + Mode + Mode: %1$s diff --git a/app/src/main/res/xml/preferences_appearance.xml b/app/src/main/res/xml/preferences_appearance.xml index b5eff4f6..cf828cf4 100644 --- a/app/src/main/res/xml/preferences_appearance.xml +++ b/app/src/main/res/xml/preferences_appearance.xml @@ -43,9 +43,8 @@ + a:key="gui.mode" + a:title="@string/cpp_mode" />