diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..b75873e --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +BPM \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fcb19bf --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..2d78bff --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..5325f55 --- /dev/null +++ b/build.gradle @@ -0,0 +1,18 @@ +buildscript { + dependencies { + classpath 'com.google.android.gms:oss-licenses-plugin:0.10.6' + } +} + +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + id 'com.android.application' version '7.4.0' apply false + id 'com.android.library' version '7.4.0' apply false + id 'org.jetbrains.kotlin.android' version '1.7.21' apply false + id 'org.jetbrains.kotlin.jvm' version '1.7.21' apply false + id 'com.google.dagger.hilt.android' version '2.44' apply false +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/data/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/data/build.gradle b/data/build.gradle new file mode 100644 index 0000000..098b9b6 --- /dev/null +++ b/data/build.gradle @@ -0,0 +1,116 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' + id 'kotlin-kapt' + id 'kotlin-parcelize' + id 'dagger.hilt.android.plugin' +} + +android { + namespace 'com.d83t.bpm.data' + compileSdk 33 + + defaultConfig { + minSdk 28 + targetSdk 33 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + kapt { + javacOptions { + option("-Adagger.fastInit=ENABLED") + option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true") + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + implementation project(path: ':domain') + + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.8.0' + + //kotlin + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.21" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" + + //android + implementation "androidx.core:core-ktx:1.9.0" + implementation "androidx.appcompat:appcompat:1.6.0" + implementation "androidx.navigation:navigation-fragment:2.5.3" + implementation "androidx.fragment:fragment-ktx:1.5.5" + implementation 'com.google.android.material:material:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation "androidx.recyclerview:recyclerview:1.2.1" + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + + //databinding + implementation "androidx.databinding:databinding-ktx:7.4.1" + implementation 'com.google.firebase:firebase-config-ktx:21.2.1' + + //lifecycle + def lifecycle_version = "2.5.0" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${lifecycle_version}" + implementation "androidx.lifecycle:lifecycle-livedata-ktx:${lifecycle_version}" + implementation "androidx.lifecycle:lifecycle-runtime-ktx:${lifecycle_version}" + implementation "androidx.lifecycle:lifecycle-common:${lifecycle_version}" + //implementation "androidx.lifecycle:lifecycle-extensions:${lifecycle_version}" + + //hilt + def hilt_version = "2.44" + implementation "com.google.dagger:hilt-android:${hilt_version}" + kapt "com.google.dagger:hilt-android-compiler:${hilt_version}" + + //material + implementation "com.google.android.material:material:1.8.0" + + //retrofit + def RETROFIT = "2.9.0" + implementation "com.squareup.retrofit2:retrofit:${RETROFIT}" + implementation "com.squareup.retrofit2:converter-gson:${RETROFIT}" + + //okhttp + def OKHTTP = "5.0.0-alpha.2" + implementation "com.squareup.okhttp3:okhttp:${OKHTTP}" + implementation "com.squareup.okhttp3:logging-interceptor:${OKHTTP}" + implementation "com.squareup.okhttp3:okhttp-urlconnection:${OKHTTP}" + + //glide + def GLIDE = "4.11.0" + implementation "com.github.bumptech.glide:glide:${GLIDE}" + implementation "com.github.bumptech.glide:okhttp3-integration:${GLIDE}" + kapt "com.github.bumptech.glide:compiler:${GLIDE}" + + //unit test + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + //tedpermission + implementation 'io.github.ParkSangGwon:tedpermission-coroutine:3.3.0' + + //timber log + implementation 'com.jakewharton.timber:timber:5.0.1' + + //opensource + implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' +} \ No newline at end of file diff --git a/data/consumer-rules.pro b/data/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/data/proguard-rules.pro b/data/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/data/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# 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 \ No newline at end of file diff --git a/data/src/androidTest/java/com/d83t/bpm/data/ExampleInstrumentedTest.kt b/data/src/androidTest/java/com/d83t/bpm/data/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..549cc8e --- /dev/null +++ b/data/src/androidTest/java/com/d83t/bpm/data/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.d83t.presentation.data + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.d83t.bpm.data.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/data/src/main/AndroidManifest.xml b/data/src/main/AndroidManifest.xml new file mode 100644 index 0000000..ec3baa9 --- /dev/null +++ b/data/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/data/src/main/java/com/d83t/bpm/data/base/BaseResponse.kt b/data/src/main/java/com/d83t/bpm/data/base/BaseResponse.kt new file mode 100644 index 0000000..6478980 --- /dev/null +++ b/data/src/main/java/com/d83t/bpm/data/base/BaseResponse.kt @@ -0,0 +1,5 @@ +package com.d83t.bpm.data.base + +import android.os.Parcelable + +interface BaseResponse : Parcelable \ No newline at end of file diff --git a/data/src/main/java/com/d83t/bpm/data/mapper/DataMapper.kt b/data/src/main/java/com/d83t/bpm/data/mapper/DataMapper.kt new file mode 100644 index 0000000..d9efc15 --- /dev/null +++ b/data/src/main/java/com/d83t/bpm/data/mapper/DataMapper.kt @@ -0,0 +1,8 @@ +package com.d83t.bpm.data.mapper + +import com.d83t.bpm.data.base.BaseResponse +import com.d83t.bpm.domain.base.BaseModel + +interface DataMapper { + fun R.toDataModel(): D +} diff --git a/data/src/main/java/com/d83t/bpm/data/network/MainApi.kt b/data/src/main/java/com/d83t/bpm/data/network/MainApi.kt new file mode 100644 index 0000000..aca13af --- /dev/null +++ b/data/src/main/java/com/d83t/bpm/data/network/MainApi.kt @@ -0,0 +1,5 @@ +package com.d83t.bpm.data.network + +interface MainApi { + +} \ No newline at end of file diff --git a/data/src/main/java/com/d83t/bpm/data/repositoryImpl/MainRepositoryImpl.kt b/data/src/main/java/com/d83t/bpm/data/repositoryImpl/MainRepositoryImpl.kt new file mode 100644 index 0000000..1dd02d3 --- /dev/null +++ b/data/src/main/java/com/d83t/bpm/data/repositoryImpl/MainRepositoryImpl.kt @@ -0,0 +1,12 @@ +package com.d83t.bpm.data.repositoryImpl + +import com.d83t.bpm.domain.repository.MainRepository +import javax.inject.Inject + +class MainRepositoryImpl @Inject constructor() : MainRepository { + + override fun getSampleText(): String { + return "text" + } + +} \ No newline at end of file diff --git a/data/src/test/java/com/d83t/bpm/data/ExampleUnitTest.kt b/data/src/test/java/com/d83t/bpm/data/ExampleUnitTest.kt new file mode 100644 index 0000000..c4300af --- /dev/null +++ b/data/src/test/java/com/d83t/bpm/data/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.d83t.presentation.data + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/domain/.gitignore b/domain/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/domain/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/build.gradle b/domain/build.gradle new file mode 100644 index 0000000..cc18666 --- /dev/null +++ b/domain/build.gradle @@ -0,0 +1,116 @@ +plugins { + id 'com.android.library' + id 'org.jetbrains.kotlin.android' + id 'kotlin-kapt' + id 'kotlin-parcelize' + id 'dagger.hilt.android.plugin' +} + +android { + namespace 'com.d83t.bpm.domain' + compileSdk 33 + + defaultConfig { + minSdk 28 + targetSdk 33 + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles "consumer-rules.pro" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + kapt { + javacOptions { + option("-Adagger.fastInit=ENABLED") + option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true") + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = '1.8' + } +} + +dependencies { + + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.8.0' + + //kotlin + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.21" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" + + //android + implementation "androidx.core:core-ktx:1.9.0" + implementation "androidx.appcompat:appcompat:1.6.0" + implementation "androidx.navigation:navigation-fragment:2.5.3" + implementation "androidx.fragment:fragment-ktx:1.5.5" + implementation 'com.google.android.material:material:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation "androidx.recyclerview:recyclerview:1.2.1" + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + + + //databinding + implementation "androidx.databinding:databinding-ktx:7.4.1" + implementation 'com.google.firebase:firebase-config-ktx:21.2.1' + + //lifecycle + def lifecycle_version = "2.5.0" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${lifecycle_version}" + implementation "androidx.lifecycle:lifecycle-livedata-ktx:${lifecycle_version}" + implementation "androidx.lifecycle:lifecycle-runtime-ktx:${lifecycle_version}" + implementation "androidx.lifecycle:lifecycle-common:${lifecycle_version}" + //implementation "androidx.lifecycle:lifecycle-extensions:${lifecycle_version}" + + //hilt + def hilt_version = "2.44" + implementation "com.google.dagger:hilt-android:${hilt_version}" + kapt "com.google.dagger:hilt-android-compiler:${hilt_version}" + + //material + implementation "com.google.android.material:material:1.8.0" + + //retrofit + def RETROFIT = "2.9.0" + implementation "com.squareup.retrofit2:retrofit:${RETROFIT}" + implementation "com.squareup.retrofit2:converter-gson:${RETROFIT}" + + //okhttp + def OKHTTP = "5.0.0-alpha.2" + implementation "com.squareup.okhttp3:okhttp:${OKHTTP}" + implementation "com.squareup.okhttp3:logging-interceptor:${OKHTTP}" + implementation "com.squareup.okhttp3:okhttp-urlconnection:${OKHTTP}" + + //glide + def GLIDE = "4.11.0" + implementation "com.github.bumptech.glide:glide:${GLIDE}" + implementation "com.github.bumptech.glide:okhttp3-integration:${GLIDE}" + kapt "com.github.bumptech.glide:compiler:${GLIDE}" + + //unit test + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + //tedpermission + implementation 'io.github.ParkSangGwon:tedpermission-coroutine:3.3.0' + + //timber log + implementation 'com.jakewharton.timber:timber:5.0.1' + + //opensource + implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' +} \ No newline at end of file diff --git a/domain/consumer-rules.pro b/domain/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/domain/proguard-rules.pro b/domain/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/domain/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# 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 \ No newline at end of file diff --git a/domain/src/androidTest/java/com/d83t/bpm/domain/ExampleInstrumentedTest.kt b/domain/src/androidTest/java/com/d83t/bpm/domain/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..099f884 --- /dev/null +++ b/domain/src/androidTest/java/com/d83t/bpm/domain/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.d83t.presentation.domain + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.d83t.bpm.domain.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/domain/src/main/AndroidManifest.xml b/domain/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8e74c2f --- /dev/null +++ b/domain/src/main/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/domain/src/main/java/com/d83t/bpm/domain/base/BaseModel.kt b/domain/src/main/java/com/d83t/bpm/domain/base/BaseModel.kt new file mode 100644 index 0000000..c22a69d --- /dev/null +++ b/domain/src/main/java/com/d83t/bpm/domain/base/BaseModel.kt @@ -0,0 +1,5 @@ +package com.d83t.bpm.domain.base + +import android.os.Parcelable + +interface BaseModel : Parcelable \ No newline at end of file diff --git a/domain/src/main/java/com/d83t/bpm/domain/repository/MainRepository.kt b/domain/src/main/java/com/d83t/bpm/domain/repository/MainRepository.kt new file mode 100644 index 0000000..dd432a1 --- /dev/null +++ b/domain/src/main/java/com/d83t/bpm/domain/repository/MainRepository.kt @@ -0,0 +1,7 @@ +package com.d83t.bpm.domain.repository + +interface MainRepository { + + fun getSampleText(): String + +} \ No newline at end of file diff --git a/domain/src/main/java/com/d83t/bpm/domain/usecase/GetSampleTextUseCase.kt b/domain/src/main/java/com/d83t/bpm/domain/usecase/GetSampleTextUseCase.kt new file mode 100644 index 0000000..cc0dea6 --- /dev/null +++ b/domain/src/main/java/com/d83t/bpm/domain/usecase/GetSampleTextUseCase.kt @@ -0,0 +1,12 @@ +package com.d83t.bpm.domain.usecase + +import com.d83t.bpm.domain.repository.MainRepository +import javax.inject.Inject + +class GetSampleTextUseCase @Inject constructor( + private val mainRepository: MainRepository +) { + operator fun invoke(): String { + return mainRepository.getSampleText() + } +} \ No newline at end of file diff --git a/domain/src/test/java/com/d83t/bpm/domain/ExampleUnitTest.kt b/domain/src/test/java/com/d83t/bpm/domain/ExampleUnitTest.kt new file mode 100644 index 0000000..53676c0 --- /dev/null +++ b/domain/src/test/java/com/d83t/bpm/domain/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.d83t.presentation.domain + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..9a78df2 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..315a36b --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Jan 30 01:01:39 KST 2023 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/presentation/.gitignore b/presentation/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/presentation/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/presentation/build.gradle b/presentation/build.gradle new file mode 100644 index 0000000..e18fd4a --- /dev/null +++ b/presentation/build.gradle @@ -0,0 +1,132 @@ +plugins { + id 'com.android.application' + id 'org.jetbrains.kotlin.android' + id 'kotlin-kapt' + id 'kotlin-parcelize' + id 'dagger.hilt.android.plugin' + id 'com.google.android.gms.oss-licenses-plugin' +} + +android { + namespace 'com.d83t.bpm.presentation' + compileSdk 33 + + defaultConfig { + applicationId "com.d83t.bpm" + minSdk 28 + targetSdk 33 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + kapt { + javacOptions { + option("-Adagger.fastInit=ENABLED") + option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true") + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + buildFeatures { + viewBinding true + } + + dataBinding { + enabled = true + } +} + +dependencies { + + implementation project(path: ':data') + implementation project(path: ':domain') + + implementation 'androidx.core:core-ktx:1.9.0' + implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'com.google.android.material:material:1.8.0' + + //kotlin + implementation "org.jetbrains.kotlin:kotlin-stdlib:1.7.21" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4" + + //android + implementation "androidx.core:core-ktx:1.9.0" + implementation "androidx.appcompat:appcompat:1.6.0" + implementation "androidx.navigation:navigation-fragment:2.5.3" + implementation "androidx.fragment:fragment-ktx:1.5.5" + implementation 'com.google.android.material:material:1.8.0' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation "androidx.recyclerview:recyclerview:1.2.1" + implementation 'androidx.legacy:legacy-support-v4:1.0.0' + implementation "androidx.navigation:navigation-fragment-ktx:2.6.0-alpha04" + implementation "androidx.navigation:navigation-ui-ktx:2.6.0-alpha04" + + //databinding + implementation "androidx.databinding:databinding-ktx:7.4.1" + implementation 'com.google.firebase:firebase-config-ktx:21.2.1' + + //lifecycle + def lifecycle_version = "2.5.0" + implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${lifecycle_version}" + implementation "androidx.lifecycle:lifecycle-livedata-ktx:${lifecycle_version}" + implementation "androidx.lifecycle:lifecycle-runtime-ktx:${lifecycle_version}" + implementation "androidx.lifecycle:lifecycle-common:${lifecycle_version}" + //implementation "androidx.lifecycle:lifecycle-extensions:${lifecycle_version}" + + //hilt + def hilt_version = "2.44" + implementation "com.google.dagger:hilt-android:${hilt_version}" + kapt "com.google.dagger:hilt-android-compiler:${hilt_version}" + + //material + implementation "com.google.android.material:material:1.8.0" + + //retrofit + def RETROFIT = "2.9.0" + implementation "com.squareup.retrofit2:retrofit:${RETROFIT}" + implementation "com.squareup.retrofit2:converter-gson:${RETROFIT}" + + //okhttp + def OKHTTP = "5.0.0-alpha.2" + implementation "com.squareup.okhttp3:okhttp:${OKHTTP}" + implementation "com.squareup.okhttp3:logging-interceptor:${OKHTTP}" + implementation "com.squareup.okhttp3:okhttp-urlconnection:${OKHTTP}" + + //glide + def GLIDE = "4.11.0" + implementation "com.github.bumptech.glide:glide:${GLIDE}" + implementation "com.github.bumptech.glide:okhttp3-integration:${GLIDE}" + kapt "com.github.bumptech.glide:compiler:${GLIDE}" + + //unit test + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.1.5' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + + //tedpermission + implementation 'io.github.ParkSangGwon:tedpermission-coroutine:3.3.0' + + //timber log + implementation 'com.jakewharton.timber:timber:5.0.1' + + //opensource + implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' +} \ No newline at end of file diff --git a/presentation/proguard-rules.pro b/presentation/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/presentation/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# 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 \ No newline at end of file diff --git a/presentation/src/androidTest/java/com/d83t/bpm/presentation/ExampleInstrumentedTest.kt b/presentation/src/androidTest/java/com/d83t/bpm/presentation/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..a7f247c --- /dev/null +++ b/presentation/src/androidTest/java/com/d83t/bpm/presentation/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.d83t.presentation + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.d83t.bpm", appContext.packageName) + } +} \ No newline at end of file diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml new file mode 100644 index 0000000..99a9400 --- /dev/null +++ b/presentation/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/App.kt b/presentation/src/main/java/com/d83t/bpm/presentation/App.kt new file mode 100644 index 0000000..5d7b688 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/App.kt @@ -0,0 +1,16 @@ +package com.d83t.bpm.presentation + +import android.app.Application +import dagger.hilt.android.HiltAndroidApp +import timber.log.Timber + +@HiltAndroidApp +class App : Application() { + + override fun onCreate() { + super.onCreate() + + Timber.plant(Timber.DebugTree()) + } + +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseActivity.kt b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseActivity.kt new file mode 100644 index 0000000..112bdff --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseActivity.kt @@ -0,0 +1,31 @@ +package com.d83t.bpm.presentation.base + +import android.os.Bundle +import android.view.LayoutInflater +import androidx.appcompat.app.AppCompatActivity +import androidx.databinding.ViewDataBinding + +abstract class BaseActivity(private val inflater: (LayoutInflater) -> T) : + AppCompatActivity() { + + lateinit var binding: T + + protected abstract val viewModel: BaseViewModel + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = inflater(layoutInflater) + setContentView(binding.root) + + initLayout() + setupCollect() + } + + protected abstract fun initLayout() + + protected abstract fun setupCollect() + + protected fun bind(action: T.() -> Unit) { + binding.run(action) + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseBottomSheetFragment.kt b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseBottomSheetFragment.kt new file mode 100644 index 0000000..866ad6d --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseBottomSheetFragment.kt @@ -0,0 +1,41 @@ +package com.d83t.bpm.presentation.base + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.databinding.ViewDataBinding +import com.google.android.material.bottomsheet.BottomSheetDialogFragment + +abstract class BaseBottomSheetFragment(private val inflater: (LayoutInflater) -> T) : + BottomSheetDialogFragment() { + + lateinit var binding: T + + protected abstract val viewModel: BaseViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + binding = inflater(layoutInflater) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + initLayout() + setupCollect() + } + + protected abstract fun initLayout() + + protected open fun setupCollect() = Unit + + protected fun bind(action: T.() -> Unit) { + binding.run(action) + } + +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseDialogFragment.kt b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseDialogFragment.kt new file mode 100644 index 0000000..1d7ccfe --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseDialogFragment.kt @@ -0,0 +1,41 @@ +package com.d83t.bpm.presentation.base + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.databinding.ViewDataBinding +import androidx.fragment.app.DialogFragment + +abstract class BaseDialogFragment(private val inflater: (LayoutInflater) -> T) : + DialogFragment() { + + lateinit var binding: T + + protected abstract val viewModel: BaseViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + binding = inflater(layoutInflater) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + initLayout() + setupCollect() + } + + protected abstract fun initLayout() + + protected open fun setupCollect() = Unit + + protected fun bind(action: T.() -> Unit) { + binding.run(action) + } + +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseFragment.kt b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseFragment.kt new file mode 100644 index 0000000..c7ee00f --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseFragment.kt @@ -0,0 +1,41 @@ +package com.d83t.bpm.presentation.base + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.databinding.ViewDataBinding +import androidx.fragment.app.Fragment + +abstract class BaseFragment(private val inflater: (LayoutInflater) -> T) : + Fragment() { + + lateinit var binding: T + + protected abstract val viewModel: BaseViewModel + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + binding = inflater(layoutInflater) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + initLayout() + setupCollect() + } + + protected abstract fun initLayout() + + protected open fun setupCollect() = Unit + + protected fun bind(action: T.() -> Unit) { + binding.run(action) + } + +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseViewModel.kt b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseViewModel.kt new file mode 100644 index 0000000..6e1a152 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/base/BaseViewModel.kt @@ -0,0 +1,5 @@ +package com.d83t.bpm.presentation.base + +import androidx.lifecycle.ViewModel + +abstract class BaseViewModel : ViewModel() \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/di/CoroutinesDispatchersModule.kt b/presentation/src/main/java/com/d83t/bpm/presentation/di/CoroutinesDispatchersModule.kt new file mode 100644 index 0000000..c1e7b94 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/di/CoroutinesDispatchersModule.kt @@ -0,0 +1,29 @@ +package com.d83t.bpm.presentation.di + +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers + +@InstallIn(SingletonComponent::class) +@Module +object CoroutinesDispatchersModule { + + @DefaultDispatcher + @Provides + fun providesDefaultDispatcher(): CoroutineDispatcher = Dispatchers.Default + + @IoDispatcher + @Provides + fun providesIoDispatcher(): CoroutineDispatcher = Dispatchers.IO + + @MainDispatcher + @Provides + fun providesMainDispatcher(): CoroutineDispatcher = Dispatchers.Main + + @MainImmediateDispatcher + @Provides + fun providesMainImmediateDispatcher(): CoroutineDispatcher = Dispatchers.Main.immediate +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/di/CoroutinesQualifiers.kt b/presentation/src/main/java/com/d83t/bpm/presentation/di/CoroutinesQualifiers.kt new file mode 100644 index 0000000..2abce03 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/di/CoroutinesQualifiers.kt @@ -0,0 +1,19 @@ +package com.d83t.bpm.presentation.di + +import javax.inject.Qualifier + +@Retention(AnnotationRetention.RUNTIME) +@Qualifier +annotation class DefaultDispatcher + +@Retention(AnnotationRetention.RUNTIME) +@Qualifier +annotation class IoDispatcher + +@Retention(AnnotationRetention.RUNTIME) +@Qualifier +annotation class MainDispatcher + +@Retention(AnnotationRetention.BINARY) +@Qualifier +annotation class MainImmediateDispatcher \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/di/CoroutinesScopesModule.kt b/presentation/src/main/java/com/d83t/bpm/presentation/di/CoroutinesScopesModule.kt new file mode 100644 index 0000000..7427010 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/di/CoroutinesScopesModule.kt @@ -0,0 +1,22 @@ +package com.d83t.bpm.presentation.di + +import com.d83t.bpm.presentation.di.DefaultDispatcher +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.SupervisorJob +import javax.inject.Singleton + +@InstallIn(SingletonComponent::class) +@Module +object CoroutinesScopesModule { + + @Singleton + @Provides + fun providesCoroutineScope( + @DefaultDispatcher defaultDispatcher: CoroutineDispatcher + ): CoroutineScope = CoroutineScope(SupervisorJob() + defaultDispatcher) +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/di/NetworkModule.kt b/presentation/src/main/java/com/d83t/bpm/presentation/di/NetworkModule.kt new file mode 100644 index 0000000..a60f273 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/di/NetworkModule.kt @@ -0,0 +1,63 @@ +package com.d83t.bpm.presentation.di + +import com.d83t.bpm.data.network.MainApi +import com.d83t.bpm.presentation.BuildConfig +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import java.util.concurrent.TimeUnit +import javax.inject.Singleton +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory + +@Module +@InstallIn(SingletonComponent::class) +object NetworkModule { + + val BASE_URL = "" + + @Singleton + @Provides + fun provideHttpClient(): OkHttpClient { + val interceptor = HttpLoggingInterceptor() +// if (BuildConfig.DEBUG) { +// interceptor.level = HttpLoggingInterceptor.Level.HEADERS +// } else { +// interceptor.level = HttpLoggingInterceptor.Level.NONE +// } + + return OkHttpClient + .Builder() + .readTimeout(15, TimeUnit.SECONDS) + .connectTimeout(15, TimeUnit.SECONDS) + .addNetworkInterceptor(interceptor) + .build() + } + + + @Singleton + @Provides + fun provideConverterFactory(): GsonConverterFactory = GsonConverterFactory.create() + + @Singleton + @Provides + fun provideRetrofit( + okHttpClient: OkHttpClient, + gsonConverterFactory: GsonConverterFactory + ): Retrofit { + return Retrofit.Builder() + .baseUrl(BASE_URL) + .client(okHttpClient) + .addConverterFactory(gsonConverterFactory) + .build() + } + + @Singleton + @Provides + fun provideMainApi(retrofit: Retrofit): MainApi { + return retrofit.create(MainApi::class.java) + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/di/RepositoryModule.kt b/presentation/src/main/java/com/d83t/bpm/presentation/di/RepositoryModule.kt new file mode 100644 index 0000000..e151498 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/di/RepositoryModule.kt @@ -0,0 +1,23 @@ +package com.d83t.bpm.presentation.di + +import com.d83t.bpm.data.repositoryImpl.MainRepositoryImpl +import com.d83t.bpm.domain.repository.MainRepository +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + + +@Module +@InstallIn(SingletonComponent::class) +object RepositoryModule { + + @Singleton + @Provides + fun provideMainRepository( + ): MainRepository { + return MainRepositoryImpl() + } + +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/di/UseCaseModule.kt b/presentation/src/main/java/com/d83t/bpm/presentation/di/UseCaseModule.kt new file mode 100644 index 0000000..f5b4f22 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/di/UseCaseModule.kt @@ -0,0 +1,21 @@ +package com.d83t.bpm.presentation.di + +import com.d83t.bpm.domain.repository.MainRepository +import com.d83t.bpm.domain.usecase.GetSampleTextUseCase +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ViewModelComponent +import dagger.hilt.android.scopes.ViewModelScoped + +@Module +@InstallIn(ViewModelComponent::class) +object UseCaseModule { + + @Provides + @ViewModelScoped + fun provideGetSampleTextUseCase(mainRepository: MainRepository): GetSampleTextUseCase { + return GetSampleTextUseCase(mainRepository) + } + +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainActivity.kt b/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainActivity.kt new file mode 100644 index 0000000..b7a8fc0 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainActivity.kt @@ -0,0 +1,37 @@ +package com.d83t.bpm.presentation.ui.main + +import androidx.activity.viewModels +import com.d83t.bpm.presentation.base.BaseActivity +import com.d83t.bpm.presentation.databinding.ActivityMainBinding +import com.d83t.bpm.presentation.util.repeatCallDefaultOnStarted +import com.d83t.bpm.presentation.util.showToast +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class MainActivity : BaseActivity(ActivityMainBinding::inflate) { + + override val viewModel: MainViewModel by viewModels() + + override fun initLayout() { + // TODO : setup view, ui + + } + + override fun setupCollect() { + // TODO : collect any SharedFlows, StateFlows + + repeatCallDefaultOnStarted { + viewModel.state.collect { state -> + when (state) { + MainState.Init -> { + viewModel.getInitText() + } + is MainState.SampleText -> { + showToast(state.text) + } + } + } + + } + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainState.kt b/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainState.kt new file mode 100644 index 0000000..c0e0e38 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainState.kt @@ -0,0 +1,6 @@ +package com.d83t.bpm.presentation.ui.main + +sealed interface MainState { + object Init : MainState + data class SampleText(val text : String) : MainState +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainViewEvent.kt b/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainViewEvent.kt new file mode 100644 index 0000000..9651e6d --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainViewEvent.kt @@ -0,0 +1,5 @@ +package com.d83t.bpm.presentation.ui.main + +sealed interface MainViewEvent { + object Click : MainViewEvent +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainViewModel.kt b/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainViewModel.kt new file mode 100644 index 0000000..d8f13f0 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/ui/main/MainViewModel.kt @@ -0,0 +1,39 @@ +package com.d83t.bpm.presentation.ui.main + +import androidx.lifecycle.viewModelScope +import com.d83t.bpm.domain.usecase.GetSampleTextUseCase +import com.d83t.bpm.presentation.base.BaseViewModel +import com.d83t.bpm.presentation.di.MainDispatcher +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.launch + +@HiltViewModel +class MainViewModel @Inject constructor( + private val getSampleTextUseCase: GetSampleTextUseCase, + @MainDispatcher private val mainDispatcher: CoroutineDispatcher +) : BaseViewModel() { + + private val _event = MutableSharedFlow() + val event: SharedFlow + get() = _event + + private val _state = MutableStateFlow(MainState.Init) + val state: StateFlow + get() = _state + + fun getInitText() { + val sampleText = getSampleTextUseCase() + + viewModelScope.launch(mainDispatcher) { + _state.emit(MainState.SampleText(sampleText)) + } + + } + +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/util/DataBindingUtils.kt b/presentation/src/main/java/com/d83t/bpm/presentation/util/DataBindingUtils.kt new file mode 100644 index 0000000..0595982 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/util/DataBindingUtils.kt @@ -0,0 +1 @@ +package com.d83t.bpm.presentation.util diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/util/LifecycleExtensions.kt b/presentation/src/main/java/com/d83t/bpm/presentation/util/LifecycleExtensions.kt new file mode 100644 index 0000000..23085f3 --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/util/LifecycleExtensions.kt @@ -0,0 +1,40 @@ +package com.d83t.bpm.presentation.util + +import androidx.fragment.app.Fragment +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.repeatOnLifecycle +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch + +fun LifecycleOwner.repeatCallDefaultOnCreated( + state: Lifecycle.State = Lifecycle.State.CREATED, + block: suspend CoroutineScope.() -> Unit +) { + lifecycleScope.launch { + lifecycle.repeatOnLifecycle(state, block) + } +} + +fun LifecycleOwner.repeatCallDefaultOnStarted( + state: Lifecycle.State = Lifecycle.State.STARTED, + block: suspend CoroutineScope.() -> Unit +) { + lifecycleScope.launch { + lifecycle.repeatOnLifecycle(state, block) + } +} + +fun LifecycleOwner.repeatCallDefaultOnResume( + state: Lifecycle.State = Lifecycle.State.RESUMED, + block: suspend CoroutineScope.() -> Unit +) { + lifecycleScope.launch { + lifecycle.repeatOnLifecycle(state, block) + } +} + +fun Fragment.requireGrandParentFragment(): Fragment { + return this.requireParentFragment().requireParentFragment() +} \ No newline at end of file diff --git a/presentation/src/main/java/com/d83t/bpm/presentation/util/ToastUtils.kt b/presentation/src/main/java/com/d83t/bpm/presentation/util/ToastUtils.kt new file mode 100644 index 0000000..ce07b4c --- /dev/null +++ b/presentation/src/main/java/com/d83t/bpm/presentation/util/ToastUtils.kt @@ -0,0 +1,8 @@ +package com.d83t.bpm.presentation.util + +import android.content.Context +import android.widget.Toast + +fun Context.showToast(text: String) { + Toast.makeText(this, text, Toast.LENGTH_SHORT).show() +} \ No newline at end of file diff --git a/presentation/src/main/res/drawable-v24/ic_launcher_foreground.xml b/presentation/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/presentation/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/drawable/ic_launcher_background.xml b/presentation/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/presentation/src/main/res/layout/activity_main.xml b/presentation/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..1642c1b --- /dev/null +++ b/presentation/src/main/res/layout/activity_main.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/menu/menu_main.xml b/presentation/src/main/res/menu/menu_main.xml new file mode 100644 index 0000000..0647ad3 --- /dev/null +++ b/presentation/src/main/res/menu/menu_main.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/mipmap-anydpi-v33/ic_launcher.xml b/presentation/src/main/res/mipmap-anydpi-v33/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/presentation/src/main/res/mipmap-anydpi-v33/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/mipmap-hdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/presentation/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/presentation/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/mipmap-mdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/presentation/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/presentation/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/mipmap-xhdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/presentation/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/presentation/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/presentation/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/presentation/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/navigation/nav_graph.xml b/presentation/src/main/res/navigation/nav_graph.xml new file mode 100644 index 0000000..4aecbef --- /dev/null +++ b/presentation/src/main/res/navigation/nav_graph.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/values-land/dimens.xml b/presentation/src/main/res/values-land/dimens.xml new file mode 100644 index 0000000..22d7f00 --- /dev/null +++ b/presentation/src/main/res/values-land/dimens.xml @@ -0,0 +1,3 @@ + + 48dp + \ No newline at end of file diff --git a/presentation/src/main/res/values-night/themes.xml b/presentation/src/main/res/values-night/themes.xml new file mode 100644 index 0000000..a2fa8de --- /dev/null +++ b/presentation/src/main/res/values-night/themes.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/presentation/src/main/res/values-w1240dp/dimens.xml b/presentation/src/main/res/values-w1240dp/dimens.xml new file mode 100644 index 0000000..d73f4a3 --- /dev/null +++ b/presentation/src/main/res/values-w1240dp/dimens.xml @@ -0,0 +1,3 @@ + + 200dp + \ No newline at end of file diff --git a/presentation/src/main/res/values-w600dp/dimens.xml b/presentation/src/main/res/values-w600dp/dimens.xml new file mode 100644 index 0000000..22d7f00 --- /dev/null +++ b/presentation/src/main/res/values-w600dp/dimens.xml @@ -0,0 +1,3 @@ + + 48dp + \ No newline at end of file diff --git a/presentation/src/main/res/values/colors.xml b/presentation/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/presentation/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/presentation/src/main/res/values/dimens.xml b/presentation/src/main/res/values/dimens.xml new file mode 100644 index 0000000..125df87 --- /dev/null +++ b/presentation/src/main/res/values/dimens.xml @@ -0,0 +1,3 @@ + + 16dp + \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml new file mode 100644 index 0000000..bc8bdbf --- /dev/null +++ b/presentation/src/main/res/values/strings.xml @@ -0,0 +1,12 @@ + + BPM + Settings + + First Fragment + Second Fragment + Next + Previous + + Hello first fragment + Hello second fragment. Arg: %1$s + \ No newline at end of file diff --git a/presentation/src/main/res/values/themes.xml b/presentation/src/main/res/values/themes.xml new file mode 100644 index 0000000..2fc5e2c --- /dev/null +++ b/presentation/src/main/res/values/themes.xml @@ -0,0 +1,19 @@ + + + + + + +