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);
theme = Preferences.Gui.getTheme(preferences);
activity.setTheme(theme.getThemeId());
activity.setTheme(theme.getThemeId(activity));
this.layout = Preferences.Gui.getLayout(preferences);

View File

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

View File

@ -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),

View File

@ -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,8 +78,10 @@ public abstract class WizardFragment extends Fragment implements View.OnClickLis
if (canGoPrev) {
setupPrevButton(R.string.acl_wizard_back);
} else {
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

View File

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

View File

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

View File

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

View File

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

View File

@ -32,4 +32,13 @@
<item name="android:colorPrimaryDark">@color/cpp_metro_button_dark</item>
</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>

View File

@ -29,7 +29,9 @@
<color name="cpp_button_text_ce">#ffffffff</color>
<color name="cpp_selected_angle_unit_text">#ffffff99</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_overscroll">#FAFAFA</color>
<color name="cpp_wizard_button_normal">#424242</color>
<color name="cpp_wizard_button_disabled">#616161</color>
<color name="cpp_wizard_button_pressed">#757575</color>