├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-v21 │ │ │ │ └── styles.xml │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── ids.xml │ │ │ ├── menu │ │ │ │ └── menu_main.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ ├── rotation_layout.xml │ │ │ │ ├── wizard_1_layout.xml │ │ │ │ ├── wizard_2_layout.xml │ │ │ │ ├── settings_layout.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── photo_display_layout.xml │ │ │ │ ├── root_layout.xml │ │ │ │ └── main_layout.xml │ │ ├── java │ │ │ └── co │ │ │ │ └── moonmonkeylabs │ │ │ │ └── flowmortarexampleapp │ │ │ │ ├── model │ │ │ │ └── WizardState.java │ │ │ │ ├── common │ │ │ │ ├── mortarscreen │ │ │ │ │ ├── ModuleFactory.java │ │ │ │ │ ├── WithModuleFactory.java │ │ │ │ │ ├── WithModule.java │ │ │ │ │ └── ScreenScoper.java │ │ │ │ ├── setting │ │ │ │ │ ├── LocalSetting.java │ │ │ │ │ ├── BooleanLocalSetting.java │ │ │ │ │ ├── LongLocalSetting.java │ │ │ │ │ ├── IntLocalSetting.java │ │ │ │ │ ├── StringLocalSetting.java │ │ │ │ │ └── AbstractLocalSetting.java │ │ │ │ ├── lifecycle │ │ │ │ │ ├── ActivityLifecycleListener.java │ │ │ │ │ ├── LifecycleActivity.java │ │ │ │ │ ├── LifecycleViewPresenter.java │ │ │ │ │ └── LifecycleOwner.java │ │ │ │ ├── flow │ │ │ │ │ ├── FlowHistoryDevHelper.java │ │ │ │ │ ├── ActivityHelper.java │ │ │ │ │ ├── BackSupport.java │ │ │ │ │ ├── Layout.java │ │ │ │ │ ├── HandlesBack.java │ │ │ │ │ ├── Utils.java │ │ │ │ │ ├── FramePathContainerView.java │ │ │ │ │ ├── GsonParceler.java │ │ │ │ │ └── SimplePathContainer.java │ │ │ │ ├── widget │ │ │ │ │ ├── CustomFrameLayout.java │ │ │ │ │ ├── CustomLinearLayout.java │ │ │ │ │ └── CustomRelativeLayout.java │ │ │ │ ├── dagger │ │ │ │ │ ├── Blueprint.java │ │ │ │ │ └── ObjectGraphService.java │ │ │ │ ├── flowmortar │ │ │ │ │ ├── MortarScreenSwitcherFrame.java │ │ │ │ │ └── MortarContextFactory.java │ │ │ │ └── actionbar │ │ │ │ │ └── ActionBarOwner.java │ │ │ │ ├── setting │ │ │ │ ├── UserPreferredName.java │ │ │ │ └── SettingsModule.java │ │ │ │ ├── view │ │ │ │ ├── RotationView.java │ │ │ │ ├── Wizard2View.java │ │ │ │ ├── SettingView.java │ │ │ │ ├── PhotoDisplayView.java │ │ │ │ ├── Wizard1View.java │ │ │ │ └── MainView.java │ │ │ │ ├── ActivityModule.java │ │ │ │ ├── WizardModule.java │ │ │ │ ├── FlowMortarExampleApplication.java │ │ │ │ ├── screen │ │ │ │ ├── RotationScreen.java │ │ │ │ ├── SettingScreen.java │ │ │ │ ├── Wizard2Screen.java │ │ │ │ ├── Wizard1Screen.java │ │ │ │ ├── MainScreen.java │ │ │ │ └── PhotoDisplayScreen.java │ │ │ │ ├── ApplicationModule.java │ │ │ │ └── FlowMortarExampleActivity.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── co │ │ └── moonmonkeylabs │ │ └── flowmortarexampleapp │ │ └── ApplicationTest.java ├── proguard-rules.pro ├── build.gradle └── app.iml ├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── scopes │ └── scope_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── settings.gradle ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── FlowMortarExampleApp.iml ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | FlowMortarExampleApp -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thorbenprimke/mortar-flow-example-app/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thorbenprimke/mortar-flow-example-app/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thorbenprimke/mortar-flow-example-app/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thorbenprimke/mortar-flow-example-app/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thorbenprimke/mortar-flow-example-app/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mortar-flow-example-app 2 | An example project that showcases Mortar and Flow 3 | 4 | Slides are here: http://speakerdeck.com/thorbenprimke/an-alternative-to-fragments-say-hello-to-mortar-plus-flow 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Flow + Mortar 3 | 4 | Hello world! 5 | Settings 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/model/WizardState.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.model; 2 | 3 | public class WizardState { 4 | 5 | public int count; 6 | 7 | public WizardState() { 8 | count = 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/common/mortarscreen/ModuleFactory.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.common.mortarscreen; 2 | 3 | import android.content.res.Resources; 4 | 5 | /** @see WithModuleFactory */ 6 | public abstract class ModuleFactory { 7 | protected abstract Object createDaggerModule(Resources resources, T screen); 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/androidTest/java/co/moonmonkeylabs/flowmortarexampleapp/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/rotation_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/setting/UserPreferredName.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.setting; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.Retention; 5 | 6 | import javax.inject.Qualifier; 7 | 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | 10 | /** 11 | * Annotation for the user's preferred name setting. 12 | */ 13 | @Documented 14 | @Retention(RUNTIME) 15 | @Qualifier 16 | public @interface UserPreferredName { 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/common/setting/LocalSetting.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.common.setting; 2 | 3 | /** 4 | * Interface for local settings. 5 | */ 6 | public interface LocalSetting { 7 | 8 | /** 9 | * Returns the value. If the value has never been set the default varies per implementation. 10 | * For certainty in this case use {@link #get(T)}. 11 | */ 12 | T get(); 13 | 14 | T get(T defaultValue); 15 | 16 | void set(T value); 17 | 18 | void remove(); 19 | } -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/common/lifecycle/ActivityLifecycleListener.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.common.lifecycle; 2 | 3 | import android.content.Intent; 4 | 5 | /** 6 | * Listen to lifecycle events. 7 | */ 8 | public interface ActivityLifecycleListener { 9 | 10 | public void onActivityResume(); 11 | 12 | public void onActivityPause(); 13 | 14 | public void onActivityStart(); 15 | 16 | public void onActivityStop(); 17 | 18 | public void onLowMemory(); 19 | 20 | public void onActivityResult(int requestCode, int resultCode, Intent data); 21 | } 22 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/common/setting/BooleanLocalSetting.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.common.setting; 2 | 3 | import android.content.SharedPreferences; 4 | 5 | public class BooleanLocalSetting extends AbstractLocalSetting { 6 | 7 | public BooleanLocalSetting(SharedPreferences preferences, String key) { 8 | super(preferences, key); 9 | } 10 | 11 | @Override 12 | protected Boolean doGet() { 13 | return preferences.getBoolean(key, false); 14 | } 15 | 16 | @Override 17 | public void set(Boolean value) { 18 | apply(preferences.edit().putBoolean(key, value)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/common/mortarscreen/WithModuleFactory.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.common.mortarscreen; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Marks a screen as defining a {@link mortar.MortarScope}, with a factory class to 10 | * create its Dagger module. 11 | * 12 | * @see WithModule 13 | * @see ScreenScoper 14 | */ 15 | @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) 16 | public @interface WithModuleFactory { 17 | Class value(); 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/common/setting/LongLocalSetting.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.common.setting; 2 | 3 | import android.content.SharedPreferences; 4 | 5 | /** 6 | * Local setting for any values of type {@link Long}. 7 | */ 8 | public class LongLocalSetting extends AbstractLocalSetting { 9 | 10 | public LongLocalSetting(SharedPreferences preferences, String key) { 11 | super(preferences, key); 12 | } 13 | 14 | @Override 15 | protected Long doGet() { 16 | return preferences.getLong(key, 0L); 17 | } 18 | 19 | @Override 20 | public void set(Long value) { 21 | apply(preferences.edit().putLong(key, value)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/thorben/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/common/setting/IntLocalSetting.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.common.setting; 2 | 3 | import android.content.SharedPreferences; 4 | 5 | import java.lang.Integer; 6 | 7 | /** 8 | * Local setting for any values of type {@link Integer}. 9 | */ 10 | public class IntLocalSetting extends AbstractLocalSetting { 11 | 12 | 13 | public IntLocalSetting(SharedPreferences preferences, String key) { 14 | super(preferences, key); 15 | } 16 | 17 | @Override 18 | protected Integer doGet() { 19 | return preferences.getInt(key, 0); 20 | } 21 | 22 | @Override 23 | public void set(Integer value) { 24 | apply(preferences.edit().putInt(key, value)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/co/moonmonkeylabs/flowmortarexampleapp/common/mortarscreen/WithModule.java: -------------------------------------------------------------------------------- 1 | package co.moonmonkeylabs.flowmortarexampleapp.common.mortarscreen; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Marks a screen as defining a {@link mortar.MortarScope}, with the class of a Dagger module 10 | * to instantiate via reflection. The module must be a static type with a default 11 | * constructor. For more flexibility, use {@link WithModuleFactory}. 12 | * 13 | * @see ScreenScoper 14 | */ 15 | @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) 16 | public @interface WithModule { 17 | Class value(); 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/wizard_1_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 |