diff --git a/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStepTest.java b/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStepTest.java index 156ba156..d1e5bc95 100644 --- a/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStepTest.java +++ b/android-app-tests/src/test/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStepTest.java @@ -78,13 +78,13 @@ public class OnScreenCalculatorWizardStepTest { @Test public void testShouldRestoreStateOnRestart() throws Exception { - fragment.getOnscreenCalculatorCheckbox().setChecked(true); + fragment.getCheckbox().setChecked(true); controller.restart(); - assertTrue(fragment.getOnscreenCalculatorCheckbox().isChecked()); + assertTrue(fragment.getCheckbox().isChecked()); - fragment.getOnscreenCalculatorCheckbox().setChecked(false); + fragment.getCheckbox().setChecked(false); controller.restart(); - assertFalse(fragment.getOnscreenCalculatorCheckbox().isChecked()); + assertFalse(fragment.getCheckbox().isChecked()); } @Test diff --git a/android-app/src/main/java/org/solovyev/android/calculator/App.java b/android-app/src/main/java/org/solovyev/android/calculator/App.java index 6083570b..3d5ef7db 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/App.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/App.java @@ -24,8 +24,10 @@ package org.solovyev.android.calculator; import android.app.Application; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.preference.PreferenceManager; import org.solovyev.android.UiThreadExecutor; +import org.solovyev.android.Views; import org.solovyev.android.calculator.ga.Ga; import org.solovyev.android.checkout.*; import org.solovyev.common.listeners.JEvent; @@ -214,4 +216,8 @@ public final class App { public static Products getProducts() { return products; } + + public static boolean isLargeScreen() { + return Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, App.getApplication().getResources().getConfiguration()); + } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java index 2ae44352..f6b1002e 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButtons.java @@ -92,8 +92,7 @@ public final class CalculatorButtons { @Nonnull Activity activity) { preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences; - final boolean large = Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) && - Preferences.Gui.getLayout(preferences).isOptimized(); + final boolean large = App.isLargeScreen() && Preferences.Gui.getLayout(preferences).isOptimized(); if (!large) { if (Views.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT diff --git a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/VarEditDialogFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/VarEditDialogFragment.java index 641c40e2..d801f015 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/math/edit/VarEditDialogFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/math/edit/VarEditDialogFragment.java @@ -59,15 +59,17 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE private final static String greekAlphabet = "αβγδεζηθικλμνξοπρστυφχψω"; private final static List acceptableChars = Arrays.asList(Strings.toObjects(("1234567890abcdefghijklmnopqrstuvwxyzйцукенгшщзхъфывапролджэячсмитьбюё_" + greekAlphabet).toCharArray())); - @Nonnull - private final Input input; + private Input input; public VarEditDialogFragment() { - this(Input.newInstance()); + input = Input.newInstance(); } - public VarEditDialogFragment(@Nonnull Input input) { - this.input = input; + @Nonnull + public static VarEditDialogFragment create(@Nonnull Input input) { + final VarEditDialogFragment fragment = new VarEditDialogFragment(); + fragment.input = input; + return fragment; } @Override @@ -255,7 +257,7 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE */ public static void showDialog(@Nonnull Input input, @Nonnull FragmentManager fm) { - AndroidSherlockUtils.showDialog(new VarEditDialogFragment(input), "constant-editor", fm); + AndroidSherlockUtils.showDialog(create(input), "constant-editor", fm); } public static class Input { diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardStep.java index bce88019..ed94a508 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardStep.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardStep.java @@ -22,22 +22,14 @@ package org.solovyev.android.calculator.wizard; -import android.content.res.Configuration; import android.os.Bundle; import android.support.v4.app.Fragment; import org.solovyev.android.calculator.App; -import org.solovyev.android.Views; -import org.solovyev.android.calculator.Preferences; import org.solovyev.android.calculator.R; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import static org.solovyev.android.calculator.CalculatorApplication.getPreferences; -import static org.solovyev.android.calculator.wizard.ChooseLayoutWizardStep.LAYOUT; -import static org.solovyev.android.calculator.wizard.ChooseModeWizardStep.MODE; -import static org.solovyev.android.calculator.wizard.OnScreenCalculatorWizardStep.ONSCREEN_CALCULATOR_ENABLED; - /** * User: serso * Date: 6/16/13 @@ -48,71 +40,14 @@ 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 onNext(@Nonnull Fragment f) { - final ChooseLayoutWizardStep fragment = (ChooseLayoutWizardStep) f; - - final CalculatorLayout layout = fragment.getSelectedLayout(); - layout.apply(getPreferences()); - - return true; - } - - @Nullable - @Override - public Bundle getFragmentArgs() { - final Bundle bundle = new Bundle(); - bundle.putSerializable(LAYOUT, CalculatorLayout.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences()))); - return bundle; - } - @Override public boolean isVisible() { - return Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, App.getApplication().getResources().getConfiguration()); + return App.isLargeScreen(); } }, - - choose_mode(ChooseModeWizardStep.class, R.string.cpp_wizard_mode_title) { - @Override - public boolean onNext(@Nonnull Fragment f) { - final ChooseModeWizardStep fragment = (ChooseModeWizardStep) f; - - final CalculatorMode mode = fragment.getSelectedMode(); - mode.apply(getPreferences()); - - return true; - } - - @Nullable - @Override - public Bundle getFragmentArgs() { - final Bundle bundle = new Bundle(); - bundle.putSerializable(MODE, CalculatorMode.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences()))); - return bundle; - } - }, - - on_screen_calculator(OnScreenCalculatorWizardStep.class, R.string.cpp_wizard_onscreen_calculator_title) { - @Override - public boolean onNext(@Nonnull Fragment f) { - final OnScreenCalculatorWizardStep fragment = (OnScreenCalculatorWizardStep) f; - - Preferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), fragment.isOnscreenCalculatorEnabled()); - - return true; - } - - @Nullable - @Override - public Bundle getFragmentArgs() { - final Bundle bundle = new Bundle(); - bundle.putSerializable(ONSCREEN_CALCULATOR_ENABLED, Preferences.OnscreenCalculator.showAppIcon.getPreference(getPreferences())); - return bundle; - } - }, - + choose_mode(ChooseModeWizardStep.class, R.string.cpp_wizard_mode_title), + on_screen_calculator(OnScreenCalculatorWizardStep.class, R.string.cpp_wizard_onscreen_calculator_title), drag_button(DragButtonWizardStep.class, R.string.cpp_wizard_dragbutton_title), - last(FinalWizardStep.class, R.string.cpp_wizard_final_title); @Nonnull diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseLayoutWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseLayoutWizardStep.java index 191ee8a0..8cd96e8d 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseLayoutWizardStep.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseLayoutWizardStep.java @@ -23,106 +23,66 @@ package org.solovyev.android.calculator.wizard; import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; -import android.widget.RadioButton; - +import android.widget.AdapterView; +import android.widget.ImageView; +import android.widget.Spinner; +import org.solovyev.android.calculator.Preferences; import org.solovyev.android.calculator.R; import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import static org.solovyev.android.calculator.wizard.CalculatorLayout.*; +import static org.solovyev.android.calculator.CalculatorApplication.getPreferences; +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 Fragment { - - /* - ********************************************************************** - * - * CONSTANTS - * - ********************************************************************** - */ - - static final String LAYOUT = "layout"; - - /* - ********************************************************************** - * - * FIELDS - * - ********************************************************************** - */ - - @Nullable - private RadioButton optimizedRadioButton; - - @Nullable - private RadioButton bigButtonsRadioButton; - - private CalculatorLayout layout; +public class ChooseLayoutWizardStep extends WizardFragment implements AdapterView.OnItemSelectedListener { @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (savedInstanceState != null) { - layout = (CalculatorLayout) savedInstanceState.getSerializable(LAYOUT); - } - - if (layout == null) { - layout = (CalculatorLayout) getArguments().getSerializable(LAYOUT); - } + protected int getViewResId() { + return R.layout.cpp_wizard_step_choose_layout; } - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.cpp_wizard_step_choose_layout, null); - } + private ImageView image; @Override public void onViewCreated(View root, Bundle savedInstanceState) { super.onViewCreated(root, savedInstanceState); - optimizedRadioButton = (RadioButton) root.findViewById(R.id.wizard_optimized_radiobutton); - bigButtonsRadioButton = (RadioButton) root.findViewById(R.id.wizard_big_buttons_radiobutton); + final CalculatorLayout layout = CalculatorLayout.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences())); - switch (layout) { - case big_buttons: - bigButtonsRadioButton.setChecked(true); - optimizedRadioButton.setChecked(false); - break; - case optimized: - bigButtonsRadioButton.setChecked(false); - optimizedRadioButton.setChecked(true); - break; - } + image = (ImageView) root.findViewById(R.id.wizard_layout_image); + final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_layout_spinner); + spinner.setAdapter(new WizardArrayAdapter(getActivity(), R.array.cpp_layouts)); + spinner.setSelection(layout == big_buttons ? 0 : 1); + spinner.setOnItemSelectedListener(this); + + updateImage(layout); } - @Nonnull - CalculatorLayout getSelectedLayout() { - CalculatorLayout layout = getDefaultLayout(); - - if (bigButtonsRadioButton != null && bigButtonsRadioButton.isChecked()) { - layout = big_buttons; - } else if (optimizedRadioButton != null && optimizedRadioButton.isChecked()) { - layout = optimized; - } - - return 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(getPreferences()); + updateImage(layout); + } + + @Override + public void onNothingSelected(AdapterView parent) { - outState.putSerializable(LAYOUT, layout); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java index 12de3357..c1ebf29d 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java @@ -22,19 +22,17 @@ package org.solovyev.android.calculator.wizard; -import android.content.Context; import android.os.Bundle; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.widget.AdapterView; -import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; +import org.solovyev.android.calculator.Preferences; import org.solovyev.android.calculator.R; import javax.annotation.Nonnull; +import static org.solovyev.android.calculator.CalculatorApplication.getPreferences; import static org.solovyev.android.calculator.wizard.CalculatorMode.*; /** @@ -44,42 +42,8 @@ import static org.solovyev.android.calculator.wizard.CalculatorMode.*; */ public class ChooseModeWizardStep extends WizardFragment implements AdapterView.OnItemSelectedListener { - /* - ********************************************************************** - * - * CONSTANTS - * - ********************************************************************** - */ - - static final String MODE = "mode"; - - /* - ********************************************************************** - * - * FIELDS - * - ********************************************************************** - */ - - private Spinner spinner; private TextView description; - private CalculatorMode mode; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (savedInstanceState != null) { - mode = (CalculatorMode) savedInstanceState.getSerializable(MODE); - } - - if (mode == null) { - mode = (CalculatorMode) getArguments().getSerializable(MODE); - } - } - @Override protected int getViewResId() { return R.layout.cpp_wizard_step_choose_mode; @@ -89,59 +53,28 @@ public class ChooseModeWizardStep extends WizardFragment implements AdapterView. public void onViewCreated(View root, Bundle savedInstanceState) { super.onViewCreated(root, savedInstanceState); - spinner = (Spinner) root.findViewById(R.id.wizard_mode_spinner); - spinner.setAdapter(new MyArrayAdapter(getActivity())); + final CalculatorMode mode = CalculatorMode.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences())); + final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_mode_spinner); + spinner.setAdapter(new WizardArrayAdapter(getActivity(), R.array.cpp_modes)); + spinner.setSelection(mode == simple ? 0 : 1); spinner.setOnItemSelectedListener(this); description = (TextView) root.findViewById(R.id.wizard_mode_description); - updateDescription(); + updateDescription(mode); } - private void updateDescription() { + private void updateDescription(@Nonnull CalculatorMode mode) { description.setText(mode == simple ? R.string.cpp_wizard_mode_simple_description : R.string.cpp_wizard_mode_engineer_description); } - @Nonnull - CalculatorMode getSelectedMode() { - if (spinner != null) { - return mode; - } - - return getDefaultMode(); - } - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - - outState.putSerializable(MODE, mode); - } - @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - mode = position == 0 ? simple : engineer; - updateDescription(); + final CalculatorMode mode = position == 0 ? simple : engineer; + mode.apply(getPreferences()); + updateDescription(mode); } @Override public void onNothingSelected(AdapterView parent) { - - } - - private static final class MyArrayAdapter extends ArrayAdapter { - - public MyArrayAdapter(Context context) { - super(context, android.R.layout.simple_spinner_item, context.getResources().getStringArray(R.array.cpp_modes)); - setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - final View view = super.getView(position, convertView, parent); - if (view instanceof TextView) { - ((TextView) view).setTextAppearance(getContext(), android.R.style.TextAppearance_Large); - } - return view; - } } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStep.java index 37c59e47..87d23363 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStep.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/OnScreenCalculatorWizardStep.java @@ -25,48 +25,18 @@ package org.solovyev.android.calculator.wizard; import android.os.Bundle; import android.view.View; import android.widget.CheckBox; +import android.widget.CompoundButton; import org.solovyev.android.calculator.Preferences; import org.solovyev.android.calculator.R; import javax.annotation.Nullable; -public class OnScreenCalculatorWizardStep extends WizardFragment { +import static org.solovyev.android.calculator.CalculatorApplication.getPreferences; - /* - ********************************************************************** - * - * CONSTANTS - * - ********************************************************************** - */ - - static final String ONSCREEN_CALCULATOR_ENABLED = "onscreen_calculator_enabled"; - - /* - ********************************************************************** - * - * FIELDS - * - ********************************************************************** - */ +public class OnScreenCalculatorWizardStep extends WizardFragment implements CompoundButton.OnCheckedChangeListener { @Nullable - private CheckBox onscreenCalculatorCheckbox; - - private Boolean onscreenCalculatorEnabled; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (savedInstanceState != null && savedInstanceState.containsKey(ONSCREEN_CALCULATOR_ENABLED)) { - onscreenCalculatorEnabled = savedInstanceState.getBoolean(ONSCREEN_CALCULATOR_ENABLED); - } - - if (onscreenCalculatorEnabled == null) { - onscreenCalculatorEnabled = getArguments().getBoolean(ONSCREEN_CALCULATOR_ENABLED, Preferences.OnscreenCalculator.showAppIcon.getDefaultValue()); - } - } + private CheckBox checkbox; @Override protected int getViewResId() { @@ -77,31 +47,20 @@ public class OnScreenCalculatorWizardStep extends WizardFragment { public void onViewCreated(View root, Bundle savedInstanceState) { super.onViewCreated(root, savedInstanceState); - onscreenCalculatorCheckbox = (CheckBox) root.findViewById(R.id.wizard_onscreen_app_enabled_checkbox); - onscreenCalculatorCheckbox.setChecked(onscreenCalculatorEnabled); - } - - public Boolean isOnscreenCalculatorEnabled() { - boolean enabled = Preferences.OnscreenCalculator.showAppIcon.getDefaultValue(); - - if (onscreenCalculatorCheckbox != null) { - enabled = onscreenCalculatorCheckbox.isChecked(); - } - - return enabled; - } - - - @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - - outState.putBoolean(ONSCREEN_CALCULATOR_ENABLED, onscreenCalculatorEnabled); + final Boolean enabled = Preferences.OnscreenCalculator.showAppIcon.getPreference(getPreferences()); + checkbox = (CheckBox) root.findViewById(R.id.wizard_onscreen_app_enabled_checkbox); + checkbox.setChecked(enabled); + checkbox.setOnCheckedChangeListener(this); } @Nullable - CheckBox getOnscreenCalculatorCheckbox() { - return onscreenCalculatorCheckbox; + CheckBox getCheckbox() { + return checkbox; + } + + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean checked) { + Preferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), checked); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardActivity.java index 5a92615a..1eea567f 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardActivity.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardActivity.java @@ -6,7 +6,6 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import com.viewpagerindicator.PageIndicator; import org.solovyev.android.calculator.BaseActivity; @@ -25,7 +24,7 @@ public class WizardActivity extends BaseActivity implements WizardsAware { private ViewPager pager; @Nonnull - private PagerAdapter pagerAdapter; + private WizardPagerAdapter pagerAdapter; @Nonnull private Wizards wizards = CalculatorApplication.getInstance().getWizards(); @@ -147,6 +146,8 @@ public class WizardActivity extends BaseActivity implements WizardsAware { public void goNext() { final int position = pager.getCurrentItem(); if (position < pagerAdapter.getCount() - 1) { + final WizardFragment fragment = (WizardFragment) pagerAdapter.getItem(position); + fragment.onNext(); pager.setCurrentItem(position + 1, true); } } @@ -154,6 +155,8 @@ public class WizardActivity extends BaseActivity implements WizardsAware { public void goPrev() { final int position = pager.getCurrentItem(); if (position > 0) { + final WizardFragment fragment = (WizardFragment) pagerAdapter.getItem(position); + fragment.onPrev(); pager.setCurrentItem(position - 1, true); } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardArrayAdapter.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardArrayAdapter.java new file mode 100644 index 00000000..c11f67df --- /dev/null +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardArrayAdapter.java @@ -0,0 +1,24 @@ +package org.solovyev.android.calculator.wizard; + +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.TextView; + +final class WizardArrayAdapter extends ArrayAdapter { + + public WizardArrayAdapter(Context context, int array) { + super(context, android.R.layout.simple_spinner_item, context.getResources().getStringArray(array)); + setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + final View view = super.getView(position, convertView, parent); + if (view instanceof TextView) { + ((TextView) view).setTextAppearance(getContext(), android.R.style.TextAppearance_Large); + } + return view; + } +} diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardFragment.java index d528787e..047ac78d 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardFragment.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardFragment.java @@ -34,7 +34,7 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis @Nonnull private CalculatorWizardStep findStepByClassName() { for (CalculatorWizardStep step : CalculatorWizardStep.values()) { - if(step.getFragmentClass().equals(getClass())) { + if (step.getFragmentClass().equals(getClass())) { return step; } } @@ -115,4 +115,19 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis private WizardActivity getWizardActivity() { return (WizardActivity) getActivity(); } + + public WizardStep getStep() { + if (step == null) { + step = findStepByClassName(); + } + return step; + } + + public void onNext() { + getStep().onNext(this); + } + + public void onPrev() { + getStep().onPrev(this); + } } diff --git a/android-app/src/main/java/org/solovyev/android/wizard/WizardUi.java b/android-app/src/main/java/org/solovyev/android/wizard/WizardUi.java index 306b452c..0702ccef 100644 --- a/android-app/src/main/java/org/solovyev/android/wizard/WizardUi.java +++ b/android-app/src/main/java/org/solovyev/android/wizard/WizardUi.java @@ -3,7 +3,6 @@ package org.solovyev.android.wizard; import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; @@ -75,29 +74,11 @@ public class WizardUi { activity.finish(); } - protected final boolean tryGoPrev() { - if (step == null) { - return true; - } else { - final Fragment fragment = getFragmentManager().findFragmentByTag(step.getFragmentTag()); - return fragment == null || step.onPrev(fragment); - } - } - @Nonnull protected final FragmentManager getFragmentManager() { return activity.getSupportFragmentManager(); } - protected final boolean tryGoNext() { - if (step == null) { - return true; - } else { - final Fragment fragment = getFragmentManager().findFragmentByTag(step.getFragmentTag()); - return fragment == null || step.onNext(fragment); - } - } - public void onSaveInstanceState(@Nonnull Bundle out) { out.putString(FLOW, wizard.getName()); out.putString(STEP, step.getName()); diff --git a/android-app/src/main/res/drawable-land-xhdpi/layout_big_buttons.png b/android-app/src/main/res/drawable-land-xhdpi/layout_big_buttons.png new file mode 100644 index 00000000..73509e40 Binary files /dev/null and b/android-app/src/main/res/drawable-land-xhdpi/layout_big_buttons.png differ diff --git a/android-app/src/main/res/drawable-land-xhdpi/layout_optimized.png b/android-app/src/main/res/drawable-land-xhdpi/layout_optimized.png new file mode 100644 index 00000000..ed62e429 Binary files /dev/null and b/android-app/src/main/res/drawable-land-xhdpi/layout_optimized.png differ diff --git a/android-app/src/main/res/drawable-xhdpi/layout_big_buttons.png b/android-app/src/main/res/drawable-xhdpi/layout_big_buttons.png new file mode 100644 index 00000000..06f1b8dd Binary files /dev/null and b/android-app/src/main/res/drawable-xhdpi/layout_big_buttons.png differ diff --git a/android-app/src/main/res/drawable-xhdpi/layout_optimized.png b/android-app/src/main/res/drawable-xhdpi/layout_optimized.png new file mode 100644 index 00000000..b0751252 Binary files /dev/null and b/android-app/src/main/res/drawable-xhdpi/layout_optimized.png differ diff --git a/android-app/src/main/res/layout/cpp_wizard_step_choose_layout.xml b/android-app/src/main/res/layout/cpp_wizard_step_choose_layout.xml index 2a20e35d..45e42a24 100644 --- a/android-app/src/main/res/layout/cpp_wizard_step_choose_layout.xml +++ b/android-app/src/main/res/layout/cpp_wizard_step_choose_layout.xml @@ -23,53 +23,29 @@ --> + a:layout_width="match_parent" + a:layout_height="match_parent" + a:orientation="vertical" + a:gravity="center"> - + - + - - - - - - - - - - - + diff --git a/android-app/src/main/res/values/arrays.xml b/android-app/src/main/res/values/arrays.xml index 29da5a3d..c27c5d20 100644 --- a/android-app/src/main/res/values/arrays.xml +++ b/android-app/src/main/res/values/arrays.xml @@ -138,4 +138,9 @@ @string/cpp_wizard_mode_simple @string/cpp_wizard_mode_engineer + + + @string/cpp_wizard_layout_big_buttons + @string/cpp_wizard_layout_optimized + \ No newline at end of file diff --git a/android-app/src/main/res/values/colors.xml b/android-app/src/main/res/values/colors.xml index 9a478486..b668ee12 100644 --- a/android-app/src/main/res/values/colors.xml +++ b/android-app/src/main/res/values/colors.xml @@ -33,7 +33,7 @@ #424242 #616161 #757575 - #ff1f1f1f + #212121 #ff000000 #212121 #393939