├── .gitignore
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── images
├── dagger-graph.png
└── modules-overview.png
├── settings.gradle
└── sources
├── base
├── core
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── kotlinsg
│ │ │ └── kworkshopapp
│ │ │ ├── App.kt
│ │ │ ├── GithubProject.kt
│ │ │ ├── actions
│ │ │ └── ShowGithubScreenAction.kt
│ │ │ ├── di
│ │ │ ├── AppComponent.kt
│ │ │ ├── ComponentInterfaces.kt
│ │ │ └── Log.kt
│ │ │ ├── notification
│ │ │ └── di
│ │ │ │ └── NotificationUseCase.kt
│ │ │ ├── repo
│ │ │ └── GithubRepo.kt
│ │ │ └── tools
│ │ │ └── Toaster.kt
│ │ └── res
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
├── injector
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ └── com
│ │ │ └── kotlinsg
│ │ │ └── kworkshopapp
│ │ │ ├── RealApp.kt
│ │ │ ├── di
│ │ │ ├── AppComponent.kt
│ │ │ └── MainToolsComponent.kt
│ │ │ └── tools
│ │ │ ├── LoggerImpl.kt
│ │ │ └── Toaster.kt
│ │ └── res
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
│ │ └── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ ├── ic_launcher_foreground.png
│ │ └── ic_launcher_round.png
├── network
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── kotlinsg
│ │ └── kworkshopapp
│ │ └── network
│ │ ├── NetworkClient.kt
│ │ ├── di
│ │ └── NetworkComponent.kt
│ │ └── model
│ │ └── GithubProjectModel.kt
└── repo
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── kotlinsg
│ └── kworkshopapp
│ └── repo
│ ├── GithubRepo.kt
│ └── di
│ ├── RepoComponent.kt
│ └── RepoModule.kt
└── features
├── githubbrowser
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── kotlinsg
│ │ └── kworkshopapp
│ │ ├── actions
│ │ └── ShowGithubScreen.kt
│ │ ├── di
│ │ ├── GithubActivityComponent.kt
│ │ ├── GithubActivityModule.kt
│ │ └── GithubBrowserExportComponent.kt
│ │ └── github
│ │ ├── GithubActivity.kt
│ │ └── GithubUseCase.kt
│ └── res
│ └── layout
│ └── activity_github.xml
├── mainscreen
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── kotlinsg
│ │ └── kworkshopapp
│ │ ├── MainActivity.kt
│ │ └── di
│ │ ├── MainActivityComponent.kt
│ │ └── MainActivityModule.kt
│ └── res
│ ├── drawable
│ └── ic_folder_open_teal_400_24dp.xml
│ └── layout
│ └── activity_main.xml
└── notifications
├── .gitignore
├── build.gradle
├── notifications-fake
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── kotlinsg
│ └── kworkshopapp
│ └── notification
│ └── di
│ └── NotificationComponent.kt
├── proguard-rules.pro
└── src
└── main
├── AndroidManifest.xml
└── java
└── com
└── kotlinsg
└── kworkshopapp
└── notification
└── di
├── NotificationComponent.kt
└── NotificationUseCase.kt
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sample app of modular architecture.
2 |
3 | # Gradle-modules in sample:
4 |
5 | 
6 |
7 | # Dagger-components in sample:
8 |
9 | 
10 |
11 |
12 | [](https://www.youtube.com/watch?v=fYY-TDYW8yI)
13 |
14 |
15 | Video from Mobius Saint-Petersburg 2018 about this sample: will be soon...
16 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.2.31'
5 | ext.daggerVersion = '2.13'
6 | repositories {
7 | google()
8 | jcenter()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.1.0'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | google()
19 | jcenter()
20 | mavenCentral()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | android.enableAapt2=true
2 | org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
3 | kotlin.daemon.jvm.options=-Xmx2g
4 | kotlin.incremental=true
5 | org.gradle.daemon=true
6 | org.gradle.caching=true
7 | org.gradle.configureondemand=true
8 | android.enableBuildCache=true
9 | android.databinding.enableV2=true
10 | android.enableD8=true
11 | org.gradle.parallel=true
12 | #kapt.verbose=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Oct 27 22:11:39 SGT 2017
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-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/images/dagger-graph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/images/dagger-graph.png
--------------------------------------------------------------------------------
/images/modules-overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/images/modules-overview.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':core'
2 | project(':core').projectDir = new File(rootDir, 'sources/base/core')
3 | include ':injector'
4 | project(':injector').projectDir = new File(rootDir, 'sources/base/injector')
5 | include ':repo'
6 | project(':repo').projectDir = new File(rootDir, 'sources/base/repo')
7 | include ':network'
8 | project(':network').projectDir = new File(rootDir, 'sources/base/network')
9 |
10 | include ':notifications'
11 | project(':notifications').projectDir = new File(rootDir, 'sources/features/notifications/notifications-fake')
12 |
13 |
14 | include ':githubbrowser'
15 | project(':githubbrowser').projectDir = new File(rootDir, 'sources/features/githubbrowser')
16 | include ':mainscreen'
17 | project(':mainscreen').projectDir = new File(rootDir, 'sources/features/mainscreen')
18 |
--------------------------------------------------------------------------------
/sources/base/core/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sources/base/core/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion 27
6 |
7 |
8 |
9 | defaultConfig {
10 | minSdkVersion 15
11 | targetSdkVersion 27
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation "com.google.dagger:dagger:$daggerVersion"
30 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
31 | }
32 | repositories {
33 | mavenCentral()
34 | }
35 |
--------------------------------------------------------------------------------
/sources/base/core/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sources/base/core/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/sources/base/core/src/main/java/com/kotlinsg/kworkshopapp/App.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp
2 |
3 | import android.content.Context
4 | import com.kotlinsg.kworkshopapp.di.ApplicationProvider
5 |
6 |
7 | interface App {
8 | fun getApplicationContext(): Context
9 | fun getAppComponent(): ApplicationProvider
10 | }
--------------------------------------------------------------------------------
/sources/base/core/src/main/java/com/kotlinsg/kworkshopapp/GithubProject.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp
2 |
3 |
4 | interface GithubProject {
5 | val name: String
6 | val stargazers_count: Int
7 | val forks_count: Int
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/sources/base/core/src/main/java/com/kotlinsg/kworkshopapp/actions/ShowGithubScreenAction.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.actions
2 |
3 | import android.content.Context
4 |
5 | interface ShowGithubScreenAction {
6 | fun show(context: Context)
7 | }
--------------------------------------------------------------------------------
/sources/base/core/src/main/java/com/kotlinsg/kworkshopapp/di/AppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di
2 |
3 | @javax.inject.Scope annotation class ActivityScope
4 | @javax.inject.Scope annotation class ServiceScope
5 | @javax.inject.Scope annotation class FragmentScope
6 | @javax.inject.Scope annotation class ViewScope
--------------------------------------------------------------------------------
/sources/base/core/src/main/java/com/kotlinsg/kworkshopapp/di/ComponentInterfaces.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di
2 |
3 | import com.kotlinsg.kworkshopapp.App
4 | import com.kotlinsg.kworkshopapp.actions.ShowGithubScreenAction
5 | import com.kotlinsg.kworkshopapp.repo.GithubRepo
6 | import com.kotlinsg.kworkshopapp.tools.Toaster
7 |
8 | interface ApplicationProvider :
9 | MainToolsProvider,
10 | GithubBrowserProvider,
11 | RepoProvider
12 |
13 | interface MainToolsProvider {
14 | fun provideContext(): App
15 | fun provideLogger(): Logger
16 | fun provideToast(): Toaster
17 | }
18 |
19 | interface GithubBrowserProvider {
20 | fun provideShowGithubScreenAction(): ShowGithubScreenAction
21 | }
22 |
23 | interface RepoProvider {
24 | fun provideGithubRepo(): GithubRepo
25 | }
--------------------------------------------------------------------------------
/sources/base/core/src/main/java/com/kotlinsg/kworkshopapp/di/Log.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di
2 |
3 |
4 | interface Logger {
5 | fun d(message:String)
6 | }
--------------------------------------------------------------------------------
/sources/base/core/src/main/java/com/kotlinsg/kworkshopapp/notification/di/NotificationUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.notification.di
2 |
3 | interface NotificationUseCase {
4 | fun showMessage()
5 | }
--------------------------------------------------------------------------------
/sources/base/core/src/main/java/com/kotlinsg/kworkshopapp/repo/GithubRepo.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.repo
2 |
3 | import com.kotlinsg.kworkshopapp.GithubProject
4 |
5 | interface GithubRepo {
6 | fun getSampleProject(onResult: (GithubProject) -> Unit, onError: (Throwable) -> Unit)
7 | }
--------------------------------------------------------------------------------
/sources/base/core/src/main/java/com/kotlinsg/kworkshopapp/tools/Toaster.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.tools
2 |
3 | interface Toaster {
4 | fun show(msg: String)
5 | }
--------------------------------------------------------------------------------
/sources/base/core/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/sources/base/core/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | KWorkshopApp
3 |
4 |
--------------------------------------------------------------------------------
/sources/base/core/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sources/base/injector/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sources/base/injector/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 |
5 | apply plugin: 'kotlin-android-extensions'
6 | apply plugin: 'kotlin-kapt'
7 |
8 | android {
9 | compileSdkVersion 27
10 | buildToolsVersion '27.0.3'
11 | defaultConfig {
12 | minSdkVersion 15
13 | targetSdkVersion 27
14 | versionCode 1
15 | versionName "1.0"
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 |
25 | }
26 |
27 | dependencies {
28 | implementation project(':repo')
29 | implementation project(':core')
30 | implementation project(':githubbrowser')
31 | implementation project(':mainscreen')
32 |
33 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
34 | implementation 'com.android.support:appcompat-v7:27.1.0'
35 |
36 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
37 | kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
38 |
39 | implementation "com.google.dagger:dagger:$daggerVersion"
40 |
41 | }
42 | repositories {
43 | mavenCentral()
44 | }
45 |
--------------------------------------------------------------------------------
/sources/base/injector/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sources/base/injector/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/sources/base/injector/src/main/java/com/kotlinsg/kworkshopapp/RealApp.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp
2 |
3 | import android.app.Application
4 | import com.kotlinsg.kworkshopapp.di.AppComponent
5 | import com.kotlinsg.kworkshopapp.di.ApplicationProvider
6 | import com.kotlinsg.kworkshopapp.tools.Toaster
7 | import javax.inject.Inject
8 |
9 |
10 | class RealApp : Application(), App {
11 |
12 | @Inject lateinit var toaster: Toaster
13 | val appComponent: AppComponent by lazy { AppComponent.Initializer.init(this@RealApp) }
14 |
15 | override fun onCreate() {
16 | super.onCreate()
17 | appComponent.inject(this)
18 | toaster.show("app injected")
19 | }
20 |
21 | override fun getAppComponent(): ApplicationProvider = appComponent
22 | }
--------------------------------------------------------------------------------
/sources/base/injector/src/main/java/com/kotlinsg/kworkshopapp/di/AppComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di
2 |
3 | import com.kotlinsg.kworkshopapp.RealApp
4 | import com.kotlinsg.kworkshopapp.repo.di.RepoComponent
5 | import dagger.Component
6 | import javax.inject.Singleton
7 |
8 |
9 | @Component(
10 | dependencies = [
11 | MainToolsProvider::class,
12 | RepoProvider::class,
13 | GithubBrowserProvider::class
14 | ]
15 | )
16 | @Singleton
17 | interface AppComponent : ApplicationProvider {
18 |
19 | fun inject(app: RealApp)
20 |
21 | class Initializer private constructor() {
22 | companion object {
23 |
24 | fun init(app: RealApp): AppComponent {
25 |
26 | val mainToolsProvider = MainToolsComponent.Initializer
27 | .init(app)
28 |
29 | val repoProvider = RepoComponent.Initializer
30 | .init(mainToolsProvider)
31 |
32 | val githubBrowserProvider = GithubBrowserExportComponent.Initializer
33 | .init(mainToolsProvider)
34 |
35 | return DaggerAppComponent.builder()
36 | .mainToolsProvider(mainToolsProvider)
37 | .repoProvider(repoProvider)
38 | .githubBrowserProvider(githubBrowserProvider)
39 | .build()
40 | }
41 | }
42 | }
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/sources/base/injector/src/main/java/com/kotlinsg/kworkshopapp/di/MainToolsComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di
2 |
3 | import com.kotlinsg.kworkshopapp.App
4 | import com.kotlinsg.kworkshopapp.tools.LoggerImpl
5 | import com.kotlinsg.kworkshopapp.tools.Toaster
6 | import com.kotlinsg.kworkshopapp.tools.ToasterImpl
7 | import dagger.BindsInstance
8 | import dagger.Component
9 | import dagger.Module
10 | import dagger.Provides
11 | import javax.inject.Singleton
12 |
13 | @Module class ToolsModule {
14 | @Module
15 | companion object {
16 | @JvmStatic
17 | @Provides
18 | @Singleton
19 | fun provideLogger(): Logger {
20 | return LoggerImpl()
21 | }
22 |
23 | @JvmStatic
24 | @Provides
25 | @Singleton
26 | fun provideToaster(app: App): Toaster {
27 | return ToasterImpl(app.getApplicationContext())
28 | }
29 | }
30 | }
31 |
32 | @Singleton
33 | @Component(modules = [ToolsModule::class])
34 | interface MainToolsComponent : MainToolsProvider {
35 |
36 | @Component.Builder
37 | interface Builder {
38 | fun build(): MainToolsComponent
39 | @BindsInstance fun app(app: App): Builder
40 | }
41 |
42 | class Initializer private constructor() {
43 | companion object {
44 |
45 | fun init(app: App): MainToolsProvider =
46 | DaggerMainToolsComponent.builder()
47 | .app(app)
48 | .build()
49 | }
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/sources/base/injector/src/main/java/com/kotlinsg/kworkshopapp/tools/LoggerImpl.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.tools
2 |
3 | import android.util.Log
4 | import com.kotlinsg.kworkshopapp.di.Logger
5 |
6 |
7 | class LoggerImpl : Logger {
8 | override fun d(message:String) {
9 | Log.d("APP",message)
10 | }
11 | }
--------------------------------------------------------------------------------
/sources/base/injector/src/main/java/com/kotlinsg/kworkshopapp/tools/Toaster.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.tools
2 |
3 | import android.content.Context
4 | import android.widget.Toast
5 | import javax.inject.Inject
6 |
7 | class ToasterImpl @Inject constructor(
8 | val appContext: Context
9 | ) : Toaster {
10 | override fun show(msg: String) {
11 | Toast.makeText(appContext, msg, Toast.LENGTH_SHORT).show()
12 | }
13 | }
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
15 |
21 |
27 |
33 |
39 |
45 |
51 |
57 |
63 |
69 |
75 |
81 |
87 |
93 |
99 |
105 |
111 |
117 |
123 |
129 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/sources/base/injector/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kotlinsg/modular/3618366c2a199f75c95d4c8af8987e6fc6723e67/sources/base/injector/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/sources/base/network/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sources/base/network/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | compileSdkVersion 27
7 |
8 |
9 |
10 | defaultConfig {
11 | minSdkVersion 15
12 | targetSdkVersion 27
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation project(':core')
31 |
32 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
33 | implementation "com.google.dagger:dagger:$daggerVersion"
34 |
35 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
36 |
37 | implementation 'com.github.kittinunf.fuel:fuel-android:1.8.0'
38 | implementation 'com.google.code.gson:gson:2.8.2'
39 | }
40 | repositories {
41 | mavenCentral()
42 | }
43 |
--------------------------------------------------------------------------------
/sources/base/network/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sources/base/network/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/sources/base/network/src/main/java/com/kotlinsg/kworkshopapp/network/NetworkClient.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.network
2 |
3 | import com.github.kittinunf.fuel.core.FuelError
4 | import com.github.kittinunf.fuel.core.Request
5 | import com.github.kittinunf.fuel.core.Response
6 | import com.github.kittinunf.fuel.httpGet
7 | import com.github.kittinunf.result.Result
8 | import com.kotlinsg.kworkshopapp.GithubProject
9 | import com.kotlinsg.kworkshopapp.di.Logger
10 | import com.kotlinsg.kworkshopapp.network.model.GithubProjectModel
11 | import javax.inject.Inject
12 |
13 | interface NetworkClient {
14 | fun requestProject(path: String, onResult: (GithubProject) -> Unit, onError: (Throwable) -> Unit)
15 | }
16 |
17 | class NetworkClientImpl @Inject constructor(
18 | val logger: Logger
19 | ) : NetworkClient {
20 |
21 | override fun requestProject(path: String, onResult: (GithubProject) -> Unit, onError: (Throwable) -> Unit) {
22 |
23 | val url = "https://api.github.com/repos/$path"
24 |
25 | logger.d("requesting: $url")
26 |
27 | url.httpGet().responseObject(
28 | deserializer = GithubProjectModel.Deserializer())
29 | { _: Request, _: Response, (result, error): Result ->
30 |
31 | result?.let(onResult)
32 | error?.let(onError)
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/sources/base/network/src/main/java/com/kotlinsg/kworkshopapp/network/di/NetworkComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.network.di
2 |
3 | import com.kotlinsg.kworkshopapp.di.MainToolsProvider
4 | import com.kotlinsg.kworkshopapp.network.NetworkClient
5 | import com.kotlinsg.kworkshopapp.network.NetworkClientImpl
6 | import dagger.Binds
7 | import dagger.Component
8 | import dagger.Module
9 |
10 | interface NetworkProvider {
11 | fun provideNetworkClient(): NetworkClient
12 | }
13 |
14 |
15 | @Module
16 | interface NetworkModule {
17 | @Binds fun bindsNetworkClient(impl: NetworkClientImpl): NetworkClient
18 | }
19 |
20 | @Component(
21 | dependencies = [MainToolsProvider::class],
22 | modules = [NetworkModule::class])
23 | interface NetworkComponent : NetworkProvider
--------------------------------------------------------------------------------
/sources/base/network/src/main/java/com/kotlinsg/kworkshopapp/network/model/GithubProjectModel.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.network.model
2 |
3 | import com.github.kittinunf.fuel.core.ResponseDeserializable
4 | import com.google.gson.Gson
5 | import com.kotlinsg.kworkshopapp.GithubProject
6 | import java.io.Reader
7 |
8 | data class GithubProjectModel(
9 | override val name: String = "",
10 | override val stargazers_count: Int = 0,
11 | override val forks_count: Int = 0
12 | ) : GithubProject {
13 |
14 | class Deserializer : ResponseDeserializable {
15 | override fun deserialize(reader: Reader) = Gson().fromJson(reader, GithubProjectModel::class.java)
16 | }
17 | }
--------------------------------------------------------------------------------
/sources/base/repo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sources/base/repo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | compileSdkVersion 27
7 |
8 |
9 |
10 | defaultConfig {
11 | minSdkVersion 15
12 | targetSdkVersion 27
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation project(':core')
31 | implementation project(':network')
32 |
33 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
34 |
35 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
36 | implementation "com.google.dagger:dagger:$daggerVersion"
37 | }
38 | repositories {
39 | mavenCentral()
40 | }
41 |
--------------------------------------------------------------------------------
/sources/base/repo/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sources/base/repo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/sources/base/repo/src/main/java/com/kotlinsg/kworkshopapp/repo/GithubRepo.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.repo
2 |
3 | import com.kotlinsg.kworkshopapp.GithubProject
4 | import com.kotlinsg.kworkshopapp.di.Logger
5 | import com.kotlinsg.kworkshopapp.network.NetworkClient
6 | import javax.inject.Inject
7 |
8 | class GithubRepoImpl @Inject constructor(
9 | val client: NetworkClient,
10 | val logger: Logger
11 | ) : GithubRepo {
12 |
13 | override fun getSampleProject(onResult: (GithubProject) -> Unit, onError: (Throwable) -> Unit) {
14 | logger.d("requested project")
15 | client.requestProject("kotlinsg/KWorkshopApp", onResult, onError)
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/sources/base/repo/src/main/java/com/kotlinsg/kworkshopapp/repo/di/RepoComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.repo.di
2 |
3 | import com.kotlinsg.kworkshopapp.di.MainToolsProvider
4 | import com.kotlinsg.kworkshopapp.di.RepoProvider
5 | import com.kotlinsg.kworkshopapp.network.di.DaggerNetworkComponent
6 | import com.kotlinsg.kworkshopapp.network.di.NetworkProvider
7 | import dagger.Component
8 |
9 | @Component(
10 | dependencies = [MainToolsProvider::class, NetworkProvider::class],
11 | modules = [RepoModule::class])
12 | interface RepoComponent : RepoProvider {
13 | class Initializer private constructor() {
14 | companion object {
15 |
16 | fun init(mainToolsProvider: MainToolsProvider): RepoProvider {
17 |
18 | val networkProvider = DaggerNetworkComponent.builder()
19 | .mainToolsProvider(mainToolsProvider)
20 | .build()
21 |
22 | return DaggerRepoComponent.builder()
23 | .mainToolsProvider(mainToolsProvider)
24 | .networkProvider(networkProvider)
25 | .build()
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/sources/base/repo/src/main/java/com/kotlinsg/kworkshopapp/repo/di/RepoModule.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.repo.di
2 |
3 | import com.kotlinsg.kworkshopapp.repo.GithubRepo
4 | import com.kotlinsg.kworkshopapp.repo.GithubRepoImpl
5 | import dagger.Binds
6 | import dagger.Module
7 |
8 | @Module
9 | interface RepoModule {
10 |
11 | @Binds fun bindsMainRepo(impl: GithubRepoImpl): GithubRepo
12 |
13 | }
--------------------------------------------------------------------------------
/sources/features/githubbrowser/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sources/features/githubbrowser/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | compileSdkVersion 27
7 | buildToolsVersion '27.0.3'
8 | defaultConfig {
9 | minSdkVersion 15
10 | targetSdkVersion 27
11 | versionCode 1
12 | versionName "1.0"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | implementation project(':core')
25 |
26 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
27 | implementation 'com.android.support:appcompat-v7:27.1.0'
28 | implementation project(':notifications')
29 |
30 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
31 | implementation "com.google.dagger:dagger:$daggerVersion"
32 | }
33 |
--------------------------------------------------------------------------------
/sources/features/githubbrowser/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/nekdenis/Work/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/sources/features/githubbrowser/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/sources/features/githubbrowser/src/main/java/com/kotlinsg/kworkshopapp/actions/ShowGithubScreen.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.actions
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import com.kotlinsg.kworkshopapp.github.GithubActivity
6 |
7 | class ShowGithubScreenActionRealImpl : ShowGithubScreenAction {
8 | override fun show(context: Context) {
9 | context.startActivity(Intent(context, GithubActivity::class.java))
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/sources/features/githubbrowser/src/main/java/com/kotlinsg/kworkshopapp/di/GithubActivityComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di
2 |
3 | import com.kotlinsg.kworkshopapp.github.GithubActivity
4 | import com.kotlinsg.kworkshopapp.notification.di.NotificationComponent
5 | import com.kotlinsg.kworkshopapp.notification.di.NotificationProvider
6 | import dagger.Component
7 |
8 | @ActivityScope
9 | @Component(
10 | dependencies = arrayOf(ApplicationProvider::class, NotificationProvider::class),
11 | modules = arrayOf(GithubActivityModule::class))
12 | interface GithubActivityComponent {
13 | fun inject(activity: GithubActivity)
14 |
15 | class Initializer private constructor() {
16 | companion object {
17 | fun init(
18 | applicationProvider: ApplicationProvider
19 | ): GithubActivityComponent {
20 |
21 | val notificationProvider = NotificationComponent.Initializer
22 | .init(applicationProvider)
23 |
24 | return DaggerGithubActivityComponent.builder()
25 | .applicationProvider(applicationProvider)
26 | .notificationProvider(notificationProvider)
27 | .build()
28 | }
29 | }
30 | }
31 | }
32 |
33 |
34 |
--------------------------------------------------------------------------------
/sources/features/githubbrowser/src/main/java/com/kotlinsg/kworkshopapp/di/GithubActivityModule.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di;
2 |
3 | import com.kotlinsg.kworkshopapp.github.GithubUseCase;
4 | import com.kotlinsg.kworkshopapp.github.GithubUseCaseImpl;
5 |
6 | import dagger.Binds;
7 | import dagger.Module;
8 |
9 | @Module
10 | interface GithubActivityModule {
11 | @ActivityScope
12 | @Binds fun bindsUseCase(impl: GithubUseCaseImpl): GithubUseCase
13 | }
--------------------------------------------------------------------------------
/sources/features/githubbrowser/src/main/java/com/kotlinsg/kworkshopapp/di/GithubBrowserExportComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di;
2 |
3 | import com.kotlinsg.kworkshopapp.actions.ShowGithubScreenAction
4 | import com.kotlinsg.kworkshopapp.actions.ShowGithubScreenActionRealImpl
5 | import dagger.Component
6 | import dagger.Module;
7 | import dagger.Provides;
8 |
9 | @Module
10 | class GithubBrowserExportModule {
11 | @Provides
12 | fun provideShowGithubAction(): ShowGithubScreenAction = ShowGithubScreenActionRealImpl()
13 | }
14 |
15 | @Component(
16 | dependencies = [MainToolsProvider::class],
17 | modules = [GithubBrowserExportModule::class]
18 | )
19 | interface GithubBrowserExportComponent : GithubBrowserProvider {
20 | class Initializer private constructor() {
21 | companion object {
22 |
23 | fun init(mainToolsProvider: MainToolsProvider): GithubBrowserProvider {
24 |
25 | return DaggerGithubBrowserExportComponent.builder()
26 | .mainToolsProvider(mainToolsProvider)
27 | .build()
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/sources/features/githubbrowser/src/main/java/com/kotlinsg/kworkshopapp/github/GithubActivity.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.github
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import android.widget.Button
6 | import android.widget.TextView
7 | import com.kotlinsg.kworkshopapp.App
8 | import com.kotlinsg.kworkshopapp.GithubProject
9 | import com.kotlinsg.kworkshopapp.app.R
10 | import com.kotlinsg.kworkshopapp.di.GithubActivityComponent
11 | import com.kotlinsg.kworkshopapp.notification.di.NotificationUseCase
12 | import com.kotlinsg.kworkshopapp.tools.Toaster
13 | import javax.inject.Inject
14 |
15 | class GithubActivity : AppCompatActivity() {
16 |
17 | @Inject lateinit var toaster: Toaster
18 | @Inject lateinit var useCase: GithubUseCase
19 | @Inject lateinit var notifications: NotificationUseCase
20 |
21 | lateinit var refreshButton: Button
22 | lateinit var starsCountText: TextView
23 |
24 | override fun onCreate(savedInstanceState: Bundle?) {
25 | super.onCreate(savedInstanceState)
26 | setContentView(R.layout.activity_github)
27 | inject()
28 | refreshButton = findViewById(R.id.stars_refresh) as Button
29 | starsCountText = findViewById(R.id.stars_count_text) as TextView
30 |
31 | refreshButton.setOnClickListener { useCase.loadInfoFromGithub(onLoaded = ::updateUI, onError = ::updateErrorUI) }
32 |
33 | notifications.showMessage()
34 | }
35 |
36 | fun inject() {
37 | GithubActivityComponent.Initializer
38 | .init((applicationContext as App).getAppComponent())
39 | .inject(this@GithubActivity)
40 | }
41 |
42 | private fun updateErrorUI(error: Throwable) {
43 | toaster.show(error.message ?: "unable to load")
44 | }
45 |
46 | private fun updateUI(result: GithubProject) {
47 | starsCountText.setText("${result.name} stars count: ${result.stargazers_count}")
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/sources/features/githubbrowser/src/main/java/com/kotlinsg/kworkshopapp/github/GithubUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.github
2 |
3 | import com.kotlinsg.kworkshopapp.GithubProject
4 | import com.kotlinsg.kworkshopapp.repo.GithubRepo
5 | import javax.inject.Inject
6 |
7 |
8 | interface GithubUseCase {
9 | fun loadInfoFromGithub(onLoaded: (GithubProject) -> Unit, onError: (Throwable) -> Unit)
10 | }
11 |
12 | class GithubUseCaseImpl @Inject constructor(
13 | val repo: GithubRepo
14 | ) : GithubUseCase {
15 |
16 | override fun loadInfoFromGithub(onLoaded: (GithubProject) -> Unit, onError: (Throwable) -> Unit) {
17 | repo.getSampleProject(onLoaded, onError)
18 | }
19 | }
--------------------------------------------------------------------------------
/sources/features/githubbrowser/src/main/res/layout/activity_github.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
26 |
27 |
--------------------------------------------------------------------------------
/sources/features/mainscreen/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sources/features/mainscreen/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | compileSdkVersion 27
7 | buildToolsVersion '27.0.3'
8 | defaultConfig {
9 | minSdkVersion 15
10 | targetSdkVersion 27
11 | versionCode 1
12 | versionName "1.0"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | implementation project(':core')
25 |
26 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
27 | implementation 'com.android.support:appcompat-v7:27.1.0'
28 |
29 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
30 | implementation "com.google.dagger:dagger:$daggerVersion"
31 | }
32 |
--------------------------------------------------------------------------------
/sources/features/mainscreen/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/nekdenis/Work/sdk/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/sources/features/mainscreen/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/sources/features/mainscreen/src/main/java/com/kotlinsg/kworkshopapp/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp
2 |
3 | import android.os.Bundle
4 | import android.support.v7.app.AppCompatActivity
5 | import android.view.View
6 | import com.kotlinsg.kworkshopapp.actions.ShowGithubScreenAction
7 | import com.kotlinsg.kworkshopapp.appB.R
8 | import com.kotlinsg.kworkshopapp.di.Logger
9 | import com.kotlinsg.kworkshopapp.di.MainActivityComponent
10 | import javax.inject.Inject
11 |
12 | class MainActivity : AppCompatActivity() {
13 |
14 | @Inject lateinit var log: Logger
15 | @Inject lateinit var showGithubScreenAction: ShowGithubScreenAction
16 |
17 | override fun onCreate(savedInstanceState: Bundle?) {
18 | super.onCreate(savedInstanceState)
19 | inject()
20 |
21 | setContentView(R.layout.activity_main)
22 |
23 | findViewById(R.id.icon).setOnClickListener { openGithubScreen() }
24 | log.d("Main activity created. Logger injected successfully")
25 | }
26 |
27 | private fun inject() {
28 | MainActivityComponent.Initializer
29 | .init((applicationContext as App).getAppComponent())
30 | .inject(this@MainActivity)
31 | }
32 |
33 | private fun openGithubScreen() {
34 | showGithubScreenAction.show(this)
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sources/features/mainscreen/src/main/java/com/kotlinsg/kworkshopapp/di/MainActivityComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di
2 |
3 | import com.kotlinsg.kworkshopapp.MainActivity
4 | import dagger.Component
5 |
6 | @ActivityScope
7 | @Component(
8 | dependencies = arrayOf(ApplicationProvider::class),
9 | modules = arrayOf(MainActivityModule::class))
10 | interface MainActivityComponent {
11 | fun inject(activity: MainActivity)
12 |
13 | class Initializer private constructor() {
14 | companion object {
15 | fun init(appComponent: ApplicationProvider): MainActivityComponent =
16 | DaggerMainActivityComponent.builder()
17 | .applicationProvider(appComponent).build()
18 | }
19 | }
20 | }
21 |
22 |
--------------------------------------------------------------------------------
/sources/features/mainscreen/src/main/java/com/kotlinsg/kworkshopapp/di/MainActivityModule.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.di;
2 |
3 | import dagger.Module;
4 |
5 | @Module
6 | public interface MainActivityModule {
7 |
8 | }
--------------------------------------------------------------------------------
/sources/features/mainscreen/src/main/res/drawable/ic_folder_open_teal_400_24dp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/sources/features/mainscreen/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/sources/features/notifications/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sources/features/notifications/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | compileSdkVersion 27
7 |
8 |
9 |
10 | defaultConfig {
11 | minSdkVersion 15
12 | targetSdkVersion 27
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation project(':core')
31 |
32 | compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
33 |
34 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
35 | implementation "com.google.dagger:dagger:$daggerVersion"
36 | }
37 | repositories {
38 | mavenCentral()
39 | }
40 |
--------------------------------------------------------------------------------
/sources/features/notifications/notifications-fake/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/sources/features/notifications/notifications-fake/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | compileSdkVersion 27
7 |
8 |
9 |
10 | defaultConfig {
11 | minSdkVersion 15
12 | targetSdkVersion 27
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 |
18 | }
19 |
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation project(':core')
31 |
32 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
33 |
34 | kapt "com.google.dagger:dagger-compiler:$daggerVersion"
35 | implementation "com.google.dagger:dagger:$daggerVersion"
36 | }
37 | repositories {
38 | mavenCentral()
39 | }
40 |
--------------------------------------------------------------------------------
/sources/features/notifications/notifications-fake/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sources/features/notifications/notifications-fake/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/sources/features/notifications/notifications-fake/src/main/java/com/kotlinsg/kworkshopapp/notification/di/NotificationComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.notification.di
2 |
3 | import com.kotlinsg.kworkshopapp.di.MainToolsProvider
4 | import com.kotlinsg.kworkshopapp.tools.Toaster
5 | import dagger.Component
6 | import dagger.Module
7 | import dagger.Provides
8 |
9 | interface NotificationProvider {
10 | fun provideNotificationUseCase(): NotificationUseCase
11 | }
12 |
13 | @Module
14 | class NotificationModule {
15 | @Provides fun providesNotificationUseCase(toaster: Toaster): NotificationUseCase =
16 | object : NotificationUseCase {
17 | override fun showMessage() {
18 | toaster.show("notifications are not implemented")
19 | }
20 | }
21 | }
22 |
23 | @Component(
24 | dependencies = [MainToolsProvider::class],
25 | modules = [NotificationModule::class])
26 | interface NotificationComponent : NotificationProvider {
27 | class Initializer private constructor() {
28 | companion object {
29 |
30 | fun init(mainToolsProvider: MainToolsProvider): NotificationProvider =
31 | DaggerNotificationComponent.builder()
32 | .mainToolsProvider(mainToolsProvider)
33 | .build()
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/sources/features/notifications/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/sources/features/notifications/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/sources/features/notifications/src/main/java/com/kotlinsg/kworkshopapp/notification/di/NotificationComponent.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.notification.di
2 |
3 | import com.kotlinsg.kworkshopapp.di.MainToolsProvider
4 | import com.kotlinsg.kworkshopapp.di.NotificaitonProvider
5 | import dagger.Binds
6 | import dagger.Component
7 | import dagger.Module
8 |
9 | @Module
10 | interface NotificationModule {
11 | @Binds fun bindsNotificationUseCase(impl: NotificationUseCaseImpl): NotificationUseCase
12 | }
13 |
14 | @Component(
15 | dependencies = [MainToolsProvider::class],
16 | modules = [NotificationModule::class])
17 | interface NotificationComponent : NotificaitonProvider
--------------------------------------------------------------------------------
/sources/features/notifications/src/main/java/com/kotlinsg/kworkshopapp/notification/di/NotificationUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.kotlinsg.kworkshopapp.notification.di
2 |
3 | import com.kotlinsg.kworkshopapp.tools.Toaster
4 | import javax.inject.Inject
5 |
6 |
7 | class NotificationUseCaseImpl @Inject constructor(
8 | val toaster: Toaster
9 | ) : NotificationUseCase {
10 | override fun showMessage() {
11 | toaster.show("notifications are not implemented")
12 | }
13 | }
--------------------------------------------------------------------------------