Skip to content

Commit

Permalink
Merge pull request #186 from pknu-wap/#185/refactor/jsp/lib_api_etc
Browse files Browse the repository at this point in the history
#185/refactor/jsp/lib api etc
  • Loading branch information
pknujsp authored Jul 23, 2023
2 parents 8b6ae76 + c6b49ef commit 57c7bc6
Show file tree
Hide file tree
Showing 65 changed files with 789 additions and 1,170 deletions.
15 changes: 5 additions & 10 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ android {
}
release {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"),
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
"proguard-glide.pro",
"proguard-okhttp3.pro",
"proguard-room.pro",
"proguard-retrofit2.pro")
"proguard-retrofit2.pro",
)
signingConfig = signingConfigs.getByName("release")
}
}
Expand Down Expand Up @@ -94,11 +96,4 @@ dependencies {

implementation(libs.firebase.crashlytics)
implementation(libs.firebase.analytics)

/*
androidTestImplementation(libs.bundles.testUIs)
testImplementation(libs.bundles.testUIs)
androidTestUtil(libs.androidx.test.orchestrator)
*/
}
}
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
</intent-filter>
</activity>

<provider
android:name=".feature.camera.tflite.CameraHelper"
android:authorities="${applicationId}.camera.helper"
android:exported="false" />
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ class LibraryConventionPlugin : Plugin<Project> {
defaultConfig.targetSdk = libs.findVersion("targetSdk").get().toString().toInt()
}

//val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")

dependencies {
// "testImplementation"(kotlin("test"))
// "androidTestImplementation"(kotlin("test"))
"testImplementation"(libs.findBundle("testLocal").get())
"androidTestImplementation"(libs.findBundle("testAndroid").get())
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal fun Project.configureKotlinAndroid(

defaultConfig {
minSdk = libs.findVersion("minSdk").get().toString().toInt()
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

dataBinding.enable = true
Expand Down Expand Up @@ -68,10 +69,10 @@ private fun Project.configureKotlin() {
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview",
"-opt-in=kotlin.Experimental"
"-opt-in=kotlin.Experimental",
)

jvmTarget = JavaVersion.VERSION_17.toString()
}
}
}
}
4 changes: 2 additions & 2 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ dependencies {
implementation(libs.kotlinx.coroutines.android)
implementation(project(":core:model"))
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.datetime)
//implementation(libs.kotlinx.datetime)
implementation(libs.kotlin.reflection)
implementation(libs.bundles.glides)
implementation(libs.lottie)
kapt(libs.bundles.glides.kapt)
kapt(libs.androidx.hilt.compilerKapt)
implementation(libs.androidx.paging.runtime)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import androidx.core.view.doOnPreDraw
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.delay
Expand All @@ -39,7 +39,7 @@ import kotlin.properties.Delegates
object SystemBarColorAnalyzer {
private val waitLock = Mutex()
private var waiting: Job? = null
private val coroutineScope = MainScope() + SupervisorJob()
private val coroutineScope = MainScope() + CoroutineName("SystemBarColorAnalyzer")
private val onChangedFragmentFlow = MutableSharedFlow<Unit>(onBufferOverflow = BufferOverflow.SUSPEND, replay = 1, extraBufferCapacity = 5)

private var decorView by Delegates.notNull<View>()
Expand Down Expand Up @@ -105,7 +105,7 @@ object SystemBarColorAnalyzer {

override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
release()
coroutineScope.cancel()
}
},
)
Expand Down Expand Up @@ -153,7 +153,4 @@ object SystemBarColorAnalyzer {
}
}

private fun release() {
coroutineScope.cancel()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsControllerCompat
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import javax.inject.Inject
import kotlin.properties.Delegates

@SuppressLint("InternalInsetResource", "DiscouragedApi", "Deprecation")
class SystemBarStyler @Inject constructor(
) : LayoutController, SystemBarController {
enum class SystemBarColor {
Expand All @@ -26,6 +26,7 @@ class SystemBarStyler @Inject constructor(
}

private var acitivityLayoutController: LayoutController? = null
private var windowInsetsController: WindowInsetsControllerCompat? = null

private var window: Window by Delegates.notNull()

Expand All @@ -40,6 +41,7 @@ class SystemBarStyler @Inject constructor(
override val navigationBarHeightPx: Int
get() = navigationBarHeight

@SuppressLint("InternalInsetResource", "DiscouragedApi")
override fun init(context: Context, window: Window, activityLayoutController: LayoutController) {
this.window = window
this.acitivityLayoutController = activityLayoutController
Expand All @@ -49,53 +51,42 @@ class SystemBarStyler @Inject constructor(
navigationBarHeight = getDimensionPixelSize(getIdentifier("navigation_bar_height", "dimen", "android"))
}

WindowCompat.setDecorFitsSystemWindows(window, true)
WindowCompat.setDecorFitsSystemWindows(window, false)
window.apply {
setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
navigationBarColor = Color.TRANSPARENT
statusBarColor = Color.TRANSPARENT
}
windowInsetsController = WindowCompat.getInsetsController(window, window.decorView)
}


override fun setStyle(systemBarColor: SystemBarColor, navigationBarSystemBarColor: SystemBarColor) {
window.navigationBarColor = android.graphics.Color.TRANSPARENT
window.statusBarColor = android.graphics.Color.TRANSPARENT

WindowCompat.getInsetsController(window, window.decorView).apply {
isAppearanceLightStatusBars = systemBarColor == SystemBarColor.BLACK
isAppearanceLightNavigationBars = navigationBarSystemBarColor == SystemBarColor.BLACK
}
}

override fun defaultStyle() {
window.navigationBarColor = android.graphics.Color.TRANSPARENT
window.statusBarColor = android.graphics.Color.TRANSPARENT

WindowCompat.getInsetsController(window, window.decorView).apply {
isAppearanceLightStatusBars = false
isAppearanceLightNavigationBars = true
override fun setStyle(statusBarColor: SystemBarColor, navBarColor: SystemBarColor) {
windowInsetsController?.apply {
isAppearanceLightStatusBars = statusBarColor == SystemBarColor.BLACK
isAppearanceLightNavigationBars = navBarColor == SystemBarColor.BLACK
}
}


override fun changeMode(topViews: List<ChangeView>, bottomViews: List<ChangeView>) {
topViews.forEach { topView ->
if (topView.type == SpacingType.MARGIN) {
topView.view.updateLayoutParams {
(this as ViewGroup.MarginLayoutParams).topMargin += statusBarHeight
topView.view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin += statusBarHeight
}
} else topView.view.updatePadding(left = 0, right = 0, top = statusBarHeight, bottom = 0)
} else {
topView.view.updatePadding(top = topView.view.paddingTop + statusBarHeight)
}
}
bottomViews.forEach { bottomView ->
if (bottomView.type == SpacingType.MARGIN) {
bottomView.view.updateLayoutParams {
(this as ViewGroup.MarginLayoutParams).bottomMargin += navigationBarHeight
bottomView.view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin += navigationBarHeight
}
} else {
bottomView.view.updatePadding(
left = 0, right = 0, top = if (bottomView in topViews) statusBarHeight else 0,
bottom = navigationBarHeight,
bottom = bottomView.view.paddingBottom + navigationBarHeight,
)
}
}
Expand All @@ -117,8 +108,7 @@ interface SystemBarController {
val navigationBarHeightPx: Int

fun init(context: Context, window: Window, activityLayoutController: LayoutController)
fun setStyle(systemBarColor: SystemBarStyler.SystemBarColor, navigationBarSystemBarColor: SystemBarStyler.SystemBarColor)
fun defaultStyle()
fun setStyle(statusBarColor: SystemBarStyler.SystemBarColor, navBarColor: SystemBarStyler.SystemBarColor)

fun changeMode(topViews: List<SystemBarStyler.ChangeView> = emptyList(), bottomViews: List<SystemBarStyler.ChangeView> = emptyList())
}
4 changes: 2 additions & 2 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.datetime)
//implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.androidx.paging.runtime)
}
}
4 changes: 2 additions & 2 deletions core/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.kotlinx.serialization.json)
implementation(libs.kotlinx.datetime)
//implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.androidx.paging.runtime)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.paging.flatMap
import com.android.mediproject.core.data.remote.comments.CommentsRepository
import com.android.mediproject.core.model.comments.CommentDto
import com.android.mediproject.core.model.comments.MyCommentDto
import com.android.mediproject.core.model.comments.toDto
import com.android.mediproject.core.model.comments.toCommentDto
import com.android.mediproject.core.model.requestparameters.DeleteCommentParameter
import com.android.mediproject.core.model.requestparameters.EditCommentParameter
import com.android.mediproject.core.model.requestparameters.LikeCommentParameter
Expand Down Expand Up @@ -35,16 +35,18 @@ class CommentsUseCase @Inject constructor(
commentsRepository.getCommentsForAMedicine(medicineId).collectLatest { pagingData ->
val result = pagingData.flatMap {
(it.replies.map { reply ->
reply.toDto().apply {
reply.toCommentDto().apply {
reply.likeList.forEach { like ->
if (like.userId == myUserId) this.isLiked = true
}
}
}.toList().reversed()) + listOf(it.toDto().apply {
it.likeList.forEach { like ->
if (like.userId == myUserId) this.isLiked = true
}
})
}.toList().reversed()) + listOf(
it.toCommentDto().apply {
it.likeList.forEach { like ->
if (like.userId == myUserId) this.isLiked = true
}
},
)
}
send(result)
}
Expand Down Expand Up @@ -72,9 +74,12 @@ class CommentsUseCase @Inject constructor(
*/
fun applyNewComment(parameter: NewCommentParameter): Flow<Result<Unit>> =
commentsRepository.applyNewComment(parameter).mapLatest { result ->
result.fold(onSuccess = {
Result.success(Unit)
}, onFailure = { Result.failure(it) })
result.fold(
onSuccess = {
Result.success(Unit)
},
onFailure = { Result.failure(it) },
)
}


Expand All @@ -94,4 +99,4 @@ class CommentsUseCase @Inject constructor(
result.fold(onSuccess = { Result.success(Unit) }, onFailure = { Result.failure(it) })
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package com.android.mediproject.core.domain

import com.android.mediproject.core.data.remote.elderlycaution.ElderlyCautionRepository
import com.android.mediproject.core.model.remote.elderlycaution.ElderlyCautionDto
import com.android.mediproject.core.model.remote.elderlycaution.toDto
import com.android.mediproject.core.model.remote.elderlycaution.toElderlyCautionDto
import javax.inject.Inject

class GetElderlyCautionUseCase @Inject constructor(
private val repository: ElderlyCautionRepository
private val repository: ElderlyCautionRepository,
) {


suspend operator fun invoke(
itemName: String?, itemSeq: String?
itemName: String?, itemSeq: String?,
): Result<ElderlyCautionDto> = repository.getElderlyCaution(itemName = itemName, itemSeq = itemSeq)
.fold(onSuccess = { Result.success(it.toDto()) }, onFailure = { Result.failure(it) })
}
.fold(onSuccess = { Result.success(it.toElderlyCautionDto()) }, onFailure = { Result.failure(it) })
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.android.mediproject.core.database.cache.manager.MedicineDataCacheMana
import com.android.mediproject.core.model.local.navargs.MedicineInfoArgs
import com.android.mediproject.core.model.medicine.medicinedetailinfo.MedicineDetatilInfoDto
import com.android.mediproject.core.model.medicine.medicinedetailinfo.cache.MedicineCacheEntity
import com.android.mediproject.core.model.medicine.medicinedetailinfo.toDto
import com.android.mediproject.core.model.medicine.medicinedetailinfo.toMedicineDetailInfoDto
import com.android.mediproject.core.model.requestparameters.GetMedicineIdParameter
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
Expand Down Expand Up @@ -56,7 +56,7 @@ class GetMedicineDetailsUseCase @Inject constructor(

val medicineInfo = medicineInfoResult.fold(
onSuccess = { item ->
Result.success(item.toDto(medicineId))
Result.success(item.toMedicineDetailInfoDto(medicineId))
},
onFailure = {
Result.failure(it)
Expand All @@ -83,7 +83,7 @@ class GetMedicineDetailsUseCase @Inject constructor(
onSuccess = { item ->
Result.success(
item.map {
it.toDto()
it.toMedicineDetailInfoDto()
},
)
},
Expand Down
Loading

0 comments on commit 57c7bc6

Please sign in to comment.