From c320631d3c011e23185660fced8d7c25d3febc93 Mon Sep 17 00:00:00 2001 From: JSPark <48265129+pknujsp@users.noreply.github.com> Date: Sat, 10 Jun 2023 15:03:26 +0900 Subject: [PATCH] =?UTF-8?q?#91=20=EC=95=B1=20=EB=A6=B4=EB=A6=AC=EC=A6=88?= =?UTF-8?q?=20=EB=AA=A8=EB=93=9C=20=EC=B2=98=EB=A6=AC=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80,=20=EC=95=B1=20=EB=B9=84=EB=B0=80?= =?UTF-8?q?=ED=82=A4=20=EC=B2=98=EB=A6=AC=20=EC=BD=94=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + app/build.gradle.kts | 28 +++++++---- app/debug/output-metadata.json | 20 ++++++++ app/proguard-glide.pro | 11 +++++ app/proguard-okhttp3.pro | 3 ++ app/proguard-retrofit2.pro | 45 ++++++++++++++++++ app/proguard-room.pro | 3 ++ app/proguard-rules.pro | 47 ++++++++++++++++++- app/release/output-metadata.json | 20 ++++++++ app/src/main/AndroidManifest.xml | 2 +- .../android/mediproject/DevDialogFragment.kt | 31 ++++++++++++ .../com/android/mediproject/MainActivity.kt | 3 +- .../com.android.mediproject/AndroidCompose.kt | 12 ++--- .../com.android.mediproject/KotlinAndroid.kt | 7 +-- build-logic/settings.gradle.kts | 1 + build.gradle.kts | 4 +- core/common/build.gradle.kts | 2 +- core/data/build.gradle.kts | 4 -- .../remote/comments/CommentsRepositoryImpl.kt | 2 +- core/database/build.gradle.kts | 4 -- core/datastore/build.gradle.kts | 4 -- core/domain/build.gradle.kts | 4 -- .../core/domain/CommentsUseCase.kt | 12 ++--- core/network/build.gradle.kts | 4 -- .../core/network/InternetNetworkListener.kt | 18 ++++--- .../comments/CommentsListDataSourceImpl.kt | 6 +-- .../core/network/module/NetworkModule.kt | 11 +++-- core/ui/build.gradle.kts | 3 -- core/ui/src/main/res/values/styles.xml | 2 + feature/camera/build.gradle.kts | 1 - feature/comments/build.gradle.kts | 4 -- .../MedicineCommentsFragment.kt | 10 ++-- .../MedicineCommentsViewModel.kt | 11 +++-- .../comments/src/main/res/values/strings.xml | 1 + feature/home/build.gradle.kts | 6 --- feature/interestedmedicine/build.gradle.kts | 5 -- feature/intro/build.gradle.kts | 3 -- feature/medicine/build.gradle.kts | 4 -- .../res/layout/fragment_medicine_info.xml | 16 +++---- feature/mypage/build.gradle.kts | 4 -- feature/news/build.gradle.kts | 3 -- feature/penalties/build.gradle.kts | 3 -- feature/search/build.gradle.kts | 3 -- feature/setting/build.gradle.kts | 4 -- gradle.properties | 8 ++-- gradle/libs.versions.toml | 13 +++-- settings.gradle.kts | 1 + 47 files changed, 271 insertions(+), 143 deletions(-) create mode 100644 app/debug/output-metadata.json create mode 100644 app/proguard-glide.pro create mode 100644 app/proguard-okhttp3.pro create mode 100644 app/proguard-retrofit2.pro create mode 100644 app/proguard-room.pro create mode 100644 app/release/output-metadata.json create mode 100644 app/src/main/java/com/android/mediproject/DevDialogFragment.kt diff --git a/.gitignore b/.gitignore index 497264f2a..b12dc7d1d 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ render.experimental.xml # Keystore files *.jks *.keystore +secretkey/ # Google Services (e.g. APIs or Firebase) google-services.json diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0c5ca96e4..a99f9c668 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,34 +1,43 @@ plugins { - id("mediproject.android.application") id("mediproject.android.hilt") id("androidx.navigation.safeargs.kotlin") + alias(libs.plugins.gms) + alias(libs.plugins.firebase.crashlytics) } android { defaultConfig { applicationId = "com.android.mediproject" versionCode = 1 - versionName = "1.0.0" + versionName = "1.0.0-alpha01" vectorDrawables { useSupportLibrary = true } - // testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + buildTypes { + debug { + + } + release { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro", + "proguard-glide.pro", + "proguard-okhttp3.pro", + "proguard-room.pro", + "proguard-retrofit2.pro") + } + } } namespace = "com.android.mediproject" - buildFeatures { - buildConfig = true - } - lint { checkDependencies = true ignoreTestSources = true } - } hilt { @@ -69,6 +78,9 @@ dependencies { implementation(libs.androidx.splash) kapt(libs.bundles.glides.kapt) + implementation(libs.firebase.crashlytics) + implementation(libs.firebase.analytics) + /* androidTestImplementation(libs.bundles.testUIs) testImplementation(libs.bundles.testUIs) diff --git a/app/debug/output-metadata.json b/app/debug/output-metadata.json new file mode 100644 index 000000000..81da20561 --- /dev/null +++ b/app/debug/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.android.mediproject", + "variantName": "debug", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 1, + "versionName": "1.0.0-alpha01", + "outputFile": "app-debug.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/app/proguard-glide.pro b/app/proguard-glide.pro new file mode 100644 index 000000000..1d231b30b --- /dev/null +++ b/app/proguard-glide.pro @@ -0,0 +1,11 @@ +-keep public class * implements com.bumptech.glide.module.GlideModule +-keep class * extends com.bumptech.glide.module.AppGlideModule { + (...); +} +-keep public enum com.bumptech.glide.load.ImageHeaderParser$** { + **[] $VALUES; + public *; +} +-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { + *** rewind(); +} \ No newline at end of file diff --git a/app/proguard-okhttp3.pro b/app/proguard-okhttp3.pro new file mode 100644 index 000000000..ee738b77a --- /dev/null +++ b/app/proguard-okhttp3.pro @@ -0,0 +1,3 @@ +-dontwarn okhttp3.** +-dontwarn okio.** +-dontnote okhttp3.** \ No newline at end of file diff --git a/app/proguard-retrofit2.pro b/app/proguard-retrofit2.pro new file mode 100644 index 000000000..a56ee242b --- /dev/null +++ b/app/proguard-retrofit2.pro @@ -0,0 +1,45 @@ +# Begin: Proguard rules for retrofit2 + +# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and +# EnclosingMethod is required to use InnerClasses. +-keepattributes Signature, InnerClasses, EnclosingMethod + +# Retrofit does reflection on method and parameter annotations. +-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations + +# Keep annotation default values (e.g., retrofit2.http.Field.encoded). +-keepattributes AnnotationDefault + +# Retain service method parameters when optimizing. +-keepclassmembers,allowshrinking,allowobfuscation interface * { + @retrofit2.http.* ; +} + +# Ignore annotation used for build tooling. +-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement.* + +# Ignore JSR 305 annotations for embedding nullability information. +-dontwarn javax.annotation.** + +# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath. +-dontwarn kotlin.Unit + +# Top-level functions that can only be used by Kotlin. +-dontwarn retrofit2.KotlinExtensions +-dontwarn retrofit2.KotlinExtensions$* + +# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy +# and replaces all potential values with null. Explicitly keeping the interfaces prevents this. +-if interface * { @retrofit2.http.* ; } +-keep,allowobfuscation interface <1> + +# Keep generic signature of Call, Response (R8 full mode strips signatures from non-kept items). +-keep,allowobfuscation,allowshrinking interface retrofit2.Call +-keep,allowobfuscation,allowshrinking class retrofit2.Response + +# With R8 full mode generic signatures are stripped for classes that are not +# kept. Suspend functions are wrapped in continuations where the type argument +# is used. +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation + +# End: Proguard rules for retrofit2 \ No newline at end of file diff --git a/app/proguard-room.pro b/app/proguard-room.pro new file mode 100644 index 000000000..42a2b2691 --- /dev/null +++ b/app/proguard-room.pro @@ -0,0 +1,3 @@ +-keep class * extends androidx.room.RoomDatabase +-keep @androidx.room.Entity class * +-dontwarn androidx.room.paging.** \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb4348..122ed34d0 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -14,8 +14,51 @@ # Uncomment this to preserve the line number information for # debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +-keepattributes SourceFile,LineNumberTable,RuntimeVisibleAnnotations,AnnotationDefault # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +#keep +-keep public class * { public protected *; } +-keep class com.luckycatlabs.sunrisesunset.** { *;} +-keepclassmembers class * extends com.google.protobuf.GeneratedMessageLite* { + ; +} + + +# Keep `Companion` object fields of serializable classes. +# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects. +-if @kotlinx.serialization.Serializable class ** +-keepclassmembers class <1> { + static <1>$Companion Companion; +} + +# Keep `serializer()` on companion objects (both default and named) of serializable classes. +-if @kotlinx.serialization.Serializable class ** { + static **$* *; +} +-keepclassmembers class <2>$<3> { + kotlinx.serialization.KSerializer serializer(...); +} + +# Keep `INSTANCE.serializer()` of serializable objects. +-if @kotlinx.serialization.Serializable class ** { + public static ** INSTANCE; +} +-keepclassmembers class <1> { + public static <1> INSTANCE; + kotlinx.serialization.KSerializer serializer(...); +} + +-dontwarn org.bouncycastle.jsse.BCSSLParameters +-dontwarn org.bouncycastle.jsse.BCSSLSocket +-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider +-dontwarn org.conscrypt.Conscrypt$Version +-dontwarn org.conscrypt.Conscrypt +-dontwarn org.conscrypt.ConscryptHostnameVerifier +-dontwarn org.openjsse.javax.net.ssl.SSLParameters +-dontwarn org.openjsse.javax.net.ssl.SSLSocket +-dontwarn org.openjsse.net.ssl.OpenJSSE +-dontwarn org.tensorflow.lite.gpu.** \ No newline at end of file diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 000000000..5840e38bd --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.android.mediproject", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 1, + "versionName": "1.0.0-alpha01", + "outputFile": "app-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a81afde49..32b51daf4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -26,7 +26,7 @@ android:exported="true" android:screenOrientation="portrait" android:theme="@style/Theme.App.Starting" - android:windowSoftInputMode="adjustUnspecified"> + android:windowSoftInputMode="adjustPan|adjustResize"> diff --git a/app/src/main/java/com/android/mediproject/DevDialogFragment.kt b/app/src/main/java/com/android/mediproject/DevDialogFragment.kt new file mode 100644 index 000000000..cf8ba1743 --- /dev/null +++ b/app/src/main/java/com/android/mediproject/DevDialogFragment.kt @@ -0,0 +1,31 @@ +package com.android.mediproject + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import com.android.mediproject.databinding.ViewNetworkStateBinding +import com.google.android.material.bottomsheet.BottomSheetDialogFragment +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class DevDialogFragment : BottomSheetDialogFragment() { + + private var _binding: ViewNetworkStateBinding? = null + + private val binding get() = _binding!! + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View = ViewNetworkStateBinding.inflate(layoutInflater, container, false).also { + _binding = it + }.root + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding.okButton.setOnClickListener { + dismiss() + requireActivity().finish() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/android/mediproject/MainActivity.kt b/app/src/main/java/com/android/mediproject/MainActivity.kt index f17357606..ac376d331 100644 --- a/app/src/main/java/com/android/mediproject/MainActivity.kt +++ b/app/src/main/java/com/android/mediproject/MainActivity.kt @@ -50,8 +50,7 @@ class MainActivity : BaseActivity(ActivityMa internetNetworkListener.activityLifeCycle = this.lifecycle internetNetworkListener.networkStateCallback = InternetNetworkListener.NetworkStateCallback { isConnected -> if (!isConnected) { - //val modalBottomSheet = NetworkStateDialogFragment() - //modalBottomSheet.show(supportFragmentManager, NetworkStateDialogFragment::class.java.name) + NetworkStateDialogFragment().show(supportFragmentManager, NetworkStateDialogFragment::class.java.name) } } diff --git a/build-logic/convention/src/main/kotlin/com.android.mediproject/AndroidCompose.kt b/build-logic/convention/src/main/kotlin/com.android.mediproject/AndroidCompose.kt index d9816d41f..75cb47c23 100644 --- a/build-logic/convention/src/main/kotlin/com.android.mediproject/AndroidCompose.kt +++ b/build-logic/convention/src/main/kotlin/com.android.mediproject/AndroidCompose.kt @@ -19,7 +19,7 @@ internal fun Project.configureAndroidCompose( commonExtension.apply { val libs = extensions.getByType().named("libs") - buildFeatures { + @Suppress("UnstableApiUsage") buildFeatures { compose = true } @@ -48,9 +48,7 @@ private fun Project.buildComposeMetricsParameters(): List { if (enableMetrics) { val metricsFolder = File(project.buildDir, "compose-metrics") metricParameters.add("-P") - metricParameters.add( - "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + metricsFolder.absolutePath - ) + metricParameters.add("plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + metricsFolder.absolutePath) } val enableReportsProvider = project.providers.gradleProperty("enableComposeCompilerReports") @@ -58,9 +56,7 @@ private fun Project.buildComposeMetricsParameters(): List { if (enableReports) { val reportsFolder = File(project.buildDir, "compose-reports") metricParameters.add("-P") - metricParameters.add( - "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + reportsFolder.absolutePath - ) + metricParameters.add("plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + reportsFolder.absolutePath) } return metricParameters.toList() -} +} \ No newline at end of file diff --git a/build-logic/convention/src/main/kotlin/com.android.mediproject/KotlinAndroid.kt b/build-logic/convention/src/main/kotlin/com.android.mediproject/KotlinAndroid.kt index a00cfad9c..e3e61a41b 100644 --- a/build-logic/convention/src/main/kotlin/com.android.mediproject/KotlinAndroid.kt +++ b/build-logic/convention/src/main/kotlin/com.android.mediproject/KotlinAndroid.kt @@ -23,7 +23,6 @@ internal fun Project.configureKotlinAndroid( commonExtension.apply { compileSdk = libs.findVersion("compileSdk").get().toString().toInt() - defaultConfig { minSdk = libs.findVersion("minSdk").get().toString().toInt() } @@ -60,7 +59,6 @@ internal fun Project.configureKotlinJvm() { } private fun Project.configureKotlin() { - // Use withType to workaround https://youtrack.jetbrains.com/issue/KT-55947 tasks.withType().configureEach { kotlinOptions { val warningsAsErrors: String? by project @@ -70,13 +68,10 @@ private fun Project.configureKotlin() { "-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", "-opt-in=kotlinx.coroutines.FlowPreview", - "-opt-in=kotlin.Experimental", - "-Xdebug", + "-opt-in=kotlin.Experimental" ) jvmTarget = JavaVersion.VERSION_17.toString() - - } } } \ No newline at end of file diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts index 622578530..b8c2f72bd 100644 --- a/build-logic/settings.gradle.kts +++ b/build-logic/settings.gradle.kts @@ -1,3 +1,4 @@ +@Suppress("UnstableApiUsage") dependencyResolutionManagement { repositories { google() diff --git a/build.gradle.kts b/build.gradle.kts index 7dba145b2..005045599 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,6 @@ buildscript { plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false - //alias(libs.plugins.firebase.crashlytics) apply false alias(libs.plugins.gms) apply false alias(libs.plugins.hilt) apply false alias(libs.plugins.kotlin.serialization) apply false @@ -21,10 +20,11 @@ plugins { alias(libs.plugins.kapt) apply false // alias(libs.plugins.ksp) apply false alias(libs.plugins.kotlin.parcelize) apply false + alias(libs.plugins.firebase.crashlytics) apply false } -gradle.projectsEvaluated { +gradle.allprojects { tasks.withType().configureEach { options.compilerArgs = options.compilerArgs + "-Xmaxerrs" + "1000" } diff --git a/core/common/build.gradle.kts b/core/common/build.gradle.kts index 2b918a5da..fc93c795d 100644 --- a/core/common/build.gradle.kts +++ b/core/common/build.gradle.kts @@ -10,7 +10,7 @@ plugins { android { namespace = "com.android.mediproject.core.common" - buildFeatures { + @Suppress("UnstableApiUsage") buildFeatures { buildConfig = true } diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index 5c0ab5b5e..ef2d92aab 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -6,10 +6,6 @@ plugins { android { namespace = "com.android.mediproject.core.data" - @Suppress("UnstableApiUsage") buildFeatures { - buildConfig = true - } - } hilt { enableAggregatingTask = true diff --git a/core/data/src/main/java/com/android/mediproject/core/data/remote/comments/CommentsRepositoryImpl.kt b/core/data/src/main/java/com/android/mediproject/core/data/remote/comments/CommentsRepositoryImpl.kt index c56b6cc24..a74eef5c2 100644 --- a/core/data/src/main/java/com/android/mediproject/core/data/remote/comments/CommentsRepositoryImpl.kt +++ b/core/data/src/main/java/com/android/mediproject/core/data/remote/comments/CommentsRepositoryImpl.kt @@ -27,7 +27,7 @@ class CommentsRepositoryImpl @Inject constructor( private val commentsDataSource: CommentsDataSource, private val signRepository: SignRepository ) : CommentsRepository { override fun getCommentsForAMedicine(medicineId: Long): Flow> = - Pager(config = PagingConfig(pageSize = AWS_LOAD_PAGE_SIZE, prefetchDistance = 5), pagingSourceFactory = { + Pager(config = PagingConfig(pageSize = AWS_LOAD_PAGE_SIZE, prefetchDistance = 0), pagingSourceFactory = { CommentsListDataSourceImpl(commentsDataSource, medicineId) }).flow diff --git a/core/database/build.gradle.kts b/core/database/build.gradle.kts index a2afa5298..b89db64b6 100644 --- a/core/database/build.gradle.kts +++ b/core/database/build.gradle.kts @@ -5,10 +5,6 @@ plugins { android { namespace = "com.android.mediproject.core.database" - - buildFeatures { - buildConfig = true - } } dependencies { diff --git a/core/datastore/build.gradle.kts b/core/datastore/build.gradle.kts index d0b668920..1b7b788e1 100644 --- a/core/datastore/build.gradle.kts +++ b/core/datastore/build.gradle.kts @@ -6,10 +6,6 @@ plugins { android { namespace = "com.android.mediproject.core.datastore" - - buildFeatures { - buildConfig = true - } } protobuf { diff --git a/core/domain/build.gradle.kts b/core/domain/build.gradle.kts index c9bbe35ea..fd98b37b6 100644 --- a/core/domain/build.gradle.kts +++ b/core/domain/build.gradle.kts @@ -7,10 +7,6 @@ plugins { android { namespace = "com.android.mediproject.core.domain" - - buildFeatures { - buildConfig = true - } } hilt { enableAggregatingTask = true diff --git a/core/domain/src/main/java/com/android/mediproject/core/domain/CommentsUseCase.kt b/core/domain/src/main/java/com/android/mediproject/core/domain/CommentsUseCase.kt index 51a70b05d..eab7ec4b1 100644 --- a/core/domain/src/main/java/com/android/mediproject/core/domain/CommentsUseCase.kt +++ b/core/domain/src/main/java/com/android/mediproject/core/domain/CommentsUseCase.kt @@ -2,10 +2,7 @@ package com.android.mediproject.core.domain import androidx.paging.PagingData import androidx.paging.flatMap -import com.android.mediproject.core.common.network.Dispatcher -import com.android.mediproject.core.common.network.MediDispatchers import com.android.mediproject.core.data.remote.comments.CommentsRepository -import com.android.mediproject.core.data.remote.user.UserInfoRepository import com.android.mediproject.core.model.comments.CommentDto import com.android.mediproject.core.model.comments.MyCommentDto import com.android.mediproject.core.model.comments.toDto @@ -13,7 +10,6 @@ import com.android.mediproject.core.model.requestparameters.DeleteCommentParamet import com.android.mediproject.core.model.requestparameters.EditCommentParameter import com.android.mediproject.core.model.requestparameters.LikeCommentParameter import com.android.mediproject.core.model.requestparameters.NewCommentParameter -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow @@ -21,14 +17,14 @@ import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.mapLatest import javax.inject.Inject +import javax.inject.Singleton +@Singleton class CommentsUseCase @Inject constructor( private val commentsRepository: CommentsRepository, - private val userInfoRepository: UserInfoRepository, - @Dispatcher(MediDispatchers.Default) private val defaultDispatcher: CoroutineDispatcher ) { - val scrollChannel = Channel(capacity = 3, onBufferOverflow = BufferOverflow.DROP_OLDEST) + val scrollChannel = Channel(capacity = 5, onBufferOverflow = BufferOverflow.DROP_OLDEST) /** * 약에 대한 댓글을 가져오는 메서드입니다. @@ -44,7 +40,7 @@ class CommentsUseCase @Inject constructor( if (like.userId == myUserId) this.isLiked = true } } - }.reversed()) + listOf(it.toDto().apply { + }.toList().reversed()) + listOf(it.toDto().apply { it.likeList.forEach { like -> if (like.userId == myUserId) this.isLiked = true } diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index 04b1dc8fe..1e29bc50c 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -5,10 +5,6 @@ plugins { android { namespace = "com.android.mediproject.core.network" - - buildFeatures { - buildConfig = true - } } hilt { diff --git a/core/network/src/main/java/com/android/mediproject/core/network/InternetNetworkListener.kt b/core/network/src/main/java/com/android/mediproject/core/network/InternetNetworkListener.kt index d83f3ddee..f9d4de076 100644 --- a/core/network/src/main/java/com/android/mediproject/core/network/InternetNetworkListener.kt +++ b/core/network/src/main/java/com/android/mediproject/core/network/InternetNetworkListener.kt @@ -1,10 +1,12 @@ package com.android.mediproject.core.network import android.content.Context +import android.content.Context.CONNECTIVITY_SERVICE import android.net.ConnectivityManager -import android.net.LinkProperties import android.net.Network import android.net.NetworkCapabilities +import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET +import android.net.NetworkRequest import android.os.Handler import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver @@ -13,11 +15,12 @@ import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject import javax.inject.Singleton + @Singleton class InternetNetworkListener @Inject constructor(@ApplicationContext private val context: Context) : LifecycleEventObserver { private val connectivityManager by lazy { - context.getSystemService(ConnectivityManager::class.java) + context.getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager } private val networkCallback: ConnectivityManager.NetworkCallback = object : ConnectivityManager.NetworkCallback() { @@ -40,8 +43,11 @@ class InternetNetworkListener @Inject constructor(@ApplicationContext private va var networkStateCallback: NetworkStateCallback? = null set(value) { field = value - connectivityManager.registerDefaultNetworkCallback(networkCallback, - Handler.createAsync(context.mainLooper)) + val request = NetworkRequest.Builder() + .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED) + .addCapability(NET_CAPABILITY_INTERNET) + .build() + connectivityManager.registerDefaultNetworkCallback(networkCallback, Handler.createAsync(context.mainLooper)) } var activityLifeCycle: Lifecycle? = null @@ -53,11 +59,11 @@ class InternetNetworkListener @Inject constructor(@ApplicationContext private va override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { when (event) { Lifecycle.Event.ON_START -> { - connectivityManager.unregisterNetworkCallback(networkCallback) + } Lifecycle.Event.ON_PAUSE -> { - networkStateCallback?.onChangedState(false) + } else -> {} diff --git a/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsListDataSourceImpl.kt b/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsListDataSourceImpl.kt index 352712b37..50dbe0933 100644 --- a/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsListDataSourceImpl.kt +++ b/core/network/src/main/java/com/android/mediproject/core/network/datasource/comments/CommentsListDataSourceImpl.kt @@ -9,15 +9,15 @@ class CommentsListDataSourceImpl( private val medicineId: Long, ) : PagingSource() { - override fun getRefreshKey(state: PagingState) = 1 + override fun getRefreshKey(state: PagingState) = 0 override suspend fun load(params: LoadParams): LoadResult { return try { commentsDataSource.getCommentsForAMedicine(medicineId).fold(onSuccess = { LoadResult.Page( - data = it.commentList.asReversed(), + data = it.commentList, prevKey = null, - nextKey = if (it.commentList.size > 100000) 1 else null, + nextKey = if (it.commentList.size > 1000000) 1 else null, ) }, onFailure = { LoadResult.Error(it) diff --git a/core/network/src/main/java/com/android/mediproject/core/network/module/NetworkModule.kt b/core/network/src/main/java/com/android/mediproject/core/network/module/NetworkModule.kt index 2de2798d7..be8af3126 100644 --- a/core/network/src/main/java/com/android/mediproject/core/network/module/NetworkModule.kt +++ b/core/network/src/main/java/com/android/mediproject/core/network/module/NetworkModule.kt @@ -1,8 +1,8 @@ package com.android.mediproject.core.network.module import android.content.Context +import com.android.mediproject.core.common.BuildConfig import com.android.mediproject.core.datastore.TokenServer -import com.android.mediproject.core.network.BuildConfig import com.android.mediproject.core.network.R import com.android.mediproject.core.network.tokens.TokenInterceptor import dagger.Module @@ -88,7 +88,8 @@ object NetworkModule { @Singleton @Named("okHttpClientWithAccessTokens") fun providesOkHttpClientWithAccessTokens( - tokenServer: TokenServer): OkHttpClient = OkHttpClient.Builder().run { + tokenServer: TokenServer + ): OkHttpClient = OkHttpClient.Builder().run { addInterceptor(HttpLoggingInterceptor().apply { if (BuildConfig.DEBUG) { level = HttpLoggingInterceptor.Level.BODY @@ -102,7 +103,8 @@ object NetworkModule { @Singleton @Named("okHttpClientWithReissueTokens") fun providesOkHttpClientWithReissueTokens( - tokenServer: TokenServer): OkHttpClient = OkHttpClient.Builder().run { + tokenServer: TokenServer + ): OkHttpClient = OkHttpClient.Builder().run { addInterceptor(HttpLoggingInterceptor().apply { if (BuildConfig.DEBUG) { level = HttpLoggingInterceptor.Level.BODY @@ -116,7 +118,8 @@ object NetworkModule { @Singleton @Named("okHttpClientWithGoogleAccessTokens") fun providesOkHttpClientGoogleWithAccessTokens( - tokenServer: TokenServer): OkHttpClient = OkHttpClient.Builder().run { + tokenServer: TokenServer + ): OkHttpClient = OkHttpClient.Builder().run { addInterceptor(HttpLoggingInterceptor().apply { if (BuildConfig.DEBUG) { level = HttpLoggingInterceptor.Level.BODY diff --git a/core/ui/build.gradle.kts b/core/ui/build.gradle.kts index 852d6e160..ed31618f6 100644 --- a/core/ui/build.gradle.kts +++ b/core/ui/build.gradle.kts @@ -4,9 +4,6 @@ plugins { android { namespace = "com.android.mediproject.core.ui" - buildFeatures { - buildConfig = true - } } hilt { diff --git a/core/ui/src/main/res/values/styles.xml b/core/ui/src/main/res/values/styles.xml index b6e7b3358..1e5c5653f 100644 --- a/core/ui/src/main/res/values/styles.xml +++ b/core/ui/src/main/res/values/styles.xml @@ -3,6 +3,8 @@