From 72d2185ef98bfd0ca9ca6a81a84b7713dd5b81d4 Mon Sep 17 00:00:00 2001 From: JackEblan Date: Mon, 11 Nov 2024 19:33:55 +0800 Subject: [PATCH 1/7] I no longer follow google's recommended app architecture. It solved my previous problem. I realized now how beautiful applying clean architecture. Now, in my domain module, I can actually see the purpose of the app. --- .idea/deploymentTargetSelector.xml | 4 +- README.md | 4 - app/build.gradle.kts | 10 ++- .../kotlin/com/android/geto/MainActivity.kt | 4 +- .../com/android/geto/MainActivityUiState.kt | 2 +- .../com/android/geto/MainActivityViewModel.kt | 2 +- broadcast-receiver/build.gradle.kts | 7 -- .../consumer-proguard-rules.pro | 0 .../src/main/AndroidManifest.xml | 2 +- .../BroadcastReceiverModule.kt | 6 ++ .../DefaultBroadcastReceiverController.kt | 7 +- ...DefaultRevertSettingsBroadcastReceiver.kt} | 10 ++- core/data-test/build.gradle.kts | 2 +- .../geto/core/data/test/TestDataModule.kt | 10 +-- .../repository/FakeAppSettingsRepository.kt | 9 ++- .../test/repository/FakePackageRepository.kt | 7 +- .../FakeSecureSettingsRepository.kt | 11 +-- .../test/repository/FakeShortcutRepository.kt | 7 +- .../test/repository/FakeUserDataRepository.kt | 11 +-- core/data/build.gradle.kts | 7 +- .../android/geto/core/data/di/DataModule.kt | 10 +-- .../DefaultAppSettingsRepository.kt | 4 +- .../repository/DefaultPackageRepository.kt | 6 +- .../DefaultSecureSettingsRepository.kt | 10 +-- .../repository/DefaultShortcutRepository.kt | 6 +- .../repository/DefaultUserDataRepository.kt | 8 +- core/database/build.gradle.kts | 2 +- .../core/database/dao/AppSettingsDaoTest.kt | 2 +- .../core/database/model/AppSettingEntity.kt | 4 +- core/datastore/build.gradle.kts | 2 +- .../datastore/GetoPreferencesDataSource.kt | 6 +- .../GetoPreferencesDataSourceTest.kt | 4 +- core/domain/build.gradle.kts | 5 -- .../BroadcastReceiverController.kt | 2 +- .../RevertSettingsBroadcastReceiver.kt | 20 +++++ .../UsageStatsForegroundServiceManager.kt | 8 +- .../domain/framework}/AssetManagerWrapper.kt | 4 +- .../framework}/ClipboardManagerWrapper.kt | 2 +- .../framework}/NotificationManagerWrapper.kt | 2 +- .../framework}/PackageManagerWrapper.kt | 4 +- .../framework}/SecureSettingsWrapper.kt | 6 +- .../ShortcutManagerCompatWrapper.kt | 4 +- .../framework}/UsageStatsManagerWrapper.kt | 4 +- .../core/domain}/model/AddAppSettingResult.kt | 2 +- .../geto/core/domain}/model/AppSetting.kt | 2 +- .../core/domain}/model/AppSettingTemplate.kt | 2 +- .../core/domain}/model/AppSettingsResult.kt | 2 +- .../core/domain}/model/DarkThemeConfig.kt | 2 +- .../ForegroundServiceAppSettingsResult.kt | 2 +- .../core/domain}/model/GetoApplicationInfo.kt | 2 +- .../domain}/model/GetoShortcutInfoCompat.kt | 2 +- .../geto/core/domain}/model/GetoUsageEvent.kt | 2 +- .../domain}/model/RequestPinShortcutResult.kt | 2 +- .../geto/core/domain}/model/SecureSetting.kt | 2 +- .../geto/core/domain}/model/ThemeBrand.kt | 2 +- .../geto/core/domain}/model/UserData.kt | 2 +- .../repository/AppSettingsRepository.kt | 4 +- .../domain}/repository/PackageRepository.kt | 4 +- .../repository/SecureSettingsRepository.kt | 8 +- .../domain}/repository/ShortcutRepository.kt | 4 +- .../domain}/repository/UserDataRepository.kt | 8 +- .../{ => usecase}/AddAppSettingUseCase.kt | 12 +-- .../{ => usecase}/ApplyAppSettingsUseCase.kt | 20 ++--- .../domain/{ => usecase}/AutoLaunchUseCase.kt | 18 ++--- .../{ => usecase}/CleanAppSettingsUseCase.kt | 6 +- .../ForegroundServiceAppSettingsUseCase.kt | 12 +-- .../RequestPinShortcutUseCase.kt | 18 ++--- .../{ => usecase}/RevertAppSettingsUseCase.kt | 20 ++--- ...pdateUsageStatsForegroundServiceUseCase.kt | 43 ++++++++++ .../{ => usecase}/AddAppSettingUseCaseTest.kt | 8 +- .../ApplyAppSettingsUseCaseTest.kt | 20 ++--- .../{ => usecase}/AutoLaunchUseCaseTest.kt | 24 +++--- ...ForegroundServiceAppSettingsUseCaseTest.kt | 12 +-- .../RequestPinShortcutUseCaseTest.kt | 12 +-- .../RevertAppSettingsUseCaseTest.kt | 18 ++--- ...eUsageStatsForegroundServiceUseCaseTest.kt | 80 +++++++++++++++++++ core/model/.gitignore | 1 - core/model/consumer-proguard-rules.pro | 1 - core/model/src/main/AndroidManifest.xml | 20 ----- core/testing/build.gradle.kts | 10 +-- .../framework/DummyClipboardManagerWrapper.kt | 2 +- .../DummyNotificationManagerWrapper.kt | 2 +- .../framework/FakeAssetManagerWrapper.kt | 4 +- ...FakeUsageStatsForegroundServiceManager.kt} | 10 +-- .../framework/FakeUsageStatsManagerWrapper.kt | 4 +- .../repository/TestAppSettingsRepository.kt | 4 +- .../repository/TestPackageRepository.kt | 4 +- .../TestSecureSettingsRepository.kt | 8 +- .../repository/TestShortcutRepository.kt | 4 +- .../repository/TestUserDataRepository.kt | 8 +- core/ui/build.gradle.kts | 2 +- .../ui/AppSettingsPreviewParameterProvider.kt | 4 +- ...ApplicationInfoPreviewParameterProvider.kt | 2 +- feature/app-settings/build.gradle.kts | 7 -- .../AppSettingsScreenDialogsTest.kt | 2 +- .../AppSettingsScreenSnackbarTest.kt | 6 +- .../appsettings/AppSettingsScreenTest.kt | 4 +- .../dialog/appsetting/AppSettingDialogTest.kt | 4 +- .../feature/appsettings/AppSettingsEvent.kt | 6 +- .../feature/appsettings/AppSettingsScreen.kt | 40 +++++----- .../feature/appsettings/AppSettingsUiState.kt | 2 +- .../appsettings/AppSettingsViewModel.kt | 41 +++++----- .../dialog/appsetting/AppSettingDialog.kt | 4 +- .../appsetting/AppSettingDialogState.kt | 6 +- .../dialog/shortcut/ShortcutDialog.kt | 2 +- .../dialog/shortcut/ShortcutDialogState.kt | 2 +- .../dialog/template/TemplateDialog.kt | 4 +- .../dialog/template/TemplateDialogState.kt | 4 +- .../dialog/template/TemplateDialogUiState.kt | 2 +- .../AppSettingsScreenScreenshotTest.kt | 4 +- ...AppSettingsScreenSnackbarScreenshotTest.kt | 4 +- .../appsettings/AppSettingsViewModelTest.kt | 36 ++++----- .../appsetting/AppSettingsDialogStateTest.kt | 4 +- .../template/TemplateDialogScreenshotTest.kt | 4 +- feature/apps/build.gradle.kts | 2 +- .../geto/feature/apps/AppsScreenTest.kt | 2 +- .../android/geto/feature/apps/AppsScreen.kt | 2 +- .../android/geto/feature/apps/AppsUiState.kt | 2 +- .../geto/feature/apps/AppsViewModel.kt | 2 +- .../feature/apps/AppsScreenScreenshotTest.kt | 2 +- .../geto/feature/apps/AppsViewModelTest.kt | 2 +- feature/service/build.gradle.kts | 4 - .../geto/feature/service/ServiceScreen.kt | 9 ++- .../geto/feature/service/ServiceUiState.kt | 2 +- .../geto/feature/service/ServiceViewModel.kt | 34 +++----- .../service/ServiceScreenScreenshotTest.kt | 9 ++- .../feature/service/ServiceViewModelTest.kt | 52 +++++++----- feature/settings/build.gradle.kts | 1 - .../settings/SettingsScreenDialogsTest.kt | 6 +- .../feature/settings/SettingsScreenTest.kt | 6 +- .../geto/feature/settings/SettingsEvent.kt | 4 +- .../geto/feature/settings/SettingsScreen.kt | 4 +- .../geto/feature/settings/SettingsUiState.kt | 2 +- .../feature/settings/SettingsViewModel.kt | 8 +- .../settings/dialog/dark/DarkDialog.kt | 2 +- .../settings/dialog/theme/ThemeDialog.kt | 2 +- .../settings/SettingsScreenScreenshotTest.kt | 6 +- .../feature/settings/SettingsViewModelTest.kt | 6 +- foreground-service/build.gradle.kts | 3 - ...roidUsageStatsForegroundServiceManager.kt} | 11 ++- .../ForegroundServiceModule.kt | 3 +- .../foregroundservice/UsageStatsService.kt | 22 +++-- framework/asset-manager/build.gradle.kts | 2 +- .../AndroidAssetManagerWrapper.kt | 7 +- .../assetmanager/AssetManagerModule.kt | 1 + framework/clipboard-manager/build.gradle.kts | 4 + .../AndroidClipboardManagerWrapper.kt | 2 +- .../ClipboardManagerModule.kt | 2 +- .../notification-manager/build.gradle.kts | 2 + .../AndroidNotificationManagerWrapper.kt | 7 +- .../NotificationManagerModule.kt | 1 + framework/package-manager/build.gradle.kts | 2 +- .../AndroidPackageManagerWrapper.kt | 3 +- .../packagemanager/PackageManagerModule.kt | 1 + .../mapper/AndroidApplicationInfoMapper.kt | 2 +- framework/secure-settings/build.gradle.kts | 2 +- .../AndroidSecureSettingsWrapper.kt | 11 +-- .../securesettings/SecureSettingsModule.kt | 1 + framework/shortcut-manager/build.gradle.kts | 2 +- .../AndroidShortcutManagerCompatWrapper.kt | 3 +- .../shortcutmanager/ShortcutManagerModule.kt | 1 + .../mapper/ShortcutInfoCompat.kt | 2 +- .../usage-stats-manager/build.gradle.kts | 2 +- .../AndroidUsageStatsManagerWrapper.kt | 5 +- .../UsageStatsManagerModule.kt | 1 + settings.gradle.kts | 1 - 166 files changed, 649 insertions(+), 530 deletions(-) delete mode 100644 broadcast-receiver/consumer-proguard-rules.pro rename broadcast-receiver/src/main/kotlin/com/android/geto/broadcastreceiver/{RevertSettingsBroadcastReceiver.kt => DefaultRevertSettingsBroadcastReceiver.kt} (72%) rename {broadcast-receiver/src/main/kotlin/com/android/geto => core/domain/src/main/kotlin/com/android/geto/core/domain}/broadcastreceiver/BroadcastReceiverController.kt (93%) create mode 100644 core/domain/src/main/kotlin/com/android/geto/core/domain/broadcastreceiver/RevertSettingsBroadcastReceiver.kt rename foreground-service/src/main/kotlin/com/android/geto/foregroundservice/ForegroundServiceManager.kt => core/domain/src/main/kotlin/com/android/geto/core/domain/foregroundservice/UsageStatsForegroundServiceManager.kt (84%) rename {framework/asset-manager/src/main/kotlin/com/android/geto/framework/assetmanager => core/domain/src/main/kotlin/com/android/geto/core/domain/framework}/AssetManagerWrapper.kt (87%) rename {framework/clipboard-manager/src/main/kotlin/com/android/geto/framework/clipboardmanager => core/domain/src/main/kotlin/com/android/geto/core/domain/framework}/ClipboardManagerWrapper.kt (93%) rename {framework/notification-manager/src/main/kotlin/com/android/geto/framework/notificationmanager => core/domain/src/main/kotlin/com/android/geto/core/domain/framework}/NotificationManagerWrapper.kt (96%) rename {framework/package-manager/src/main/kotlin/com/android/geto/framework/packagemanager => core/domain/src/main/kotlin/com/android/geto/core/domain/framework}/PackageManagerWrapper.kt (89%) rename {framework/secure-settings/src/main/kotlin/com/android/geto/framework/securesettings => core/domain/src/main/kotlin/com/android/geto/core/domain/framework}/SecureSettingsWrapper.kt (84%) rename {framework/shortcut-manager/src/main/kotlin/com/android/geto/framework/shortcutmanager => core/domain/src/main/kotlin/com/android/geto/core/domain/framework}/ShortcutManagerCompatWrapper.kt (90%) rename {framework/usage-stats-manager/src/main/kotlin/com/android/geto/framework/usagestatsmanager => core/domain/src/main/kotlin/com/android/geto/core/domain/framework}/UsageStatsManagerWrapper.kt (88%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/AddAppSettingResult.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/AppSetting.kt (95%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/AppSettingTemplate.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/AppSettingsResult.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/DarkThemeConfig.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/ForegroundServiceAppSettingsResult.kt (97%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/GetoApplicationInfo.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/GetoShortcutInfoCompat.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/GetoUsageEvent.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/RequestPinShortcutResult.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/SecureSetting.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/ThemeBrand.kt (94%) rename core/{model/src/main/kotlin/com/android/geto/core => domain/src/main/kotlin/com/android/geto/core/domain}/model/UserData.kt (94%) rename core/{data/src/main/kotlin/com/android/geto/core/data => domain/src/main/kotlin/com/android/geto/core/domain}/repository/AppSettingsRepository.kt (90%) rename core/{data/src/main/kotlin/com/android/geto/core/data => domain/src/main/kotlin/com/android/geto/core/domain}/repository/PackageRepository.kt (88%) rename core/{data/src/main/kotlin/com/android/geto/core/data => domain/src/main/kotlin/com/android/geto/core/domain}/repository/SecureSettingsRepository.kt (81%) rename core/{data/src/main/kotlin/com/android/geto/core/data => domain/src/main/kotlin/com/android/geto/core/domain}/repository/ShortcutRepository.kt (91%) rename core/{data/src/main/kotlin/com/android/geto/core/data => domain/src/main/kotlin/com/android/geto/core/domain}/repository/UserDataRepository.kt (82%) rename core/domain/src/main/kotlin/com/android/geto/core/domain/{ => usecase}/AddAppSettingUseCase.kt (77%) rename core/domain/src/main/kotlin/com/android/geto/core/domain/{ => usecase}/ApplyAppSettingsUseCase.kt (69%) rename core/domain/src/main/kotlin/com/android/geto/core/domain/{ => usecase}/AutoLaunchUseCase.kt (73%) rename core/domain/src/main/kotlin/com/android/geto/core/domain/{ => usecase}/CleanAppSettingsUseCase.kt (88%) rename core/domain/src/main/kotlin/com/android/geto/core/domain/{ => usecase}/ForegroundServiceAppSettingsUseCase.kt (84%) rename core/domain/src/main/kotlin/com/android/geto/core/domain/{ => usecase}/RequestPinShortcutUseCase.kt (80%) rename core/domain/src/main/kotlin/com/android/geto/core/domain/{ => usecase}/RevertAppSettingsUseCase.kt (68%) create mode 100644 core/domain/src/main/kotlin/com/android/geto/core/domain/usecase/UpdateUsageStatsForegroundServiceUseCase.kt rename core/domain/src/test/kotlin/com/android/geto/core/domain/{ => usecase}/AddAppSettingUseCaseTest.kt (93%) rename core/domain/src/test/kotlin/com/android/geto/core/domain/{ => usecase}/ApplyAppSettingsUseCaseTest.kt (89%) rename core/domain/src/test/kotlin/com/android/geto/core/domain/{ => usecase}/AutoLaunchUseCaseTest.kt (92%) rename core/domain/src/test/kotlin/com/android/geto/core/domain/{ => usecase}/ForegroundServiceAppSettingsUseCaseTest.kt (92%) rename core/domain/src/test/kotlin/com/android/geto/core/domain/{ => usecase}/RequestPinShortcutUseCaseTest.kt (90%) rename core/domain/src/test/kotlin/com/android/geto/core/domain/{ => usecase}/RevertAppSettingsUseCaseTest.kt (90%) create mode 100644 core/domain/src/test/kotlin/com/android/geto/core/domain/usecase/UpdateUsageStatsForegroundServiceUseCaseTest.kt delete mode 100644 core/model/.gitignore delete mode 100644 core/model/consumer-proguard-rules.pro delete mode 100644 core/model/src/main/AndroidManifest.xml rename core/testing/src/main/kotlin/com/android/geto/core/testing/framework/{FakeForegroundServiceManager.kt => FakeUsageStatsForegroundServiceManager.kt} (81%) rename foreground-service/src/main/kotlin/com/android/geto/foregroundservice/{AndroidForegroundServiceManager.kt => AndroidUsageStatsForegroundServiceManager.kt} (85%) diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml index 2dfa2cba1..6d756725c 100644 --- a/.idea/deploymentTargetSelector.xml +++ b/.idea/deploymentTargetSelector.xml @@ -4,10 +4,10 @@