Wizard -> Wizards

This commit is contained in:
Sergey Solovyev 2013-06-25 23:09:59 +04:00
parent b4198f7918
commit d800895380
6 changed files with 27 additions and 28 deletions

View File

@ -21,7 +21,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
@ -45,9 +44,9 @@ import static android.os.Build.VERSION_CODES.GINGERBREAD_MR1;
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
import static org.solovyev.android.calculator.CalculatorPreferences.Gui.preventScreenFromFading;
import static org.solovyev.android.calculator.wizard.Wizard.FIRST_TIME_WIZARD;
import static org.solovyev.android.calculator.wizard.Wizard.isWizardFinished;
import static org.solovyev.android.calculator.wizard.Wizard.isWizardStarted;
import static org.solovyev.android.calculator.wizard.Wizards.FIRST_TIME_WIZARD;
import static org.solovyev.android.calculator.wizard.Wizards.isWizardFinished;
import static org.solovyev.android.calculator.wizard.Wizards.isWizardStarted;
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener {

View File

@ -27,7 +27,7 @@ import org.solovyev.android.ads.AdsController;
import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.calculator.wizard.CalculatorWizardActivity;
import org.solovyev.android.calculator.wizard.Wizard;
import org.solovyev.android.calculator.wizard.Wizards;
import org.solovyev.android.msg.AndroidMessage;
import org.solovyev.android.view.VibratorContainer;
import org.solovyev.common.msg.Message;
@ -60,7 +60,7 @@ public class CalculatorPreferencesActivity extends SherlockPreferenceActivity im
restartWizardPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
CalculatorWizardActivity.startWizard(Wizard.DEFAULT_WIZARD_FLOW, CalculatorPreferencesActivity.this);
CalculatorWizardActivity.startWizard(Wizards.DEFAULT_WIZARD_FLOW, CalculatorPreferencesActivity.this);
return true;
}
});

View File

@ -5,8 +5,8 @@ import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import static org.solovyev.android.calculator.wizard.Wizard.DEFAULT_WIZARD_FLOW;
import static org.solovyev.android.calculator.wizard.Wizard.FIRST_TIME_WIZARD;
import static org.solovyev.android.calculator.wizard.Wizards.DEFAULT_WIZARD_FLOW;
import static org.solovyev.android.calculator.wizard.Wizards.FIRST_TIME_WIZARD;
import static org.solovyev.android.calculator.wizard.WizardStep.welcome;
/**

View File

@ -14,8 +14,8 @@ import javax.annotation.Nonnull;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static org.solovyev.android.calculator.wizard.Wizard.FLOW;
import static org.solovyev.android.calculator.wizard.Wizard.STEP;
import static org.solovyev.android.calculator.wizard.Wizards.FLOW;
import static org.solovyev.android.calculator.wizard.Wizards.STEP;
/**
* User: serso
@ -64,7 +64,7 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
stepName = savedInstanceState.getString(STEP);
}
flow = Wizard.getWizardFlow(wizardName != null ? wizardName : Wizard.FIRST_TIME_WIZARD);
flow = Wizards.getWizardFlow(wizardName != null ? wizardName : Wizards.FIRST_TIME_WIZARD);
WizardStep step = null;
if(stepName != null) {
@ -155,7 +155,7 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
void finishFlow(boolean forceFinish) {
if (flow != null && step != null) {
Wizard.saveWizardFinished(flow, step, forceFinish);
Wizards.saveWizardFinished(flow, step, forceFinish);
}
finish();
}
@ -236,7 +236,7 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
super.onPause();
if (flow != null && step != null) {
Wizard.saveLastWizardStep(flow, step);
Wizards.saveLastWizardStep(flow, step);
}
}
@ -280,7 +280,7 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
public static void continueWizard(@Nonnull String name, @Nonnull Context context) {
final Intent intent = createLaunchIntent(name, context);
final String step = Wizard.getLastSavedWizardStepName(name);
final String step = Wizards.getLastSavedWizardStepName(name);
if (step != null) {
intent.putExtra(STEP, step);
}

View File

@ -15,7 +15,7 @@ import static org.solovyev.android.calculator.wizard.AppWizardFlow.newFirstTimeW
* Date: 6/16/13
* Time: 9:23 PM
*/
public final class Wizard {
public final class Wizards {
public static final String FIRST_TIME_WIZARD = "first-wizard";
public static final String DEFAULT_WIZARD_FLOW = "app-wizard";
@ -23,7 +23,7 @@ public final class Wizard {
static final String FLOW_FINISHED = "flow_finished";
static final String STEP = "step";
private Wizard() {
private Wizards() {
throw new AssertionError();
}

View File

@ -44,7 +44,7 @@ public class CalculatorWizardActivityTest {
@Test
public void testShouldBeFirstTimeWizardByDefault() throws Exception {
assertEquals(Wizard.FIRST_TIME_WIZARD, activity.getFlow().getName());
assertEquals(Wizards.FIRST_TIME_WIZARD, activity.getFlow().getName());
}
@Test
@ -65,7 +65,7 @@ public class CalculatorWizardActivityTest {
activity = controller.get();
assertNotNull(activity.getFlow());
assertEquals(Wizard.FIRST_TIME_WIZARD, activity.getFlow().getName());
assertEquals(Wizards.FIRST_TIME_WIZARD, activity.getFlow().getName());
assertNotNull(activity.getStep());
assertEquals(choose_mode, activity.getStep());
}
@ -74,11 +74,11 @@ public class CalculatorWizardActivityTest {
public void testCreate() throws Exception {
final Intent intent = new Intent();
intent.setClass(activity, CalculatorWizardActivity.class);
intent.putExtra(Wizard.FLOW, Wizard.DEFAULT_WIZARD_FLOW);
intent.putExtra(Wizards.FLOW, Wizards.DEFAULT_WIZARD_FLOW);
controller = Robolectric.buildActivity(CalculatorWizardActivity.class).withIntent(intent);
controller.create();
activity = controller.get();
assertEquals(Wizard.DEFAULT_WIZARD_FLOW, activity.getFlow().getName());
assertEquals(Wizards.DEFAULT_WIZARD_FLOW, activity.getFlow().getName());
assertEquals(activity.getFlow().getFirstStep(), activity.getStep());
final Bundle outState1 = new Bundle();
@ -87,7 +87,7 @@ public class CalculatorWizardActivityTest {
controller = Robolectric.buildActivity(CalculatorWizardActivity.class);
activity = controller.get();
controller.create(outState1);
assertEquals(Wizard.DEFAULT_WIZARD_FLOW, activity.getFlow().getName());
assertEquals(Wizards.DEFAULT_WIZARD_FLOW, activity.getFlow().getName());
assertEquals(activity.getFlow().getFirstStep(), activity.getStep());
}
@ -123,7 +123,7 @@ public class CalculatorWizardActivityTest {
@Test
public void testShouldStartWizardActivityAfterStart() throws Exception {
final ShadowActivity shadowActivity = Robolectric.shadowOf(controller.get());
startWizard(Wizard.DEFAULT_WIZARD_FLOW, shadowActivity.getApplicationContext());
startWizard(Wizards.DEFAULT_WIZARD_FLOW, shadowActivity.getApplicationContext());
assertNotNull(shadowActivity.getNextStartedActivity());
}
@ -159,25 +159,25 @@ public class CalculatorWizardActivityTest {
@Test
public void testShouldSaveLastWizardStateOnPause() throws Exception {
assertNull(Wizard.getLastSavedWizardStepName(activity.getFlow().getName()));
assertNull(Wizards.getLastSavedWizardStepName(activity.getFlow().getName()));
activity.setStep(WizardStep.drag_button_step);
activity.onPause();
assertEquals(WizardStep.drag_button_step.getName(), Wizard.getLastSavedWizardStepName(activity.getFlow().getName()));
assertEquals(WizardStep.drag_button_step.getName(), Wizards.getLastSavedWizardStepName(activity.getFlow().getName()));
}
@Test
public void testShouldSaveFinishedIfLastStep() throws Exception {
assertFalse(Wizard.isWizardFinished(activity.getFlow().getName()));
assertFalse(Wizards.isWizardFinished(activity.getFlow().getName()));
setLastStep();
activity.finishFlow();
assertTrue(Wizard.isWizardFinished(activity.getFlow().getName()));
assertTrue(Wizards.isWizardFinished(activity.getFlow().getName()));
}
@Test
public void testShouldNotSaveFinishedIfNotLastStep() throws Exception {
assertFalse(Wizard.isWizardFinished(activity.getFlow().getName()));
assertFalse(Wizards.isWizardFinished(activity.getFlow().getName()));
setFirstStep();
activity.finishFlow();
assertFalse(Wizard.isWizardFinished(activity.getFlow().getName()));
assertFalse(Wizards.isWizardFinished(activity.getFlow().getName()));
}
}