Choose layout wizard step

This commit is contained in:
serso 2015-01-31 20:26:25 +01:00
parent 20b408dc5c
commit c380dc82e3
19 changed files with 152 additions and 354 deletions

View File

@ -78,13 +78,13 @@ public class OnScreenCalculatorWizardStepTest {
@Test @Test
public void testShouldRestoreStateOnRestart() throws Exception { public void testShouldRestoreStateOnRestart() throws Exception {
fragment.getOnscreenCalculatorCheckbox().setChecked(true); fragment.getCheckbox().setChecked(true);
controller.restart(); controller.restart();
assertTrue(fragment.getOnscreenCalculatorCheckbox().isChecked()); assertTrue(fragment.getCheckbox().isChecked());
fragment.getOnscreenCalculatorCheckbox().setChecked(false); fragment.getCheckbox().setChecked(false);
controller.restart(); controller.restart();
assertFalse(fragment.getOnscreenCalculatorCheckbox().isChecked()); assertFalse(fragment.getCheckbox().isChecked());
} }
@Test @Test

View File

@ -24,8 +24,10 @@ package org.solovyev.android.calculator;
import android.app.Application; import android.app.Application;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.solovyev.android.UiThreadExecutor; import org.solovyev.android.UiThreadExecutor;
import org.solovyev.android.Views;
import org.solovyev.android.calculator.ga.Ga; import org.solovyev.android.calculator.ga.Ga;
import org.solovyev.android.checkout.*; import org.solovyev.android.checkout.*;
import org.solovyev.common.listeners.JEvent; import org.solovyev.common.listeners.JEvent;
@ -214,4 +216,8 @@ public final class App {
public static Products getProducts() { public static Products getProducts() {
return products; return products;
} }
public static boolean isLargeScreen() {
return Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, App.getApplication().getResources().getConfiguration());
}
} }

View File

@ -92,8 +92,7 @@ public final class CalculatorButtons {
@Nonnull Activity activity) { @Nonnull Activity activity) {
preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences; preferences = preferences == null ? PreferenceManager.getDefaultSharedPreferences(activity) : preferences;
final boolean large = Views.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE, activity.getResources().getConfiguration()) && final boolean large = App.isLargeScreen() && Preferences.Gui.getLayout(preferences).isOptimized();
Preferences.Gui.getLayout(preferences).isOptimized();
if (!large) { if (!large) {
if (Views.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT if (Views.getScreenOrientation(activity) == Configuration.ORIENTATION_PORTRAIT

View File

@ -59,15 +59,17 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE
private final static String greekAlphabet = "αβγδεζηθικλμνξοπρστυφχψω"; private final static String greekAlphabet = "αβγδεζηθικλμνξοπρστυφχψω";
private final static List<Character> acceptableChars = Arrays.asList(Strings.toObjects(("1234567890abcdefghijklmnopqrstuvwxyzйцукенгшщзхъфывапролджэячсмитьбюё_" + greekAlphabet).toCharArray())); private final static List<Character> acceptableChars = Arrays.asList(Strings.toObjects(("1234567890abcdefghijklmnopqrstuvwxyzйцукенгшщзхъфывапролджэячсмитьбюё_" + greekAlphabet).toCharArray()));
@Nonnull private Input input;
private final Input input;
public VarEditDialogFragment() { public VarEditDialogFragment() {
this(Input.newInstance()); input = Input.newInstance();
} }
public VarEditDialogFragment(@Nonnull Input input) { @Nonnull
this.input = input; public static VarEditDialogFragment create(@Nonnull Input input) {
final VarEditDialogFragment fragment = new VarEditDialogFragment();
fragment.input = input;
return fragment;
} }
@Override @Override
@ -255,7 +257,7 @@ public class VarEditDialogFragment extends DialogFragment implements CalculatorE
*/ */
public static void showDialog(@Nonnull Input input, @Nonnull FragmentManager fm) { 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 { public static class Input {

View File

@ -22,22 +22,14 @@
package org.solovyev.android.calculator.wizard; package org.solovyev.android.calculator.wizard;
import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import org.solovyev.android.calculator.App; import org.solovyev.android.calculator.App;
import org.solovyev.android.Views;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; 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 * User: serso
* Date: 6/16/13 * 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), welcome(WelcomeWizardStep.class, R.string.cpp_wizard_welcome_title, R.string.cpp_wizard_start),
choose_layout(ChooseLayoutWizardStep.class, R.string.cpp_wizard_layout_title) { 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 @Override
public boolean isVisible() { 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),
choose_mode(ChooseModeWizardStep.class, R.string.cpp_wizard_mode_title) { on_screen_calculator(OnScreenCalculatorWizardStep.class, R.string.cpp_wizard_onscreen_calculator_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;
}
},
drag_button(DragButtonWizardStep.class, R.string.cpp_wizard_dragbutton_title), drag_button(DragButtonWizardStep.class, R.string.cpp_wizard_dragbutton_title),
last(FinalWizardStep.class, R.string.cpp_wizard_final_title); last(FinalWizardStep.class, R.string.cpp_wizard_final_title);
@Nonnull @Nonnull

View File

@ -23,106 +23,66 @@
package org.solovyev.android.calculator.wizard; package org.solovyev.android.calculator.wizard;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.widget.AdapterView;
import android.widget.RadioButton; import android.widget.ImageView;
import android.widget.Spinner;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import 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 * User: serso
* Date: 6/19/13 * Date: 6/19/13
* Time: 12:33 AM * Time: 12:33 AM
*/ */
public class ChooseLayoutWizardStep extends Fragment { public class ChooseLayoutWizardStep extends WizardFragment implements AdapterView.OnItemSelectedListener {
/*
**********************************************************************
*
* CONSTANTS
*
**********************************************************************
*/
static final String LAYOUT = "layout";
/*
**********************************************************************
*
* FIELDS
*
**********************************************************************
*/
@Nullable
private RadioButton optimizedRadioButton;
@Nullable
private RadioButton bigButtonsRadioButton;
private CalculatorLayout layout;
@Override @Override
public void onCreate(Bundle savedInstanceState) { protected int getViewResId() {
super.onCreate(savedInstanceState); return R.layout.cpp_wizard_step_choose_layout;
if (savedInstanceState != null) {
layout = (CalculatorLayout) savedInstanceState.getSerializable(LAYOUT);
} }
if (layout == null) { private ImageView image;
layout = (CalculatorLayout) getArguments().getSerializable(LAYOUT);
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.cpp_wizard_step_choose_layout, null);
}
@Override @Override
public void onViewCreated(View root, Bundle savedInstanceState) { public void onViewCreated(View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState); super.onViewCreated(root, savedInstanceState);
optimizedRadioButton = (RadioButton) root.findViewById(R.id.wizard_optimized_radiobutton); final CalculatorLayout layout = CalculatorLayout.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences()));
bigButtonsRadioButton = (RadioButton) root.findViewById(R.id.wizard_big_buttons_radiobutton);
switch (layout) { image = (ImageView) root.findViewById(R.id.wizard_layout_image);
case big_buttons: final Spinner spinner = (Spinner) root.findViewById(R.id.wizard_layout_spinner);
bigButtonsRadioButton.setChecked(true); spinner.setAdapter(new WizardArrayAdapter(getActivity(), R.array.cpp_layouts));
optimizedRadioButton.setChecked(false); spinner.setSelection(layout == big_buttons ? 0 : 1);
break; spinner.setOnItemSelectedListener(this);
case optimized:
bigButtonsRadioButton.setChecked(false); updateImage(layout);
optimizedRadioButton.setChecked(true);
break;
}
} }
@Nonnull private void updateImage(@Nonnull CalculatorLayout layout) {
CalculatorLayout getSelectedLayout() { image.setImageResource(layout == big_buttons ? R.drawable.layout_big_buttons : R.drawable.layout_optimized);
CalculatorLayout layout = getDefaultLayout();
if (bigButtonsRadioButton != null && bigButtonsRadioButton.isChecked()) {
layout = big_buttons;
} else if (optimizedRadioButton != null && optimizedRadioButton.isChecked()) {
layout = optimized;
}
return layout;
} }
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(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);
} }
} }

View File

@ -22,19 +22,17 @@
package org.solovyev.android.calculator.wizard; package org.solovyev.android.calculator.wizard;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import static org.solovyev.android.calculator.CalculatorApplication.getPreferences;
import static org.solovyev.android.calculator.wizard.CalculatorMode.*; 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 { public class ChooseModeWizardStep extends WizardFragment implements AdapterView.OnItemSelectedListener {
/*
**********************************************************************
*
* CONSTANTS
*
**********************************************************************
*/
static final String MODE = "mode";
/*
**********************************************************************
*
* FIELDS
*
**********************************************************************
*/
private Spinner spinner;
private TextView description; 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 @Override
protected int getViewResId() { protected int getViewResId() {
return R.layout.cpp_wizard_step_choose_mode; 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) { public void onViewCreated(View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState); super.onViewCreated(root, savedInstanceState);
spinner = (Spinner) root.findViewById(R.id.wizard_mode_spinner); final CalculatorMode mode = CalculatorMode.fromGuiLayout(Preferences.Gui.layout.getPreference(getPreferences()));
spinner.setAdapter(new MyArrayAdapter(getActivity())); 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); spinner.setOnItemSelectedListener(this);
description = (TextView) root.findViewById(R.id.wizard_mode_description); 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); 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 @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mode = position == 0 ? simple : engineer; final CalculatorMode mode = position == 0 ? simple : engineer;
updateDescription(); mode.apply(getPreferences());
updateDescription(mode);
} }
@Override @Override
public void onNothingSelected(AdapterView<?> parent) { public void onNothingSelected(AdapterView<?> parent) {
}
private static final class MyArrayAdapter extends ArrayAdapter<String> {
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;
}
} }
} }

View File

@ -25,48 +25,18 @@ package org.solovyev.android.calculator.wizard;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton;
import org.solovyev.android.calculator.Preferences; import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class OnScreenCalculatorWizardStep extends WizardFragment { import static org.solovyev.android.calculator.CalculatorApplication.getPreferences;
/* public class OnScreenCalculatorWizardStep extends WizardFragment implements CompoundButton.OnCheckedChangeListener {
**********************************************************************
*
* CONSTANTS
*
**********************************************************************
*/
static final String ONSCREEN_CALCULATOR_ENABLED = "onscreen_calculator_enabled";
/*
**********************************************************************
*
* FIELDS
*
**********************************************************************
*/
@Nullable @Nullable
private CheckBox onscreenCalculatorCheckbox; private CheckBox checkbox;
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());
}
}
@Override @Override
protected int getViewResId() { protected int getViewResId() {
@ -77,31 +47,20 @@ public class OnScreenCalculatorWizardStep extends WizardFragment {
public void onViewCreated(View root, Bundle savedInstanceState) { public void onViewCreated(View root, Bundle savedInstanceState) {
super.onViewCreated(root, savedInstanceState); super.onViewCreated(root, savedInstanceState);
onscreenCalculatorCheckbox = (CheckBox) root.findViewById(R.id.wizard_onscreen_app_enabled_checkbox); final Boolean enabled = Preferences.OnscreenCalculator.showAppIcon.getPreference(getPreferences());
onscreenCalculatorCheckbox.setChecked(onscreenCalculatorEnabled); checkbox = (CheckBox) root.findViewById(R.id.wizard_onscreen_app_enabled_checkbox);
} checkbox.setChecked(enabled);
checkbox.setOnCheckedChangeListener(this);
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);
} }
@Nullable @Nullable
CheckBox getOnscreenCalculatorCheckbox() { CheckBox getCheckbox() {
return onscreenCalculatorCheckbox; return checkbox;
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
Preferences.OnscreenCalculator.showAppIcon.putPreference(getPreferences(), checked);
} }
} }

View File

@ -6,7 +6,6 @@ import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import com.viewpagerindicator.PageIndicator; import com.viewpagerindicator.PageIndicator;
import org.solovyev.android.calculator.BaseActivity; import org.solovyev.android.calculator.BaseActivity;
@ -25,7 +24,7 @@ public class WizardActivity extends BaseActivity implements WizardsAware {
private ViewPager pager; private ViewPager pager;
@Nonnull @Nonnull
private PagerAdapter pagerAdapter; private WizardPagerAdapter pagerAdapter;
@Nonnull @Nonnull
private Wizards wizards = CalculatorApplication.getInstance().getWizards(); private Wizards wizards = CalculatorApplication.getInstance().getWizards();
@ -147,6 +146,8 @@ public class WizardActivity extends BaseActivity implements WizardsAware {
public void goNext() { public void goNext() {
final int position = pager.getCurrentItem(); final int position = pager.getCurrentItem();
if (position < pagerAdapter.getCount() - 1) { if (position < pagerAdapter.getCount() - 1) {
final WizardFragment fragment = (WizardFragment) pagerAdapter.getItem(position);
fragment.onNext();
pager.setCurrentItem(position + 1, true); pager.setCurrentItem(position + 1, true);
} }
} }
@ -154,6 +155,8 @@ public class WizardActivity extends BaseActivity implements WizardsAware {
public void goPrev() { public void goPrev() {
final int position = pager.getCurrentItem(); final int position = pager.getCurrentItem();
if (position > 0) { if (position > 0) {
final WizardFragment fragment = (WizardFragment) pagerAdapter.getItem(position);
fragment.onPrev();
pager.setCurrentItem(position - 1, true); pager.setCurrentItem(position - 1, true);
} }
} }

View File

@ -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<String> {
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;
}
}

View File

@ -115,4 +115,19 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
private WizardActivity getWizardActivity() { private WizardActivity getWizardActivity() {
return (WizardActivity) getActivity(); 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);
}
} }

View File

@ -3,7 +3,6 @@ package org.solovyev.android.wizard;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
@ -75,29 +74,11 @@ public class WizardUi<A extends FragmentActivity> {
activity.finish(); 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 @Nonnull
protected final FragmentManager getFragmentManager() { protected final FragmentManager getFragmentManager() {
return activity.getSupportFragmentManager(); 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) { public void onSaveInstanceState(@Nonnull Bundle out) {
out.putString(FLOW, wizard.getName()); out.putString(FLOW, wizard.getName());
out.putString(STEP, step.getName()); out.putString(STEP, step.getName());

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -25,51 +25,27 @@
<LinearLayout xmlns:a="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"
a:layout_width="match_parent" a:layout_width="match_parent"
a:layout_height="match_parent" a:layout_height="match_parent"
a:orientation="vertical"> a:orientation="vertical"
a:gravity="center">
<RadioGroup <TextView
a:orientation="horizontal" a:layout_width="wrap_content"
a:layout_width="match_parent"
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:gravity="center_vertical|top"> a:textAppearance="@android:style/TextAppearance.Large"
style="@style/WizardLabel"
a:text="Choose layout" />
<RadioButton <Spinner
a:layout_width="0dp" a:id="@+id/wizard_layout_spinner"
a:id="@+id/wizard_optimized_radiobutton" a:layout_width="wrap_content"
a:layout_weight="1"
a:text="@string/cpp_wizard_layout_optimized"
a:layout_height="wrap_content"/>
<RadioButton
a:layout_width="0dp"
a:id="@+id/wizard_big_buttons_radiobutton"
a:layout_weight="1"
a:text="@string/cpp_wizard_layout_big_buttons"
a:layout_height="wrap_content"/>
</RadioGroup>
<LinearLayout
a:layout_width="match_parent"
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:orientation="horizontal"> style="@style/WizardLabel" />
<ImageView <ImageView
a:layout_width="0dp" a:id="@+id/wizard_layout_image"
a:layout_weight="1" a:layout_width="wrap_content"
a:scaleType="centerInside" a:layout_height="wrap_content"
a:layout_height="match_parent" style="@style/WizardLabel.Last"
a:padding="10dp" />
a:src="@drawable/tablet_optimized"/>
<ImageView
a:layout_width="0dp"
a:layout_weight="1"
a:scaleType="centerInside"
a:layout_height="match_parent"
a:padding="10dp"
a:src="@drawable/tablet_big_buttons"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -138,4 +138,9 @@
<item>@string/cpp_wizard_mode_simple</item> <item>@string/cpp_wizard_mode_simple</item>
<item>@string/cpp_wizard_mode_engineer</item> <item>@string/cpp_wizard_mode_engineer</item>
</string-array> </string-array>
<string-array name="cpp_layouts">
<item>@string/cpp_wizard_layout_big_buttons</item>
<item>@string/cpp_wizard_layout_optimized</item>
</string-array>
</resources> </resources>

View File

@ -33,7 +33,7 @@
<color name="cpp_wizard_button_normal">#424242</color> <color name="cpp_wizard_button_normal">#424242</color>
<color name="cpp_wizard_button_disabled">#616161</color> <color name="cpp_wizard_button_disabled">#616161</color>
<color name="cpp_wizard_button_pressed">#757575</color> <color name="cpp_wizard_button_pressed">#757575</color>
<color name="cpp_pane_background">#ff1f1f1f</color> <color name="cpp_pane_background">#212121</color>
<color name="cpp_metro_button_dark">#ff000000</color> <color name="cpp_metro_button_dark">#ff000000</color>
<color name="cpp_metro_button">#212121</color> <color name="cpp_metro_button">#212121</color>
<color name="cpp_metro_button_light">#393939</color> <color name="cpp_metro_button_light">#393939</color>