Mode menu setting
This commit is contained in:
parent
4b413022a1
commit
d6ea6c742f
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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> theme = StringPreference.ofEnum("gui.theme", Theme.material_theme, Theme.class);
|
||||
public static final Preference<Layout> layout = StringPreference.ofEnum("gui.layout", Layout.simple, Layout.class);
|
||||
public static final Preference<Mode> mode = StringPreference.ofEnum("gui.mode", Mode.simple, Mode.class);
|
||||
public static final Preference<String> language = StringPreference.of("gui.language", Languages.SYSTEM_LANGUAGE_CODE);
|
||||
public static final Preference<Boolean> showReleaseNotes = BooleanPreference.of("gui.showReleaseNotes", true);
|
||||
public static final Preference<Boolean> 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<Boolean> colorDisplay = BooleanPreference.of("org.solovyev.android.calculator.CalculatorModel_color_display", true);
|
||||
static final Preference<Boolean> preventScreenFromFading = BooleanPreference.of("preventScreenFromFading", true);
|
||||
static final Preference<Gui.Theme> theme = StringPreference.ofEnum("org.solovyev.android.calculator.CalculatorActivity_calc_theme", Gui.Theme.material_theme, Gui.Theme.class);
|
||||
static final Preference<Gui.Layout> layout = StringPreference.ofEnum("org.solovyev.android.calculator.CalculatorActivity_calc_layout", Gui.Layout.simple, Gui.Layout.class);
|
||||
static final StringPreference<String> layout = StringPreference.of("org.solovyev.android.calculator.CalculatorActivity_calc_layout", "simple");
|
||||
static final Preference<Boolean> showReleaseNotes = BooleanPreference.of("org.solovyev.android.calculator.CalculatorActivity_show_release_notes", true);
|
||||
static final Preference<Boolean> usePrevAsBack = BooleanPreference.of("org.solovyev.android.calculator.CalculatorActivity_use_back_button_as_prev", false);
|
||||
static final Preference<Boolean> showEqualsButton = BooleanPreference.of("showEqualsButton", true);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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<HistoryState> {
|
||||
|
||||
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<HistoryState> 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;
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ 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
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
|
||||
a:layout_width="match_parent"
|
||||
a:layout_height="match_parent"
|
||||
a:gravity="center"
|
||||
a:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/WizardLabel"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content"
|
||||
a:text="@string/cpp_wizard_layout_title"
|
||||
a:textAppearance="@android:style/TextAppearance.Large" />
|
||||
|
||||
<Spinner
|
||||
a:id="@+id/wizard_layout_spinner"
|
||||
style="@style/WizardLabel"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content" />
|
||||
|
||||
<ImageView
|
||||
a:id="@+id/wizard_layout_image"
|
||||
style="@style/WizardLabel.Last"
|
||||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
@ -2,6 +2,20 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_mode"
|
||||
android:title="@string/cpp_mode"
|
||||
app:showAsAction="never">
|
||||
<menu>
|
||||
<item
|
||||
android:id="@+id/menu_mode_engineer"
|
||||
android:title="@string/cpp_wizard_mode_engineer" />
|
||||
<item
|
||||
android:id="@+id/menu_mode_simple"
|
||||
android:title="@string/cpp_wizard_mode_simple" />
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_settings"
|
||||
android:title="@string/cpp_settings"
|
||||
|
@ -66,12 +66,12 @@
|
||||
<item>"∙"</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="p_layout_names" tools:ignore="InconsistentArrays">
|
||||
<item>@string/p_layout_calculator</item>
|
||||
<item>@string/p_layout_simple</item>
|
||||
<string-array name="p_layout_names">
|
||||
<item>@string/cpp_wizard_mode_engineer</item>
|
||||
<item>@string/cpp_wizard_mode_simple</item>
|
||||
</string-array>
|
||||
<string-array name="p_layout_values" translatable="false" tools:ignore="InconsistentArrays">
|
||||
<item>main_calculator</item>
|
||||
<string-array name="p_layout_values" translatable="false">
|
||||
<item>engineer</item>
|
||||
<item>simple</item>
|
||||
</string-array>
|
||||
|
||||
|
@ -241,4 +241,6 @@
|
||||
<string name="cpp_missing_permission_msg">Please enable \"%1$s\" permission in system settings</string>
|
||||
<string name="fn_line_width">Line width</string>
|
||||
<string name="fn_line_color">Line color</string>
|
||||
<string name="cpp_mode">Mode</string>
|
||||
<string name="cpp_mode_status">Mode: %1$s</string>
|
||||
</resources>
|
||||
|
@ -43,9 +43,8 @@
|
||||
<ListPreference
|
||||
a:entries="@array/p_layout_names"
|
||||
a:entryValues="@array/p_layout_values"
|
||||
a:key="gui.layout"
|
||||
a:summary="@string/c_calc_layout_summary"
|
||||
a:title="@string/c_calc_layout" />
|
||||
a:key="gui.mode"
|
||||
a:title="@string/cpp_mode" />
|
||||
|
||||
<android.preference.CheckBoxPreference
|
||||
a:defaultValue="true"
|
||||
|
Loading…
Reference in New Issue
Block a user