From a56756e8cec09ee35c8bffd161e122e83bd83262 Mon Sep 17 00:00:00 2001 From: serso Date: Sun, 1 Feb 2015 18:05:59 +0100 Subject: [PATCH] Wizard changes --- .../solovyev/android/calculator/ActivityUi.java | 2 +- .../solovyev/android/calculator/Preferences.java | 11 +++++++++++ .../calculator/wizard/CalculatorWizardStep.java | 5 ----- .../android/calculator/wizard/WizardFragment.java | 14 +++++++++++--- .../src/main/res/layout/cpp_activity_wizard.xml | 1 + .../res/layout/cpp_wizard_step_choose_layout.xml | 2 +- .../res/layout/cpp_wizard_step_choose_mode.xml | 2 +- .../main/res/layout/fragment_wizard_buttons.xml | 2 ++ android-app/src/main/res/values-v21/theme.xml | 9 +++++++++ android-app/src/main/res/values/colors.xml | 2 ++ 10 files changed, 39 insertions(+), 11 deletions(-) diff --git a/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java b/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java index 2994a265..299ef765 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/ActivityUi.java @@ -77,7 +77,7 @@ public class ActivityUi extends BaseUi { final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); theme = Preferences.Gui.getTheme(preferences); - activity.setTheme(theme.getThemeId()); + activity.setTheme(theme.getThemeId(activity)); this.layout = Preferences.Gui.getLayout(preferences); diff --git a/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java b/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java index c117f595..438c846d 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/Preferences.java @@ -22,15 +22,18 @@ package org.solovyev.android.calculator; +import android.app.Activity; import android.content.SharedPreferences; import jscl.AngleUnit; import jscl.NumeralBase; import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.model.AndroidCalculatorEngine; +import org.solovyev.android.calculator.wizard.WizardActivity; import org.solovyev.android.prefs.*; import org.solovyev.android.view.VibratorContainer; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.text.DecimalFormatSymbols; import java.util.Locale; @@ -123,6 +126,14 @@ public final class Preferences { @Nonnull public Integer getThemeId() { + return getThemeId(null); + } + + @Nonnull + public Integer getThemeId(@Nullable Activity activity) { + if (activity instanceof WizardActivity) { + return R.style.Theme_Wizard; + } return themeId; } } 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 ed94a508..f7e2bce5 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 @@ -30,11 +30,6 @@ import org.solovyev.android.calculator.R; import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** - * User: serso - * Date: 6/16/13 - * Time: 9:17 PM - */ enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep { welcome(WelcomeWizardStep.class, R.string.cpp_wizard_welcome_title, R.string.cpp_wizard_start), 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 047ac78d..99841d0e 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 @@ -3,11 +3,13 @@ package org.solovyev.android.calculator.wizard; import android.os.Bundle; import android.support.annotation.LayoutRes; import android.support.v4.app.Fragment; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import org.solovyev.android.calculator.R; +import org.solovyev.android.wizard.Wizard; import org.solovyev.android.wizard.WizardFlow; import org.solovyev.android.wizard.WizardStep; @@ -58,11 +60,13 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis prevButton.setOnClickListener(this); } - final WizardFlow flow = getWizardActivity().getFlow(); + final Wizard wizard = getWizardActivity().getWizard(); + final WizardFlow flow = wizard.getFlow(); final boolean canGoNext = flow.getNextStep(step) != null; final boolean canGoPrev = flow.getPrevStep(step) != null; + final boolean firstTimeWizard = TextUtils.equals(wizard.getName(), CalculatorWizards.FIRST_TIME_WIZARD); if (canGoNext) { - if (canGoPrev) { + if (canGoPrev || !firstTimeWizard) { setupNextButton(R.string.acl_wizard_next); } else { setupNextButton(R.string.acl_wizard_start); @@ -74,7 +78,9 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis if (canGoPrev) { setupPrevButton(R.string.acl_wizard_back); } else { - setupPrevButton(R.string.wizard_skip); + if (firstTimeWizard) { + setupPrevButton(R.string.wizard_skip); + } } return view; @@ -83,11 +89,13 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis protected final void setupNextButton(int textResId) { assert nextButton != null; nextButton.setText(textResId); + nextButton.setVisibility(View.VISIBLE); } protected final void setupPrevButton(int textResId) { assert prevButton != null; prevButton.setText(textResId); + prevButton.setVisibility(View.VISIBLE); } @LayoutRes diff --git a/android-app/src/main/res/layout/cpp_activity_wizard.xml b/android-app/src/main/res/layout/cpp_activity_wizard.xml index 4c0e29eb..7f763b87 100644 --- a/android-app/src/main/res/layout/cpp_activity_wizard.xml +++ b/android-app/src/main/res/layout/cpp_activity_wizard.xml @@ -2,6 +2,7 @@ + a:text="@string/cpp_wizard_layout_title" /> + a:text="@string/cpp_wizard_mode_title"/> @@ -17,6 +18,7 @@ diff --git a/android-app/src/main/res/values-v21/theme.xml b/android-app/src/main/res/values-v21/theme.xml index dc7c52e0..98738578 100644 --- a/android-app/src/main/res/values-v21/theme.xml +++ b/android-app/src/main/res/values-v21/theme.xml @@ -32,4 +32,13 @@ @color/cpp_metro_button_dark + + \ 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 b668ee12..ed7fc753 100644 --- a/android-app/src/main/res/values/colors.xml +++ b/android-app/src/main/res/values/colors.xml @@ -29,7 +29,9 @@ #ffffffff #ffffff99 #ff000000 + #FAFAFA #212121 + #FAFAFA #424242 #616161 #757575