Skip to content

Commit

Permalink
Merge 1f77476 into 26fd53d
Browse files Browse the repository at this point in the history
  • Loading branch information
KxxHyoRim authored Nov 10, 2023
2 parents 26fd53d + 1f77476 commit 3289065
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 11 deletions.
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,9 @@
android:name=".main.notification.NotificationCenterActivity"
android:exported="false" />

<activity
android:name=".auth.ui.SystemMaintenanceActivity"
android:exported="false" />

</application>
</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion common-ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
<string name="cannot_cancle_after_participate_mission">참여한 미션은 취소가 불가능해요</string>
<string name="do_you_want_to_participate_mission">미션에 참여하시겠어요?</string>
<string name="delete_mission_title">미션을 삭제하시겠어요?</string>
<string name="delete_mission_message">이미 미션에 참여한 리뷰이가 있다면 미션 삭제가 불가능합니다.</string>
<string name="delete_mission_message">참여중인 리뷰어가 있다면 삭제가 불가능해요.</string>
<string name="delete_mission_success">미션이 삭제되었습니다.</string>

<!-- Profile -->
Expand Down Expand Up @@ -191,4 +191,8 @@
<string name="update">업데이트</string>
<string name="latest_version">최신 버전</string>

<!-- 시스템 점검중 -->
<string name="system_under_maintenance">시스템 점검 안내</string>


</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface MissionService {
@GET("v1/home")
suspend fun getHomeMission(): Response<BaseDTO<SduiDTO>>

@POST("v1/mission")
@POST("v2/mission")
suspend fun postMission(
@Body postMissionRequest: PostMissionRequestDTO
): Response<BaseDTO<PostMissionResponseDTO>>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.lgtm.android.auth.ui

import com.google.firebase.ktx.Firebase
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
import com.lgtm.android.auth.R
import com.lgtm.android.auth.databinding.ActivitySystemMaintenanceBinding
import com.lgtm.android.common_ui.base.BaseActivity

class SystemMaintenanceActivity :
BaseActivity<ActivitySystemMaintenanceBinding>(R.layout.activity_system_maintenance) {
override fun initializeViewModel() {
viewModel = null
}

override fun onResume() {
super.onResume()

val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 10
}
remoteConfig.setConfigSettingsAsync(configSettings)
remoteConfig.fetchAndActivate().addOnCompleteListener {
val isSystemMaintenance = remoteConfig.getString("systemUnderMaintenanceDescription")
.replace("\\n", "\n")
binding.tvDescription.text = isSystemMaintenance
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.lgtm.android.auth.R
import com.lgtm.android.auth.constant.AutoLoginState
import com.lgtm.android.auth.databinding.ActivitySplashBinding
import com.lgtm.android.auth.ui.SignInActivity
import com.lgtm.android.auth.ui.SystemMaintenanceActivity
import com.lgtm.android.common_ui.base.BaseActivity
import dagger.hilt.android.AndroidEntryPoint

Expand All @@ -31,6 +32,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_spl

override fun onResume() {
super.onResume()
splashViewModel.checkSystemMaintenance()
splashViewModel.getAppVersionInfo()
}

Expand All @@ -55,24 +57,43 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(R.layout.activity_spl
}

private fun startNextActivity() {
if (autoLoginState == AutoLoginState.AUTO_LOGIN_SUCCESS) {
moveToMainActivity()
} else {
moveToAuthActivity()
splashViewModel.isDataAllSet.observe(this) { isReady ->
if (isReady == true) {
when {
isSystemMaintenance() -> navigateToSystemMaintenanceActivity()
isAutoLoginAvailable() -> moveToMainActivity()
isAutoLoginAvailable().not() -> moveToAuthActivity()
else -> throw IllegalStateException("Unhandled state")
}
}
}
}

private fun isSystemMaintenance() = splashViewModel.isSystemMaintenance.value == true

private fun isAutoLoginAvailable() = autoLoginState == AutoLoginState.AUTO_LOGIN_SUCCESS

private fun moveToMainActivity() {
lgtmNavigator.navigateToMain(this)
finish()
}

private fun navigateToSystemMaintenanceActivity() {
startActivity(Intent(this, SystemMaintenanceActivity::class.java))
finish()
}

private fun moveToAuthActivity() {
startActivity(Intent(this, SignInActivity::class.java))
overridePendingTransition(0, 0)
finish()
}

override fun onDestroy() {
splashViewModel.removeSourceOnIsDataAllSet()
super.onDestroy()
}

companion object {
private const val SPLASH_DELAY: Long = 1000
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package com.lgtm.android.auth.ui.splash
import android.content.ContentValues.TAG
import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MediatorLiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.google.firebase.crashlytics.ktx.crashlytics
import com.google.firebase.ktx.Firebase
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfig
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
import com.lgtm.android.common_ui.base.BaseViewModel
import com.lgtm.domain.repository.AuthRepository
import com.lgtm.domain.repository.IntroRepository
Expand All @@ -17,7 +21,7 @@ import javax.inject.Inject
@HiltViewModel
class SplashViewModel @Inject constructor(
private val introRepository: IntroRepository,
private val authRepository: AuthRepository
private val authRepository: AuthRepository,
) : BaseViewModel() {
private val _minVersion = MutableLiveData<Int>()
val minVersion: LiveData<Int> = _minVersion
Expand All @@ -38,7 +42,53 @@ class SplashViewModel @Inject constructor(
}
}

private val _isDataAllSet = MediatorLiveData<Boolean>().apply { value = false }
val isDataAllSet: LiveData<Boolean> = _isDataAllSet

init {
addSourceOnIsDataAllSet()
}

private fun addSourceOnIsDataAllSet() {
_isDataAllSet.addSource(minVersion) {
if (_isDataAllSet.value == true) return@addSource
fetchIsDataAllSetState()
}
_isDataAllSet.addSource(latestVersion) {
if (_isDataAllSet.value == true) return@addSource
fetchIsDataAllSetState()
}
}

fun removeSourceOnIsDataAllSet() {
_isDataAllSet.removeSource(minVersion)
_isDataAllSet.removeSource(latestVersion)
}

private fun fetchIsDataAllSetState() {
_isDataAllSet.value = _minVersion.value != null && _isSystemMaintenance.value != null
}

private val _isSystemMaintenance = MutableLiveData<Boolean>()
val isSystemMaintenance: LiveData<Boolean> = _isSystemMaintenance

fun checkSystemMaintenance() {
val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {
minimumFetchIntervalInSeconds = 10
}
remoteConfig.setConfigSettingsAsync(configSettings)
remoteConfig.fetchAndActivate().addOnCompleteListener {
val isSystemMaintenance = remoteConfig.getBoolean(IS_SYSTEM_MAINTENANCE)
_isSystemMaintenance.postValue(isSystemMaintenance)
}
}

fun isAutoLoginAvailable(): Boolean {
return authRepository.isAutoLoginAvailable()
}

companion object {
private const val IS_SYSTEM_MAINTENANCE = "isSystemUnderMaintenance"
}
}
57 changes: 57 additions & 0 deletions feature/auth/src/main/res/layout/activity_system_maintenance.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/gray_3"
tools:context=".ui.SystemMaintenanceActivity">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="5dp"
android:background="@drawable/rectangle_gray_2_radius_20">

<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/ic_info"
android:layout_width="55dp"
android:layout_height="55dp"
android:src="@drawable/ic_info_gray_6"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.36" />

<TextView
android:id="@+id/tv_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="13dp"
android:gravity="center"
android:text="@string/system_under_maintenance"
android:textAppearance="@style/Body2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ic_info" />

<TextView
android:id="@+id/tv_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="50dp"
android:layout_marginTop="4dp"
android:gravity="center"
android:textAppearance="@style/Description"
android:textColor="@color/gray_6"
app:layout_constraintTop_toBottomOf="@id/tv_title"
tools:text="현재는 시스템 점검 중입니다.\n불편을 끼쳐드려 죄송합니다" />

</androidx.constraintlayout.widget.ConstraintLayout>


</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
3 changes: 3 additions & 0 deletions feature/auth/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class MissionDetailActivity :
title = title,
description = description,
doAfterConfirm = ::deleteMission,
confirmBtnBackground = LgtmConfirmationDialog.ConfirmButtonBackground.GREEN
confirmBtnBackground = LgtmConfirmationDialog.ConfirmButtonBackground.GRAY
)
dialog.show(supportFragmentManager, this.javaClass.name)
}
Expand Down
7 changes: 4 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
compileSdk = "33"
minSdk = "26"
targetSdk = "33"
appVersion = "1.1.0"
versionCode = "110"
appVersion = "1.1.1"
versionCode = "111"

# Kotlin and Serialization
kotlin = "1.7.20"
Expand Down Expand Up @@ -128,6 +128,7 @@ firebase = { module = "com.google.firebase:firebase-bom", version.ref = "firebas
firebase-analytics = { module = "com.google.firebase:firebase-analytics-ktx" }
firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics-ktx" }
firebase-messaging = { module = "com.google.firebase:firebase-messaging-ktx" }
firebase-config = { module = "com.google.firebase:firebase-config-ktx" }
kotlin-bom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version.ref = "kotlin-bom" }

jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
Expand All @@ -138,7 +139,7 @@ androidx-ui-foundation = ["core-ktx", "appcompat", "lifecycle-viewmodel", "const
okhttp = ["okhttp", "okhttp-logging-interceptor", "okhttp-bom"]
retrofit = ["retrofit", "retrofit-kotlin-serialization-converter"]
gson = ["gson", "gson-converter"]
firebase = ["firebase-analytics", "firebase-crashlytics", "firebase-messaging"]
firebase = ["firebase-analytics", "firebase-crashlytics", "firebase-messaging", "firebase-config"]
accompanist = ["accompanist-systemuicontroller"]
androidx-android-test = ["androidx-test-runner", "androidx-test-rules"]
basic-test = ["junit", "androidx-test-junit", "androidx-test-espresso"]
Expand Down

0 comments on commit 3289065

Please sign in to comment.