diff --git a/README.md b/README.md
index 99676874..3dd5dcbc 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,20 @@
-# android-map-notification
+# 맵 위치 검색 안드로이드 앱
+- 카테캠 Step2 Week6
+- 장소 검색 및 장소 저장이 가능한 안드로이드 앱
+
+## 기능
+**1. 초기 진입 화면 추가**
+- firebase의 Remote Config 설정
+- serviceState 값이 ON_SERVICE 일 때
+ - 지도 화면으로 진입
+- serviceState 값이 ON_SERVICE가 아닐 때
+ - serviceMessage를 초기 진입 화면 하단에 표시
+ - 지도 화면으로 진입하지 않음
+
+
+## 실행
+- SplashActivity.kt 에서 시작
+
+## 환경
+- Kotlin
+- Android Studio
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5b33cea8..eaa2bff3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -7,8 +7,8 @@
+
+ android:value="${KAKAO_API_KEY}" />
+
+ android:value="${KAKAO_API_KEY}" />
+
+ android:name=".ui.SplashActivity"
+ android:exported="true">
-
-
+ android:exported="false">
-
+
\ No newline at end of file
diff --git a/app/src/main/java/campus/tech/kakao/map/ui/MainActivity.kt b/app/src/main/java/campus/tech/kakao/map/ui/MainActivity.kt
index b4aa1365..a651933b 100644
--- a/app/src/main/java/campus/tech/kakao/map/ui/MainActivity.kt
+++ b/app/src/main/java/campus/tech/kakao/map/ui/MainActivity.kt
@@ -23,9 +23,6 @@ import javax.inject.Inject
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
- @Inject
- lateinit var db: AppDatabase
-
@Inject
lateinit var searchSave: SaveHelper
@@ -49,12 +46,6 @@ class MainActivity : AppCompatActivity() {
} else {
adapter.updateProfiles(profiles)
mainBinding.tvNoResult.visibility = View.GONE
-
- lifecycleScope.launch {
- withContext(Dispatchers.IO) {
- db.profileDao().insertAll(*profiles.toTypedArray())
- }
- }
}
})
diff --git a/app/src/main/java/campus/tech/kakao/map/ui/MainViewModel.kt b/app/src/main/java/campus/tech/kakao/map/ui/MainViewModel.kt
index 6e38ecfc..a9a26f05 100644
--- a/app/src/main/java/campus/tech/kakao/map/ui/MainViewModel.kt
+++ b/app/src/main/java/campus/tech/kakao/map/ui/MainViewModel.kt
@@ -2,6 +2,7 @@ package campus.tech.kakao.map.ui
import android.widget.Toast
import androidx.lifecycle.*
+import campus.tech.kakao.map.data.AppDatabase
import campus.tech.kakao.map.data.Profile
import campus.tech.kakao.map.network.Document
import campus.tech.kakao.map.network.KakaoResponse
@@ -14,7 +15,10 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
@HiltViewModel
-class MainViewModel @Inject constructor(private val searchService: SearchService) : ViewModel() {
+class MainViewModel @Inject constructor(
+ private val searchService: SearchService,
+ private val db: AppDatabase // Inject the database here
+) : ViewModel() {
private val _profiles = MutableLiveData>()
val profiles: LiveData> get() = _profiles
@@ -52,6 +56,12 @@ class MainViewModel @Inject constructor(private val searchService: SearchService
} else {
val profilesList = documents.map { it.toProfile() }
_profiles.value = profilesList
+
+ viewModelScope.launch {
+ withContext(Dispatchers.IO) {
+ db.profileDao().insertAll(*profilesList.toTypedArray())
+ }
+ }
}
} ?: run {
_noResult.value = true
diff --git a/app/src/main/java/campus/tech/kakao/map/ui/SplashActivity.kt b/app/src/main/java/campus/tech/kakao/map/ui/SplashActivity.kt
new file mode 100644
index 00000000..176eae45
--- /dev/null
+++ b/app/src/main/java/campus/tech/kakao/map/ui/SplashActivity.kt
@@ -0,0 +1,38 @@
+package campus.tech.kakao.map.ui
+
+import android.content.Intent
+import android.os.Bundle
+import android.util.Log
+import android.widget.TextView
+import android.widget.Toast
+import androidx.activity.viewModels
+import androidx.appcompat.app.AppCompatActivity
+import androidx.databinding.DataBindingUtil
+import androidx.lifecycle.Observer
+import campus.tech.kakao.map.R
+import campus.tech.kakao.map.databinding.ActivitySplashBinding
+
+class SplashActivity : AppCompatActivity() {
+
+ private val splashViewModel: SplashViewModel by viewModels()
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ val binding: ActivitySplashBinding = DataBindingUtil.setContentView(this, R.layout.activity_splash)
+ binding.lifecycleOwner = this
+ binding.viewModel = splashViewModel
+
+ splashViewModel.serviceState.observe(this, Observer { state ->
+ if (state == "ON_SERVICE") {
+ startActivity(Intent(this, MapActivity::class.java))
+ finish()
+ } else {
+ binding.tvServiceMessage.visibility = TextView.VISIBLE
+ }
+ })
+
+ splashViewModel.serviceMessage.observe(this, Observer { message ->
+ Log.d("SplashActivity", "serviceMessage: $message")
+ })
+ }
+}
diff --git a/app/src/main/java/campus/tech/kakao/map/ui/SplashViewModel.kt b/app/src/main/java/campus/tech/kakao/map/ui/SplashViewModel.kt
new file mode 100644
index 00000000..a4baac42
--- /dev/null
+++ b/app/src/main/java/campus/tech/kakao/map/ui/SplashViewModel.kt
@@ -0,0 +1,38 @@
+package campus.tech.kakao.map.ui
+
+import android.app.Application
+import androidx.lifecycle.AndroidViewModel
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import com.google.firebase.remoteconfig.FirebaseRemoteConfig
+import com.google.firebase.remoteconfig.remoteConfigSettings
+
+class SplashViewModel(application: Application) : AndroidViewModel(application) {
+
+ private val _serviceState = MutableLiveData()
+ val serviceState: LiveData = _serviceState
+
+ private val _serviceMessage = MutableLiveData()
+ val serviceMessage: LiveData = _serviceMessage
+
+ init {
+ remoteConfigValues()
+ }
+
+ private fun remoteConfigValues() {
+ val remoteConfig: FirebaseRemoteConfig = FirebaseRemoteConfig.getInstance()
+ val configSettings = remoteConfigSettings {
+ minimumFetchIntervalInSeconds = 0
+ }
+ remoteConfig.setConfigSettingsAsync(configSettings)
+
+ remoteConfig.fetchAndActivate().addOnCompleteListener { task ->
+ if (task.isSuccessful) {
+ _serviceState.value = remoteConfig.getString("serviceState")
+ _serviceMessage.value = remoteConfig.getString("serviceMessage")
+ } else {
+ _serviceMessage.value = "Failed to fetch remote config values"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/map.png b/app/src/main/res/drawable/map.png
new file mode 100644
index 00000000..fc3da4eb
Binary files /dev/null and b/app/src/main/res/drawable/map.png differ
diff --git a/app/src/main/res/layout/activity_splash.xml b/app/src/main/res/layout/activity_splash.xml
new file mode 100644
index 00000000..cf6401a1
--- /dev/null
+++ b/app/src/main/res/layout/activity_splash.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file