diff --git a/README.md b/README.md index 99676874..b7226bd3 100644 --- a/README.md +++ b/README.md @@ -1 +1,20 @@ # android-map-notification + +## Step1 + +### ๐Ÿ“œ Description + +์นด์นด์˜ค๋งต ํด๋ก  ์ฝ”๋”ฉ _ ์•Œ๋ฆผ-ํŒŒ์ด์–ด๋ฒ ์ด + + +### ๐ŸŽฏ Tasks + +- Main ๊ธฐ๋Šฅ : **Splash Screen** + +- ์ดˆ๊ธฐ ์ง„์ž… ํ™”๋ฉด ์ถ”๊ฐ€ +- Firebase์˜ Remote Config ์„ค์ • +- ์„œ๋น„์Šค ์ƒํƒœ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜ ๊ฐ๊ฐ ๋“ฑ๋ก + - ๋งค๊ฐœ๋ณ€์ˆ˜ ์ด๋ฆ„ : serviceState, serviceMessage +- ๋งค๊ฐœ๋ณ€์ˆ˜ serviceState ๊ฐ’์ด ON_SERVICE์ผ ๋•Œ๋งŒ ์ดˆ๊ธฐ ์ง„์ž… ํ™”๋ฉด์ด ์ง€๋„ ํ™”๋ฉด์œผ๋กœ ๋„˜์–ด๊ฐ +- ๋งค๊ฐœ๋ณ€์ˆ˜ serviceState ๊ฐ’์ด ON_SERVICE์ด ์•„๋‹Œ ๊ฒฝ์šฐ, serviceMessage ๊ฐ’์„ ์ดˆ๊ธฐ ์ง„์ž… ํ™”๋ฉด ํ•˜๋‹จ์— ํ‘œ์‹œํ•˜๊ณ  ์ง€๋„ ํ™”๋ฉด์œผ๋กœ ์ง„์ž…ํ•˜์ง€ ์•Š์Œ +- ์„œ๋ฒ„ ์ƒํƒœ, UI ๋กœ๋”ฉ ๋“ฑ์— ๋Œ€ํ•œ ์ƒํƒœ ๊ด€๋ฆฌ \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1001628e..45f6371a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,31 +7,35 @@ + tools:targetApi="31"> + android:exported="false" /> + + - - + + + - - + \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/di/AppModule.kt b/app/src/main/java/campus/tech/kakao/map/di/AppModule.kt index d124d375..77b032e0 100644 --- a/app/src/main/java/campus/tech/kakao/map/di/AppModule.kt +++ b/app/src/main/java/campus/tech/kakao/map/di/AppModule.kt @@ -5,6 +5,7 @@ import androidx.room.Room import campus.tech.kakao.map.database.AppDatabase import campus.tech.kakao.map.database.MapItemDao import campus.tech.kakao.map.repository.MapItemRepository +import com.google.firebase.remoteconfig.FirebaseRemoteConfig import dagger.Module import dagger.Provides import dagger.hilt.InstallIn @@ -39,4 +40,10 @@ object AppModule { ): MapItemRepository { return MapItemRepository(mapItemDao, context) } + + @Provides + @Singleton + fun provideFirebaseRemoteConfig(): FirebaseRemoteConfig { + return FirebaseRemoteConfig.getInstance() + } } \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/ui/SplashScreenActivity.kt b/app/src/main/java/campus/tech/kakao/map/ui/SplashScreenActivity.kt new file mode 100644 index 00000000..8fb67d00 --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/ui/SplashScreenActivity.kt @@ -0,0 +1,50 @@ +package campus.tech.kakao.map.ui + +import android.content.Intent +import android.os.Bundle +import android.os.Handler +import android.os.Looper +import android.util.Log +import androidx.activity.viewModels +import androidx.appcompat.app.AppCompatActivity +import androidx.databinding.DataBindingUtil +import campus.tech.kakao.map.R +import campus.tech.kakao.map.databinding.ActivitySplashScreenBinding +import campus.tech.kakao.map.viewmodel.SplashScreenViewModel +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class SplashScreenActivity : AppCompatActivity() { + + private val viewModel: SplashScreenViewModel by viewModels() + private lateinit var binding: ActivitySplashScreenBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + binding = DataBindingUtil.setContentView(this, R.layout.activity_splash_screen) + binding.lifecycleOwner = this + binding.viewModel = viewModel + + viewModel.serviceState.observe(this) { state -> + if (state == "ON_SERVICE") { + navigateToMapActivity() + } else { + showServiceMessage() + } + } + } + + private fun navigateToMapActivity() { + Log.d("SplashScreen", "Success") + Handler(Looper.getMainLooper()).postDelayed({ + startActivity(Intent(this, MapActivity::class.java)) + finish() + }, 3000) + } + + private fun showServiceMessage() { + Log.d("SplashScreen", "Failed") + binding.tvServiceMessage.text = viewModel.serviceMessage.value + } +} \ No newline at end of file diff --git a/app/src/main/java/campus/tech/kakao/map/viewmodel/SplashScreenViewModel.kt b/app/src/main/java/campus/tech/kakao/map/viewmodel/SplashScreenViewModel.kt new file mode 100644 index 00000000..bfc23c3b --- /dev/null +++ b/app/src/main/java/campus/tech/kakao/map/viewmodel/SplashScreenViewModel.kt @@ -0,0 +1,55 @@ +package campus.tech.kakao.map.viewmodel + +import android.util.Log +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.google.firebase.remoteconfig.FirebaseRemoteConfig +import com.google.firebase.remoteconfig.remoteConfigSettings +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class SplashScreenViewModel @Inject constructor( + private val remoteConfig: FirebaseRemoteConfig +) : ViewModel() { + + private val _serviceState = MutableLiveData() + val serviceState: LiveData = _serviceState + + private val _serviceMessage = MutableLiveData() + val serviceMessage: LiveData = _serviceMessage + + init { + setupRemoteConfig() + fetchRemoteConfig() + } + + private fun setupRemoteConfig() { + val configSettings = remoteConfigSettings { + minimumFetchIntervalInSeconds = 0 + } + remoteConfig.setConfigSettingsAsync(configSettings) + } + + private fun fetchRemoteConfig() { + viewModelScope.launch { + remoteConfig.fetchAndActivate() + .addOnCompleteListener { task -> + if (task.isSuccessful) { + handleRemoteConfig() + } else { + Log.d("SplashScreenViewModel", "Fetch failed") + } + } + } + } + + private fun handleRemoteConfig() { + _serviceState.value = remoteConfig.getString("serviceState") + _serviceMessage.value = remoteConfig.getString("serviceMessage") + } + +} \ 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..f7a97d9d Binary files /dev/null and b/app/src/main/res/drawable/map.png differ diff --git a/app/src/main/res/layout/activity_splash_screen.xml b/app/src/main/res/layout/activity_splash_screen.xml new file mode 100644 index 00000000..24bd9117 --- /dev/null +++ b/app/src/main/res/layout/activity_splash_screen.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4bc21f24..843469f2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -16,4 +16,6 @@ ์ง€๋„ ์ธ์ฆ์„ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.\n๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”. ์—๋Ÿฌ ๋ฉ”์„ธ์ง€ ๋กœ๋”ฉ ์ด๋ฏธ์ง€ + tvServiceMessage + splashScreenMapIcon \ No newline at end of file