diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bf6d6da --- /dev/null +++ b/.travis.yml @@ -0,0 +1,39 @@ +language: java +jdk: oraclejdk7 +env: + matrix: + - ANDROID_SDKS=android-18,sysimg-18 ANDROID_TARGET=android-18 ANDROID_ABI=armeabi-v7a +before_install: + # Install base Android SDK + - sudo apt-get update -qq + - if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch > /dev/null; fi + - wget http://dl.google.com/android/android-sdk_r22.0.5-linux.tgz + - tar xzf android-sdk_r22.0.5-linux.tgz + - export ANDROID_HOME=$PWD/android-sdk-linux + - export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools + + # Gradle + - wget http://services.gradle.org/distributions/gradle-1.7-bin.zip + - unzip gradle-1.7-bin.zip + - export GRADLE_HOME=$PWD/gradle-1.7 + - export PATH=$GRADLE_HOME/bin:$PATH + + # install android build tools + - wget https://dl-ssl.google.com/android/repository/build-tools_r18.0.1-linux.zip + - unzip build-tools_r18.0.1-linux.zip -d $ANDROID_HOME + - mkdir -p $ANDROID_HOME/build-tools/ + - mv $ANDROID_HOME/android-4.3 $ANDROID_HOME/build-tools/18.0.1 + + # Install required components. + # For a full list, run `android list sdk -a --extended` + # Note that sysimg-18 downloads the ARM, x86 and MIPS images (we should optimize this). + # Other relevant API's + - echo yes | android update sdk --filter platform-tools --no-ui --force > /dev/null + - echo yes | android update sdk --filter android-17 --no-ui --force > /dev/null + - echo yes | android update sdk --filter android-18 --no-ui --force > /dev/null + - echo yes | android update sdk --filter sysimg-18 --no-ui --force > /dev/null + - echo yes | android update sdk --filter extra-android-support --no-ui --force > /dev/null + - echo yes | android update sdk --filter extra-android-m2repository --no-ui --force > /dev/null + +script: + - gradle assemble diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c101f73 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +Change Log +=============================================================================== + +Version 1.0.1 *(2013-10-06)* +---------------------------- + + * Fix: Crash when moving to another screen after the display orientation had changed in the middle of the wizard \ No newline at end of file diff --git a/build.gradle b/build.gradle index 847a496..9d5fda6 100755 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } allprojects { - version = "1.0.0" + version = "1.0.1" group = "org.codepond" } diff --git a/wizardroid-sample/src/main/AndroidManifest.xml b/wizardroid-sample/src/main/AndroidManifest.xml index 4d16599..6f1793f 100644 --- a/wizardroid-sample/src/main/AndroidManifest.xml +++ b/wizardroid-sample/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionCode="2" android:versionName="1.0.1"> - + \ No newline at end of file diff --git a/wizardroid/src/main/java/org/codepond/wizardroid/Wizard.java b/wizardroid/src/main/java/org/codepond/wizardroid/Wizard.java index fc0beb8..860ad8e 100644 --- a/wizardroid/src/main/java/org/codepond/wizardroid/Wizard.java +++ b/wizardroid/src/main/java/org/codepond/wizardroid/Wizard.java @@ -13,7 +13,8 @@ /** * The engine of the Wizard. This class controls the flow of the wizard * and is using {@link ViewPager} under the hood. You would normally want to - * extend {@link WizardFragment} instead of using this class directly. Use this + * extend {@link WizardFragment} instead of using this class directly and make calls to the wizard API + * via {@link org.codepond.wizardroid.WizardFragment#wizard} field. Use this * class only if you wish to create a custom WizardFragment to control the wizard. */ public class Wizard { @@ -40,7 +41,6 @@ public static interface WizardCallbacks { private final WizardCallbacks callbacks; private final ViewPager mPager; - private WizardStep[] wizardStepInstances; private boolean fingerSlide; @@ -181,7 +181,7 @@ public int getCurrentStepPosition() { * @return WizardStep the current WizardStep instance */ public WizardStep getCurrentStep() { - return wizardStepInstances[mPager.getCurrentItem()]; + return ((WizardPagerAdapter)mPager.getAdapter()).getPrimaryItem(); } /** @@ -206,14 +206,12 @@ public class WizardPagerAdapter extends FragmentStatePagerAdapter { public WizardPagerAdapter(FragmentManager fm) { super(fm); - wizardStepInstances = new WizardStep[getCount()]; } @Override public Fragment getItem(int i) { try { WizardStep step = wizardFlow.getSteps().get(i).newInstance(); - wizardStepInstances[i] = step; contextManager.loadStepContext(step); Log.v(TAG, "context loaded for " + step.toString()); return step; @@ -245,5 +243,9 @@ public int getItemPosition(Object object) { public int getCount() { return wizardFlow.getSteps().size(); } + + public WizardStep getPrimaryItem() { + return (WizardStep) mPrimaryItem; + } } } \ No newline at end of file diff --git a/wizardroid/src/main/java/org/codepond/wizardroid/WizardFlow.java b/wizardroid/src/main/java/org/codepond/wizardroid/WizardFlow.java index 0740bc6..6973e9f 100644 --- a/wizardroid/src/main/java/org/codepond/wizardroid/WizardFlow.java +++ b/wizardroid/src/main/java/org/codepond/wizardroid/WizardFlow.java @@ -23,8 +23,10 @@ public List> getSteps() { } /** - * Builder for {@link WizardFlow}. Use this class to build an instance of WizardFlow and - * eventually call {@link WizardFlow.Builder#create()} to create the instance. + * Builder for {@link WizardFlow}. Use this class to build an instance of WizardFlow. + * You need to use this class in your wizard's {@link WizardFragment#onSetup()} to return an instance of WizardFlow. + * Call {@link #addStep(Class)} to add steps to the flow, keeping in mind that the order you the steps + * will be the order the wizard will display them. Eventually call {@link WizardFlow.Builder#create()} to create the instance. */ public static class Builder { diff --git a/wizardroid/src/main/java/org/codepond/wizardroid/WizardFragment.java b/wizardroid/src/main/java/org/codepond/wizardroid/WizardFragment.java index d0c367d..dbf2ac6 100644 --- a/wizardroid/src/main/java/org/codepond/wizardroid/WizardFragment.java +++ b/wizardroid/src/main/java/org/codepond/wizardroid/WizardFragment.java @@ -15,6 +15,10 @@ * Extend this class to implement your own custom wizard layout and user {@link Wizard} API to * control the wizard. Typically, you'd call {@link Wizard#goNext()} and {@link Wizard#goBack()} * from your controls onClick event to control the flow of the wizard. + * The implementation takes care of persisting the instance of the fragment and therefore the wizard context. + * Keep in mind that if for some reason you are not able to extend this class and have to implement your + * own, then wizard context persistence is totally up to you by implementing {@link ContextManager} and passing + * an instance of it when you construct {@link Wizard}. */ public abstract class WizardFragment extends Fragment implements Wizard.WizardCallbacks { private static final String TAG = WizardFragment.class.getSimpleName(); diff --git a/wizardroid/src/main/java/org/codepond/wizardroid/WizardStep.java b/wizardroid/src/main/java/org/codepond/wizardroid/WizardStep.java index 7419fbc..712b6fa 100644 --- a/wizardroid/src/main/java/org/codepond/wizardroid/WizardStep.java +++ b/wizardroid/src/main/java/org/codepond/wizardroid/WizardStep.java @@ -9,7 +9,8 @@ import java.util.Date; /** - * Base class for a wizard's step. + * Base class for a wizard's step. Extend this class to create a step and override {@link #onExit(int)} + * to handle input and do tasks before the wizard changes the current step. * As with regular {@link Fragment} each inherited class must have an empty constructor. */ public abstract class WizardStep extends Fragment { @@ -27,6 +28,7 @@ public abstract class WizardStep extends Fragment { /** * Called when the wizard is about to go to the next step or * the previous step. Override this method to handle input from the step. + * Possible exit codes are {@link #EXIT_NEXT} and {@link #EXIT_PREVIOUS}. * @param exitCode Code indicating whether the wizard is going to the next or previous step. The value would either be * WizardStep.EXIT_NEXT when wizard is about to go to the next step or * WizardStep.EXIT_PREVIOUS when wizard is about to go to the previous step. @@ -34,6 +36,10 @@ public abstract class WizardStep extends Fragment { public void onExit(int exitCode) { } + /** + * IMPORTANT: This method is overridden to bind the wizard context to the step's fields. + * Make sure to call super.onAttach(activity), if you override this method in your step class. + */ @Override public void onAttach(Activity activity) { super.onAttach(activity); diff --git a/wizardroid/src/main/java/org/codepond/wizardroid/layouts/BasicWizardLayout.java b/wizardroid/src/main/java/org/codepond/wizardroid/layouts/BasicWizardLayout.java index 8b9ea1b..e043b73 100644 --- a/wizardroid/src/main/java/org/codepond/wizardroid/layouts/BasicWizardLayout.java +++ b/wizardroid/src/main/java/org/codepond/wizardroid/layouts/BasicWizardLayout.java @@ -16,6 +16,8 @@ * Otherwise, extend {@link WizardFragment} and implement a custom wizard layout. * Override {@link WizardFragment#onSetup()} to set up the wizard's flow * and optionally {@link WizardFragment#onWizardComplete()} to handle wizard's finish event. + * Note that button labels are changeable by calling {@link #setNextButtonText(String)}, {@link #setBackButtonText(String)} and + * {@link #setFinishButtonText(String)}. */ public abstract class BasicWizardLayout extends WizardFragment implements View.OnClickListener { @@ -35,7 +37,8 @@ public BasicWizardLayout() { super(); } /** - * Setting common layout for all wizards + * Setting the layout for this basic wizard layout and hooking up wizard controls to their + * OnClickListeners. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -80,7 +83,7 @@ else if (v.getId() == R.id.wizard_previous_button) { } /** - * Event triggered after a step was changed + * Event triggered after a step was changed, updating the button labels accordingly */ @Override public void onStepChanged() {