-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Remote Config 기반 앱 테마 전환 추가 #516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5a00644
feat: 벚꽃 리소스 추가
PeraSite 3dfed08
feat: AndroidManifest.xml에 activity-alias 적용
PeraSite a86b722
chore: Blossom 대신 Spring으로 명칭 통일
PeraSite a2f76a0
feat: 스플래시 화면의 로고를 바꿀 수 있게 ID 추가
PeraSite 39cb2e5
feat: AppTheme enum, Firebase Remote Config에서 불러오기 추가
PeraSite 55387d0
feat: DataStore에 테마 저장 및 적용
PeraSite f429dcb
feat: SharedPreference로 변경
PeraSite f8ec64f
fix: 유닛 테스트 타입 오류 수정
PeraSite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/eatssu/android/data/local/AppThemePreferences.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.eatssu.android.data.local | ||
|
|
||
| import android.content.Context | ||
| import android.content.SharedPreferences | ||
| import com.eatssu.android.domain.model.AppTheme | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
| import androidx.core.content.edit | ||
|
|
||
| @Singleton | ||
| class AppThemePreferences @Inject constructor( | ||
| @ApplicationContext context: Context, | ||
| ) { | ||
|
|
||
| companion object { | ||
| private const val PREFS_NAME = "app_theme" | ||
| private const val KEY_APP_THEME = "app_theme" | ||
| } | ||
|
|
||
| private val prefs: SharedPreferences = | ||
| context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE) | ||
|
|
||
| fun getAppTheme(): AppTheme { | ||
| return AppTheme.fromStringOrDefault(prefs.getString(KEY_APP_THEME, null).orEmpty()) | ||
| } | ||
|
|
||
| fun setAppTheme(theme: AppTheme) { | ||
| prefs.edit { | ||
| putString(KEY_APP_THEME, theme.remoteValue) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/main/java/com/eatssu/android/domain/model/AppTheme.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.eatssu.android.domain.model | ||
|
|
||
| import androidx.annotation.AnyRes | ||
| import androidx.annotation.DrawableRes | ||
| import com.eatssu.android.R | ||
|
|
||
| enum class AppTheme( | ||
| val remoteValue: String, | ||
| @AnyRes val splashBackgroundResId: Int, | ||
| @DrawableRes val splashLogoResId: Int, | ||
| val launcherAliasSuffix: String, | ||
| ) { | ||
| DEFAULT( | ||
| remoteValue = "default", | ||
| splashBackgroundResId = R.color.primary, | ||
| splashLogoResId = R.drawable.img_logo, | ||
| launcherAliasSuffix = ".alias.DefaultLauncherAlias", | ||
| ), | ||
| CHRISTMAS( | ||
| remoteValue = "christmas", | ||
| splashBackgroundResId = R.drawable.img_background_snow, | ||
| splashLogoResId = R.drawable.img_logo_snow, | ||
| launcherAliasSuffix = ".alias.ChristmasLauncherAlias", | ||
| ), | ||
| SPRING( | ||
| remoteValue = "spring", | ||
| splashBackgroundResId = R.drawable.img_background_spring, | ||
| splashLogoResId = R.drawable.img_logo, | ||
| launcherAliasSuffix = ".alias.SpringLauncherAlias", | ||
| ); | ||
|
|
||
| companion object { | ||
| fun fromStringOrDefault(value: String): AppTheme { | ||
| return entries.find { it.remoteValue.equals(value, ignoreCase = true) } ?: DEFAULT | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <background android:drawable="@color/white"/> | ||
| <foreground android:drawable="@mipmap/ic_launcher_spring_foreground"/> | ||
| </adaptive-icon> |
5 changes: 5 additions & 0 deletions
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_spring_round.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| <background android:drawable="@color/white"/> | ||
| <foreground android:drawable="@mipmap/ic_launcher_spring_foreground"/> | ||
| </adaptive-icon> |
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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getMinimumVersionCode()/getAppTheme()/getRestaurantInfo()가 모두fetchAndActivateSafely()를 호출하고 있어, 앱 시작 시 여러 값을 연속으로 읽는 경우fetchAndActivate()가 중복 호출됩니다. Remote Config가 내부적으로 캐시를 쓰더라도 불필요한 작업/지연이 발생할 수 있으니, fetch를 1회만 수행하도록 (예: fetch 작업을 memoize하거나, 외부에서 한 번 fetch 후 여러 getter가 값을 읽도록) 구조를 조정하는 게 좋습니다.