Skip to content

Commit

Permalink
[MERGE] #1 -> develop
Browse files Browse the repository at this point in the history
[ADD/#1] 프로젝트 초기 세팅
  • Loading branch information
leeeyubin authored Jul 1, 2024
2 parents 0c38889 + 26bdc57 commit 3745e87
Show file tree
Hide file tree
Showing 86 changed files with 1,652 additions and 105 deletions.
67 changes: 51 additions & 16 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.hilt)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.ksp)
}

android {
namespace = "com.terning.point"
compileSdk = 34
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
applicationId = "com.terning.point"
minSdk = 28
targetSdk = 34
versionCode = 1
versionName = "1.0"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = libs.versions.versionCode.get().toInt()
versionName = libs.versions.versionName.get()

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand All @@ -21,6 +26,13 @@ android {
}

buildTypes {
debug {
buildConfigField(
"String",
"OPEN_BASE_URL",
gradleLocalProperties(rootDir, providers).getProperty("open.base.url")
)
}
release {
isMinifyEnabled = false
proguardFiles(
Expand All @@ -34,36 +46,59 @@ android {
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = libs.versions.jvmTarget.get()
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get()
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
excludes += "/META-INF/gradle/incremental.annotation.processors"
}
}
}

dependencies {
implementation(project(":core"))
implementation(project(":data"))
implementation(project(":domain"))
implementation(project(":feature"))

implementation(libs.kotlinx.serialization.json)
implementation(libs.coroutines.android)
implementation(libs.kotlin)

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.appcompat)
implementation(libs.hilt.android)
ksp(libs.hilt.android.compiler)
ksp(libs.hilt.manager)
implementation(libs.androidx.workManager)
implementation(libs.androidx.hiltWorkManager)

implementation(libs.hilt.compiler)
implementation(libs.androidx.hiltWorkManagerCompiler)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)

implementation(platform(libs.okhttp.bom))
implementation(libs.okhttp)
implementation(libs.okhttp.logging)
implementation(libs.retrofit.core)
implementation(libs.retrofit.kotlin.serialization)
implementation(libs.retrofit2.kotlinx.serialization.converter)
implementation(libs.timber)
implementation(libs.ossLicense)

debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
}
15 changes: 5 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,22 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:name=".MyApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:theme="@style/Theme.TerningAndroid"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.TerningAndroid">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
47 changes: 0 additions & 47 deletions app/src/main/java/com/terning/point/MainActivity.kt

This file was deleted.

25 changes: 25 additions & 0 deletions app/src/main/java/com/terning/point/MyApp.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.terning.point

import android.app.Application
import androidx.appcompat.app.AppCompatDelegate
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber

@HiltAndroidApp
class MyApp : Application() {

override fun onCreate() {
super.onCreate()

initTimber()
setDayMode()
}

private fun initTimber() {
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
}

private fun setDayMode() {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
}
}
18 changes: 18 additions & 0 deletions app/src/main/java/com/terning/point/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.terning.point.di

import com.terning.data.datasource.MockDataSource
import com.terning.data.datasourceimpl.MockDataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class DataSourceModule {

@Binds
@Singleton
abstract fun bindMockDataSource(mockDataSourceImpl: MockDataSourceImpl): MockDataSource
}
18 changes: 18 additions & 0 deletions app/src/main/java/com/terning/point/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.terning.point.di

import com.terning.data.repositoryimpl.MockRepositoryImpl
import com.terning.domain.repository.MockRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class RepositoryModule {

@Binds
@Singleton
abstract fun bindMockRepository(mockRepositoryImpl: MockRepositoryImpl): MockRepository
}
78 changes: 78 additions & 0 deletions app/src/main/java/com/terning/point/di/RetrofitModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.terning.point.di

import com.terning.core.extension.isJsonArray
import com.terning.core.extension.isJsonObject
import com.terning.point.BuildConfig
import com.terning.point.di.qualifier.OPEN
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.serialization.json.Json
import okhttp3.Interceptor
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.json.JSONObject
import retrofit2.Converter
import retrofit2.Retrofit
import retrofit2.converter.kotlinx.serialization.asConverterFactory
import timber.log.Timber
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object RetrofitModule {
private const val APPLICATION_JSON = "application/json"

@Provides
@Singleton
fun provideJson(): Json = Json {
ignoreUnknownKeys = true
prettyPrint = true
}

@Provides
@Singleton
fun provideJsonConverter(json: Json): Converter.Factory =
json.asConverterFactory(APPLICATION_JSON.toMediaType())

@Provides
@Singleton
fun provideHttpLoggingInterceptor(): Interceptor = HttpLoggingInterceptor { message ->
when {
message.isJsonObject() ->
Timber.tag("okhttp").d(JSONObject(message).toString(4))

message.isJsonArray() ->
Timber.tag("okhttp").d(JSONObject(message).toString(4))

else -> {
Timber.tag("okhttp").d("CONNECTION INFO -> $message")
}
}
}.apply {
level = HttpLoggingInterceptor.Level.BODY
}

@Provides
@Singleton
fun provideOkHttpClient(
loggingInterceptor: Interceptor
): OkHttpClient = OkHttpClient.Builder()
.addInterceptor(loggingInterceptor)
.build()

@Provides
@Singleton
@OPEN
fun provideOpenRetrofit(
client: OkHttpClient,
factory: Converter.Factory
): Retrofit = Retrofit.Builder()
.baseUrl(BuildConfig.OPEN_BASE_URL)
.addConverterFactory(factory)
.client(client)
.build()

}
21 changes: 21 additions & 0 deletions app/src/main/java/com/terning/point/di/ServiceModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.terning.point.di

import com.terning.data.service.MockService
import com.terning.point.di.qualifier.OPEN
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ServiceModule {

@Provides
@Singleton
fun provideMockService(@OPEN retrofit: Retrofit): MockService =
retrofit.create(MockService::class.java)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.terning.point.di.qualifier


import javax.inject.Qualifier

@Qualifier
@Retention(AnnotationRetention.BINARY)
annotation class OPEN
10 changes: 0 additions & 10 deletions app/src/main/res/values/colors.xml

This file was deleted.

3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml

This file was deleted.

Loading

0 comments on commit 3745e87

Please sign in to comment.