Remove "mobile" layouts from settings
This commit is contained in:
parent
dc1c392a94
commit
d7318bbc17
@ -154,19 +154,10 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
final Preferences.Gui.Layout layout = Preferences.Gui.layout.getPreferenceNoError(preferences);
|
||||
ui.setLayoutId(layout.layoutId);
|
||||
ui.setLayoutId(R.layout.main_calculator);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (isMultiPane()) {
|
||||
ui.addTab(this, FragmentTab.history, null, R.id.main_second_pane);
|
||||
ui.addTab(this, FragmentTab.saved_history, null, R.id.main_second_pane);
|
||||
ui.addTab(this, FragmentTab.variables, null, R.id.main_second_pane);
|
||||
ui.addTab(this, FragmentTab.functions, null, R.id.main_second_pane);
|
||||
ui.addTab(this, FragmentTab.operators, null, R.id.main_second_pane);
|
||||
} else {
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (Build.VERSION.SDK_INT <= GINGERBREAD_MR1 || (Build.VERSION.SDK_INT >= ICE_CREAM_SANDWICH && hasPermanentMenuKey())) {
|
||||
actionBar.hide();
|
||||
@ -174,7 +165,6 @@ public class CalculatorActivity extends BaseActivity implements SharedPreference
|
||||
actionBar.setDisplayShowTitleEnabled(false);
|
||||
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
|
||||
}
|
||||
}
|
||||
ButterKnife.bind(this);
|
||||
|
||||
FragmentUtils.createFragment(this, EditorFragment.class, R.id.editor, "editor");
|
||||
|
@ -96,13 +96,8 @@ public class DisplayFragment extends BaseFragment implements View.OnClickListene
|
||||
@Nonnull
|
||||
@Override
|
||||
protected FragmentUi createUi() {
|
||||
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(preferences);
|
||||
if (!layout.optimized) {
|
||||
return new FragmentUi(R.layout.cpp_app_display_mobile, R.string.result);
|
||||
} else {
|
||||
return new FragmentUi(R.layout.cpp_app_display, R.string.result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void inject(@Nonnull AppComponent component) {
|
||||
|
@ -68,13 +68,6 @@ public class DisplayView extends AutoResizeTextView {
|
||||
setMinTextSize(applyDimension(COMPLEX_UNIT_SP, 10, resources.getDisplayMetrics()));
|
||||
// make text scrollable if it doesn't fit
|
||||
setMovementMethod(ScrollingMovementMethod.getInstance());
|
||||
if (context instanceof Service) {
|
||||
return;
|
||||
}
|
||||
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(App.getPreferences());
|
||||
if (!layout.optimized) {
|
||||
setTextSize(resources.getDimensionPixelSize(R.dimen.cpp_display_text_size_mobile));
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -65,13 +65,8 @@ public class EditorFragment extends BaseFragment {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected FragmentUi createUi() {
|
||||
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(preferences);
|
||||
if (!layout.optimized) {
|
||||
return new FragmentUi(R.layout.cpp_app_editor_mobile, R.string.editor);
|
||||
} else {
|
||||
return new FragmentUi(R.layout.cpp_app_editor, R.string.editor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -59,13 +59,8 @@ public class KeyboardFragment extends BaseFragment {
|
||||
@Nonnull
|
||||
@Override
|
||||
protected FragmentUi createUi() {
|
||||
final Preferences.Gui.Layout layout = Preferences.Gui.getLayout(preferences);
|
||||
if (!layout.optimized) {
|
||||
return new FragmentUi(R.layout.cpp_app_keyboard_mobile);
|
||||
} else {
|
||||
return new FragmentUi(R.layout.cpp_app_keyboard);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
|
@ -22,11 +22,6 @@
|
||||
|
||||
package org.solovyev.android.calculator;
|
||||
|
||||
import static org.solovyev.android.Android.isPhoneModel;
|
||||
import static org.solovyev.android.DeviceModel.samsung_galaxy_s;
|
||||
import static org.solovyev.android.DeviceModel.samsung_galaxy_s_2;
|
||||
import static org.solovyev.android.prefs.IntegerPreference.DEF_VALUE;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
@ -39,28 +34,26 @@ import android.support.annotation.LayoutRes;
|
||||
import android.support.annotation.StyleRes;
|
||||
import android.util.SparseArray;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
||||
import jscl.AngleUnit;
|
||||
import jscl.NumeralBase;
|
||||
import org.solovyev.android.Check;
|
||||
import org.solovyev.android.calculator.language.Languages;
|
||||
import org.solovyev.android.calculator.math.MathType;
|
||||
import org.solovyev.android.calculator.preferences.PurchaseDialogActivity;
|
||||
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 jscl.AngleUnit;
|
||||
import jscl.NumeralBase;
|
||||
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 static org.solovyev.android.Android.isPhoneModel;
|
||||
import static org.solovyev.android.DeviceModel.samsung_galaxy_s;
|
||||
import static org.solovyev.android.DeviceModel.samsung_galaxy_s_2;
|
||||
import static org.solovyev.android.prefs.IntegerPreference.DEF_VALUE;
|
||||
|
||||
public final class Preferences {
|
||||
|
||||
@ -77,12 +70,18 @@ public final class Preferences {
|
||||
setInitialDefaultValues(application, preferences, editor);
|
||||
editor.apply();
|
||||
} else if (version > 143) {
|
||||
if (!Gui.vibrateOnKeypress.isSet(preferences)) {
|
||||
// FIXME: 2016-02-20 use correct version
|
||||
final SharedPreferences.Editor editor = preferences.edit();
|
||||
if (!Gui.vibrateOnKeypress.isSet(preferences)) {
|
||||
//noinspection deprecation
|
||||
Gui.vibrateOnKeypress.putPreference(editor, Gui.hapticFeedback.getPreference(preferences) > 0);
|
||||
editor.apply();
|
||||
}
|
||||
Gui.Layout layout = Gui.layout.getPreference(preferences);
|
||||
//noinspection deprecation
|
||||
if (layout == Gui.Layout.main_cellphone || layout == Gui.Layout.main_calculator_mobile || layout == Gui.Layout.simple_mobile) {
|
||||
Gui.layout.putDefault(editor);
|
||||
}
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,10 +114,6 @@ public final class Preferences {
|
||||
|
||||
Gui.theme.tryPutDefault(preferences, editor);
|
||||
Gui.layout.tryPutDefault(preferences, editor);
|
||||
//noinspection deprecation
|
||||
if (Gui.layout.getPreference(preferences) == Gui.Layout.main_cellphone) {
|
||||
Gui.layout.putDefault(editor);
|
||||
}
|
||||
Gui.feedbackWindowShown.tryPutDefault(preferences, editor);
|
||||
Gui.showReleaseNotes.tryPutDefault(preferences, editor);
|
||||
Gui.usePrevAsBack.tryPutDefault(preferences, editor);
|
||||
@ -354,23 +349,18 @@ public final class Preferences {
|
||||
}
|
||||
|
||||
public enum Layout {
|
||||
main_calculator(R.layout.main_calculator, true),
|
||||
main_calculator_mobile(R.layout.main_calculator_mobile, false),
|
||||
main_calculator,
|
||||
simple,
|
||||
|
||||
// not used anymore
|
||||
@Deprecated
|
||||
main_cellphone(R.layout.main_calculator, true),
|
||||
|
||||
simple(R.layout.main_calculator, true),
|
||||
simple_mobile(R.layout.main_calculator_mobile, false);
|
||||
|
||||
public final int layoutId;
|
||||
public final boolean optimized;
|
||||
|
||||
Layout(int layoutId, boolean optimized) {
|
||||
this.layoutId = layoutId;
|
||||
this.optimized = optimized;
|
||||
}
|
||||
main_cellphone,
|
||||
// not used anymore
|
||||
@Deprecated
|
||||
main_calculator_mobile,
|
||||
// not used anymore
|
||||
@Deprecated
|
||||
simple_mobile;
|
||||
}
|
||||
|
||||
public static final class TextColor {
|
||||
|
@ -1,13 +1,5 @@
|
||||
package org.solovyev.android.calculator.keyboard;
|
||||
|
||||
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING;
|
||||
import static android.view.HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING;
|
||||
import static android.view.HapticFeedbackConstants.KEYBOARD_TAP;
|
||||
import static org.solovyev.android.calculator.App.cast;
|
||||
import static org.solovyev.android.calculator.App.getScreenMetrics;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple_mobile;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
@ -19,14 +11,8 @@ import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.solovyev.android.Views;
|
||||
import org.solovyev.android.calculator.BaseUi;
|
||||
import org.solovyev.android.calculator.Calculator;
|
||||
import org.solovyev.android.calculator.Editor;
|
||||
import org.solovyev.android.calculator.Keyboard;
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.android.calculator.PreferredPreferences;
|
||||
import org.solovyev.android.calculator.*;
|
||||
import org.solovyev.android.calculator.buttons.CppSpecialButton;
|
||||
import org.solovyev.android.calculator.view.ScreenMetrics;
|
||||
import org.solovyev.android.views.Adjuster;
|
||||
@ -35,11 +21,16 @@ import org.solovyev.android.views.dragbutton.DragButton;
|
||||
import org.solovyev.android.views.dragbutton.DragDirection;
|
||||
import org.solovyev.android.views.dragbutton.SimpleDragListener;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.inject.Inject;
|
||||
import static android.view.HapticFeedbackConstants.*;
|
||||
import static org.solovyev.android.calculator.App.cast;
|
||||
import static org.solovyev.android.calculator.App.getScreenMetrics;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.simple_mobile;
|
||||
|
||||
public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPreferenceChangeListener, SimpleDragListener.DragProcessor, View.OnClickListener {
|
||||
|
||||
@ -85,7 +76,7 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
|
||||
|
||||
orientation = Views.getScreenOrientation(activity);
|
||||
layout = Preferences.Gui.layout.getPreferenceNoError(preferences);
|
||||
textSize = layout.optimized ? 0 : calculateTextSize();
|
||||
textSize = calculateTextSize();
|
||||
}
|
||||
|
||||
protected final void prepareButton(@Nullable ImageView button) {
|
||||
@ -118,9 +109,7 @@ public abstract class BaseKeyboardUi implements SharedPreferences.OnSharedPrefer
|
||||
prepareButton((View) button);
|
||||
button.setOnDragListener(listener);
|
||||
BaseUi.setFont(button, typeface);
|
||||
if (textSize > 0) {
|
||||
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
|
||||
}
|
||||
Adjuster.adjustText(button, TEXT_SCALE);
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,5 @@
|
||||
package org.solovyev.android.calculator.keyboard;
|
||||
|
||||
import static org.solovyev.android.calculator.Engine.Preferences.numeralBase;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.showEqualsButton;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.vibrateOnKeypress;
|
||||
import static org.solovyev.android.views.dragbutton.DragDirection.down;
|
||||
import static org.solovyev.android.views.dragbutton.DragDirection.left;
|
||||
import static org.solovyev.android.views.dragbutton.DragDirection.up;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.SharedPreferences;
|
||||
@ -20,10 +13,11 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import jscl.NumeralBase;
|
||||
import org.solovyev.android.Check;
|
||||
import org.solovyev.android.calculator.ActivityLauncher;
|
||||
import org.solovyev.android.calculator.App;
|
||||
import org.solovyev.android.calculator.Engine;
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.android.calculator.R;
|
||||
@ -34,13 +28,14 @@ import org.solovyev.android.views.dragbutton.DirectionDragButton;
|
||||
import org.solovyev.android.views.dragbutton.DragButton;
|
||||
import org.solovyev.android.views.dragbutton.DragDirection;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import jscl.NumeralBase;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.solovyev.android.calculator.Engine.Preferences.numeralBase;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.showEqualsButton;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.vibrateOnKeypress;
|
||||
import static org.solovyev.android.views.dragbutton.DragDirection.*;
|
||||
|
||||
public class PartialKeyboardUi extends BaseKeyboardUi {
|
||||
|
||||
@Nullable
|
||||
@ -90,10 +85,6 @@ public class PartialKeyboardUi extends BaseKeyboardUi {
|
||||
if (equalsButton == null) {
|
||||
return;
|
||||
}
|
||||
final boolean large = App.isLargeScreen() && Preferences.Gui.getLayout(preferences).optimized;
|
||||
if (large) {
|
||||
return;
|
||||
}
|
||||
if (orientation != Configuration.ORIENTATION_PORTRAIT && Preferences.Gui.autoOrientation.getPreference(preferences)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,81 +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.wizard;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.android.calculator.R;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator_mobile;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 6/19/13
|
||||
* Time: 12:39 AM
|
||||
*/
|
||||
enum CalculatorLayout {
|
||||
|
||||
big_buttons(R.string.cpp_wizard_layout_big_buttons) {
|
||||
@Override
|
||||
protected void apply(@Nonnull SharedPreferences preferences) {
|
||||
Preferences.Gui.layout.putPreference(preferences, main_calculator_mobile);
|
||||
}
|
||||
},
|
||||
|
||||
optimized(R.string.cpp_wizard_layout_optimized) {
|
||||
@Override
|
||||
protected void apply(@Nonnull SharedPreferences preferences) {
|
||||
Preferences.Gui.layout.putPreference(preferences, main_calculator);
|
||||
}
|
||||
};
|
||||
|
||||
private final int nameResId;
|
||||
|
||||
CalculatorLayout(int nameResId) {
|
||||
this.nameResId = nameResId;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static CalculatorLayout getDefaultLayout() {
|
||||
return big_buttons;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static CalculatorLayout fromGuiLayout(@Nonnull Preferences.Gui.Layout layout) {
|
||||
if (layout.optimized) {
|
||||
return optimized;
|
||||
} else {
|
||||
return big_buttons;
|
||||
}
|
||||
}
|
||||
|
||||
int getNameResId() {
|
||||
return nameResId;
|
||||
}
|
||||
|
||||
protected abstract void apply(@Nonnull SharedPreferences preferences);
|
||||
}
|
@ -23,63 +23,46 @@
|
||||
package org.solovyev.android.calculator.wizard;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import jscl.AngleUnit;
|
||||
import org.solovyev.android.calculator.Engine;
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.android.calculator.R;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import jscl.AngleUnit;
|
||||
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator;
|
||||
import static org.solovyev.android.calculator.Preferences.Gui.Layout.main_calculator_mobile;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 6/17/13
|
||||
* Time: 9:30 PM
|
||||
*/
|
||||
enum CalculatorMode {
|
||||
|
||||
simple(R.string.cpp_wizard_mode_simple) {
|
||||
simple() {
|
||||
@Override
|
||||
protected void apply(@Nonnull SharedPreferences preferences) {
|
||||
final Preferences.Gui.Layout layout = Preferences.Gui.layout.getPreference(preferences);
|
||||
if (layout.optimized) {
|
||||
Preferences.Gui.layout.putPreference(preferences, Preferences.Gui.Layout.simple);
|
||||
} else {
|
||||
Preferences.Gui.layout.putPreference(preferences, Preferences.Gui.Layout.simple_mobile);
|
||||
}
|
||||
Preferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.deg);
|
||||
Engine.Preferences.angleUnit.putPreference(preferences, AngleUnit.deg);
|
||||
Engine.Preferences.Output.scientificNotation.putPreference(preferences, false);
|
||||
Engine.Preferences.Output.round.putPreference(preferences, true);
|
||||
final SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
Preferences.Gui.layout.putPreference(editor, Preferences.Gui.Layout.simple);
|
||||
Preferences.Calculations.preferredAngleUnits.putPreference(editor, AngleUnit.deg);
|
||||
Engine.Preferences.angleUnit.putPreference(editor, AngleUnit.deg);
|
||||
Engine.Preferences.Output.scientificNotation.putPreference(editor, false);
|
||||
Engine.Preferences.Output.round.putPreference(editor, true);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
},
|
||||
|
||||
engineer(R.string.cpp_wizard_mode_engineer) {
|
||||
engineer() {
|
||||
@Override
|
||||
protected void apply(@Nonnull SharedPreferences preferences) {
|
||||
final Preferences.Gui.Layout layout = Preferences.Gui.layout.getPreference(preferences);
|
||||
if (layout.optimized) {
|
||||
Preferences.Gui.layout.putPreference(preferences, main_calculator);
|
||||
} else {
|
||||
Preferences.Gui.layout.putPreference(preferences, main_calculator_mobile);
|
||||
}
|
||||
Preferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.rad);
|
||||
Engine.Preferences.angleUnit.putPreference(preferences, AngleUnit.rad);
|
||||
Engine.Preferences.Output.scientificNotation.putPreference(preferences, true);
|
||||
Engine.Preferences.Output.round.putPreference(preferences, false);
|
||||
final SharedPreferences.Editor editor = preferences.edit();
|
||||
|
||||
Preferences.Gui.layout.putPreference(editor, main_calculator);
|
||||
Preferences.Calculations.preferredAngleUnits.putPreference(editor, AngleUnit.rad);
|
||||
Engine.Preferences.angleUnit.putPreference(editor, AngleUnit.rad);
|
||||
Engine.Preferences.Output.scientificNotation.putPreference(editor, true);
|
||||
Engine.Preferences.Output.round.putPreference(editor, false);
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
};
|
||||
|
||||
private final int nameResId;
|
||||
|
||||
CalculatorMode(int nameResId) {
|
||||
this.nameResId = nameResId;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static CalculatorMode getDefaultMode() {
|
||||
return engineer;
|
||||
@ -100,9 +83,5 @@ enum CalculatorMode {
|
||||
}
|
||||
}
|
||||
|
||||
int getNameResId() {
|
||||
return nameResId;
|
||||
}
|
||||
|
||||
protected abstract void apply(@Nonnull SharedPreferences preferences);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ package org.solovyev.android.calculator.wizard;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.solovyev.android.calculator.App;
|
||||
import org.solovyev.android.calculator.R;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -34,13 +33,6 @@ import javax.annotation.Nullable;
|
||||
enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep {
|
||||
|
||||
welcome(WelcomeWizardStep.class, R.string.cpp_wizard_welcome_title, R.string.cpp_wizard_start),
|
||||
|
||||
choose_layout(ChooseLayoutWizardStep.class, R.string.cpp_wizard_layout_title) {
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return App.isLargeScreen();
|
||||
}
|
||||
},
|
||||
choose_mode(ChooseModeWizardStep.class, R.string.cpp_wizard_mode_title),
|
||||
choose_theme(ChooseThemeWizardStep.class, R.string.cpp_wizard_theme_title),
|
||||
on_screen_calculator(OnScreenCalculatorWizardStep.class, R.string.cpp_wizard_onscreen_calculator_title),
|
||||
|
@ -1,88 +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.wizard;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import org.solovyev.android.calculator.App;
|
||||
import org.solovyev.android.calculator.Preferences;
|
||||
import org.solovyev.android.calculator.R;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.solovyev.android.calculator.wizard.CalculatorLayout.big_buttons;
|
||||
import static org.solovyev.android.calculator.wizard.CalculatorLayout.optimized;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 6/19/13
|
||||
* Time: 12:33 AM
|
||||
*/
|
||||
public class ChooseLayoutWizardStep extends WizardFragment implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
private ImageView image;
|
||||
|
||||
@Override
|
||||
protected int getViewResId() {
|
||||
return R.layout.cpp_wizard_step_choose_layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View root, Bundle savedInstanceState) {
|
||||
super.onViewCreated(root, savedInstanceState);
|
||||
|
||||
final CalculatorLayout layout = CalculatorLayout.fromGuiLayout(Preferences.Gui.layout.getPreference(App.getPreferences()));
|
||||
|
||||
image = (ImageView) root.findViewById(R.id.wizard_layout_image);
|
||||
final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_layout_spinner);
|
||||
spinner.setAdapter(WizardArrayAdapter.create(getActivity(), R.array.cpp_layouts));
|
||||
spinner.setSelection(layout == big_buttons ? 0 : 1);
|
||||
spinner.setOnItemSelectedListener(this);
|
||||
|
||||
updateImage(layout);
|
||||
}
|
||||
|
||||
private void updateImage(@Nonnull CalculatorLayout layout) {
|
||||
image.setImageResource(layout == big_buttons ? R.drawable.layout_big_buttons : R.drawable.layout_optimized);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
final CalculatorLayout layout = position == 0 ? big_buttons : optimized;
|
||||
layout.apply(App.getPreferences());
|
||||
updateImage(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
}
|
@ -1,38 +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
|
||||
-->
|
||||
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<string-array name="p_layout_names" tools:ignore="InconsistentArrays">
|
||||
<item>@string/p_layout_calculator</item>
|
||||
<item>@string/p_layout_calculator_mobile</item>
|
||||
<item>@string/p_layout_simple</item>
|
||||
<item>@string/p_layout_simple_mobile</item>
|
||||
</string-array>
|
||||
<string-array name="p_layout_values" translatable="false" tools:ignore="InconsistentArrays">
|
||||
<item>main_calculator</item>
|
||||
<item>main_calculator_mobile</item>
|
||||
<item>simple</item>
|
||||
<item>simple_mobile</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user