diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..39fb081a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 000000000..7ac24c777 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..ba7052b81 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..1026e73fb --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 000000000..7f68460d8 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 000000000..2940d6671 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'com.android.application' +apply plugin: 'com.neenbedankt.android-apt' + + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.2" + defaultConfig { + applicationId "org.mifos.mobilewallet" + minSdkVersion 15 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + compileOptions.incremental = false +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:25.3.1' + + compile 'com.jakewharton:butterknife:8.6.0' + apt 'com.jakewharton:butterknife-compiler:8.6.0' + annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0' + + compile 'com.google.dagger:dagger:2.11' + annotationProcessor 'com.google.dagger:dagger-compiler:2.11' + apt 'com.google.dagger:dagger-compiler:2.11' + + + testCompile 'junit:junit:4.12' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 000000000..6a795823c --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/naman/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/org/mifos/mobilewallet/ExampleInstrumentedTest.java b/app/src/androidTest/java/org/mifos/mobilewallet/ExampleInstrumentedTest.java new file mode 100644 index 000000000..c6d0bed6f --- /dev/null +++ b/app/src/androidTest/java/org/mifos/mobilewallet/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package org.mifos.mobilewallet; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("org.mifos.mobilewallet", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..b38c311aa --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/org/mifos/mobilewallet/MifosWalletApp.java b/app/src/main/java/org/mifos/mobilewallet/MifosWalletApp.java new file mode 100644 index 000000000..485d72255 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/MifosWalletApp.java @@ -0,0 +1,51 @@ +package org.mifos.mobilewallet; + +import android.app.Application; +import android.content.Context; + +import org.mifos.mobilewallet.injection.component.ApplicationComponent; +import org.mifos.mobilewallet.injection.component.DaggerApplicationComponent; +import org.mifos.mobilewallet.injection.module.ApplicationModule; + +import butterknife.ButterKnife; + +/** + * Created by naman on 16/6/17. + */ + +public class MifosWalletApp extends Application { + + ApplicationComponent applicationComponent; + + private static MifosWalletApp instance; + + public static MifosWalletApp get(Context context) { + return (MifosWalletApp) context.getApplicationContext(); + } + + public static Context getContext() { + return instance; + } + + @Override + public void onCreate() { + super.onCreate(); + instance = this; + ButterKnife.setDebug(true); + } + + public ApplicationComponent component() { + if (applicationComponent == null) { + applicationComponent = DaggerApplicationComponent.builder() + .applicationModule(new ApplicationModule(this)) + .build(); + } + return applicationComponent; + } + + // Needed to replace the component with a test specific one + public void setComponent(ApplicationComponent applicationComponent) { + this.applicationComponent = applicationComponent; + } + +} diff --git a/app/src/main/java/org/mifos/mobilewallet/auth/AuthContract.java b/app/src/main/java/org/mifos/mobilewallet/auth/AuthContract.java new file mode 100644 index 000000000..ff6af8fd6 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/auth/AuthContract.java @@ -0,0 +1,47 @@ +package org.mifos.mobilewallet.auth; + +import org.mifos.mobilewallet.core.BasePresenter; +import org.mifos.mobilewallet.core.BaseView; + +/** + * Created by naman on 16/6/17. + */ + +/** + * This specifies the contract between the view and the presenter. + */ +public interface AuthContract { + + interface LoginView extends BaseView { + + } + + interface LoginPresenter extends BasePresenter { + + + } + + + interface SignupView extends BaseView { + + } + + interface SignupPresenter extends BasePresenter { + + + } + + + interface LandingView extends BaseView { + + void openLoginScreen(); + void openSignupScreen(); + } + + interface LandingPresenter extends BasePresenter { + + void navigateLogin(); + void navigateSignup(); + + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/auth/domain/model/UserLogin.java b/app/src/main/java/org/mifos/mobilewallet/auth/domain/model/UserLogin.java new file mode 100644 index 000000000..02fd9676a --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/auth/domain/model/UserLogin.java @@ -0,0 +1,31 @@ +package org.mifos.mobilewallet.auth.domain.model; + +import android.support.annotation.NonNull; + +/** + * Created by naman on 16/6/17. + */ + +public class UserLogin { + + @NonNull + private final String mUserName; + + @NonNull + private final String mPassword; + + public UserLogin(@NonNull String username, @NonNull String password) { + this.mUserName = username; + this.mPassword = password; + } + + @NonNull + public String getmPassword() { + return mPassword; + } + + @NonNull + public String getmUserName() { + return mUserName; + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/auth/domain/usecase/AuthenticateUser.java b/app/src/main/java/org/mifos/mobilewallet/auth/domain/usecase/AuthenticateUser.java new file mode 100644 index 000000000..cfbdd2519 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/auth/domain/usecase/AuthenticateUser.java @@ -0,0 +1,28 @@ +package org.mifos.mobilewallet.auth.domain.usecase; + +import org.mifos.mobilewallet.core.UseCase; + +/** + * Created by naman on 16/6/17. + */ + +public class AuthenticateUser extends UseCase { + + + @Override + protected void executeUseCase(RequestValues requestValues) { + + } + + public static final class RequestValues implements UseCase.RequestValues { + + + public RequestValues() { + + } + + } + + public static final class ResponseValue implements UseCase.ResponseValue { + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/auth/presenter/LandingPresenter.java b/app/src/main/java/org/mifos/mobilewallet/auth/presenter/LandingPresenter.java new file mode 100644 index 000000000..a79200fd3 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/auth/presenter/LandingPresenter.java @@ -0,0 +1,41 @@ +package org.mifos.mobilewallet.auth.presenter; + +import org.mifos.mobilewallet.core.BaseView; +import org.mifos.mobilewallet.auth.AuthContract; +import org.mifos.mobilewallet.core.UseCaseHandler; + +import javax.inject.Inject; + +/** + * Created by naman on 16/6/17. + */ + +public class LandingPresenter implements AuthContract.LandingPresenter { + + private AuthContract.LandingView mLandingView; + private final UseCaseHandler mUsecaseHandler; + + + @Inject + public LandingPresenter(UseCaseHandler useCaseHandler){ + this.mUsecaseHandler = useCaseHandler; + } + + @Override + public void attachView(BaseView baseView) { + this.mLandingView = (AuthContract.LandingView) baseView; + mLandingView.setPresenter(this); + + } + + + @Override + public void navigateLogin() { + mLandingView.openLoginScreen(); + } + + @Override + public void navigateSignup() { + mLandingView.openSignupScreen(); + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/auth/presenter/LoginPresenter.java b/app/src/main/java/org/mifos/mobilewallet/auth/presenter/LoginPresenter.java new file mode 100644 index 000000000..839f5c2e6 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/auth/presenter/LoginPresenter.java @@ -0,0 +1,16 @@ +package org.mifos.mobilewallet.auth.presenter; + +import org.mifos.mobilewallet.core.BaseView; +import org.mifos.mobilewallet.auth.AuthContract; + +/** + * Created by naman on 16/6/17. + */ + +public class LoginPresenter implements AuthContract.LoginPresenter { + + @Override + public void attachView(BaseView baseView) { + + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/auth/presenter/SignupPresenter.java b/app/src/main/java/org/mifos/mobilewallet/auth/presenter/SignupPresenter.java new file mode 100644 index 000000000..08137283d --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/auth/presenter/SignupPresenter.java @@ -0,0 +1,16 @@ +package org.mifos.mobilewallet.auth.presenter; + +import org.mifos.mobilewallet.core.BaseView; +import org.mifos.mobilewallet.auth.AuthContract; + +/** + * Created by naman on 16/6/17. + */ + +public class SignupPresenter implements AuthContract.SignupPresenter { + + @Override + public void attachView(BaseView baseView) { + + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/auth/ui/LandingActivity.java b/app/src/main/java/org/mifos/mobilewallet/auth/ui/LandingActivity.java new file mode 100644 index 000000000..e9b66114c --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/auth/ui/LandingActivity.java @@ -0,0 +1,64 @@ +package org.mifos.mobilewallet.auth.ui; + +import android.content.Intent; +import android.os.Bundle; +import android.support.annotation.Nullable; + +import org.mifos.mobilewallet.core.BaseActivity; +import org.mifos.mobilewallet.R; +import org.mifos.mobilewallet.auth.AuthContract; +import org.mifos.mobilewallet.auth.presenter.LandingPresenter; + +import javax.inject.Inject; + +import butterknife.ButterKnife; +import butterknife.OnClick; + +/** + * Created by naman on 16/6/17. + */ + +public class LandingActivity extends BaseActivity implements AuthContract.LandingView { + + @Inject + LandingPresenter mPresenter; + + AuthContract.LandingPresenter mLandingPresenter; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_landing); + getActivityComponent().inject(this); + + ButterKnife.bind(LandingActivity.this); + mPresenter.attachView(this); + } + + @Override + public void setPresenter(AuthContract.LandingPresenter presenter) { + mLandingPresenter = presenter; + } + + @Override + public void openLoginScreen() { + Intent intent = new Intent(LandingActivity.this, LoginActivity.class); + startActivity(intent); + } + + @Override + public void openSignupScreen() { + Intent intent = new Intent(LandingActivity.this, SignupActivity.class); + startActivity(intent); + } + + @OnClick(R.id.btn_login) + public void onLoginClicked() { + mLandingPresenter.navigateLogin(); + } + + @OnClick(R.id.btn_signup) + public void onSignupClicked() { + mLandingPresenter.navigateSignup(); + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/auth/ui/LoginActivity.java b/app/src/main/java/org/mifos/mobilewallet/auth/ui/LoginActivity.java new file mode 100644 index 000000000..706fea061 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/auth/ui/LoginActivity.java @@ -0,0 +1,10 @@ +package org.mifos.mobilewallet.auth.ui; + +import android.support.v7.app.AppCompatActivity; + +/** + * Created by naman on 16/6/17. + */ + +public class LoginActivity extends AppCompatActivity { +} diff --git a/app/src/main/java/org/mifos/mobilewallet/auth/ui/SignupActivity.java b/app/src/main/java/org/mifos/mobilewallet/auth/ui/SignupActivity.java new file mode 100644 index 000000000..ffd1f253f --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/auth/ui/SignupActivity.java @@ -0,0 +1,10 @@ +package org.mifos.mobilewallet.auth.ui; + +import android.support.v7.app.AppCompatActivity; + +/** + * Created by naman on 16/6/17. + */ + +public class SignupActivity extends AppCompatActivity { +} diff --git a/app/src/main/java/org/mifos/mobilewallet/core/BaseActivity.java b/app/src/main/java/org/mifos/mobilewallet/core/BaseActivity.java new file mode 100644 index 000000000..10c8f3345 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/core/BaseActivity.java @@ -0,0 +1,27 @@ +package org.mifos.mobilewallet.core; + +import android.support.v7.app.AppCompatActivity; + +import org.mifos.mobilewallet.MifosWalletApp; +import org.mifos.mobilewallet.injection.component.ActivityComponent; +import org.mifos.mobilewallet.injection.component.DaggerActivityComponent; +import org.mifos.mobilewallet.injection.module.ActivityModule; + +/** + * Created by naman on 16/6/17. + */ + +public class BaseActivity extends AppCompatActivity { + + private ActivityComponent activityComponent; + + public ActivityComponent getActivityComponent() { + if (activityComponent == null) { + activityComponent = DaggerActivityComponent.builder() + .activityModule(new ActivityModule(this)) + .applicationComponent(MifosWalletApp.get(this).component()) + .build(); + } + return activityComponent; + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/core/BasePresenter.java b/app/src/main/java/org/mifos/mobilewallet/core/BasePresenter.java new file mode 100644 index 000000000..3eb6b96de --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/core/BasePresenter.java @@ -0,0 +1,6 @@ +package org.mifos.mobilewallet.core; + +public interface BasePresenter { + + void attachView(BaseView baseView); +} diff --git a/app/src/main/java/org/mifos/mobilewallet/core/BaseView.java b/app/src/main/java/org/mifos/mobilewallet/core/BaseView.java new file mode 100644 index 000000000..d20065285 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/core/BaseView.java @@ -0,0 +1,7 @@ +package org.mifos.mobilewallet.core; + +public interface BaseView { + + void setPresenter(T presenter); + +} diff --git a/app/src/main/java/org/mifos/mobilewallet/core/UseCase.java b/app/src/main/java/org/mifos/mobilewallet/core/UseCase.java new file mode 100644 index 000000000..85e944829 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/core/UseCase.java @@ -0,0 +1,53 @@ +package org.mifos.mobilewallet.core; + +/** + * Use cases are the entry points to the domain layer. + * + * @param the request type + * @param

the response type + */ +public abstract class UseCase { + + private Q mRequestValues; + + private UseCaseCallback

mUseCaseCallback; + + public void setRequestValues(Q requestValues) { + mRequestValues = requestValues; + } + + public Q getRequestValues() { + return mRequestValues; + } + + public UseCaseCallback

getUseCaseCallback() { + return mUseCaseCallback; + } + + public void setUseCaseCallback(UseCaseCallback

useCaseCallback) { + mUseCaseCallback = useCaseCallback; + } + + void run() { + executeUseCase(mRequestValues); + } + + protected abstract void executeUseCase(Q requestValues); + + /** + * Data passed to a request. + */ + public interface RequestValues { + } + + /** + * Data received from a request. + */ + public interface ResponseValue { + } + + public interface UseCaseCallback { + void onSuccess(R response); + void onError(); + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/core/UseCaseHandler.java b/app/src/main/java/org/mifos/mobilewallet/core/UseCaseHandler.java new file mode 100644 index 000000000..532c2b754 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/core/UseCaseHandler.java @@ -0,0 +1,69 @@ +package org.mifos.mobilewallet.core; + + +/** + * Runs {@link UseCase}s using a {@link UseCaseScheduler}. + */ +public class UseCaseHandler { + + private static UseCaseHandler INSTANCE; + + private final UseCaseScheduler mUseCaseScheduler; + + public UseCaseHandler(UseCaseScheduler useCaseScheduler) { + mUseCaseScheduler = useCaseScheduler; + } + + public void execute( + final UseCase useCase, T values, UseCase.UseCaseCallback callback) { + useCase.setRequestValues(values); + useCase.setUseCaseCallback(new UiCallbackWrapper(callback, this)); + + mUseCaseScheduler.execute(new Runnable() { + @Override + public void run() { + + useCase.run(); + } + }); + } + + public void notifyResponse(final V response, + final UseCase.UseCaseCallback useCaseCallback) { + mUseCaseScheduler.notifyResponse(response, useCaseCallback); + } + + private void notifyError( + final UseCase.UseCaseCallback useCaseCallback) { + mUseCaseScheduler.onError(useCaseCallback); + } + + private static final class UiCallbackWrapper implements + UseCase.UseCaseCallback { + private final UseCase.UseCaseCallback mCallback; + private final UseCaseHandler mUseCaseHandler; + + public UiCallbackWrapper(UseCase.UseCaseCallback callback, + UseCaseHandler useCaseHandler) { + mCallback = callback; + mUseCaseHandler = useCaseHandler; + } + + @Override + public void onSuccess(V response) { + mUseCaseHandler.notifyResponse(response, mCallback); + } + + @Override + public void onError() { + mUseCaseHandler.notifyError(mCallback); + } + } + + public static UseCaseHandler getInstance() { + if (INSTANCE == null) { + INSTANCE = new UseCaseHandler(new UseCaseThreadPoolScheduler()); + } + return INSTANCE; + } +} diff --git a/app/src/main/java/org/mifos/mobilewallet/core/UseCaseScheduler.java b/app/src/main/java/org/mifos/mobilewallet/core/UseCaseScheduler.java new file mode 100644 index 000000000..5aac8679e --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/core/UseCaseScheduler.java @@ -0,0 +1,15 @@ +package org.mifos.mobilewallet.core; + +/** + * Interface for schedulers, see {@link UseCaseThreadPoolScheduler}. + */ +public interface UseCaseScheduler { + + void execute(Runnable runnable); + + void notifyResponse(final V response, + final UseCase.UseCaseCallback useCaseCallback); + + void onError( + final UseCase.UseCaseCallback useCaseCallback); +} diff --git a/app/src/main/java/org/mifos/mobilewallet/core/UseCaseThreadPoolScheduler.java b/app/src/main/java/org/mifos/mobilewallet/core/UseCaseThreadPoolScheduler.java new file mode 100644 index 000000000..05f6fbfa5 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/core/UseCaseThreadPoolScheduler.java @@ -0,0 +1,63 @@ +package org.mifos.mobilewallet.core; + +import android.os.Handler; + +import org.mifos.mobilewallet.core.UseCase; +import org.mifos.mobilewallet.core.UseCaseScheduler; + +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +/** + * Executes asynchronous tasks using a {@link ThreadPoolExecutor}. + *

+ * See also {@link Executors} for a list of factory methods to create common + * {@link java.util.concurrent.ExecutorService}s for different scenarios. + */ +public class UseCaseThreadPoolScheduler implements UseCaseScheduler { + + private final Handler mHandler = new Handler(); + + public static final int POOL_SIZE = 2; + + public static final int MAX_POOL_SIZE = 4; + + public static final int TIMEOUT = 30; + + ThreadPoolExecutor mThreadPoolExecutor; + + public UseCaseThreadPoolScheduler() { + mThreadPoolExecutor = new ThreadPoolExecutor(POOL_SIZE, MAX_POOL_SIZE, TIMEOUT, + TimeUnit.SECONDS, new ArrayBlockingQueue(POOL_SIZE)); + } + + @Override + public void execute(Runnable runnable) { + mThreadPoolExecutor.execute(runnable); + } + + @Override + public void notifyResponse(final V response, + final UseCase.UseCaseCallback useCaseCallback) { + mHandler.post(new Runnable() { + @Override + public void run() { + useCaseCallback.onSuccess(response); + } + }); + } + + @Override + public void onError( + final UseCase.UseCaseCallback useCaseCallback) { + mHandler.post(new Runnable() { + @Override + public void run() { + useCaseCallback.onError(); + } + }); + } + +} diff --git a/app/src/main/java/org/mifos/mobilewallet/injection/ActivityContext.java b/app/src/main/java/org/mifos/mobilewallet/injection/ActivityContext.java new file mode 100644 index 000000000..f6fb234a0 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/injection/ActivityContext.java @@ -0,0 +1,12 @@ +package org.mifos.mobilewallet.injection; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.inject.Qualifier; + + +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +public @interface ActivityContext { +} \ No newline at end of file diff --git a/app/src/main/java/org/mifos/mobilewallet/injection/ApplicationContext.java b/app/src/main/java/org/mifos/mobilewallet/injection/ApplicationContext.java new file mode 100644 index 000000000..1b9c90007 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/injection/ApplicationContext.java @@ -0,0 +1,11 @@ +package org.mifos.mobilewallet.injection; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.inject.Qualifier; + +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +public @interface ApplicationContext { +} \ No newline at end of file diff --git a/app/src/main/java/org/mifos/mobilewallet/injection/PerActivity.java b/app/src/main/java/org/mifos/mobilewallet/injection/PerActivity.java new file mode 100644 index 000000000..e52bbcaae --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/injection/PerActivity.java @@ -0,0 +1,11 @@ +package org.mifos.mobilewallet.injection; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +import javax.inject.Scope; + +@Scope +@Retention(RetentionPolicy.RUNTIME) +public @interface PerActivity { +} diff --git a/app/src/main/java/org/mifos/mobilewallet/injection/component/ActivityComponent.java b/app/src/main/java/org/mifos/mobilewallet/injection/component/ActivityComponent.java new file mode 100644 index 000000000..203f0ed2b --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/injection/component/ActivityComponent.java @@ -0,0 +1,16 @@ +package org.mifos.mobilewallet.injection.component; + +import org.mifos.mobilewallet.auth.ui.LandingActivity; +import org.mifos.mobilewallet.injection.PerActivity; +import org.mifos.mobilewallet.injection.module.ActivityModule; + +import dagger.Component; + +@PerActivity +@Component(dependencies = ApplicationComponent.class, modules = ActivityModule.class) +public interface ActivityComponent { + + void inject(LandingActivity landingActivity); + + +} diff --git a/app/src/main/java/org/mifos/mobilewallet/injection/component/ApplicationComponent.java b/app/src/main/java/org/mifos/mobilewallet/injection/component/ApplicationComponent.java new file mode 100644 index 000000000..fa6b90a5e --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/injection/component/ApplicationComponent.java @@ -0,0 +1,26 @@ +package org.mifos.mobilewallet.injection.component; + +import android.app.Application; +import android.content.Context; + +import org.mifos.mobilewallet.core.UseCaseHandler; +import org.mifos.mobilewallet.injection.ApplicationContext; +import org.mifos.mobilewallet.injection.module.ApplicationModule; + +import javax.inject.Singleton; + +import dagger.Component; + + +@Singleton +@Component(modules = ApplicationModule.class) +public interface ApplicationComponent { + + @ApplicationContext + Context context(); + + Application application(); + + UseCaseHandler usecasehandler(); + +} \ No newline at end of file diff --git a/app/src/main/java/org/mifos/mobilewallet/injection/module/ActivityModule.java b/app/src/main/java/org/mifos/mobilewallet/injection/module/ActivityModule.java new file mode 100644 index 000000000..951a0efda --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/injection/module/ActivityModule.java @@ -0,0 +1,31 @@ +package org.mifos.mobilewallet.injection.module; + +import android.app.Activity; +import android.content.Context; + +import org.mifos.mobilewallet.injection.ActivityContext; + +import dagger.Module; +import dagger.Provides; + +@Module +public class ActivityModule { + + private Activity activity; + + public ActivityModule(Activity activity) { + this.activity = activity; + } + + @Provides + Activity providesActivity() { + return activity; + } + + @Provides + @ActivityContext + Context providesContext() { + return activity; + } + +} \ No newline at end of file diff --git a/app/src/main/java/org/mifos/mobilewallet/injection/module/ApplicationModule.java b/app/src/main/java/org/mifos/mobilewallet/injection/module/ApplicationModule.java new file mode 100644 index 000000000..f4ff0e211 --- /dev/null +++ b/app/src/main/java/org/mifos/mobilewallet/injection/module/ApplicationModule.java @@ -0,0 +1,38 @@ +package org.mifos.mobilewallet.injection.module; + +import android.app.Application; +import android.content.Context; + +import org.mifos.mobilewallet.core.UseCaseHandler; +import org.mifos.mobilewallet.core.UseCaseThreadPoolScheduler; +import org.mifos.mobilewallet.injection.ApplicationContext; + +import dagger.Module; +import dagger.Provides; + + +@Module +public class ApplicationModule { + + private Application application; + + public ApplicationModule(Application application) { + this.application = application; + } + + @Provides + Application provideApplication() { + return application; + } + + @Provides + @ApplicationContext + Context provideContext() { + return application; + } + + @Provides + UseCaseHandler provideUsecaseHandler() { + return new UseCaseHandler(new UseCaseThreadPoolScheduler()); + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_primary.xml b/app/src/main/res/drawable/button_round_primary.xml new file mode 100644 index 000000000..c17f2150f --- /dev/null +++ b/app/src/main/res/drawable/button_round_primary.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_stroke.xml b/app/src/main/res/drawable/button_round_stroke.xml new file mode 100644 index 000000000..f0d15e37b --- /dev/null +++ b/app/src/main/res/drawable/button_round_stroke.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button_round_white.xml b/app/src/main/res/drawable/button_round_white.xml new file mode 100644 index 000000000..8952542e3 --- /dev/null +++ b/app/src/main/res/drawable/button_round_white.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_landing.xml b/app/src/main/res/layout/activity_landing.xml new file mode 100644 index 000000000..3121d6927 --- /dev/null +++ b/app/src/main/res/layout/activity_landing.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + +