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 7bfd99f5..12de3357 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
@@ -80,14 +80,6 @@ public class ChooseModeWizardStep extends WizardFragment implements AdapterView.
}
}
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final View view = super.onCreateView(inflater, container, savedInstanceState);
- setupNextButton(R.string.acl_wizard_next);
- setupPrevButton(R.string.acl_wizard_back);
- return view;
- }
-
@Override
protected int getViewResId() {
return R.layout.cpp_wizard_step_choose_mode;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/DragButtonWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/DragButtonWizardStep.java
index 4cac0135..c199bd6c 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/DragButtonWizardStep.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/DragButtonWizardStep.java
@@ -75,14 +75,6 @@ public class DragButtonWizardStep extends WizardFragment {
super.onCreate(savedInstanceState);
}
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final View view = super.onCreateView(inflater, container, savedInstanceState);
- setupNextButton(R.string.acl_wizard_next);
- setupPrevButton(R.string.acl_wizard_back);
- return view;
- }
-
@Override
protected int getViewResId() {
return R.layout.cpp_wizard_step_drag_button;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/FinalWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/FinalWizardStep.java
index cff8bf85..76aa5e9f 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/FinalWizardStep.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/FinalWizardStep.java
@@ -3,17 +3,14 @@ package org.solovyev.android.calculator.wizard;
import android.content.Intent;
import android.net.Uri;
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.Button;
import org.solovyev.android.calculator.R;
import org.solovyev.android.calculator.preferences.PurchaseDialogActivity;
import static android.content.Intent.ACTION_VIEW;
-public class FinalWizardStep extends Fragment {
+public class FinalWizardStep extends WizardFragment {
private static final String GITHUB_URL = "https://github.com/serso/android-calculatorpp";
private static final String CROWDIN_URL = "http://crowdin.net/project/calculatorpp";
@@ -23,8 +20,8 @@ public class FinalWizardStep extends Fragment {
private Button contributeButton;
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- return inflater.inflate(R.layout.cpp_wizard_step_final, null);
+ protected int getViewResId() {
+ return R.layout.cpp_wizard_step_final;
}
@Override
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 0f7aceac..37c59e47 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
@@ -23,9 +23,7 @@
package org.solovyev.android.calculator.wizard;
import android.os.Bundle;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.CheckBox;
import org.solovyev.android.calculator.Preferences;
import org.solovyev.android.calculator.R;
@@ -70,14 +68,6 @@ public class OnScreenCalculatorWizardStep extends WizardFragment {
}
}
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final View view = super.onCreateView(inflater, container, savedInstanceState);
- setupNextButton(R.string.acl_wizard_next);
- setupPrevButton(R.string.acl_wizard_back);
- return view;
- }
-
@Override
protected int getViewResId() {
return R.layout.cpp_wizard_step_onscreen;
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WelcomeWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WelcomeWizardStep.java
index ccf492e2..19d68767 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WelcomeWizardStep.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WelcomeWizardStep.java
@@ -38,8 +38,6 @@ public final class WelcomeWizardStep extends WizardFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = super.onCreateView(inflater, container, savedInstanceState);
- setupNextButton(R.string.wizard_start);
- setupPrevButton(R.string.wizard_skip);
prevButton.setTextColor(getResources().getColor(R.color.cpp_wizard_disabled_text));
return view;
}
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 5ddbeb74..5a92615a 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
@@ -158,6 +158,14 @@ public class WizardActivity extends BaseActivity implements WizardsAware {
}
}
+ public WizardFlow getFlow() {
+ return wizardUi.getFlow();
+ }
+
+ public Wizard getWizard() {
+ return wizardUi.getWizard();
+ }
+
@Override
protected void onDestroy() {
dismissDialog();
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 3b03fce5..d528787e 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
@@ -8,7 +8,10 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.solovyev.android.calculator.R;
+import org.solovyev.android.wizard.WizardFlow;
+import org.solovyev.android.wizard.WizardStep;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class WizardFragment extends Fragment implements View.OnClickListener {
@@ -19,6 +22,26 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
@Nullable
protected TextView prevButton;
+ private WizardStep step;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ step = findStepByClassName();
+ }
+
+ @Nonnull
+ private CalculatorWizardStep findStepByClassName() {
+ for (CalculatorWizardStep step : CalculatorWizardStep.values()) {
+ if(step.getFragmentClass().equals(getClass())) {
+ return step;
+ }
+ }
+
+ throw new AssertionError("Wizard step for class " + getClass() + " was not found");
+ }
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_wizard, container, false);
@@ -35,6 +58,25 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
prevButton.setOnClickListener(this);
}
+ final WizardFlow flow = getWizardActivity().getFlow();
+ final boolean canGoNext = flow.getNextStep(step) != null;
+ final boolean canGoPrev = flow.getPrevStep(step) != null;
+ if (canGoNext) {
+ if (canGoPrev) {
+ setupNextButton(R.string.acl_wizard_next);
+ } else {
+ setupNextButton(R.string.acl_wizard_start);
+ }
+ } else {
+ setupNextButton(R.string.acl_wizard_finish);
+ }
+
+ if (canGoPrev) {
+ setupPrevButton(R.string.acl_wizard_back);
+ } else {
+ setupPrevButton(R.string.wizard_skip);
+ }
+
return view;
}
diff --git a/android-app/src/main/res/layout/cpp_wizard_step_choose_mode.xml b/android-app/src/main/res/layout/cpp_wizard_step_choose_mode.xml
index bea3c9ef..2187d885 100644
--- a/android-app/src/main/res/layout/cpp_wizard_step_choose_mode.xml
+++ b/android-app/src/main/res/layout/cpp_wizard_step_choose_mode.xml
@@ -45,6 +45,6 @@
a:id="@+id/wizard_mode_description"
a:layout_width="wrap_content"
a:layout_height="wrap_content"
- style="@style/WizardLabel"/>
+ style="@style/WizardLabel.Last"/>
diff --git a/android-app/src/main/res/layout/cpp_wizard_step_onscreen.xml b/android-app/src/main/res/layout/cpp_wizard_step_onscreen.xml
index a05daeb7..0d19811a 100644
--- a/android-app/src/main/res/layout/cpp_wizard_step_onscreen.xml
+++ b/android-app/src/main/res/layout/cpp_wizard_step_onscreen.xml
@@ -40,6 +40,6 @@
a:layout_height="wrap_content"
a:layout_width="wrap_content"
a:text="@string/cpp_wizard_onscreen_checkbox"
- style="@style/WizardLabel" />
+ style="@style/WizardLabel.Last" />
diff --git a/android-app/src/main/res/layout/cpp_wizard_step_welcome.xml b/android-app/src/main/res/layout/cpp_wizard_step_welcome.xml
index 4bd3ac45..f72ffa37 100644
--- a/android-app/src/main/res/layout/cpp_wizard_step_welcome.xml
+++ b/android-app/src/main/res/layout/cpp_wizard_step_welcome.xml
@@ -27,7 +27,7 @@
a:layout_height="match_parent">
diff --git a/android-app/src/main/res/values/styles.xml b/android-app/src/main/res/values/styles.xml
index f481c16b..98c14e04 100644
--- a/android-app/src/main/res/values/styles.xml
+++ b/android-app/src/main/res/values/styles.xml
@@ -145,6 +145,9 @@
- 1dp
+