Wizard changes

This commit is contained in:
serso 2015-02-01 18:05:59 +01:00
parent f2320fbe8a
commit a56756e8ce
10 changed files with 39 additions and 11 deletions

View File

@ -77,7 +77,7 @@ public class ActivityUi extends BaseUi {
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
theme = Preferences.Gui.getTheme(preferences); theme = Preferences.Gui.getTheme(preferences);
activity.setTheme(theme.getThemeId()); activity.setTheme(theme.getThemeId(activity));
this.layout = Preferences.Gui.getLayout(preferences); this.layout = Preferences.Gui.getLayout(preferences);

View File

@ -22,15 +22,18 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.NumeralBase; import jscl.NumeralBase;
import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.math.MathType;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine; import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.wizard.WizardActivity;
import org.solovyev.android.prefs.*; import org.solovyev.android.prefs.*;
import org.solovyev.android.view.VibratorContainer; import org.solovyev.android.view.VibratorContainer;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.Locale; import java.util.Locale;
@ -123,6 +126,14 @@ public final class Preferences {
@Nonnull @Nonnull
public Integer getThemeId() { public Integer getThemeId() {
return getThemeId(null);
}
@Nonnull
public Integer getThemeId(@Nullable Activity activity) {
if (activity instanceof WizardActivity) {
return R.style.Theme_Wizard;
}
return themeId; return themeId;
} }
} }

View File

@ -30,11 +30,6 @@ import org.solovyev.android.calculator.R;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/**
* User: serso
* Date: 6/16/13
* Time: 9:17 PM
*/
enum CalculatorWizardStep implements org.solovyev.android.wizard.WizardStep { 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),

View File

@ -3,11 +3,13 @@ package org.solovyev.android.calculator.wizard;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import org.solovyev.android.calculator.R; import org.solovyev.android.calculator.R;
import org.solovyev.android.wizard.Wizard;
import org.solovyev.android.wizard.WizardFlow; import org.solovyev.android.wizard.WizardFlow;
import org.solovyev.android.wizard.WizardStep; import org.solovyev.android.wizard.WizardStep;
@ -58,11 +60,13 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
prevButton.setOnClickListener(this); 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 canGoNext = flow.getNextStep(step) != null;
final boolean canGoPrev = flow.getPrevStep(step) != null; final boolean canGoPrev = flow.getPrevStep(step) != null;
final boolean firstTimeWizard = TextUtils.equals(wizard.getName(), CalculatorWizards.FIRST_TIME_WIZARD);
if (canGoNext) { if (canGoNext) {
if (canGoPrev) { if (canGoPrev || !firstTimeWizard) {
setupNextButton(R.string.acl_wizard_next); setupNextButton(R.string.acl_wizard_next);
} else { } else {
setupNextButton(R.string.acl_wizard_start); setupNextButton(R.string.acl_wizard_start);
@ -74,8 +78,10 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
if (canGoPrev) { if (canGoPrev) {
setupPrevButton(R.string.acl_wizard_back); setupPrevButton(R.string.acl_wizard_back);
} else { } else {
if (firstTimeWizard) {
setupPrevButton(R.string.wizard_skip); setupPrevButton(R.string.wizard_skip);
} }
}
return view; return view;
} }
@ -83,11 +89,13 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
protected final void setupNextButton(int textResId) { protected final void setupNextButton(int textResId) {
assert nextButton != null; assert nextButton != null;
nextButton.setText(textResId); nextButton.setText(textResId);
nextButton.setVisibility(View.VISIBLE);
} }
protected final void setupPrevButton(int textResId) { protected final void setupPrevButton(int textResId) {
assert prevButton != null; assert prevButton != null;
prevButton.setText(textResId); prevButton.setText(textResId);
prevButton.setVisibility(View.VISIBLE);
} }
@LayoutRes @LayoutRes

View File

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:my="http://schemas.android.com/apk/res-auto" xmlns:my="http://schemas.android.com/apk/res-auto"
style="@style/MaterialActivity" style="@style/MaterialActivity"
android:padding="0dp"
android:orientation="vertical"> android:orientation="vertical">
<android.support.v4.view.ViewPager <android.support.v4.view.ViewPager

View File

@ -33,7 +33,7 @@
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:textAppearance="@android:style/TextAppearance.Large" a:textAppearance="@android:style/TextAppearance.Large"
style="@style/WizardLabel" style="@style/WizardLabel"
a:text="Choose layout" /> a:text="@string/cpp_wizard_layout_title" />
<Spinner <Spinner
a:id="@+id/wizard_layout_spinner" a:id="@+id/wizard_layout_spinner"

View File

@ -33,7 +33,7 @@
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:textAppearance="@android:style/TextAppearance.Large" a:textAppearance="@android:style/TextAppearance.Large"
style="@style/WizardLabel" style="@style/WizardLabel"
a:text="Choose mode"/> a:text="@string/cpp_wizard_mode_title"/>
<Spinner <Spinner
a:id="@+id/wizard_mode_spinner" a:id="@+id/wizard_mode_spinner"

View File

@ -10,6 +10,7 @@
<org.solovyev.android.material.MaterialButton <org.solovyev.android.material.MaterialButton
style="@style/MaterialButton.Wizard" style="@style/MaterialButton.Wizard"
a:id="@+id/wizard_prev" a:id="@+id/wizard_prev"
a:visibility="gone"
a:layout_width="0dp" a:layout_width="0dp"
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" /> a:layout_weight="1" />
@ -17,6 +18,7 @@
<org.solovyev.android.material.MaterialButton <org.solovyev.android.material.MaterialButton
style="@style/MaterialButton.Wizard" style="@style/MaterialButton.Wizard"
a:id="@+id/wizard_next" a:id="@+id/wizard_next"
a:visibility="gone"
a:layout_width="0dp" a:layout_width="0dp"
a:layout_height="wrap_content" a:layout_height="wrap_content"
a:layout_weight="1" /> a:layout_weight="1" />

View File

@ -32,4 +32,13 @@
<item name="android:colorPrimaryDark">@color/cpp_metro_button_dark</item> <item name="android:colorPrimaryDark">@color/cpp_metro_button_dark</item>
</style> </style>
<style name="Theme.Wizard" parent="@style/cpp_metro_blue_theme">
<item name="android:windowBackground">@color/cpp_wizard_bg</item>
<item name="android:colorEdgeEffect">@color/cpp_wizard_overscroll</item>
<item name="colorAccent">@color/cpp_wizard_primary</item>
<item name="android:colorAccent">@color/cpp_wizard_primary</item>
<item name="android:textColorSecondary">@color/cpp_wizard_primary</item>
<item name="android:textColorPrimary">@color/cpp_wizard_primary</item>
</style>
</resources> </resources>

View File

@ -29,7 +29,9 @@
<color name="cpp_button_text_ce">#ffffffff</color> <color name="cpp_button_text_ce">#ffffffff</color>
<color name="cpp_selected_angle_unit_text">#ffffff99</color> <color name="cpp_selected_angle_unit_text">#ffffff99</color>
<color name="cpp_main_bg">#ff000000</color> <color name="cpp_main_bg">#ff000000</color>
<color name="cpp_wizard_primary">#FAFAFA</color>
<color name="cpp_wizard_bg">#212121</color> <color name="cpp_wizard_bg">#212121</color>
<color name="cpp_wizard_overscroll">#FAFAFA</color>
<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>