Wizard -> Wizards
This commit is contained in:
parent
b4198f7918
commit
d800895380
@ -21,7 +21,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.actionbarsherlock.app.ActionBar;
|
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.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
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.CalculatorPreferences.Gui.preventScreenFromFading;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizard.FIRST_TIME_WIZARD;
|
import static org.solovyev.android.calculator.wizard.Wizards.FIRST_TIME_WIZARD;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizard.isWizardFinished;
|
import static org.solovyev.android.calculator.wizard.Wizards.isWizardFinished;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizard.isWizardStarted;
|
import static org.solovyev.android.calculator.wizard.Wizards.isWizardStarted;
|
||||||
|
|
||||||
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener {
|
public class CalculatorActivity extends SherlockFragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener, CalculatorEventListener {
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import org.solovyev.android.ads.AdsController;
|
|||||||
import org.solovyev.android.calculator.*;
|
import org.solovyev.android.calculator.*;
|
||||||
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
|
||||||
import org.solovyev.android.calculator.wizard.CalculatorWizardActivity;
|
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.msg.AndroidMessage;
|
||||||
import org.solovyev.android.view.VibratorContainer;
|
import org.solovyev.android.view.VibratorContainer;
|
||||||
import org.solovyev.common.msg.Message;
|
import org.solovyev.common.msg.Message;
|
||||||
@ -60,7 +60,7 @@ public class CalculatorPreferencesActivity extends SherlockPreferenceActivity im
|
|||||||
restartWizardPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
restartWizardPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
CalculatorWizardActivity.startWizard(Wizard.DEFAULT_WIZARD_FLOW, CalculatorPreferencesActivity.this);
|
CalculatorWizardActivity.startWizard(Wizards.DEFAULT_WIZARD_FLOW, CalculatorPreferencesActivity.this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -5,8 +5,8 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.solovyev.android.calculator.wizard.Wizard.DEFAULT_WIZARD_FLOW;
|
import static org.solovyev.android.calculator.wizard.Wizards.DEFAULT_WIZARD_FLOW;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizard.FIRST_TIME_WIZARD;
|
import static org.solovyev.android.calculator.wizard.Wizards.FIRST_TIME_WIZARD;
|
||||||
import static org.solovyev.android.calculator.wizard.WizardStep.welcome;
|
import static org.solovyev.android.calculator.wizard.WizardStep.welcome;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,8 +14,8 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizard.FLOW;
|
import static org.solovyev.android.calculator.wizard.Wizards.FLOW;
|
||||||
import static org.solovyev.android.calculator.wizard.Wizard.STEP;
|
import static org.solovyev.android.calculator.wizard.Wizards.STEP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User: serso
|
* User: serso
|
||||||
@ -64,7 +64,7 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
|
|||||||
stepName = savedInstanceState.getString(STEP);
|
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;
|
WizardStep step = null;
|
||||||
if(stepName != null) {
|
if(stepName != null) {
|
||||||
@ -155,7 +155,7 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
|
|||||||
|
|
||||||
void finishFlow(boolean forceFinish) {
|
void finishFlow(boolean forceFinish) {
|
||||||
if (flow != null && step != null) {
|
if (flow != null && step != null) {
|
||||||
Wizard.saveWizardFinished(flow, step, forceFinish);
|
Wizards.saveWizardFinished(flow, step, forceFinish);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
|
|||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (flow != null && step != null) {
|
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) {
|
public static void continueWizard(@Nonnull String name, @Nonnull Context context) {
|
||||||
final Intent intent = createLaunchIntent(name, context);
|
final Intent intent = createLaunchIntent(name, context);
|
||||||
|
|
||||||
final String step = Wizard.getLastSavedWizardStepName(name);
|
final String step = Wizards.getLastSavedWizardStepName(name);
|
||||||
if (step != null) {
|
if (step != null) {
|
||||||
intent.putExtra(STEP, step);
|
intent.putExtra(STEP, step);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import static org.solovyev.android.calculator.wizard.AppWizardFlow.newFirstTimeW
|
|||||||
* Date: 6/16/13
|
* Date: 6/16/13
|
||||||
* Time: 9:23 PM
|
* 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 FIRST_TIME_WIZARD = "first-wizard";
|
||||||
public static final String DEFAULT_WIZARD_FLOW = "app-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 FLOW_FINISHED = "flow_finished";
|
||||||
static final String STEP = "step";
|
static final String STEP = "step";
|
||||||
|
|
||||||
private Wizard() {
|
private Wizards() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +44,7 @@ public class CalculatorWizardActivityTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldBeFirstTimeWizardByDefault() throws Exception {
|
public void testShouldBeFirstTimeWizardByDefault() throws Exception {
|
||||||
assertEquals(Wizard.FIRST_TIME_WIZARD, activity.getFlow().getName());
|
assertEquals(Wizards.FIRST_TIME_WIZARD, activity.getFlow().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -65,7 +65,7 @@ public class CalculatorWizardActivityTest {
|
|||||||
|
|
||||||
activity = controller.get();
|
activity = controller.get();
|
||||||
assertNotNull(activity.getFlow());
|
assertNotNull(activity.getFlow());
|
||||||
assertEquals(Wizard.FIRST_TIME_WIZARD, activity.getFlow().getName());
|
assertEquals(Wizards.FIRST_TIME_WIZARD, activity.getFlow().getName());
|
||||||
assertNotNull(activity.getStep());
|
assertNotNull(activity.getStep());
|
||||||
assertEquals(choose_mode, activity.getStep());
|
assertEquals(choose_mode, activity.getStep());
|
||||||
}
|
}
|
||||||
@ -74,11 +74,11 @@ public class CalculatorWizardActivityTest {
|
|||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.setClass(activity, CalculatorWizardActivity.class);
|
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 = Robolectric.buildActivity(CalculatorWizardActivity.class).withIntent(intent);
|
||||||
controller.create();
|
controller.create();
|
||||||
activity = controller.get();
|
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());
|
assertEquals(activity.getFlow().getFirstStep(), activity.getStep());
|
||||||
|
|
||||||
final Bundle outState1 = new Bundle();
|
final Bundle outState1 = new Bundle();
|
||||||
@ -87,7 +87,7 @@ public class CalculatorWizardActivityTest {
|
|||||||
controller = Robolectric.buildActivity(CalculatorWizardActivity.class);
|
controller = Robolectric.buildActivity(CalculatorWizardActivity.class);
|
||||||
activity = controller.get();
|
activity = controller.get();
|
||||||
controller.create(outState1);
|
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());
|
assertEquals(activity.getFlow().getFirstStep(), activity.getStep());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ public class CalculatorWizardActivityTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testShouldStartWizardActivityAfterStart() throws Exception {
|
public void testShouldStartWizardActivityAfterStart() throws Exception {
|
||||||
final ShadowActivity shadowActivity = Robolectric.shadowOf(controller.get());
|
final ShadowActivity shadowActivity = Robolectric.shadowOf(controller.get());
|
||||||
startWizard(Wizard.DEFAULT_WIZARD_FLOW, shadowActivity.getApplicationContext());
|
startWizard(Wizards.DEFAULT_WIZARD_FLOW, shadowActivity.getApplicationContext());
|
||||||
assertNotNull(shadowActivity.getNextStartedActivity());
|
assertNotNull(shadowActivity.getNextStartedActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,25 +159,25 @@ public class CalculatorWizardActivityTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldSaveLastWizardStateOnPause() throws Exception {
|
public void testShouldSaveLastWizardStateOnPause() throws Exception {
|
||||||
assertNull(Wizard.getLastSavedWizardStepName(activity.getFlow().getName()));
|
assertNull(Wizards.getLastSavedWizardStepName(activity.getFlow().getName()));
|
||||||
activity.setStep(WizardStep.drag_button_step);
|
activity.setStep(WizardStep.drag_button_step);
|
||||||
activity.onPause();
|
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
|
@Test
|
||||||
public void testShouldSaveFinishedIfLastStep() throws Exception {
|
public void testShouldSaveFinishedIfLastStep() throws Exception {
|
||||||
assertFalse(Wizard.isWizardFinished(activity.getFlow().getName()));
|
assertFalse(Wizards.isWizardFinished(activity.getFlow().getName()));
|
||||||
setLastStep();
|
setLastStep();
|
||||||
activity.finishFlow();
|
activity.finishFlow();
|
||||||
assertTrue(Wizard.isWizardFinished(activity.getFlow().getName()));
|
assertTrue(Wizards.isWizardFinished(activity.getFlow().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldNotSaveFinishedIfNotLastStep() throws Exception {
|
public void testShouldNotSaveFinishedIfNotLastStep() throws Exception {
|
||||||
assertFalse(Wizard.isWizardFinished(activity.getFlow().getName()));
|
assertFalse(Wizards.isWizardFinished(activity.getFlow().getName()));
|
||||||
setFirstStep();
|
setFirstStep();
|
||||||
activity.finishFlow();
|
activity.finishFlow();
|
||||||
assertFalse(Wizard.isWizardFinished(activity.getFlow().getName()));
|
assertFalse(Wizards.isWizardFinished(activity.getFlow().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user