From 53101d68cc1b4888e6e9d6d860a56d919c83e614 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 19:00:30 +0900 Subject: [PATCH 01/14] #176 update : pager beyondBoundsPageCount --- .../com/titi/app/core/designsystem/component/TdsGraphContent.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsGraphContent.kt b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsGraphContent.kt index 2066db15..b397f411 100644 --- a/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsGraphContent.kt +++ b/core/designsystem/src/main/kotlin/com/titi/app/core/designsystem/component/TdsGraphContent.kt @@ -49,7 +49,7 @@ fun TdsGraphContent( modifier = Modifier.wrapContentSize(), userScrollEnabled = true, state = pagerState, - beyondBoundsPageCount = 2, + beyondBoundsPageCount = 3, ) { page -> when (page % 4) { 0 -> TdsStandardDailyGraph( From c3c84b42db2d2a62f6c345376419af38f75c9d9b Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 19:30:40 +0900 Subject: [PATCH 02/14] =?UTF-8?q?#169=20feat=20:=20=EC=96=B8=EC=96=B4=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/values-ko-rKR/strings.xml | 2 + .../src/main/res/values-zh/strings.xml | 2 + .../src/main/res/values/strings.xml | 2 + .../app/feature/setting/ui/SettingScreen.kt | 66 +++++++++++++++++++ 4 files changed, 72 insertions(+) diff --git a/core/designsystem/src/main/res/values-ko-rKR/strings.xml b/core/designsystem/src/main/res/values-ko-rKR/strings.xml index 181e97aa..4fe66a6f 100644 --- a/core/designsystem/src/main/res/values-ko-rKR/strings.xml +++ b/core/designsystem/src/main/res/values-ko-rKR/strings.xml @@ -65,4 +65,6 @@ 새로운 기록 설정 Daily 수정/생성 중복된 내역이 존재 합니다. + 언어 + 시스템 \ No newline at end of file diff --git a/core/designsystem/src/main/res/values-zh/strings.xml b/core/designsystem/src/main/res/values-zh/strings.xml index 43dbd7af..8cde168b 100644 --- a/core/designsystem/src/main/res/values-zh/strings.xml +++ b/core/designsystem/src/main/res/values-zh/strings.xml @@ -65,4 +65,6 @@ 新建日志设置 "每日修改/创建 " 重复的历史存在。 + 语言 + 系统 \ No newline at end of file diff --git a/core/designsystem/src/main/res/values/strings.xml b/core/designsystem/src/main/res/values/strings.xml index 09c9ff95..7e773bc3 100644 --- a/core/designsystem/src/main/res/values/strings.xml +++ b/core/designsystem/src/main/res/values/strings.xml @@ -70,4 +70,6 @@ Setting New Record Daily Modify/Create Duplicate history exists. + Language + System \ No newline at end of file diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt index 017bd96a..f02e5e05 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt @@ -23,6 +23,7 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.verticalScroll import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon +import androidx.compose.material3.RadioButton import androidx.compose.material3.Scaffold import androidx.compose.material3.Switch import androidx.compose.material3.TopAppBar @@ -179,6 +180,10 @@ private fun SettingScreen( Spacer(modifier = Modifier.height(35.dp)) + SettingLanguageSection() + + Spacer(modifier = Modifier.height(35.dp)) + SettingVersionSection( versionState = uiState.versionState, onSettingActions = onSettingActions, @@ -297,6 +302,67 @@ private fun SettingNotificationSection( ) } +@Composable +private fun SettingLanguageSection() { + TdsText( + modifier = Modifier.padding(start = 16.dp), + text = stringResource(R.string.setting_text_launguage), + textStyle = TdsTextStyle.SEMI_BOLD_TEXT_STYLE, + fontSize = 14.sp, + color = TdsColor.TEXT, + ) + + Spacer(modifier = Modifier.height(4.dp)) + + ListContent( + title = stringResource(R.string.setting_text_system), + rightAreaContent = { + RadioButton( + selected = true, + onClick = {}, + ) + }, + ) + + Spacer(modifier = Modifier.height(1.dp)) + + ListContent( + title = "한국어", + rightAreaContent = { + RadioButton( + selected = true, + onClick = {}, + ) + }, + ) + + Spacer(modifier = Modifier.height(1.dp)) + + ListContent( + title = "English", + rightAreaContent = { + RadioButton( + selected = true, + onClick = {}, + ) + }, + ) + + Spacer(modifier = Modifier.height(1.dp)) + + ListContent( + title = "中国话", + rightAreaContent = { + RadioButton( + selected = true, + onClick = {}, + ) + }, + ) + + Spacer(modifier = Modifier.height(1.dp)) +} + @Composable private fun SettingVersionSection( versionState: SettingUiState.VersionState, From 54558b568f1e795958ea130c0803e4aa11651e77 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 19:41:56 +0900 Subject: [PATCH 03/14] #169 update : spelling --- core/designsystem/src/main/res/values-ko-rKR/strings.xml | 2 +- core/designsystem/src/main/res/values-zh/strings.xml | 2 +- core/designsystem/src/main/res/values/strings.xml | 2 +- .../kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/designsystem/src/main/res/values-ko-rKR/strings.xml b/core/designsystem/src/main/res/values-ko-rKR/strings.xml index 4fe66a6f..8f9ad336 100644 --- a/core/designsystem/src/main/res/values-ko-rKR/strings.xml +++ b/core/designsystem/src/main/res/values-ko-rKR/strings.xml @@ -65,6 +65,6 @@ 새로운 기록 설정 Daily 수정/생성 중복된 내역이 존재 합니다. - 언어 + 언어 시스템 \ No newline at end of file diff --git a/core/designsystem/src/main/res/values-zh/strings.xml b/core/designsystem/src/main/res/values-zh/strings.xml index 8cde168b..5eaa4f85 100644 --- a/core/designsystem/src/main/res/values-zh/strings.xml +++ b/core/designsystem/src/main/res/values-zh/strings.xml @@ -65,6 +65,6 @@ 新建日志设置 "每日修改/创建 " 重复的历史存在。 - 语言 + 语言 系统 \ No newline at end of file diff --git a/core/designsystem/src/main/res/values/strings.xml b/core/designsystem/src/main/res/values/strings.xml index 7e773bc3..17a5f6e7 100644 --- a/core/designsystem/src/main/res/values/strings.xml +++ b/core/designsystem/src/main/res/values/strings.xml @@ -70,6 +70,6 @@ Setting New Record Daily Modify/Create Duplicate history exists. - Language + Language System \ No newline at end of file diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt index f02e5e05..8c296a70 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt @@ -306,7 +306,7 @@ private fun SettingNotificationSection( private fun SettingLanguageSection() { TdsText( modifier = Modifier.padding(start = 16.dp), - text = stringResource(R.string.setting_text_launguage), + text = stringResource(R.string.setting_text_language), textStyle = TdsTextStyle.SEMI_BOLD_TEXT_STYLE, fontSize = 14.sp, color = TdsColor.TEXT, From 549a7d009d6506f89a9f80df61b00862fa304878 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 20:03:57 +0900 Subject: [PATCH 04/14] #169 chore : data language api --- data/language/api/build.gradle.kts | 7 +++++++ data/language/api/src/main/AndroidManifest.xml | 4 ++++ .../app/data/language/api/ExampleUnitTest.kt | 16 ++++++++++++++++ settings.gradle.kts | 1 + 4 files changed, 28 insertions(+) create mode 100644 data/language/api/build.gradle.kts create mode 100644 data/language/api/src/main/AndroidManifest.xml create mode 100644 data/language/api/src/test/kotlin/com/titi/app/data/language/api/ExampleUnitTest.kt diff --git a/data/language/api/build.gradle.kts b/data/language/api/build.gradle.kts new file mode 100644 index 00000000..f9060d35 --- /dev/null +++ b/data/language/api/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + id("titi.android.library-no-hilt") +} + +android { + namespace = "com.titi.app.data.language.api" +} diff --git a/data/language/api/src/main/AndroidManifest.xml b/data/language/api/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/data/language/api/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/data/language/api/src/test/kotlin/com/titi/app/data/language/api/ExampleUnitTest.kt b/data/language/api/src/test/kotlin/com/titi/app/data/language/api/ExampleUnitTest.kt new file mode 100644 index 00000000..5d30e8ed --- /dev/null +++ b/data/language/api/src/test/kotlin/com/titi/app/data/language/api/ExampleUnitTest.kt @@ -0,0 +1,16 @@ +package com.titi.app.data.language.api + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 0399c87f..b22b1b93 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -52,3 +52,4 @@ include(":data:notification:impl") include(":feature:webview") include(":feature:edit") include(":tds") +include(":data:language:api") From bbc044533b095bb1c7c1372c455bc6bc4a0e8d68 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 20:07:43 +0900 Subject: [PATCH 05/14] #169 chore : data language impl --- data/language/impl/build.gradle.kts | 11 +++++++++++ data/language/impl/src/main/AndroidManifest.xml | 4 ++++ .../app/data/language/impl/ExampleUnitTest.kt | 16 ++++++++++++++++ settings.gradle.kts | 1 + 4 files changed, 32 insertions(+) create mode 100644 data/language/impl/build.gradle.kts create mode 100644 data/language/impl/src/main/AndroidManifest.xml create mode 100644 data/language/impl/src/test/kotlin/com/titi/app/data/language/impl/ExampleUnitTest.kt diff --git a/data/language/impl/build.gradle.kts b/data/language/impl/build.gradle.kts new file mode 100644 index 00000000..6265fbb0 --- /dev/null +++ b/data/language/impl/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("titi.android.data.local") +} + +android { + namespace = "com.titi.app.data.language.impl" +} + +dependencies { + implementation(project(":data:language:api")) +} diff --git a/data/language/impl/src/main/AndroidManifest.xml b/data/language/impl/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/data/language/impl/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/data/language/impl/src/test/kotlin/com/titi/app/data/language/impl/ExampleUnitTest.kt b/data/language/impl/src/test/kotlin/com/titi/app/data/language/impl/ExampleUnitTest.kt new file mode 100644 index 00000000..cb0b8aaf --- /dev/null +++ b/data/language/impl/src/test/kotlin/com/titi/app/data/language/impl/ExampleUnitTest.kt @@ -0,0 +1,16 @@ +package com.titi.app.data.language.impl + +import org.junit.Assert.assertEquals +import org.junit.Test + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index b22b1b93..f8ccf56a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -53,3 +53,4 @@ include(":feature:webview") include(":feature:edit") include(":tds") include(":data:language:api") +include(":data:language:impl") From b6c45b09c7a83095e58598b2ff6d15ee2b9487d3 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 20:12:00 +0900 Subject: [PATCH 06/14] #169 feat : LanguageDataStore --- .../language/impl/local/LanguageDataStore.kt | 33 +++++++++++++++++++ .../impl/local/model/LanguageEntity.kt | 11 +++++++ 2 files changed, 44 insertions(+) create mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/LanguageDataStore.kt create mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/model/LanguageEntity.kt diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/LanguageDataStore.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/LanguageDataStore.kt new file mode 100644 index 00000000..ed956c48 --- /dev/null +++ b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/LanguageDataStore.kt @@ -0,0 +1,33 @@ +package com.titi.app.data.language.impl.local + +import android.content.Context +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.stringPreferencesKey +import androidx.datastore.preferences.preferencesDataStore +import com.titi.app.core.util.fromJson +import com.titi.app.core.util.readFlowValue +import com.titi.app.core.util.storeValue +import com.titi.app.core.util.toJson +import com.titi.app.data.language.impl.local.model.LanguageEntity +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map + +internal class LanguageDataStore(context: Context) { + private val dataStore: DataStore = context.dataStore + + suspend fun setLanguage(languageEntity: LanguageEntity) { + dataStore.storeValue(LANGUAGE_KEY, languageEntity.toJson()) + } + + fun getLanguageFlow(): Flow = + dataStore.readFlowValue(LANGUAGE_KEY).map { it?.fromJson() } + + companion object { + private const val LANGUAGE_PREF_NAME = "languagePrefName" + private val LANGUAGE_KEY = stringPreferencesKey("languageKey") + + private val Context.dataStore: DataStore + by preferencesDataStore(LANGUAGE_PREF_NAME) + } +} diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/model/LanguageEntity.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/model/LanguageEntity.kt new file mode 100644 index 00000000..9db7ff8d --- /dev/null +++ b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/model/LanguageEntity.kt @@ -0,0 +1,11 @@ +package com.titi.app.data.language.impl.local.model + +import com.squareup.moshi.JsonClass + +@JsonClass(generateAdapter = true) +data class LanguageEntity( + val system: Boolean, + val korean: Boolean, + val english: Boolean, + val china: Boolean, +) From 50ed790c1e72488fdfbe2011f67f4cc93ce88f0e Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 20:13:38 +0900 Subject: [PATCH 07/14] #169 feat : DataStoreModule --- .../data/language/impl/di/DataStoreModule.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt new file mode 100644 index 00000000..c3748ead --- /dev/null +++ b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt @@ -0,0 +1,17 @@ +package com.titi.app.data.language.impl.di + +import android.content.Context +import com.titi.app.data.language.impl.local.LanguageDataStore +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal object DataStoreModule { + @Provides + @Singleton + fun provideLanguageDataStore(context: Context) = LanguageDataStore(context) +} From ba13cc2efe30db1f55c37927d3cdbc6721f7d54f Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 20:20:28 +0900 Subject: [PATCH 08/14] #169 feat : LanguageRepository --- .../data/language/api/LanguageRepository.kt | 10 ++++++++ .../api/model/LanguageRepositoryModel.kt | 8 +++++++ .../impl/mapper/LocalToRepositoryMapper.kt | 11 +++++++++ .../impl/mapper/RepositoryToLocalMapper.kt | 11 +++++++++ .../impl/repository/LanguageRepositoryImpl.kt | 23 +++++++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt create mode 100644 data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt create mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/LocalToRepositoryMapper.kt create mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/RepositoryToLocalMapper.kt create mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt diff --git a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt new file mode 100644 index 00000000..bebf17e9 --- /dev/null +++ b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt @@ -0,0 +1,10 @@ +package com.titi.app.data.language.api + +import com.titi.app.data.language.api.model.LanguageRepositoryModel +import kotlinx.coroutines.flow.Flow + +interface LanguageRepository { + suspend fun setLanguage(languageRepositoryModel: LanguageRepositoryModel) + + fun getLanguageFlow(): Flow +} diff --git a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt new file mode 100644 index 00000000..aa7d8241 --- /dev/null +++ b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt @@ -0,0 +1,8 @@ +package com.titi.app.data.language.api.model + +data class LanguageRepositoryModel( + val system: Boolean = true, + val korean: Boolean = false, + val english: Boolean = false, + val china: Boolean = false, +) diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/LocalToRepositoryMapper.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/LocalToRepositoryMapper.kt new file mode 100644 index 00000000..f030cf9e --- /dev/null +++ b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/LocalToRepositoryMapper.kt @@ -0,0 +1,11 @@ +package com.titi.app.data.language.impl.mapper + +import com.titi.app.data.language.api.model.LanguageRepositoryModel +import com.titi.app.data.language.impl.local.model.LanguageEntity + +internal fun LanguageEntity.toRepositoryModel() = LanguageRepositoryModel( + system = system, + korean = korean, + english = english, + china = china, +) diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/RepositoryToLocalMapper.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/RepositoryToLocalMapper.kt new file mode 100644 index 00000000..9e18bc34 --- /dev/null +++ b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/RepositoryToLocalMapper.kt @@ -0,0 +1,11 @@ +package com.titi.app.data.language.impl.mapper + +import com.titi.app.data.language.api.model.LanguageRepositoryModel +import com.titi.app.data.language.impl.local.model.LanguageEntity + +internal fun LanguageRepositoryModel.toLocalModel(): LanguageEntity = LanguageEntity( + system = system, + korean = korean, + english = english, + china = china, +) diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt new file mode 100644 index 00000000..f57b8bff --- /dev/null +++ b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt @@ -0,0 +1,23 @@ +package com.titi.app.data.language.impl.repository + +import com.titi.app.data.language.api.LanguageRepository +import com.titi.app.data.language.api.model.LanguageRepositoryModel +import com.titi.app.data.language.impl.local.LanguageDataStore +import com.titi.app.data.language.impl.mapper.toLocalModel +import com.titi.app.data.language.impl.mapper.toRepositoryModel +import javax.inject.Inject +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map + +internal class LanguageRepositoryImpl @Inject constructor( + private val languageDataStore: LanguageDataStore, +) : LanguageRepository { + override suspend fun setLanguage(languageRepositoryModel: LanguageRepositoryModel) { + languageDataStore.setLanguage(languageRepositoryModel.toLocalModel()) + } + + override fun getLanguageFlow(): Flow { + return languageDataStore.getLanguageFlow() + .map { it?.toRepositoryModel() ?: LanguageRepositoryModel() } + } +} From d1a1ffcd09c80a5dc780133fb15195cf57206072 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 20:20:52 +0900 Subject: [PATCH 09/14] #169 feat : RepositoryModule --- .../data/language/impl/di/RepositoryModule.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/RepositoryModule.kt diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/RepositoryModule.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/RepositoryModule.kt new file mode 100644 index 00000000..3a624201 --- /dev/null +++ b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/RepositoryModule.kt @@ -0,0 +1,19 @@ +package com.titi.app.data.language.impl.di + +import com.titi.app.data.language.api.LanguageRepository +import com.titi.app.data.language.impl.repository.LanguageRepositoryImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal interface RepositoryModule { + @Binds + @Singleton + fun provideLanguageRepository( + languageRepositoryImpl: LanguageRepositoryImpl, + ): LanguageRepository +} From 89ed59ef5a797c2cd8fd8c1d8e006801ce79d1a0 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 20:24:38 +0900 Subject: [PATCH 10/14] #169 feat : RadioState --- app/build.gradle.kts | 1 + .../com/titi/app/data/language/api/LanguageRepository.kt | 2 +- .../data/language/api/model/LanguageRepositoryModel.kt | 8 ++++---- .../language/impl/repository/LanguageRepositoryImpl.kt | 4 ++-- feature/setting/build.gradle.kts | 1 + .../com/titi/app/feature/setting/model/SettingUiState.kt | 8 ++++++++ 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f23126a4..3949ae82 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -73,6 +73,7 @@ dependencies { implementation(project(":data:alarm:impl")) implementation(project(":data:graph:impl")) implementation(project(":data:notification:impl")) + implementation(project(":data:language:impl")) implementation(platform(libs.firebase.bom)) implementation(libs.firebase.analytics) diff --git a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt index bebf17e9..89d17ae1 100644 --- a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt +++ b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt @@ -6,5 +6,5 @@ import kotlinx.coroutines.flow.Flow interface LanguageRepository { suspend fun setLanguage(languageRepositoryModel: LanguageRepositoryModel) - fun getLanguageFlow(): Flow + fun getLanguageFlow(): Flow } diff --git a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt index aa7d8241..668b8d64 100644 --- a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt +++ b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt @@ -1,8 +1,8 @@ package com.titi.app.data.language.api.model data class LanguageRepositoryModel( - val system: Boolean = true, - val korean: Boolean = false, - val english: Boolean = false, - val china: Boolean = false, + val system: Boolean, + val korean: Boolean, + val english: Boolean, + val china: Boolean, ) diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt index f57b8bff..81c4cf58 100644 --- a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt +++ b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt @@ -16,8 +16,8 @@ internal class LanguageRepositoryImpl @Inject constructor( languageDataStore.setLanguage(languageRepositoryModel.toLocalModel()) } - override fun getLanguageFlow(): Flow { + override fun getLanguageFlow(): Flow { return languageDataStore.getLanguageFlow() - .map { it?.toRepositoryModel() ?: LanguageRepositoryModel() } + .map { it?.toRepositoryModel() } } } diff --git a/feature/setting/build.gradle.kts b/feature/setting/build.gradle.kts index 1e260fa8..290e6f04 100644 --- a/feature/setting/build.gradle.kts +++ b/feature/setting/build.gradle.kts @@ -8,6 +8,7 @@ android { dependencies { implementation(project(":data:notification:api")) + implementation(project(":data:language:api")) implementation(platform(libs.firebase.bom)) implementation(libs.firebase.database) diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingUiState.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingUiState.kt index 2885ca44..849eb007 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingUiState.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingUiState.kt @@ -4,6 +4,7 @@ import com.airbnb.mvrx.MavericksState data class SettingUiState( val switchState: SwitchState = SwitchState(), + val radioState: RadioState = RadioState(), val versionState: VersionState = VersionState(), ) : MavericksState { data class SwitchState( @@ -12,6 +13,13 @@ data class SettingUiState( val stopwatch: Boolean = true, ) + data class RadioState( + val system: Boolean = true, + val korean: Boolean = false, + val english: Boolean = false, + val china: Boolean = false, + ) + data class VersionState( val currentVersion: String = "", val newVersion: String = "", From 064f11bb45a7c0a9fcd189d3a50a6b6da20298b5 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Mon, 29 Jul 2024 22:18:26 +0900 Subject: [PATCH 11/14] =?UTF-8?q?#169=20feat=20:=20=EC=96=B8=EC=96=B4=20ui?= =?UTF-8?q?=20=EB=B0=8F=20data=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/res/values-ko-rKR/strings.xml | 3 + .../src/main/res/values-zh/strings.xml | 3 + .../src/main/res/values/strings.xml | 3 + .../data/language/impl/di/DataStoreModule.kt | 3 +- .../mapper/FeatureToRepositoryMapper.kt | 10 ++- .../mapper/RepositoryToFeatureMapper.kt | 10 ++- .../feature/setting/model/SettingActions.kt | 3 + .../app/feature/setting/ui/SettingScreen.kt | 78 +++++++++++++++---- .../feature/setting/ui/SettingViewModel.kt | 44 ++++++++--- 9 files changed, 128 insertions(+), 29 deletions(-) diff --git a/core/designsystem/src/main/res/values-ko-rKR/strings.xml b/core/designsystem/src/main/res/values-ko-rKR/strings.xml index 8f9ad336..670b3fca 100644 --- a/core/designsystem/src/main/res/values-ko-rKR/strings.xml +++ b/core/designsystem/src/main/res/values-ko-rKR/strings.xml @@ -67,4 +67,7 @@ 중복된 내역이 존재 합니다. 언어 시스템 + 한국어 + 영어 + 중국어 \ No newline at end of file diff --git a/core/designsystem/src/main/res/values-zh/strings.xml b/core/designsystem/src/main/res/values-zh/strings.xml index 5eaa4f85..3cd6d171 100644 --- a/core/designsystem/src/main/res/values-zh/strings.xml +++ b/core/designsystem/src/main/res/values-zh/strings.xml @@ -67,4 +67,7 @@ 重复的历史存在。 语言 系统 + 韩国语 + 英语 + 中国话 \ No newline at end of file diff --git a/core/designsystem/src/main/res/values/strings.xml b/core/designsystem/src/main/res/values/strings.xml index 17a5f6e7..16f7941a 100644 --- a/core/designsystem/src/main/res/values/strings.xml +++ b/core/designsystem/src/main/res/values/strings.xml @@ -72,4 +72,7 @@ Duplicate history exists. Language System + Korean + English + Chinese \ No newline at end of file diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt index c3748ead..2871f1fe 100644 --- a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt +++ b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt @@ -5,6 +5,7 @@ import com.titi.app.data.language.impl.local.LanguageDataStore import dagger.Module import dagger.Provides import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import javax.inject.Singleton @@ -13,5 +14,5 @@ import javax.inject.Singleton internal object DataStoreModule { @Provides @Singleton - fun provideLanguageDataStore(context: Context) = LanguageDataStore(context) + fun provideLanguageDataStore(@ApplicationContext context: Context) = LanguageDataStore(context) } diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/FeatureToRepositoryMapper.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/FeatureToRepositoryMapper.kt index 393b9d85..23522988 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/FeatureToRepositoryMapper.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/FeatureToRepositoryMapper.kt @@ -1,10 +1,18 @@ package com.titi.app.feature.setting.mapper +import com.titi.app.data.language.api.model.LanguageRepositoryModel import com.titi.app.data.notification.api.model.NotificationRepositoryModel import com.titi.app.feature.setting.model.SettingUiState -fun SettingUiState.SwitchState.toRepositoryModel() = NotificationRepositoryModel( +internal fun SettingUiState.SwitchState.toRepositoryModel() = NotificationRepositoryModel( timerFiveMinutesBeforeTheEnd = timerFiveMinutesBeforeTheEnd, timerBeforeTheEnd = timerBeforeTheEnd, stopwatch = stopwatch, ) + +internal fun SettingUiState.RadioState.toRepositoryModel() = LanguageRepositoryModel( + system = system, + korean = korean, + english = english, + china = china, +) diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/RepositoryToFeatureMapper.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/RepositoryToFeatureMapper.kt index c261b703..df70a764 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/RepositoryToFeatureMapper.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/RepositoryToFeatureMapper.kt @@ -1,10 +1,18 @@ package com.titi.app.feature.setting.mapper +import com.titi.app.data.language.api.model.LanguageRepositoryModel import com.titi.app.data.notification.api.model.NotificationRepositoryModel import com.titi.app.feature.setting.model.SettingUiState -fun NotificationRepositoryModel.toFeatureModel() = SettingUiState.SwitchState( +internal fun NotificationRepositoryModel.toFeatureModel() = SettingUiState.SwitchState( timerFiveMinutesBeforeTheEnd = timerFiveMinutesBeforeTheEnd, timerBeforeTheEnd = timerBeforeTheEnd, stopwatch = stopwatch, ) + +internal fun LanguageRepositoryModel.toFeatureModel() = SettingUiState.RadioState( + system = system, + korean = korean, + english = english, + china = china, +) diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingActions.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingActions.kt index d665f7ba..7c6e1e63 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingActions.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingActions.kt @@ -15,6 +15,9 @@ sealed interface SettingActions { @JvmInline value class Switch(val switchState: SettingUiState.SwitchState) : Updates + @JvmInline + value class Radio(val radioState: SettingUiState.RadioState) : Updates + @JvmInline value class Version(val versionState: SettingUiState.VersionState) : Updates } diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt index 8c296a70..84dbef75 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt @@ -61,7 +61,7 @@ import com.titi.app.feature.setting.model.Version @OptIn(ExperimentalMaterial3Api::class) @Composable -fun SettingScreen( +internal fun SettingScreen( viewModel: SettingViewModel = mavericksViewModel(), handleNavigateActions: (SettingActions.Navigates) -> Unit, onNavigateToDestination: (TopLevelDestination) -> Unit, @@ -180,7 +180,10 @@ private fun SettingScreen( Spacer(modifier = Modifier.height(35.dp)) - SettingLanguageSection() + SettingLanguageSection( + radioState = uiState.radioState, + onSettingActions = onSettingActions, + ) Spacer(modifier = Modifier.height(35.dp)) @@ -303,7 +306,10 @@ private fun SettingNotificationSection( } @Composable -private fun SettingLanguageSection() { +private fun SettingLanguageSection( + radioState: SettingUiState.RadioState, + onSettingActions: (SettingActions) -> Unit, +) { TdsText( modifier = Modifier.padding(start = 16.dp), text = stringResource(R.string.setting_text_language), @@ -318,8 +324,19 @@ private fun SettingLanguageSection() { title = stringResource(R.string.setting_text_system), rightAreaContent = { RadioButton( - selected = true, - onClick = {}, + selected = radioState.system, + onClick = { + onSettingActions( + SettingActions.Updates.Radio( + SettingUiState.RadioState( + system = true, + korean = false, + english = false, + china = false, + ), + ), + ) + }, ) }, ) @@ -327,11 +344,22 @@ private fun SettingLanguageSection() { Spacer(modifier = Modifier.height(1.dp)) ListContent( - title = "한국어", + title = stringResource(R.string.setting_text_korean), rightAreaContent = { RadioButton( - selected = true, - onClick = {}, + selected = radioState.korean, + onClick = { + onSettingActions( + SettingActions.Updates.Radio( + SettingUiState.RadioState( + system = false, + korean = true, + english = false, + china = false, + ), + ), + ) + }, ) }, ) @@ -339,11 +367,22 @@ private fun SettingLanguageSection() { Spacer(modifier = Modifier.height(1.dp)) ListContent( - title = "English", + title = stringResource(R.string.setting_text_english), rightAreaContent = { RadioButton( - selected = true, - onClick = {}, + selected = radioState.english, + onClick = { + onSettingActions( + SettingActions.Updates.Radio( + SettingUiState.RadioState( + system = false, + korean = false, + english = true, + china = false, + ), + ), + ) + }, ) }, ) @@ -351,11 +390,22 @@ private fun SettingLanguageSection() { Spacer(modifier = Modifier.height(1.dp)) ListContent( - title = "中国话", + title = stringResource(R.string.setting_text_china), rightAreaContent = { RadioButton( - selected = true, - onClick = {}, + selected = radioState.china, + onClick = { + onSettingActions( + SettingActions.Updates.Radio( + SettingUiState.RadioState( + system = false, + korean = false, + english = false, + china = true, + ), + ), + ) + }, ) }, ) diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingViewModel.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingViewModel.kt index d0b399f1..08ccd829 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingViewModel.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingViewModel.kt @@ -1,9 +1,11 @@ package com.titi.app.feature.setting.ui +import android.util.Log import com.airbnb.mvrx.MavericksViewModel import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.hilt.AssistedViewModelFactory import com.airbnb.mvrx.hilt.hiltMavericksViewModelFactory +import com.titi.app.data.language.api.LanguageRepository import com.titi.app.data.notification.api.NotificationRepository import com.titi.app.feature.setting.mapper.toFeatureModel import com.titi.app.feature.setting.mapper.toRepositoryModel @@ -12,39 +14,57 @@ import com.titi.app.feature.setting.model.SettingUiState import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject -import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.launch -class SettingViewModel @AssistedInject constructor( +internal class SettingViewModel @AssistedInject constructor( @Assisted initialState: SettingUiState, private val notificationRepository: NotificationRepository, + private val languageRepository: LanguageRepository, ) : MavericksViewModel(initialState) { init { viewModelScope.launch { notificationRepository.getNotificationFlow() - .collectLatest { - updateSwitch(it.toFeatureModel()) + .catch { + Log.e("SettingViewModel", it.message.toString()) + }.setOnEach { + copy(switchState = it.toFeatureModel()) + } + } + + viewModelScope.launch { + languageRepository.getLanguageFlow() + .catch { + Log.e("SettingViewModel", it.message.toString()) + } + .filterNotNull() + .setOnEach { + copy(radioState = it.toFeatureModel()) } } } fun handleUpdateActions(updateActions: SettingActions.Updates) { when (updateActions) { - is SettingActions.Updates.Switch -> { - viewModelScope.launch { - notificationRepository - .setNotification(updateActions.switchState.toRepositoryModel()) - } - } + is SettingActions.Updates.Switch -> updateSwitch(updateActions.switchState) + + is SettingActions.Updates.Radio -> updateRadio(updateActions.radioState) is SettingActions.Updates.Version -> updateVersion(updateActions.versionState) } } private fun updateSwitch(switchState: SettingUiState.SwitchState) { - setState { - copy(switchState = switchState) + viewModelScope.launch { + notificationRepository.setNotification(switchState.toRepositoryModel()) + } + } + + private fun updateRadio(radioState: SettingUiState.RadioState) { + viewModelScope.launch { + languageRepository.setLanguage(radioState.toRepositoryModel()) } } From e882b9889c112704b8f93f8e98a59e002c033d51 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Tue, 30 Jul 2024 09:48:32 +0900 Subject: [PATCH 12/14] #169 feat : languagemanager --- app/build.gradle.kts | 1 - core/ui/build.gradle.kts | 1 + .../com/titi/app/core/ui/LanguageManager.kt | 61 +++++++++++++++++++ data/language/api/build.gradle.kts | 7 --- .../language/api/src/main/AndroidManifest.xml | 4 -- .../data/language/api/LanguageRepository.kt | 10 --- .../api/model/LanguageRepositoryModel.kt | 8 --- .../app/data/language/api/ExampleUnitTest.kt | 16 ----- data/language/impl/build.gradle.kts | 11 ---- .../impl/src/main/AndroidManifest.xml | 4 -- .../data/language/impl/di/DataStoreModule.kt | 18 ------ .../data/language/impl/di/RepositoryModule.kt | 19 ------ .../language/impl/local/LanguageDataStore.kt | 33 ---------- .../impl/local/model/LanguageEntity.kt | 11 ---- .../impl/mapper/LocalToRepositoryMapper.kt | 11 ---- .../impl/mapper/RepositoryToLocalMapper.kt | 11 ---- .../impl/repository/LanguageRepositoryImpl.kt | 23 ------- .../app/data/language/impl/ExampleUnitTest.kt | 16 ----- feature/setting/build.gradle.kts | 1 - .../mapper/FeatureToRepositoryMapper.kt | 8 --- .../mapper/RepositoryToFeatureMapper.kt | 8 --- .../feature/setting/model/SettingActions.kt | 6 +- .../feature/setting/model/SettingUiState.kt | 8 --- .../app/feature/setting/ui/SettingScreen.kt | 60 +++++++----------- .../feature/setting/ui/SettingViewModel.kt | 22 ------- settings.gradle.kts | 2 - 26 files changed, 87 insertions(+), 293 deletions(-) create mode 100644 core/ui/src/main/kotlin/com/titi/app/core/ui/LanguageManager.kt delete mode 100644 data/language/api/build.gradle.kts delete mode 100644 data/language/api/src/main/AndroidManifest.xml delete mode 100644 data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt delete mode 100644 data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt delete mode 100644 data/language/api/src/test/kotlin/com/titi/app/data/language/api/ExampleUnitTest.kt delete mode 100644 data/language/impl/build.gradle.kts delete mode 100644 data/language/impl/src/main/AndroidManifest.xml delete mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt delete mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/RepositoryModule.kt delete mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/LanguageDataStore.kt delete mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/model/LanguageEntity.kt delete mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/LocalToRepositoryMapper.kt delete mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/RepositoryToLocalMapper.kt delete mode 100644 data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt delete mode 100644 data/language/impl/src/test/kotlin/com/titi/app/data/language/impl/ExampleUnitTest.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3949ae82..f23126a4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -73,7 +73,6 @@ dependencies { implementation(project(":data:alarm:impl")) implementation(project(":data:graph:impl")) implementation(project(":data:notification:impl")) - implementation(project(":data:language:impl")) implementation(platform(libs.firebase.bom)) implementation(libs.firebase.analytics) diff --git a/core/ui/build.gradle.kts b/core/ui/build.gradle.kts index 443ea1bf..9020b4e7 100644 --- a/core/ui/build.gradle.kts +++ b/core/ui/build.gradle.kts @@ -1,4 +1,5 @@ plugins { + id("titi.android.compose") id("titi.android.library") } diff --git a/core/ui/src/main/kotlin/com/titi/app/core/ui/LanguageManager.kt b/core/ui/src/main/kotlin/com/titi/app/core/ui/LanguageManager.kt new file mode 100644 index 00000000..0ec2c90d --- /dev/null +++ b/core/ui/src/main/kotlin/com/titi/app/core/ui/LanguageManager.kt @@ -0,0 +1,61 @@ +package com.titi.app.core.ui + +import android.app.LocaleManager +import android.content.Context +import android.os.Build +import android.os.LocaleList +import androidx.core.app.LocaleManagerCompat +import java.util.Locale +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow + +class LanguageManager(private val context: Context) { + private val _currentLanguage = MutableStateFlow(getCurrentLanguage()) + val currentLanguage: StateFlow = _currentLanguage.asStateFlow() + + fun setLanguage(languageCode: String) { + val localeList = when (languageCode) { + SYSTEM_DEFAULT -> LocaleList.getEmptyLocaleList() + else -> LocaleList.forLanguageTags(languageCode) + } + + _currentLanguage.value = languageCode + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + context.getSystemService(LocaleManager::class.java).applicationLocales = localeList + } else { + val locale = Locale(languageCode) + Locale.setDefault(locale) + + val resources = context.resources + val configuration = resources.configuration + configuration.setLocale(locale) + resources.updateConfiguration(configuration, resources.displayMetrics) + } + } + + private fun getCurrentLanguage(): String { + return if (isUsingSystemDefault()) { + SYSTEM_DEFAULT + } else { + val currentLocale = context.resources.configuration.locales[0] + when (currentLocale.language) { + "en" -> ENGLISH + "ko" -> KOREAN + "zh" -> CHINA + else -> SYSTEM_DEFAULT + } + } + } + + private fun isUsingSystemDefault(): Boolean { + return LocaleManagerCompat.getApplicationLocales(context).isEmpty + } + + companion object { + const val SYSTEM_DEFAULT = "system" + const val ENGLISH = "en" + const val KOREAN = "ko" + const val CHINA = "zh" + } +} diff --git a/data/language/api/build.gradle.kts b/data/language/api/build.gradle.kts deleted file mode 100644 index f9060d35..00000000 --- a/data/language/api/build.gradle.kts +++ /dev/null @@ -1,7 +0,0 @@ -plugins { - id("titi.android.library-no-hilt") -} - -android { - namespace = "com.titi.app.data.language.api" -} diff --git a/data/language/api/src/main/AndroidManifest.xml b/data/language/api/src/main/AndroidManifest.xml deleted file mode 100644 index a5918e68..00000000 --- a/data/language/api/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt deleted file mode 100644 index 89d17ae1..00000000 --- a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/LanguageRepository.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.titi.app.data.language.api - -import com.titi.app.data.language.api.model.LanguageRepositoryModel -import kotlinx.coroutines.flow.Flow - -interface LanguageRepository { - suspend fun setLanguage(languageRepositoryModel: LanguageRepositoryModel) - - fun getLanguageFlow(): Flow -} diff --git a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt b/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt deleted file mode 100644 index 668b8d64..00000000 --- a/data/language/api/src/main/kotlin/com/titi/app/data/language/api/model/LanguageRepositoryModel.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.titi.app.data.language.api.model - -data class LanguageRepositoryModel( - val system: Boolean, - val korean: Boolean, - val english: Boolean, - val china: Boolean, -) diff --git a/data/language/api/src/test/kotlin/com/titi/app/data/language/api/ExampleUnitTest.kt b/data/language/api/src/test/kotlin/com/titi/app/data/language/api/ExampleUnitTest.kt deleted file mode 100644 index 5d30e8ed..00000000 --- a/data/language/api/src/test/kotlin/com/titi/app/data/language/api/ExampleUnitTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.titi.app.data.language.api - -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} diff --git a/data/language/impl/build.gradle.kts b/data/language/impl/build.gradle.kts deleted file mode 100644 index 6265fbb0..00000000 --- a/data/language/impl/build.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - id("titi.android.data.local") -} - -android { - namespace = "com.titi.app.data.language.impl" -} - -dependencies { - implementation(project(":data:language:api")) -} diff --git a/data/language/impl/src/main/AndroidManifest.xml b/data/language/impl/src/main/AndroidManifest.xml deleted file mode 100644 index a5918e68..00000000 --- a/data/language/impl/src/main/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt deleted file mode 100644 index 2871f1fe..00000000 --- a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/DataStoreModule.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.titi.app.data.language.impl.di - -import android.content.Context -import com.titi.app.data.language.impl.local.LanguageDataStore -import dagger.Module -import dagger.Provides -import dagger.hilt.InstallIn -import dagger.hilt.android.qualifiers.ApplicationContext -import dagger.hilt.components.SingletonComponent -import javax.inject.Singleton - -@Module -@InstallIn(SingletonComponent::class) -internal object DataStoreModule { - @Provides - @Singleton - fun provideLanguageDataStore(@ApplicationContext context: Context) = LanguageDataStore(context) -} diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/RepositoryModule.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/RepositoryModule.kt deleted file mode 100644 index 3a624201..00000000 --- a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/di/RepositoryModule.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.titi.app.data.language.impl.di - -import com.titi.app.data.language.api.LanguageRepository -import com.titi.app.data.language.impl.repository.LanguageRepositoryImpl -import dagger.Binds -import dagger.Module -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent -import javax.inject.Singleton - -@Module -@InstallIn(SingletonComponent::class) -internal interface RepositoryModule { - @Binds - @Singleton - fun provideLanguageRepository( - languageRepositoryImpl: LanguageRepositoryImpl, - ): LanguageRepository -} diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/LanguageDataStore.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/LanguageDataStore.kt deleted file mode 100644 index ed956c48..00000000 --- a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/LanguageDataStore.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.titi.app.data.language.impl.local - -import android.content.Context -import androidx.datastore.core.DataStore -import androidx.datastore.preferences.core.Preferences -import androidx.datastore.preferences.core.stringPreferencesKey -import androidx.datastore.preferences.preferencesDataStore -import com.titi.app.core.util.fromJson -import com.titi.app.core.util.readFlowValue -import com.titi.app.core.util.storeValue -import com.titi.app.core.util.toJson -import com.titi.app.data.language.impl.local.model.LanguageEntity -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map - -internal class LanguageDataStore(context: Context) { - private val dataStore: DataStore = context.dataStore - - suspend fun setLanguage(languageEntity: LanguageEntity) { - dataStore.storeValue(LANGUAGE_KEY, languageEntity.toJson()) - } - - fun getLanguageFlow(): Flow = - dataStore.readFlowValue(LANGUAGE_KEY).map { it?.fromJson() } - - companion object { - private const val LANGUAGE_PREF_NAME = "languagePrefName" - private val LANGUAGE_KEY = stringPreferencesKey("languageKey") - - private val Context.dataStore: DataStore - by preferencesDataStore(LANGUAGE_PREF_NAME) - } -} diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/model/LanguageEntity.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/model/LanguageEntity.kt deleted file mode 100644 index 9db7ff8d..00000000 --- a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/local/model/LanguageEntity.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.titi.app.data.language.impl.local.model - -import com.squareup.moshi.JsonClass - -@JsonClass(generateAdapter = true) -data class LanguageEntity( - val system: Boolean, - val korean: Boolean, - val english: Boolean, - val china: Boolean, -) diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/LocalToRepositoryMapper.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/LocalToRepositoryMapper.kt deleted file mode 100644 index f030cf9e..00000000 --- a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/LocalToRepositoryMapper.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.titi.app.data.language.impl.mapper - -import com.titi.app.data.language.api.model.LanguageRepositoryModel -import com.titi.app.data.language.impl.local.model.LanguageEntity - -internal fun LanguageEntity.toRepositoryModel() = LanguageRepositoryModel( - system = system, - korean = korean, - english = english, - china = china, -) diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/RepositoryToLocalMapper.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/RepositoryToLocalMapper.kt deleted file mode 100644 index 9e18bc34..00000000 --- a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/mapper/RepositoryToLocalMapper.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.titi.app.data.language.impl.mapper - -import com.titi.app.data.language.api.model.LanguageRepositoryModel -import com.titi.app.data.language.impl.local.model.LanguageEntity - -internal fun LanguageRepositoryModel.toLocalModel(): LanguageEntity = LanguageEntity( - system = system, - korean = korean, - english = english, - china = china, -) diff --git a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt b/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt deleted file mode 100644 index 81c4cf58..00000000 --- a/data/language/impl/src/main/kotlin/com/titi/app/data/language/impl/repository/LanguageRepositoryImpl.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.titi.app.data.language.impl.repository - -import com.titi.app.data.language.api.LanguageRepository -import com.titi.app.data.language.api.model.LanguageRepositoryModel -import com.titi.app.data.language.impl.local.LanguageDataStore -import com.titi.app.data.language.impl.mapper.toLocalModel -import com.titi.app.data.language.impl.mapper.toRepositoryModel -import javax.inject.Inject -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map - -internal class LanguageRepositoryImpl @Inject constructor( - private val languageDataStore: LanguageDataStore, -) : LanguageRepository { - override suspend fun setLanguage(languageRepositoryModel: LanguageRepositoryModel) { - languageDataStore.setLanguage(languageRepositoryModel.toLocalModel()) - } - - override fun getLanguageFlow(): Flow { - return languageDataStore.getLanguageFlow() - .map { it?.toRepositoryModel() } - } -} diff --git a/data/language/impl/src/test/kotlin/com/titi/app/data/language/impl/ExampleUnitTest.kt b/data/language/impl/src/test/kotlin/com/titi/app/data/language/impl/ExampleUnitTest.kt deleted file mode 100644 index cb0b8aaf..00000000 --- a/data/language/impl/src/test/kotlin/com/titi/app/data/language/impl/ExampleUnitTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.titi.app.data.language.impl - -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Example local unit test, which will execute on the development machine (host). - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} diff --git a/feature/setting/build.gradle.kts b/feature/setting/build.gradle.kts index 290e6f04..1e260fa8 100644 --- a/feature/setting/build.gradle.kts +++ b/feature/setting/build.gradle.kts @@ -8,7 +8,6 @@ android { dependencies { implementation(project(":data:notification:api")) - implementation(project(":data:language:api")) implementation(platform(libs.firebase.bom)) implementation(libs.firebase.database) diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/FeatureToRepositoryMapper.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/FeatureToRepositoryMapper.kt index 23522988..182f8591 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/FeatureToRepositoryMapper.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/FeatureToRepositoryMapper.kt @@ -1,6 +1,5 @@ package com.titi.app.feature.setting.mapper -import com.titi.app.data.language.api.model.LanguageRepositoryModel import com.titi.app.data.notification.api.model.NotificationRepositoryModel import com.titi.app.feature.setting.model.SettingUiState @@ -9,10 +8,3 @@ internal fun SettingUiState.SwitchState.toRepositoryModel() = NotificationReposi timerBeforeTheEnd = timerBeforeTheEnd, stopwatch = stopwatch, ) - -internal fun SettingUiState.RadioState.toRepositoryModel() = LanguageRepositoryModel( - system = system, - korean = korean, - english = english, - china = china, -) diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/RepositoryToFeatureMapper.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/RepositoryToFeatureMapper.kt index df70a764..a0d3f088 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/RepositoryToFeatureMapper.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/mapper/RepositoryToFeatureMapper.kt @@ -1,6 +1,5 @@ package com.titi.app.feature.setting.mapper -import com.titi.app.data.language.api.model.LanguageRepositoryModel import com.titi.app.data.notification.api.model.NotificationRepositoryModel import com.titi.app.feature.setting.model.SettingUiState @@ -9,10 +8,3 @@ internal fun NotificationRepositoryModel.toFeatureModel() = SettingUiState.Switc timerBeforeTheEnd = timerBeforeTheEnd, stopwatch = stopwatch, ) - -internal fun LanguageRepositoryModel.toFeatureModel() = SettingUiState.RadioState( - system = system, - korean = korean, - english = english, - china = china, -) diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingActions.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingActions.kt index 7c6e1e63..568c3b25 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingActions.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingActions.kt @@ -15,10 +15,10 @@ sealed interface SettingActions { @JvmInline value class Switch(val switchState: SettingUiState.SwitchState) : Updates - @JvmInline - value class Radio(val radioState: SettingUiState.RadioState) : Updates - @JvmInline value class Version(val versionState: SettingUiState.VersionState) : Updates } + + @JvmInline + value class Language(val language: String) : SettingActions } diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingUiState.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingUiState.kt index 849eb007..2885ca44 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingUiState.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/model/SettingUiState.kt @@ -4,7 +4,6 @@ import com.airbnb.mvrx.MavericksState data class SettingUiState( val switchState: SwitchState = SwitchState(), - val radioState: RadioState = RadioState(), val versionState: VersionState = VersionState(), ) : MavericksState { data class SwitchState( @@ -13,13 +12,6 @@ data class SettingUiState( val stopwatch: Boolean = true, ) - data class RadioState( - val system: Boolean = true, - val korean: Boolean = false, - val english: Boolean = false, - val china: Boolean = false, - ) - data class VersionState( val currentVersion: String = "", val newVersion: String = "", diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt index 84dbef75..7af4bc97 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingScreen.kt @@ -31,6 +31,7 @@ import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -41,6 +42,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.airbnb.mvrx.compose.collectAsState import com.airbnb.mvrx.compose.mavericksViewModel import com.google.firebase.database.DataSnapshot @@ -55,6 +57,7 @@ import com.titi.app.core.designsystem.navigation.TopLevelDestination import com.titi.app.core.designsystem.theme.TdsColor import com.titi.app.core.designsystem.theme.TdsTextStyle import com.titi.app.core.designsystem.theme.TiTiTheme +import com.titi.app.core.ui.LanguageManager import com.titi.app.feature.setting.model.SettingActions import com.titi.app.feature.setting.model.SettingUiState import com.titi.app.feature.setting.model.Version @@ -72,6 +75,8 @@ internal fun SettingScreen( val databaseReference = firebaseDatabase.getReference("versions") val context = LocalContext.current + val languageManager = remember { LanguageManager(context) } + val currentLanguage by languageManager.currentLanguage.collectAsStateWithLifecycle() LaunchedEffect(Unit) { databaseReference.addValueEventListener( @@ -143,11 +148,16 @@ internal fun SettingScreen( .padding(it) .safeDrawingPadding(), uiState = uiState, + currentLanguage = currentLanguage, onSettingActions = { settingActions -> when (settingActions) { is SettingActions.Navigates -> handleNavigateActions(settingActions) is SettingActions.Updates -> viewModel.handleUpdateActions(settingActions) + + is SettingActions.Language -> { + languageManager.setLanguage(settingActions.language) + } } }, ) @@ -158,6 +168,7 @@ internal fun SettingScreen( private fun SettingScreen( modifier: Modifier, uiState: SettingUiState, + currentLanguage: String, onSettingActions: (SettingActions) -> Unit, ) { val scrollState = rememberScrollState() @@ -181,7 +192,7 @@ private fun SettingScreen( Spacer(modifier = Modifier.height(35.dp)) SettingLanguageSection( - radioState = uiState.radioState, + currentLanguage = currentLanguage, onSettingActions = onSettingActions, ) @@ -307,7 +318,7 @@ private fun SettingNotificationSection( @Composable private fun SettingLanguageSection( - radioState: SettingUiState.RadioState, + currentLanguage: String, onSettingActions: (SettingActions) -> Unit, ) { TdsText( @@ -324,17 +335,10 @@ private fun SettingLanguageSection( title = stringResource(R.string.setting_text_system), rightAreaContent = { RadioButton( - selected = radioState.system, + selected = currentLanguage == LanguageManager.SYSTEM_DEFAULT, onClick = { onSettingActions( - SettingActions.Updates.Radio( - SettingUiState.RadioState( - system = true, - korean = false, - english = false, - china = false, - ), - ), + SettingActions.Language(LanguageManager.SYSTEM_DEFAULT), ) }, ) @@ -347,17 +351,10 @@ private fun SettingLanguageSection( title = stringResource(R.string.setting_text_korean), rightAreaContent = { RadioButton( - selected = radioState.korean, + selected = currentLanguage == LanguageManager.KOREAN, onClick = { onSettingActions( - SettingActions.Updates.Radio( - SettingUiState.RadioState( - system = false, - korean = true, - english = false, - china = false, - ), - ), + SettingActions.Language(LanguageManager.KOREAN), ) }, ) @@ -370,17 +367,10 @@ private fun SettingLanguageSection( title = stringResource(R.string.setting_text_english), rightAreaContent = { RadioButton( - selected = radioState.english, + selected = currentLanguage == LanguageManager.ENGLISH, onClick = { onSettingActions( - SettingActions.Updates.Radio( - SettingUiState.RadioState( - system = false, - korean = false, - english = true, - china = false, - ), - ), + SettingActions.Language(LanguageManager.ENGLISH), ) }, ) @@ -393,17 +383,10 @@ private fun SettingLanguageSection( title = stringResource(R.string.setting_text_china), rightAreaContent = { RadioButton( - selected = radioState.china, + selected = currentLanguage == LanguageManager.CHINA, onClick = { onSettingActions( - SettingActions.Updates.Radio( - SettingUiState.RadioState( - system = false, - korean = false, - english = false, - china = true, - ), - ), + SettingActions.Language(LanguageManager.CHINA), ) }, ) @@ -616,6 +599,7 @@ private fun SettingScreenPreview() { SettingScreen( modifier = Modifier, uiState = SettingUiState(), + currentLanguage = LanguageManager.SYSTEM_DEFAULT, onSettingActions = {}, ) } diff --git a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingViewModel.kt b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingViewModel.kt index 08ccd829..a88ac1ad 100644 --- a/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingViewModel.kt +++ b/feature/setting/src/main/kotlin/com/titi/app/feature/setting/ui/SettingViewModel.kt @@ -5,7 +5,6 @@ import com.airbnb.mvrx.MavericksViewModel import com.airbnb.mvrx.MavericksViewModelFactory import com.airbnb.mvrx.hilt.AssistedViewModelFactory import com.airbnb.mvrx.hilt.hiltMavericksViewModelFactory -import com.titi.app.data.language.api.LanguageRepository import com.titi.app.data.notification.api.NotificationRepository import com.titi.app.feature.setting.mapper.toFeatureModel import com.titi.app.feature.setting.mapper.toRepositoryModel @@ -15,13 +14,11 @@ import dagger.assisted.Assisted import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.launch internal class SettingViewModel @AssistedInject constructor( @Assisted initialState: SettingUiState, private val notificationRepository: NotificationRepository, - private val languageRepository: LanguageRepository, ) : MavericksViewModel(initialState) { init { @@ -33,25 +30,12 @@ internal class SettingViewModel @AssistedInject constructor( copy(switchState = it.toFeatureModel()) } } - - viewModelScope.launch { - languageRepository.getLanguageFlow() - .catch { - Log.e("SettingViewModel", it.message.toString()) - } - .filterNotNull() - .setOnEach { - copy(radioState = it.toFeatureModel()) - } - } } fun handleUpdateActions(updateActions: SettingActions.Updates) { when (updateActions) { is SettingActions.Updates.Switch -> updateSwitch(updateActions.switchState) - is SettingActions.Updates.Radio -> updateRadio(updateActions.radioState) - is SettingActions.Updates.Version -> updateVersion(updateActions.versionState) } } @@ -62,12 +46,6 @@ internal class SettingViewModel @AssistedInject constructor( } } - private fun updateRadio(radioState: SettingUiState.RadioState) { - viewModelScope.launch { - languageRepository.setLanguage(radioState.toRepositoryModel()) - } - } - private fun updateVersion(versionState: SettingUiState.VersionState) { setState { copy(versionState = versionState) diff --git a/settings.gradle.kts b/settings.gradle.kts index f8ccf56a..0399c87f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -52,5 +52,3 @@ include(":data:notification:impl") include(":feature:webview") include(":feature:edit") include(":tds") -include(":data:language:api") -include(":data:language:impl") From a6ce7c49ea697dbe4ffcf9f03acbbfb070ed63c7 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Tue, 30 Jul 2024 09:51:00 +0900 Subject: [PATCH 13/14] update : version --- build-logic/src/main/kotlin/com/titi/common/BuildInfo.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-logic/src/main/kotlin/com/titi/common/BuildInfo.kt b/build-logic/src/main/kotlin/com/titi/common/BuildInfo.kt index f5825f41..2aeed66f 100644 --- a/build-logic/src/main/kotlin/com/titi/common/BuildInfo.kt +++ b/build-logic/src/main/kotlin/com/titi/common/BuildInfo.kt @@ -9,7 +9,7 @@ object BuildType { object AppConfig { const val APP_ID = "com.titi.app" - const val APP_VERSION_NAME = "1.3.1" - const val APP_VERSION_CODE = 39 + const val APP_VERSION_NAME = "1.4.0" + const val APP_VERSION_CODE = 40 const val APP_NAME = "TiTi" } \ No newline at end of file From 6f482d071c10b64b94e692b4e485d616fbe04cd7 Mon Sep 17 00:00:00 2001 From: koreatlwls Date: Tue, 30 Jul 2024 09:51:57 +0900 Subject: [PATCH 14/14] docs : release-note --- release-note.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/release-note.txt b/release-note.txt index cd9e99c0..eec84856 100644 --- a/release-note.txt +++ b/release-note.txt @@ -1,2 +1,3 @@ -TiTi android dev 1.3.1 -- \ No newline at end of file +TiTi android 1.4.0 +- Setting Screen Ver.3 +- Bug share picture \ No newline at end of file