From 23893a4ac1cae96d59a0335d5ec8ee1821de08cb Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Wed, 24 Apr 2024 17:13:39 +0800 Subject: [PATCH] Refactor(Data): Rename datastore into data Rename top.fatweb.oxygen.toolbox.datastore into top.fatweb.oxygen.toolbox.data --- .../{datastore => data}/tool/ToolDataSource.kt | 2 +- .../userdata/IntToStringIdsMigration.kt | 6 +++--- .../userdata/OxygenPreferencesDataSource.kt | 14 +++++++------- .../userdata/UserPreferencesSerializer.kt | 4 ++-- .../top/fatweb/oxygen/toolbox/di/DataModule.kt | 8 ++++---- .../fatweb/oxygen/toolbox/di/DataStoreModule.kt | 6 +++--- ...rstToolRepository.kt => LocalToolRepository.kt} | 4 ++-- ...ataRepository.kt => LocalUserDataRepository.kt} | 4 ++-- .../oxygen/toolbox/ui/component/ToolGroupCard.kt | 2 +- .../fatweb/oxygen/toolbox/ui/tool/ToolsScreen.kt | 2 +- .../oxygen/toolbox/data/dark_theme_config.proto | 2 +- .../oxygen/toolbox/data/language_config.proto | 2 +- .../oxygen/toolbox/data/launch_page_config.proto | 2 +- .../oxygen/toolbox/data/theme_brand_config.proto | 2 +- .../oxygen/toolbox/data/user_preferences.proto | 2 +- 15 files changed, 31 insertions(+), 31 deletions(-) rename app/src/main/kotlin/top/fatweb/oxygen/toolbox/{datastore => data}/tool/ToolDataSource.kt (95%) rename app/src/main/kotlin/top/fatweb/oxygen/toolbox/{datastore => data}/userdata/IntToStringIdsMigration.kt (69%) rename app/src/main/kotlin/top/fatweb/oxygen/toolbox/{datastore => data}/userdata/OxygenPreferencesDataSource.kt (92%) rename app/src/main/kotlin/top/fatweb/oxygen/toolbox/{datastore => data}/userdata/UserPreferencesSerializer.kt (87%) rename app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/{OfflineFirstToolRepository.kt => LocalToolRepository.kt} (70%) rename app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/{OfflineFirstUserDataRepository.kt => LocalUserDataRepository.kt} (90%) diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/tool/ToolDataSource.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDataSource.kt similarity index 95% rename from app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/tool/ToolDataSource.kt rename to app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDataSource.kt index f447333..b42835b 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/tool/ToolDataSource.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/tool/ToolDataSource.kt @@ -1,4 +1,4 @@ -package top.fatweb.oxygen.toolbox.datastore.tool +package top.fatweb.oxygen.toolbox.data.tool import kotlinx.coroutines.flow.flowOf import top.fatweb.oxygen.toolbox.icon.OxygenIcons diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/userdata/IntToStringIdsMigration.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/IntToStringIdsMigration.kt similarity index 69% rename from app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/userdata/IntToStringIdsMigration.kt rename to app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/IntToStringIdsMigration.kt index fcc424e..c2e5a59 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/userdata/IntToStringIdsMigration.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/IntToStringIdsMigration.kt @@ -1,8 +1,8 @@ -package top.fatweb.oxygen.toolbox.datastore.userdata +package top.fatweb.oxygen.toolbox.data.userdata import androidx.datastore.core.DataMigration -import top.fatweb.oxygen.toolbox.datastore.UserPreferences -import top.fatweb.oxygen.toolbox.datastore.copy +import top.fatweb.oxygen.toolbox.data.UserPreferences +import top.fatweb.oxygen.toolbox.data.copy internal object IntToStringIdsMigration : DataMigration { override suspend fun cleanUp() = Unit diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/userdata/OxygenPreferencesDataSource.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/OxygenPreferencesDataSource.kt similarity index 92% rename from app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/userdata/OxygenPreferencesDataSource.kt rename to app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/OxygenPreferencesDataSource.kt index 53dc743..57e7b7f 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/userdata/OxygenPreferencesDataSource.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/OxygenPreferencesDataSource.kt @@ -1,13 +1,13 @@ -package top.fatweb.oxygen.toolbox.datastore.userdata +package top.fatweb.oxygen.toolbox.data.userdata import androidx.datastore.core.DataStore import kotlinx.coroutines.flow.map -import top.fatweb.oxygen.toolbox.datastore.DarkThemeConfigProto -import top.fatweb.oxygen.toolbox.datastore.LanguageConfigProto -import top.fatweb.oxygen.toolbox.datastore.LaunchPageConfigProto -import top.fatweb.oxygen.toolbox.datastore.ThemeBrandConfigProto -import top.fatweb.oxygen.toolbox.datastore.UserPreferences -import top.fatweb.oxygen.toolbox.datastore.copy +import top.fatweb.oxygen.toolbox.data.DarkThemeConfigProto +import top.fatweb.oxygen.toolbox.data.LanguageConfigProto +import top.fatweb.oxygen.toolbox.data.LaunchPageConfigProto +import top.fatweb.oxygen.toolbox.data.ThemeBrandConfigProto +import top.fatweb.oxygen.toolbox.data.UserPreferences +import top.fatweb.oxygen.toolbox.data.copy import top.fatweb.oxygen.toolbox.model.userdata.DarkThemeConfig import top.fatweb.oxygen.toolbox.model.userdata.LanguageConfig import top.fatweb.oxygen.toolbox.model.userdata.LaunchPageConfig diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/userdata/UserPreferencesSerializer.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/UserPreferencesSerializer.kt similarity index 87% rename from app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/userdata/UserPreferencesSerializer.kt rename to app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/UserPreferencesSerializer.kt index 95b3ec0..cb0a96b 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/datastore/userdata/UserPreferencesSerializer.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/UserPreferencesSerializer.kt @@ -1,9 +1,9 @@ -package top.fatweb.oxygen.toolbox.datastore.userdata +package top.fatweb.oxygen.toolbox.data.userdata import androidx.datastore.core.CorruptionException import androidx.datastore.core.Serializer import com.google.protobuf.InvalidProtocolBufferException -import top.fatweb.oxygen.toolbox.datastore.UserPreferences +import top.fatweb.oxygen.toolbox.data.UserPreferences import java.io.InputStream import java.io.OutputStream import javax.inject.Inject diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/di/DataModule.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/di/DataModule.kt index 492ac46..8de504d 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/di/DataModule.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/di/DataModule.kt @@ -8,9 +8,9 @@ import top.fatweb.oxygen.toolbox.monitor.ConnectivityManagerNetworkMonitor import top.fatweb.oxygen.toolbox.monitor.NetworkMonitor import top.fatweb.oxygen.toolbox.monitor.TimeZoneBroadcastMonitor import top.fatweb.oxygen.toolbox.monitor.TimeZoneMonitor -import top.fatweb.oxygen.toolbox.repository.tool.OfflineFirstToolRepository +import top.fatweb.oxygen.toolbox.repository.tool.LocalToolRepository import top.fatweb.oxygen.toolbox.repository.tool.ToolRepository -import top.fatweb.oxygen.toolbox.repository.userdata.OfflineFirstUserDataRepository +import top.fatweb.oxygen.toolbox.repository.userdata.LocalUserDataRepository import top.fatweb.oxygen.toolbox.repository.userdata.UserDataRepository @Module @@ -23,8 +23,8 @@ abstract class DataModule { internal abstract fun bindsTimeZoneMonitor(timeZoneMonitor: TimeZoneBroadcastMonitor): TimeZoneMonitor @Binds - internal abstract fun bindsUserDataRepository(userDataRepository: OfflineFirstUserDataRepository): UserDataRepository + internal abstract fun bindsUserDataRepository(userDataRepository: LocalUserDataRepository): UserDataRepository @Binds - internal abstract fun bindsToolRepository(toolRepository: OfflineFirstToolRepository): ToolRepository + internal abstract fun bindsToolRepository(toolRepository: LocalToolRepository): ToolRepository } \ No newline at end of file diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/di/DataStoreModule.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/di/DataStoreModule.kt index 1c739f4..16147bc 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/di/DataStoreModule.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/di/DataStoreModule.kt @@ -11,9 +11,9 @@ import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope -import top.fatweb.oxygen.toolbox.datastore.UserPreferences -import top.fatweb.oxygen.toolbox.datastore.userdata.IntToStringIdsMigration -import top.fatweb.oxygen.toolbox.datastore.userdata.UserPreferencesSerializer +import top.fatweb.oxygen.toolbox.data.UserPreferences +import top.fatweb.oxygen.toolbox.data.userdata.IntToStringIdsMigration +import top.fatweb.oxygen.toolbox.data.userdata.UserPreferencesSerializer import top.fatweb.oxygen.toolbox.network.Dispatcher import top.fatweb.oxygen.toolbox.network.OxygenDispatchers import javax.inject.Singleton diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/OfflineFirstToolRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/LocalToolRepository.kt similarity index 70% rename from app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/OfflineFirstToolRepository.kt rename to app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/LocalToolRepository.kt index f8e89e3..a023841 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/OfflineFirstToolRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/LocalToolRepository.kt @@ -1,11 +1,11 @@ package top.fatweb.oxygen.toolbox.repository.tool import kotlinx.coroutines.flow.Flow -import top.fatweb.oxygen.toolbox.datastore.tool.ToolDataSource +import top.fatweb.oxygen.toolbox.data.tool.ToolDataSource import top.fatweb.oxygen.toolbox.model.tool.ToolGroup import javax.inject.Inject -internal class OfflineFirstToolRepository @Inject constructor( +internal class LocalToolRepository @Inject constructor( toolDataSource: ToolDataSource ) : ToolRepository { override val toolGroups: Flow> = diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/OfflineFirstUserDataRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/LocalUserDataRepository.kt similarity index 90% rename from app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/OfflineFirstUserDataRepository.kt rename to app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/LocalUserDataRepository.kt index 1aeb19b..25726c2 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/OfflineFirstUserDataRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/userdata/LocalUserDataRepository.kt @@ -1,7 +1,7 @@ package top.fatweb.oxygen.toolbox.repository.userdata import kotlinx.coroutines.flow.Flow -import top.fatweb.oxygen.toolbox.datastore.userdata.OxygenPreferencesDataSource +import top.fatweb.oxygen.toolbox.data.userdata.OxygenPreferencesDataSource import top.fatweb.oxygen.toolbox.model.userdata.DarkThemeConfig import top.fatweb.oxygen.toolbox.model.userdata.LanguageConfig import top.fatweb.oxygen.toolbox.model.userdata.LaunchPageConfig @@ -9,7 +9,7 @@ import top.fatweb.oxygen.toolbox.model.userdata.ThemeBrandConfig import top.fatweb.oxygen.toolbox.model.userdata.UserData import javax.inject.Inject -internal class OfflineFirstUserDataRepository @Inject constructor( +internal class LocalUserDataRepository @Inject constructor( private val oxygenPreferencesDataSource: OxygenPreferencesDataSource ) : UserDataRepository { override val userData: Flow = diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolGroupCard.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolGroupCard.kt index 796f34b..5a26587 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolGroupCard.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/component/ToolGroupCard.kt @@ -34,7 +34,7 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.dp import kotlinx.coroutines.flow.first import kotlinx.coroutines.runBlocking -import top.fatweb.oxygen.toolbox.datastore.tool.ToolDataSource +import top.fatweb.oxygen.toolbox.data.tool.ToolDataSource import top.fatweb.oxygen.toolbox.icon.OxygenIcons import top.fatweb.oxygen.toolbox.model.tool.Tool import top.fatweb.oxygen.toolbox.model.tool.ToolGroup diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tool/ToolsScreen.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tool/ToolsScreen.kt index f2657d0..0a1f659 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tool/ToolsScreen.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/tool/ToolsScreen.kt @@ -32,7 +32,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import kotlinx.coroutines.flow.first import kotlinx.coroutines.runBlocking import top.fatweb.oxygen.toolbox.R -import top.fatweb.oxygen.toolbox.datastore.tool.ToolDataSource +import top.fatweb.oxygen.toolbox.data.tool.ToolDataSource import top.fatweb.oxygen.toolbox.ui.component.scrollbar.DraggableScrollbar import top.fatweb.oxygen.toolbox.ui.component.scrollbar.rememberDraggableScroller import top.fatweb.oxygen.toolbox.ui.component.scrollbar.scrollbarState diff --git a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/dark_theme_config.proto b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/dark_theme_config.proto index 2314c85..4063cd0 100644 --- a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/dark_theme_config.proto +++ b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/dark_theme_config.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option java_package = "top.fatweb.oxygen.toolbox.datastore"; +option java_package = "top.fatweb.oxygen.toolbox.data"; option java_multiple_files = true; enum DarkThemeConfigProto { diff --git a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/language_config.proto b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/language_config.proto index ab6f311..882bc95 100644 --- a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/language_config.proto +++ b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/language_config.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option java_package = "top.fatweb.oxygen.toolbox.datastore"; +option java_package = "top.fatweb.oxygen.toolbox.data"; option java_multiple_files = true; enum LanguageConfigProto { diff --git a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/launch_page_config.proto b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/launch_page_config.proto index de62ac0..864a8b5 100644 --- a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/launch_page_config.proto +++ b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/launch_page_config.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option java_package = "top.fatweb.oxygen.toolbox.datastore"; +option java_package = "top.fatweb.oxygen.toolbox.data"; option java_multiple_files = true; enum LaunchPageConfigProto { diff --git a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/theme_brand_config.proto b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/theme_brand_config.proto index 68a9d04..4389de6 100644 --- a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/theme_brand_config.proto +++ b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/theme_brand_config.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option java_package = "top.fatweb.oxygen.toolbox.datastore"; +option java_package = "top.fatweb.oxygen.toolbox.data"; option java_multiple_files = true; enum ThemeBrandConfigProto { diff --git a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/user_preferences.proto b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/user_preferences.proto index 38f6a25..7ea1577 100644 --- a/app/src/main/proto/com/fatweb/oxygen/toolbox/data/user_preferences.proto +++ b/app/src/main/proto/com/fatweb/oxygen/toolbox/data/user_preferences.proto @@ -5,7 +5,7 @@ import "com/fatweb/oxygen/toolbox/data/launch_page_config.proto"; import "com/fatweb/oxygen/toolbox/data/theme_brand_config.proto"; import "com/fatweb/oxygen/toolbox/data/dark_theme_config.proto"; -option java_package = "top.fatweb.oxygen.toolbox.datastore"; +option java_package = "top.fatweb.oxygen.toolbox.data"; option java_multiple_files = true; message UserPreferences {