From e0d6c8c11010bc509ce0f067376ae25e44609f57 Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 18 Jun 2026 14:32:27 +0800 Subject: [PATCH 01/21] Share :ui --- .../github/kr328/clash/ui/component/ModelProgressBarDialog.kt | 0 .../kotlin/com/github/kr328/clash/ui/component/Spacers.kt | 0 .../kotlin/com/github/kr328/clash/ui/component/TabbyScaffold.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineAdb.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineAdd.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineApps.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineArrowBack.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineArrowUp.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineAssignment.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineAttachFile.kt | 0 .../com/github/kr328/clash/ui/icon/BaselineBrightness4.kt | 0 .../com/github/kr328/clash/ui/icon/BaselineCircleCenter.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineClearAll.kt | 0 .../com/github/kr328/clash/ui/icon/BaselineCloudDownload.kt | 0 .../com/github/kr328/clash/ui/icon/BaselineContentCopy.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineDelete.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineDns.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineDomain.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineDragHandle.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineEdit.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineExtension.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineFlashOn.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineGetApp.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineHelpCenter.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineHide.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineInfo.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineKey.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineMeta.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineMoreVert.kt | 0 .../com/github/kr328/clash/ui/icon/BaselineQrCodeScanner.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineReplay.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineRestore.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineSave.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineSearch.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineSettings.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineStack.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineStop.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVert.kt | 0 .../github/kr328/clash/ui/icon/BaselineSwapVerticalCircle.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineSync.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineUpdate.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineViewList.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/BaselineVpnLock.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/OutlineArticle.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/OutlineCheckCircle.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/OutlineDelete.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/OutlineFolder.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/OutlineInbox.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/OutlineInfo.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/OutlineLabel.kt | 0 .../com/github/kr328/clash/ui/icon/OutlineNotInterested.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/OutlineUpdate.kt | 0 .../kotlin/com/github/kr328/clash/ui/icon/TabbyIcons.kt | 0 .../kotlin/com/github/kr328/clash/ui/lifecycle/ViewModel.kt | 0 .../kotlin/com/github/kr328/clash/ui/nav/TabbyNavDisplay.kt | 0 .../kotlin/com/github/kr328/clash/ui/theme/Color.kt | 0 .../kotlin/com/github/kr328/clash/ui/theme/Theme.kt | 2 +- .../kotlin/com/github/kr328/clash/ui/theme/Type.kt | 0 58 files changed, 1 insertion(+), 1 deletion(-) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/component/ModelProgressBarDialog.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/component/Spacers.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/component/TabbyScaffold.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineAdb.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineAdd.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineApps.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowBack.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowUp.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineAssignment.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineAttachFile.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineBrightness4.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineCircleCenter.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineClearAll.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineCloudDownload.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineContentCopy.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineDelete.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineDns.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineDomain.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineDragHandle.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineEdit.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineExtension.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineFlashOn.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineGetApp.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineHelpCenter.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineHide.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineInfo.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineKey.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineMeta.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineMoreVert.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineQrCodeScanner.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineReplay.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineRestore.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineSave.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineSearch.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineSettings.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineStack.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineStop.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVert.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVerticalCircle.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineSync.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineUpdate.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineViewList.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/BaselineVpnLock.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/OutlineArticle.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/OutlineCheckCircle.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/OutlineDelete.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/OutlineFolder.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/OutlineInbox.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/OutlineInfo.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/OutlineLabel.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/OutlineNotInterested.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/OutlineUpdate.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/icon/TabbyIcons.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/lifecycle/ViewModel.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/nav/TabbyNavDisplay.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/theme/Color.kt (100%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/theme/Theme.kt (98%) rename ui/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/ui/theme/Type.kt (100%) diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/component/ModelProgressBarDialog.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/component/ModelProgressBarDialog.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/component/ModelProgressBarDialog.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/component/ModelProgressBarDialog.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/component/Spacers.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/component/Spacers.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/component/Spacers.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/component/Spacers.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/component/TabbyScaffold.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/component/TabbyScaffold.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/component/TabbyScaffold.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/component/TabbyScaffold.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAdb.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAdb.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAdb.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAdb.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAdd.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAdd.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAdd.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAdd.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineApps.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineApps.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineApps.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineApps.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowBack.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowBack.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowBack.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowBack.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowUp.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowUp.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowUp.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineArrowUp.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAssignment.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAssignment.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAssignment.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAssignment.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAttachFile.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAttachFile.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAttachFile.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineAttachFile.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineBrightness4.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineBrightness4.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineBrightness4.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineBrightness4.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineCircleCenter.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineCircleCenter.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineCircleCenter.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineCircleCenter.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineClearAll.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineClearAll.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineClearAll.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineClearAll.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineCloudDownload.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineCloudDownload.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineCloudDownload.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineCloudDownload.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineContentCopy.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineContentCopy.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineContentCopy.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineContentCopy.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDelete.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDelete.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDelete.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDelete.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDns.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDns.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDns.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDns.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDomain.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDomain.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDomain.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDomain.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDragHandle.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDragHandle.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDragHandle.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineDragHandle.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineEdit.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineEdit.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineEdit.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineEdit.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineExtension.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineExtension.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineExtension.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineExtension.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineFlashOn.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineFlashOn.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineFlashOn.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineFlashOn.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineGetApp.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineGetApp.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineGetApp.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineGetApp.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineHelpCenter.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineHelpCenter.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineHelpCenter.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineHelpCenter.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineHide.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineHide.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineHide.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineHide.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineInfo.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineInfo.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineInfo.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineInfo.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineKey.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineKey.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineKey.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineKey.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineMeta.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineMeta.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineMeta.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineMeta.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineMoreVert.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineMoreVert.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineMoreVert.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineMoreVert.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineQrCodeScanner.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineQrCodeScanner.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineQrCodeScanner.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineQrCodeScanner.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineReplay.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineReplay.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineReplay.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineReplay.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineRestore.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineRestore.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineRestore.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineRestore.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSave.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSave.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSave.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSave.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSearch.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSearch.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSearch.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSearch.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSettings.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSettings.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSettings.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSettings.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineStack.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineStack.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineStack.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineStack.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineStop.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineStop.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineStop.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineStop.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVert.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVert.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVert.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVert.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVerticalCircle.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVerticalCircle.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVerticalCircle.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSwapVerticalCircle.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSync.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSync.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSync.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineSync.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineUpdate.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineUpdate.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineUpdate.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineUpdate.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineViewList.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineViewList.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineViewList.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineViewList.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineVpnLock.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineVpnLock.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/BaselineVpnLock.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/BaselineVpnLock.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineArticle.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineArticle.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineArticle.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineArticle.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineCheckCircle.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineCheckCircle.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineCheckCircle.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineCheckCircle.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineDelete.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineDelete.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineDelete.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineDelete.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineFolder.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineFolder.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineFolder.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineFolder.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineInbox.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineInbox.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineInbox.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineInbox.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineInfo.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineInfo.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineInfo.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineInfo.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineLabel.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineLabel.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineLabel.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineLabel.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineNotInterested.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineNotInterested.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineNotInterested.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineNotInterested.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineUpdate.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineUpdate.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/OutlineUpdate.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/OutlineUpdate.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/TabbyIcons.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/TabbyIcons.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/icon/TabbyIcons.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/icon/TabbyIcons.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/lifecycle/ViewModel.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/lifecycle/ViewModel.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/lifecycle/ViewModel.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/lifecycle/ViewModel.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/nav/TabbyNavDisplay.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/nav/TabbyNavDisplay.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/nav/TabbyNavDisplay.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/nav/TabbyNavDisplay.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/theme/Color.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Color.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/theme/Color.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Color.kt diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt similarity index 98% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt index 9eebf6e53f..0df95c6a57 100644 --- a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt +++ b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt @@ -1,6 +1,5 @@ package com.github.kr328.clash.ui.theme -import android.content.res.Configuration.UI_MODE_NIGHT_YES import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.MaterialTheme import androidx.compose.material3.darkColorScheme @@ -10,6 +9,7 @@ import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.Immutable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.staticCompositionLocalOf +import androidx.compose.ui.tooling.preview.AndroidUiModes.UI_MODE_NIGHT_YES import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewWrapperProvider import androidx.compose.ui.unit.Dp diff --git a/ui/src/androidMain/kotlin/com/github/kr328/clash/ui/theme/Type.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Type.kt similarity index 100% rename from ui/src/androidMain/kotlin/com/github/kr328/clash/ui/theme/Type.kt rename to ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Type.kt From 51ca0a0008530aaad51c24addcf9e69372194d03 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 30 Jun 2026 08:40:38 +0800 Subject: [PATCH 02/21] Move crash module files to commonMain --- .../kotlin/com/github/kr328/clash/crash/CrashNav.kt | 0 .../kotlin/com/github/kr328/clash/crash/di/CrashModule.kt | 0 .../kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt | 0 .../kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt | 0 .../kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename ui/crash/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/crash/CrashNav.kt (100%) rename ui/crash/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt (100%) rename ui/crash/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt (100%) rename ui/crash/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt (100%) rename ui/crash/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt (100%) diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt b/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt similarity index 100% rename from ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt rename to ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt b/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt similarity index 100% rename from ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt rename to ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt b/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt similarity index 100% rename from ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt rename to ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt b/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt similarity index 100% rename from ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt rename to ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt b/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt similarity index 100% rename from ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt rename to ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt From fe79a69200cd12f253d4ba9e9fdd2a4c1de3f733 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 30 Jun 2026 08:48:59 +0800 Subject: [PATCH 03/21] Move the most files --- .../kotlin/com/github/kr328/clash/home/HomeNav.kt | 0 .../kotlin/com/github/kr328/clash/home/api/HelpApi.kt | 0 .../kotlin/com/github/kr328/clash/home/di/HomeModule.kt | 0 .../kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt | 0 .../kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt | 0 .../kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt | 0 .../kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt | 0 .../kotlin/com/github/kr328/clash/profile/ProfilesNav.kt | 0 .../kotlin/com/github/kr328/clash/profile/di/ProfileModule.kt | 0 .../com/github/kr328/clash/profile/model/ProfileProvider.kt | 0 .../kotlin/com/github/kr328/clash/profile/ui/FilesScreen.kt | 0 .../kotlin/com/github/kr328/clash/profile/ui/NewProfileScreen.kt | 0 .../com/github/kr328/clash/profile/ui/PreferencesInProfiles.kt | 0 .../kotlin/com/github/kr328/clash/profile/ui/ProfilesScreen.kt | 0 .../kotlin/com/github/kr328/clash/profile/ui/PropertiesScreen.kt | 0 .../kotlin/com/github/kr328/clash/profile/ui/ProvidersScreen.kt | 0 .../kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt | 0 .../com/github/kr328/clash/profile/vm/NewProfileViewModel.kt | 0 .../kotlin/com/github/kr328/clash/profile/vm/ProfilesViewModel.kt | 0 .../com/github/kr328/clash/profile/vm/PropertiesViewModel.kt | 0 .../com/github/kr328/clash/profile/vm/ProvidersViewModel.kt | 0 .../kotlin/com/github/kr328/clash/proxy/ProxyNav.kt | 0 .../kotlin/com/github/kr328/clash/proxy/di/ProxyModule.kt | 0 .../kotlin/com/github/kr328/clash/proxy/ui/ProxyScreen.kt | 0 .../kotlin/com/github/kr328/clash/proxy/vm/ProxyViewModel.kt | 0 .../kotlin/com/github/kr328/clash/settings/SettingsNav.kt | 0 .../kotlin/com/github/kr328/clash/settings/di/SettingsModule.kt | 0 .../com/github/kr328/clash/settings/ui/AccessControlScreen.kt | 0 .../com/github/kr328/clash/settings/ui/AppSettingsScreen.kt | 0 .../com/github/kr328/clash/settings/ui/EditableTextMapScreen.kt | 0 .../com/github/kr328/clash/settings/ui/EditableTextSetScreen.kt | 0 .../github/kr328/clash/settings/ui/MetaFeatureSettingsScreen.kt | 0 .../com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt | 0 .../com/github/kr328/clash/settings/ui/OverrideSettingsScreen.kt | 0 .../com/github/kr328/clash/settings/ui/PreferencesInSettings.kt | 0 .../github/kr328/clash/settings/ui/ResetOverrideSettingsDialog.kt | 0 .../com/github/kr328/clash/settings/ui/SettingsPreference.kt | 0 .../kotlin/com/github/kr328/clash/settings/ui/SettingsScreen.kt | 0 .../com/github/kr328/clash/settings/vm/AccessControlViewModel.kt | 0 .../com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt | 0 .../kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt | 0 .../github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt | 0 .../github/kr328/clash/settings/vm/OverrideSettingsViewModel.kt | 0 43 files changed, 0 insertions(+), 0 deletions(-) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/HomeNav.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/api/HelpApi.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/di/HomeModule.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/ProfilesNav.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/di/ProfileModule.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/model/ProfileProvider.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/ui/FilesScreen.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/ui/NewProfileScreen.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/ui/PreferencesInProfiles.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/ui/ProfilesScreen.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/ui/PropertiesScreen.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/ui/ProvidersScreen.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/vm/NewProfileViewModel.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/vm/ProfilesViewModel.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/vm/PropertiesViewModel.kt (100%) rename ui/profile/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/profile/vm/ProvidersViewModel.kt (100%) rename ui/proxy/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/proxy/ProxyNav.kt (100%) rename ui/proxy/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/proxy/di/ProxyModule.kt (100%) rename ui/proxy/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/proxy/ui/ProxyScreen.kt (100%) rename ui/proxy/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/proxy/vm/ProxyViewModel.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/SettingsNav.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/di/SettingsModule.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/AccessControlScreen.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/EditableTextMapScreen.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/EditableTextSetScreen.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/MetaFeatureSettingsScreen.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/OverrideSettingsScreen.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/PreferencesInSettings.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/ResetOverrideSettingsDialog.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/SettingsPreference.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/ui/SettingsScreen.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/vm/AccessControlViewModel.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt (100%) rename ui/settings/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/settings/vm/OverrideSettingsViewModel.kt (100%) diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/api/HelpApi.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/api/HelpApi.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/api/HelpApi.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/api/HelpApi.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ProfilesNav.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ProfilesNav.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ProfilesNav.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ProfilesNav.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/di/ProfileModule.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/di/ProfileModule.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/di/ProfileModule.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/di/ProfileModule.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/model/ProfileProvider.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/model/ProfileProvider.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/model/ProfileProvider.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/model/ProfileProvider.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/FilesScreen.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/FilesScreen.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/FilesScreen.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/FilesScreen.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/NewProfileScreen.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/NewProfileScreen.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/NewProfileScreen.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/NewProfileScreen.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/PreferencesInProfiles.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/PreferencesInProfiles.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/PreferencesInProfiles.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/PreferencesInProfiles.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/ProfilesScreen.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/ProfilesScreen.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/ProfilesScreen.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/ProfilesScreen.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/PropertiesScreen.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/PropertiesScreen.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/PropertiesScreen.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/PropertiesScreen.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/ProvidersScreen.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/ProvidersScreen.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/ui/ProvidersScreen.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/ui/ProvidersScreen.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/NewProfileViewModel.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/NewProfileViewModel.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/NewProfileViewModel.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/NewProfileViewModel.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/ProfilesViewModel.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/ProfilesViewModel.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/ProfilesViewModel.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/ProfilesViewModel.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/PropertiesViewModel.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/PropertiesViewModel.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/PropertiesViewModel.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/PropertiesViewModel.kt diff --git a/ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/ProvidersViewModel.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/ProvidersViewModel.kt similarity index 100% rename from ui/profile/src/androidMain/kotlin/com/github/kr328/clash/profile/vm/ProvidersViewModel.kt rename to ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/ProvidersViewModel.kt diff --git a/ui/proxy/src/androidMain/kotlin/com/github/kr328/clash/proxy/ProxyNav.kt b/ui/proxy/src/commonMain/kotlin/com/github/kr328/clash/proxy/ProxyNav.kt similarity index 100% rename from ui/proxy/src/androidMain/kotlin/com/github/kr328/clash/proxy/ProxyNav.kt rename to ui/proxy/src/commonMain/kotlin/com/github/kr328/clash/proxy/ProxyNav.kt diff --git a/ui/proxy/src/androidMain/kotlin/com/github/kr328/clash/proxy/di/ProxyModule.kt b/ui/proxy/src/commonMain/kotlin/com/github/kr328/clash/proxy/di/ProxyModule.kt similarity index 100% rename from ui/proxy/src/androidMain/kotlin/com/github/kr328/clash/proxy/di/ProxyModule.kt rename to ui/proxy/src/commonMain/kotlin/com/github/kr328/clash/proxy/di/ProxyModule.kt diff --git a/ui/proxy/src/androidMain/kotlin/com/github/kr328/clash/proxy/ui/ProxyScreen.kt b/ui/proxy/src/commonMain/kotlin/com/github/kr328/clash/proxy/ui/ProxyScreen.kt similarity index 100% rename from ui/proxy/src/androidMain/kotlin/com/github/kr328/clash/proxy/ui/ProxyScreen.kt rename to ui/proxy/src/commonMain/kotlin/com/github/kr328/clash/proxy/ui/ProxyScreen.kt diff --git a/ui/proxy/src/androidMain/kotlin/com/github/kr328/clash/proxy/vm/ProxyViewModel.kt b/ui/proxy/src/commonMain/kotlin/com/github/kr328/clash/proxy/vm/ProxyViewModel.kt similarity index 100% rename from ui/proxy/src/androidMain/kotlin/com/github/kr328/clash/proxy/vm/ProxyViewModel.kt rename to ui/proxy/src/commonMain/kotlin/com/github/kr328/clash/proxy/vm/ProxyViewModel.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/SettingsNav.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/SettingsNav.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/SettingsNav.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/SettingsNav.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/di/SettingsModule.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/di/SettingsModule.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/di/SettingsModule.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/di/SettingsModule.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/AccessControlScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AccessControlScreen.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/AccessControlScreen.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AccessControlScreen.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/EditableTextMapScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/EditableTextMapScreen.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/EditableTextMapScreen.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/EditableTextMapScreen.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/EditableTextSetScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/EditableTextSetScreen.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/EditableTextSetScreen.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/EditableTextSetScreen.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/MetaFeatureSettingsScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/MetaFeatureSettingsScreen.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/MetaFeatureSettingsScreen.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/MetaFeatureSettingsScreen.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/OverrideSettingsScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/OverrideSettingsScreen.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/OverrideSettingsScreen.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/OverrideSettingsScreen.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/PreferencesInSettings.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/PreferencesInSettings.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/PreferencesInSettings.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/PreferencesInSettings.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/ResetOverrideSettingsDialog.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/ResetOverrideSettingsDialog.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/ResetOverrideSettingsDialog.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/ResetOverrideSettingsDialog.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/SettingsPreference.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/SettingsPreference.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/SettingsPreference.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/SettingsPreference.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/SettingsScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/SettingsScreen.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/ui/SettingsScreen.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/SettingsScreen.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/AccessControlViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AccessControlViewModel.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/AccessControlViewModel.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AccessControlViewModel.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt diff --git a/ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/OverrideSettingsViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/OverrideSettingsViewModel.kt similarity index 100% rename from ui/settings/src/androidMain/kotlin/com/github/kr328/clash/settings/vm/OverrideSettingsViewModel.kt rename to ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/OverrideSettingsViewModel.kt From 3965fe3da458073a775c36e79923fbf36dfaa8d0 Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 30 Jun 2026 08:59:01 +0800 Subject: [PATCH 04/21] Add jvm target --- build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 08e55b4efa..51e6a80566 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,6 +62,8 @@ allprojects { plugins.withId(rootProject.libs.plugins.android.multiplatform.get().pluginId) { plugins.apply(libs.plugins.kotlin.multiplatform.get().pluginId) extensions.configure { + jvm() + extensions.configure { namespace = "com.github.kr328.clash.${project.name}" compileSdk = 37 From 6183e7d58fce892c71804203e112592da90a054b Mon Sep 17 00:00:00 2001 From: Goooler Date: Tue, 30 Jun 2026 10:32:33 +0800 Subject: [PATCH 05/21] Revert "Move crash module files to commonMain" This reverts commit 1da382e24436f94627097e9e467c0fb63034bd86. --- .../kotlin/com/github/kr328/clash/crash/CrashNav.kt | 0 .../kotlin/com/github/kr328/clash/crash/di/CrashModule.kt | 0 .../kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt | 0 .../kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt | 0 .../kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename ui/crash/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/crash/CrashNav.kt (100%) rename ui/crash/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt (100%) rename ui/crash/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt (100%) rename ui/crash/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt (100%) rename ui/crash/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt (100%) diff --git a/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt similarity index 100% rename from ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt rename to ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt diff --git a/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt similarity index 100% rename from ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt rename to ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/di/CrashModule.kt diff --git a/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt similarity index 100% rename from ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt rename to ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt diff --git a/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt similarity index 100% rename from ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt rename to ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt diff --git a/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt similarity index 100% rename from ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt rename to ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt From 364dc8bd27ef1a808f01e353d64cdf05b9670be2 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 15:08:37 +0800 Subject: [PATCH 06/21] Don't share res for crash module --- .../kr328/clash/crash/ui/ApkBrokenScreen.kt | 16 ++++++---------- .../kr328/clash/crash/ui/AppCrashedScreen.kt | 7 +++---- .../res}/values-ja-rJP/strings.xml | 0 .../res}/values-ko-rKR/strings.xml | 0 .../res}/values-ru/strings.xml | 0 .../res}/values-vi/strings.xml | 0 .../res}/values-zh-rHK/strings.xml | 0 .../res}/values-zh-rTW/strings.xml | 0 .../res}/values-zh/strings.xml | 0 .../res}/values/strings.xml | 0 10 files changed, 9 insertions(+), 14 deletions(-) rename ui/crash/src/{commonMain/composeResources => androidMain/res}/values-ja-rJP/strings.xml (100%) rename ui/crash/src/{commonMain/composeResources => androidMain/res}/values-ko-rKR/strings.xml (100%) rename ui/crash/src/{commonMain/composeResources => androidMain/res}/values-ru/strings.xml (100%) rename ui/crash/src/{commonMain/composeResources => androidMain/res}/values-vi/strings.xml (100%) rename ui/crash/src/{commonMain/composeResources => androidMain/res}/values-zh-rHK/strings.xml (100%) rename ui/crash/src/{commonMain/composeResources => androidMain/res}/values-zh-rTW/strings.xml (100%) rename ui/crash/src/{commonMain/composeResources => androidMain/res}/values-zh/strings.xml (100%) rename ui/crash/src/{commonMain/composeResources => androidMain/res}/values/strings.xml (100%) diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt index 189cfd186d..8d13a7c923 100644 --- a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt +++ b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt @@ -7,12 +7,9 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewWrapper -import com.github.kr328.clash.crash.Res -import com.github.kr328.clash.crash.application_broken -import com.github.kr328.clash.crash.application_broken_tips -import com.github.kr328.clash.crash.github_releases -import com.github.kr328.clash.crash.reinstall +import com.github.kr328.clash.crash.R import com.github.kr328.clash.glue.util.TABBY_GITHUB import com.github.kr328.clash.glue.util.openLink import com.github.kr328.clash.ui.component.TabbyScaffold @@ -23,27 +20,26 @@ import com.github.kr328.clash.ui.theme.TabbyThemeWrapper import me.zhanghai.compose.preference.ProvidePreferenceLocals import me.zhanghai.compose.preference.preference import me.zhanghai.compose.preference.preferenceCategory -import org.jetbrains.compose.resources.stringResource @Composable internal fun ApkBrokenScreen() { - TabbyScaffold(title = stringResource(Res.string.application_broken)) { innerPadding -> + TabbyScaffold(title = stringResource(R.string.application_broken)) { innerPadding -> val context = LocalContext.current ProvidePreferenceLocals { LazyColumn(modifier = Modifier.fillMaxSize(), contentPadding = innerPadding) { preference( key = "tips", title = {}, - summary = { Text(stringResource(Res.string.application_broken_tips)) }, + summary = { Text(stringResource(R.string.application_broken_tips)) }, icon = { Icon(imageVector = TabbyIcons.OutlineInfo, contentDescription = null) }, ) preferenceCategory( key = "cat_reinstall", - title = { Text(stringResource(Res.string.reinstall)) }, + title = { Text(stringResource(R.string.reinstall)) }, ) preference( key = "github_releases", - title = { Text(stringResource(Res.string.github_releases)) }, + title = { Text(stringResource(R.string.github_releases)) }, summary = { Text(TABBY_GITHUB) }, onClick = { context.openLink(TABBY_GITHUB) }, ) diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt index 4c59270680..b799a0a1e5 100644 --- a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt +++ b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/AppCrashedScreen.kt @@ -10,16 +10,15 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewWrapper import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.github.kr328.clash.crash.Res -import com.github.kr328.clash.crash.application_crashed +import com.github.kr328.clash.crash.R import com.github.kr328.clash.crash.vm.AppCrashedViewModel import com.github.kr328.clash.ui.component.TabbyScaffold import com.github.kr328.clash.ui.theme.PreviewTabby import com.github.kr328.clash.ui.theme.TabbyThemeWrapper -import org.jetbrains.compose.resources.stringResource import org.koin.compose.viewmodel.koinViewModel @Composable @@ -34,7 +33,7 @@ internal fun AppCrashedScreen( @Composable private fun AppCrashedContent(modifier: Modifier = Modifier, logs: String) { - TabbyScaffold(modifier = modifier, title = stringResource(Res.string.application_crashed)) { + TabbyScaffold(modifier = modifier, title = stringResource(R.string.application_crashed)) { innerPadding -> SelectionContainer { Text( diff --git a/ui/crash/src/commonMain/composeResources/values-ja-rJP/strings.xml b/ui/crash/src/androidMain/res/values-ja-rJP/strings.xml similarity index 100% rename from ui/crash/src/commonMain/composeResources/values-ja-rJP/strings.xml rename to ui/crash/src/androidMain/res/values-ja-rJP/strings.xml diff --git a/ui/crash/src/commonMain/composeResources/values-ko-rKR/strings.xml b/ui/crash/src/androidMain/res/values-ko-rKR/strings.xml similarity index 100% rename from ui/crash/src/commonMain/composeResources/values-ko-rKR/strings.xml rename to ui/crash/src/androidMain/res/values-ko-rKR/strings.xml diff --git a/ui/crash/src/commonMain/composeResources/values-ru/strings.xml b/ui/crash/src/androidMain/res/values-ru/strings.xml similarity index 100% rename from ui/crash/src/commonMain/composeResources/values-ru/strings.xml rename to ui/crash/src/androidMain/res/values-ru/strings.xml diff --git a/ui/crash/src/commonMain/composeResources/values-vi/strings.xml b/ui/crash/src/androidMain/res/values-vi/strings.xml similarity index 100% rename from ui/crash/src/commonMain/composeResources/values-vi/strings.xml rename to ui/crash/src/androidMain/res/values-vi/strings.xml diff --git a/ui/crash/src/commonMain/composeResources/values-zh-rHK/strings.xml b/ui/crash/src/androidMain/res/values-zh-rHK/strings.xml similarity index 100% rename from ui/crash/src/commonMain/composeResources/values-zh-rHK/strings.xml rename to ui/crash/src/androidMain/res/values-zh-rHK/strings.xml diff --git a/ui/crash/src/commonMain/composeResources/values-zh-rTW/strings.xml b/ui/crash/src/androidMain/res/values-zh-rTW/strings.xml similarity index 100% rename from ui/crash/src/commonMain/composeResources/values-zh-rTW/strings.xml rename to ui/crash/src/androidMain/res/values-zh-rTW/strings.xml diff --git a/ui/crash/src/commonMain/composeResources/values-zh/strings.xml b/ui/crash/src/androidMain/res/values-zh/strings.xml similarity index 100% rename from ui/crash/src/commonMain/composeResources/values-zh/strings.xml rename to ui/crash/src/androidMain/res/values-zh/strings.xml diff --git a/ui/crash/src/commonMain/composeResources/values/strings.xml b/ui/crash/src/androidMain/res/values/strings.xml similarity index 100% rename from ui/crash/src/commonMain/composeResources/values/strings.xml rename to ui/crash/src/androidMain/res/values/strings.xml From e69216a5710c7be0470fcd29c5f0861bb5de8f37 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 15:12:14 +0800 Subject: [PATCH 07/21] Share CrashRoute and crashEntries --- .../kotlin/com/github/kr328/clash/crash/CrashNav.kt | 9 +-------- .../kotlin/com/github/kr328/clash/crash/CrashNav.kt | 13 +++++++++++++ .../kotlin/com/github/kr328/clash/crash/CrashNav.kt | 6 ++++++ 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt create mode 100644 ui/crash/src/jvmMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt index 6109dc6594..7638d71d10 100644 --- a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt +++ b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt @@ -4,15 +4,8 @@ import androidx.navigation3.runtime.EntryProviderScope import androidx.navigation3.runtime.NavKey import com.github.kr328.clash.crash.ui.ApkBrokenScreen import com.github.kr328.clash.crash.ui.AppCrashedScreen -import kotlinx.serialization.Serializable -sealed interface CrashRoute : NavKey { - @Serializable data object ApkBroken : CrashRoute - - @Serializable data object AppCrashed : CrashRoute -} - -fun EntryProviderScope.crashEntries() { +actual fun EntryProviderScope.crashEntries() { entry { ApkBrokenScreen() } entry { AppCrashedScreen() } } diff --git a/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt b/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt new file mode 100644 index 0000000000..4da6b61389 --- /dev/null +++ b/ui/crash/src/commonMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt @@ -0,0 +1,13 @@ +package com.github.kr328.clash.crash + +import androidx.navigation3.runtime.EntryProviderScope +import androidx.navigation3.runtime.NavKey +import kotlinx.serialization.Serializable + +sealed interface CrashRoute : NavKey { + @Serializable data object ApkBroken : CrashRoute + + @Serializable data object AppCrashed : CrashRoute +} + +expect fun EntryProviderScope.crashEntries() diff --git a/ui/crash/src/jvmMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt b/ui/crash/src/jvmMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt new file mode 100644 index 0000000000..02b02744e2 --- /dev/null +++ b/ui/crash/src/jvmMain/kotlin/com/github/kr328/clash/crash/CrashNav.kt @@ -0,0 +1,6 @@ +package com.github.kr328.clash.crash + +import androidx.navigation3.runtime.EntryProviderScope +import androidx.navigation3.runtime.NavKey + +actual fun EntryProviderScope.crashEntries() = Unit From 742b4796ef0f48edc2ca2c2f2023e157ceeeb3e0 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 15:28:59 +0800 Subject: [PATCH 08/21] Revert "Move shared models to core model module" This reverts commit 8084a64c9e285fc9bf3f230df5a32d23ef322adc. --- .../com/github/kr328/clash/app/MainActivity.kt | 2 +- .../github/kr328/clash/common}/model/DarkMode.kt | 2 +- core/build.gradle.kts | 2 -- core/model/build.gradle.kts | 16 ---------------- .../github/kr328/clash/core/model/AgeKeyPair.kt | 0 .../github/kr328/clash/core/model/ProxySort.kt | 0 glue/build.gradle.kts | 1 - .../com/github/kr328/clash/glue/store/UiStore.kt | 2 +- service/build.gradle.kts | 2 -- .../clash/service}/model/AccessControlMode.kt | 2 +- .../kr328/clash/service/store/ServiceStore.kt | 2 +- settings.gradle.kts | 1 - ui/build.gradle.kts | 1 - .../kr328/clash/settings/ui/AppSettingsScreen.kt | 2 +- .../clash/settings/ui/NetworkSettingsScreen.kt | 2 +- .../clash/settings/vm/AppSettingsViewModel.kt | 2 +- .../settings/vm/NetworkSettingsViewModel.kt | 2 +- .../com/github/kr328/clash/ui/theme/Theme.kt | 2 +- 18 files changed, 10 insertions(+), 33 deletions(-) rename {core/model/src/commonMain/kotlin/com/github/kr328/clash/core => common/src/commonMain/kotlin/com/github/kr328/clash/common}/model/DarkMode.kt (57%) delete mode 100644 core/model/build.gradle.kts rename core/{model/src/commonMain => src/main}/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt (100%) rename core/{model/src/commonMain => src/main}/kotlin/com/github/kr328/clash/core/model/ProxySort.kt (100%) rename {core/model/src/commonMain/kotlin/com/github/kr328/clash/core => service/src/main/kotlin/com/github/kr328/clash/service}/model/AccessControlMode.kt (64%) diff --git a/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainActivity.kt b/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainActivity.kt index c2822a94b2..bf5d49c8e1 100644 --- a/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainActivity.kt +++ b/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainActivity.kt @@ -38,9 +38,9 @@ import androidx.lifecycle.viewModelScope import androidx.navigation3.runtime.NavKey import androidx.navigation3.runtime.entryProvider import com.github.kr328.clash.common.constants.Intents +import com.github.kr328.clash.common.model.DarkMode import com.github.kr328.clash.common.util.mainIntent import com.github.kr328.clash.common.util.uuid -import com.github.kr328.clash.core.model.DarkMode import com.github.kr328.clash.crash.CrashRoute import com.github.kr328.clash.crash.crashEntries import com.github.kr328.clash.glue.remote.Remote diff --git a/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/DarkMode.kt b/common/src/commonMain/kotlin/com/github/kr328/clash/common/model/DarkMode.kt similarity index 57% rename from core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/DarkMode.kt rename to common/src/commonMain/kotlin/com/github/kr328/clash/common/model/DarkMode.kt index 4a976c8cdb..399462945f 100644 --- a/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/DarkMode.kt +++ b/common/src/commonMain/kotlin/com/github/kr328/clash/common/model/DarkMode.kt @@ -1,4 +1,4 @@ -package com.github.kr328.clash.core.model +package com.github.kr328.clash.common.model enum class DarkMode { Auto, diff --git a/core/build.gradle.kts b/core/build.gradle.kts index e78a89475c..bba4105a2e 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -25,8 +25,6 @@ android { } dependencies { - implementation(projects.core.model) - implementation(projects.common) implementation(libs.androidx.core) diff --git a/core/model/build.gradle.kts b/core/model/build.gradle.kts deleted file mode 100644 index 5ffd06e8af..0000000000 --- a/core/model/build.gradle.kts +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - alias(libs.plugins.android.multiplatform) - alias(libs.plugins.kotlin.serialization) -} - -kotlin { - android { - namespace = "com.github.kr328.clash.core.model" - } - - sourceSets { - commonMain.dependencies { - api(libs.kotlin.serialization.json) - } - } -} diff --git a/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt b/core/src/main/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt similarity index 100% rename from core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt rename to core/src/main/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt diff --git a/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/ProxySort.kt b/core/src/main/kotlin/com/github/kr328/clash/core/model/ProxySort.kt similarity index 100% rename from core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/ProxySort.kt rename to core/src/main/kotlin/com/github/kr328/clash/core/model/ProxySort.kt diff --git a/glue/build.gradle.kts b/glue/build.gradle.kts index e7260016fd..8105634858 100644 --- a/glue/build.gradle.kts +++ b/glue/build.gradle.kts @@ -4,7 +4,6 @@ plugins { dependencies { api(projects.core) - api(projects.core.model) api(projects.service) api(projects.common) diff --git a/glue/src/main/kotlin/com/github/kr328/clash/glue/store/UiStore.kt b/glue/src/main/kotlin/com/github/kr328/clash/glue/store/UiStore.kt index ecc6166d21..f9baf83dac 100644 --- a/glue/src/main/kotlin/com/github/kr328/clash/glue/store/UiStore.kt +++ b/glue/src/main/kotlin/com/github/kr328/clash/glue/store/UiStore.kt @@ -5,9 +5,9 @@ import android.content.Context import android.content.SharedPreferences.OnSharedPreferenceChangeListener import android.content.pm.PackageManager import com.github.kr328.clash.common.di.AppInfoProvider +import com.github.kr328.clash.common.model.DarkMode import com.github.kr328.clash.common.store.Store import com.github.kr328.clash.common.store.asStoreProvider -import com.github.kr328.clash.core.model.DarkMode import com.github.kr328.clash.core.model.ProxySort import com.github.kr328.clash.glue.model.AppInfo import kotlin.LazyThreadSafetyMode.NONE diff --git a/service/build.gradle.kts b/service/build.gradle.kts index d67339fd50..f71b6c5b67 100644 --- a/service/build.gradle.kts +++ b/service/build.gradle.kts @@ -6,8 +6,6 @@ plugins { } dependencies { - implementation(projects.core.model) - implementation(projects.core) implementation(projects.common) diff --git a/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AccessControlMode.kt b/service/src/main/kotlin/com/github/kr328/clash/service/model/AccessControlMode.kt similarity index 64% rename from core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AccessControlMode.kt rename to service/src/main/kotlin/com/github/kr328/clash/service/model/AccessControlMode.kt index 57838e1953..26f95776f8 100644 --- a/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AccessControlMode.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/model/AccessControlMode.kt @@ -1,4 +1,4 @@ -package com.github.kr328.clash.core.model +package com.github.kr328.clash.service.model enum class AccessControlMode { AcceptAll, diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/store/ServiceStore.kt b/service/src/main/kotlin/com/github/kr328/clash/service/store/ServiceStore.kt index d6a8c65d94..b6bc870cb6 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/store/ServiceStore.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/store/ServiceStore.kt @@ -3,8 +3,8 @@ package com.github.kr328.clash.service.store import android.content.Context import com.github.kr328.clash.common.store.Store import com.github.kr328.clash.common.store.asStoreProvider -import com.github.kr328.clash.core.model.AccessControlMode import com.github.kr328.clash.service.PreferenceProvider +import com.github.kr328.clash.service.model.AccessControlMode import kotlin.uuid.Uuid class ServiceStore(context: Context) { diff --git a/settings.gradle.kts b/settings.gradle.kts index 8ecbfadaa7..3afff15feb 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -51,7 +51,6 @@ enableFeaturePreview("STABLE_CONFIGURATION_CACHE") include( ":androidApp", ":core", - ":core:model", ":service", ":common", ":glue", diff --git a/ui/build.gradle.kts b/ui/build.gradle.kts index 403c56cafd..d48e49cf82 100644 --- a/ui/build.gradle.kts +++ b/ui/build.gradle.kts @@ -5,7 +5,6 @@ plugins { kotlin { sourceSets { commonMain.dependencies { - implementation(projects.core.model) implementation(projects.common) } } diff --git a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt index c7b7205cd1..1f554c4582 100644 --- a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt +++ b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt @@ -10,7 +10,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.tooling.preview.PreviewWrapper import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.github.kr328.clash.core.model.DarkMode +import com.github.kr328.clash.common.model.DarkMode import com.github.kr328.clash.settings.Res import com.github.kr328.clash.settings.allow_tabby_auto_restart import com.github.kr328.clash.settings.always_dark diff --git a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt index 982666cd7b..2ffd4182a9 100644 --- a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt +++ b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.tooling.preview.PreviewWrapper import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.github.kr328.clash.core.model.AccessControlMode +import com.github.kr328.clash.service.model.AccessControlMode import com.github.kr328.clash.settings.Res import com.github.kr328.clash.settings.access_control_mode import com.github.kr328.clash.settings.access_control_packages diff --git a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt index 03cf837880..1888d68543 100644 --- a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt +++ b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt @@ -4,8 +4,8 @@ import android.app.Application import android.content.pm.PackageManager import androidx.lifecycle.ViewModel import com.github.kr328.clash.common.di.AppInfoProvider +import com.github.kr328.clash.common.model.DarkMode import com.github.kr328.clash.common.util.componentName -import com.github.kr328.clash.core.model.DarkMode import com.github.kr328.clash.glue.remote.Remote import com.github.kr328.clash.glue.store.UiStore import com.github.kr328.clash.glue.util.ApplicationObserver diff --git a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt index 8811178388..bcec61ddd7 100644 --- a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt +++ b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt @@ -3,9 +3,9 @@ package com.github.kr328.clash.settings.vm import android.app.Application import android.os.Build import androidx.lifecycle.ViewModel -import com.github.kr328.clash.core.model.AccessControlMode import com.github.kr328.clash.glue.remote.Remote import com.github.kr328.clash.glue.store.UiStore +import com.github.kr328.clash.service.model.AccessControlMode import com.github.kr328.clash.service.store.ServiceStore import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow diff --git a/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt index 0df95c6a57..b08352f704 100644 --- a/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt +++ b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewWrapperProvider import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import com.github.kr328.clash.core.model.DarkMode +import com.github.kr328.clash.common.model.DarkMode private val DarkColorScheme = darkColorScheme( From 1830a21581591b9f3b08da65e58c0c8f6884bb9a Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 15:32:59 +0800 Subject: [PATCH 09/21] Add projects.common into implementation --- build.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 51e6a80566..f95fc64fd8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -74,6 +74,9 @@ allprojects { extensions.configure> { commonMain.dependencies { + if (project.path != projects.common.path) { + implementation(projects.common) + } implementation(libs.jetbrains.compose.ui) implementation(libs.jetbrains.compose.uiTooling) implementation(libs.jetbrains.compose.uiToolingPreview) From 79894c4c96b20e94857e51c8dc6ea2ba40b6c7bc Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 15:40:50 +0800 Subject: [PATCH 10/21] Move links --- common/build.gradle.kts | 1 + .../com/github/kr328/clash/common/util/Context.kt | 9 +++++++++ .../com/github/kr328/clash/common}/util/Links.kt | 10 +--------- glue/build.gradle.kts | 1 - .../com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt | 4 ++-- .../kotlin/com/github/kr328/clash/home/api/HelpApi.kt | 2 +- .../com/github/kr328/clash/home/ui/HelpScreen.kt | 8 ++++---- .../com/github/kr328/clash/home/vm/HelpViewModel.kt | 2 +- 8 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Context.kt rename {glue/src/main/kotlin/com/github/kr328/clash/glue => common/src/commonMain/kotlin/com/github/kr328/clash/common}/util/Links.kt (51%) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index d790d2fe2a..1aceba1f9f 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -11,6 +11,7 @@ kotlin { } androidMain.dependencies { implementation(libs.androidx.core) + implementation(libs.androidx.browser) } } } diff --git a/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Context.kt b/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Context.kt new file mode 100644 index 0000000000..6fcba7c37b --- /dev/null +++ b/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Context.kt @@ -0,0 +1,9 @@ +package com.github.kr328.clash.common.util + +import android.content.Context +import androidx.browser.customtabs.CustomTabsIntent +import androidx.core.net.toUri + +fun Context.openLink(link: String) { + CustomTabsIntent.Builder().build().launchUrl(this, link.toUri()) +} diff --git a/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Links.kt b/common/src/commonMain/kotlin/com/github/kr328/clash/common/util/Links.kt similarity index 51% rename from glue/src/main/kotlin/com/github/kr328/clash/glue/util/Links.kt rename to common/src/commonMain/kotlin/com/github/kr328/clash/common/util/Links.kt index 142f7a163f..643f760c09 100644 --- a/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Links.kt +++ b/common/src/commonMain/kotlin/com/github/kr328/clash/common/util/Links.kt @@ -1,15 +1,7 @@ -package com.github.kr328.clash.glue.util - -import android.content.Context -import androidx.browser.customtabs.CustomTabsIntent -import androidx.core.net.toUri +package com.github.kr328.clash.common.util const val MIHOMO_CORE = "https://github.com/MetaCubeX/mihomo" const val MIHOMO_WIKI = "https://wiki.metacubex.one/" const val TABBY_REPO = "Goooler/Tabby" const val TABBY_GITHUB = "https://github.com/$TABBY_REPO" const val TABBY_RELEASES_LATEST = "$TABBY_GITHUB/releases/latest" - -fun Context.openLink(link: String) { - CustomTabsIntent.Builder().build().launchUrl(this, link.toUri()) -} diff --git a/glue/build.gradle.kts b/glue/build.gradle.kts index 8105634858..192c451dec 100644 --- a/glue/build.gradle.kts +++ b/glue/build.gradle.kts @@ -8,6 +8,5 @@ dependencies { api(projects.common) implementation(libs.kotlin.coroutine) - implementation(libs.androidx.browser) implementation(libs.androidx.core) } diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt index 8d13a7c923..b04a010862 100644 --- a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt +++ b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/ui/ApkBrokenScreen.kt @@ -9,9 +9,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewWrapper +import com.github.kr328.clash.common.util.TABBY_GITHUB +import com.github.kr328.clash.common.util.openLink import com.github.kr328.clash.crash.R -import com.github.kr328.clash.glue.util.TABBY_GITHUB -import com.github.kr328.clash.glue.util.openLink import com.github.kr328.clash.ui.component.TabbyScaffold import com.github.kr328.clash.ui.icon.OutlineInfo import com.github.kr328.clash.ui.icon.TabbyIcons diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/api/HelpApi.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/api/HelpApi.kt index 3bb076d20e..c94f7feba6 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/api/HelpApi.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/api/HelpApi.kt @@ -1,6 +1,6 @@ package com.github.kr328.clash.home.api -import com.github.kr328.clash.glue.util.TABBY_REPO +import com.github.kr328.clash.common.util.TABBY_REPO import io.ktor.client.HttpClient import io.ktor.client.call.body import io.ktor.client.engine.cio.CIO diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt index 9de87f2ac7..18ca3484eb 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt @@ -30,10 +30,10 @@ import com.github.kr328.clash.common.R as CommonR import com.github.kr328.clash.common.Res as CommonRes import com.github.kr328.clash.common.copied import com.github.kr328.clash.common.tabby -import com.github.kr328.clash.glue.util.MIHOMO_CORE -import com.github.kr328.clash.glue.util.MIHOMO_WIKI -import com.github.kr328.clash.glue.util.TABBY_GITHUB -import com.github.kr328.clash.glue.util.openLink +import com.github.kr328.clash.common.util.MIHOMO_CORE +import com.github.kr328.clash.common.util.MIHOMO_WIKI +import com.github.kr328.clash.common.util.TABBY_GITHUB +import com.github.kr328.clash.common.util.openLink import com.github.kr328.clash.home.Res import com.github.kr328.clash.home.about import com.github.kr328.clash.home.app_version diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt index 21f8af7736..de3fbd07b6 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt @@ -5,8 +5,8 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.github.kr328.clash.common.di.AppInfoProvider import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.TABBY_RELEASES_LATEST import com.github.kr328.clash.core.bridge.Bridge -import com.github.kr328.clash.glue.util.TABBY_RELEASES_LATEST import com.github.kr328.clash.home.Res import com.github.kr328.clash.home.already_up_to_date import com.github.kr328.clash.home.api.HelpApi From e6241f97fa2a4d432aaec71a04fe37ff8649b328 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 15:55:26 +0800 Subject: [PATCH 11/21] Share AppInfoProvider and ComponentName --- .../kotlin/com/github/kr328/clash/app/di/AppModule.kt | 2 ++ build.gradle.kts | 2 +- .../com/github/kr328/clash/common/model/ComponentName.kt | 3 +++ .../com/github/kr328/clash/common/di/AppInfoProvider.kt | 3 ++- .../com/github/kr328/clash/common/model/ComponentName.kt | 3 +++ .../com/github/kr328/clash/common/model/ComponentName.kt | 3 +++ .../com/github/kr328/clash/home/vm/HelpViewModel.kt | 8 +++----- 7 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 common/src/androidMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt rename common/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/common/di/AppInfoProvider.kt (85%) create mode 100644 common/src/commonMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt create mode 100644 common/src/jvmMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt diff --git a/androidApp/src/main/kotlin/com/github/kr328/clash/app/di/AppModule.kt b/androidApp/src/main/kotlin/com/github/kr328/clash/app/di/AppModule.kt index b6f93fc465..c4ccf22874 100644 --- a/androidApp/src/main/kotlin/com/github/kr328/clash/app/di/AppModule.kt +++ b/androidApp/src/main/kotlin/com/github/kr328/clash/app/di/AppModule.kt @@ -23,6 +23,8 @@ val appModule = module { } private class AppInfoProviderImpl(application: Application) : AppInfoProvider { + override val versionName: String = + checkNotNull(application.packageManager.getPackageInfo(application.packageName, 0).versionName) override val packageName: String = application.packageName override val buildCommit: String = BuildConfig.COMMIT override val receiveBroadcastsPermission: String = "${packageName}.permission.RECEIVE_BROADCASTS" diff --git a/build.gradle.kts b/build.gradle.kts index f95fc64fd8..535c20ca07 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -46,7 +46,7 @@ allprojects { compilerOptions { allWarningsAsErrors = true jvmTarget = JvmTarget.fromTarget(libs.versions.jvmTarget.get()) - freeCompilerArgs.addAll("-Xcontext-sensitive-resolution") + freeCompilerArgs.addAll("-Xcontext-sensitive-resolution", "-Xexpect-actual-classes") } } diff --git a/common/src/androidMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt b/common/src/androidMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt new file mode 100644 index 0000000000..8af9495e6c --- /dev/null +++ b/common/src/androidMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt @@ -0,0 +1,3 @@ +package com.github.kr328.clash.common.model + +actual typealias ComponentName = android.content.ComponentName diff --git a/common/src/androidMain/kotlin/com/github/kr328/clash/common/di/AppInfoProvider.kt b/common/src/commonMain/kotlin/com/github/kr328/clash/common/di/AppInfoProvider.kt similarity index 85% rename from common/src/androidMain/kotlin/com/github/kr328/clash/common/di/AppInfoProvider.kt rename to common/src/commonMain/kotlin/com/github/kr328/clash/common/di/AppInfoProvider.kt index 6db11c6cd3..5831f72213 100644 --- a/common/src/androidMain/kotlin/com/github/kr328/clash/common/di/AppInfoProvider.kt +++ b/common/src/commonMain/kotlin/com/github/kr328/clash/common/di/AppInfoProvider.kt @@ -1,11 +1,12 @@ package com.github.kr328.clash.common.di -import android.content.ComponentName +import com.github.kr328.clash.common.model.ComponentName import kotlin.reflect.KClass import org.koin.core.component.KoinComponent import org.koin.core.component.get interface AppInfoProvider { + val versionName: String val packageName: String val buildCommit: String val receiveBroadcastsPermission: String diff --git a/common/src/commonMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt b/common/src/commonMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt new file mode 100644 index 0000000000..43552d7601 --- /dev/null +++ b/common/src/commonMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt @@ -0,0 +1,3 @@ +package com.github.kr328.clash.common.model + +expect class ComponentName diff --git a/common/src/jvmMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt b/common/src/jvmMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt new file mode 100644 index 0000000000..01c2a5a199 --- /dev/null +++ b/common/src/jvmMain/kotlin/com/github/kr328/clash/common/model/ComponentName.kt @@ -0,0 +1,3 @@ +package com.github.kr328.clash.common.model + +actual class ComponentName diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt index de3fbd07b6..41a858b60f 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt @@ -51,9 +51,7 @@ internal class HelpViewModel( return@launch } - val localVersion = - application.packageManager.getPackageInfo(application.packageName, 0).versionName ?: "" - if (SemVer.parse(latestTag) > SemVer.parse(localVersion)) { + if (SemVer.parse(latestTag) > SemVer.parse(appInfoProvider.versionName)) { eventState.update { EventState.UpdateAvailable(TABBY_RELEASES_LATEST) } } else { eventState.update { @@ -79,8 +77,8 @@ internal class HelpViewModel( viewModelScope.launch { val (appVersion, coreVersion) = withContext(Dispatchers.IO) { - val pkgInfo = application.packageManager.getPackageInfo(application.packageName, 0) - "${pkgInfo.versionName} - ${appInfoProvider.buildCommit}" to Bridge.nativeCoreVersion() + "${appInfoProvider.versionName} - ${appInfoProvider.buildCommit}" to + Bridge.nativeCoreVersion() } uiState.update { it.copy(appVersion = appVersion, coreVersion = coreVersion) } From 7267f79d1c2711f5b05019717b10ced80cb30a4f Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:00:29 +0800 Subject: [PATCH 12/21] Share nativeCoreVersion --- .../kotlin/com/github/kr328/clash/home/util/CoreVersion.kt | 5 +++++ .../kotlin/com/github/kr328/clash/home/util/CoreVersion.kt | 3 +++ .../kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt | 5 ++--- .../kotlin/com/github/kr328/clash/home/util/CoreVersion.kt | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt create mode 100644 ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt create mode 100644 ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt new file mode 100644 index 0000000000..5478c7a5fd --- /dev/null +++ b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt @@ -0,0 +1,5 @@ +package com.github.kr328.clash.home.util + +import com.github.kr328.clash.core.bridge.Bridge + +actual val nativeCoreVersion: String = Bridge.nativeCoreVersion() diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt new file mode 100644 index 0000000000..27166d5f14 --- /dev/null +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt @@ -0,0 +1,3 @@ +package com.github.kr328.clash.home.util + +expect val nativeCoreVersion: String diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt index 41a858b60f..b51916659f 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt @@ -6,11 +6,11 @@ import androidx.lifecycle.viewModelScope import com.github.kr328.clash.common.di.AppInfoProvider import com.github.kr328.clash.common.log.Log import com.github.kr328.clash.common.util.TABBY_RELEASES_LATEST -import com.github.kr328.clash.core.bridge.Bridge import com.github.kr328.clash.home.Res import com.github.kr328.clash.home.already_up_to_date import com.github.kr328.clash.home.api.HelpApi import com.github.kr328.clash.home.check_update_failed +import com.github.kr328.clash.home.util.nativeCoreVersion import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow @@ -77,8 +77,7 @@ internal class HelpViewModel( viewModelScope.launch { val (appVersion, coreVersion) = withContext(Dispatchers.IO) { - "${appInfoProvider.versionName} - ${appInfoProvider.buildCommit}" to - Bridge.nativeCoreVersion() + "${appInfoProvider.versionName} - ${appInfoProvider.buildCommit}" to nativeCoreVersion } uiState.update { it.copy(appVersion = appVersion, coreVersion = coreVersion) } diff --git a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt new file mode 100644 index 0000000000..d5e7191b94 --- /dev/null +++ b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/util/CoreVersion.kt @@ -0,0 +1,3 @@ +package com.github.kr328.clash.home.util + +actual val nativeCoreVersion: String = "Undefined" From 5d7a505296a71c051bfda5d438bc5f5b1a6eb5fd Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:07:10 +0800 Subject: [PATCH 13/21] Share Log --- .../github/kr328/clash/app/MainApplication.kt | 2 +- .../com/github/kr328/clash/common/log/Log.kt | 17 ----------- .../com/github/kr328/clash/common/util/Log.kt | 29 +++++++++++++++++++ .../github/kr328/clash/common/util/Ticker.kt | 1 - .../com/github/kr328/clash/common/util/Log.kt | 15 ++++++++++ .../com/github/kr328/clash/common/util/Log.kt | 17 +++++++++++ .../com/github/kr328/clash/core/Clash.kt | 2 +- .../github/kr328/clash/core/bridge/Bridge.kt | 2 +- .../kr328/clash/glue/remote/Broadcasts.kt | 2 +- .../github/kr328/clash/glue/remote/Remote.kt | 2 +- .../github/kr328/clash/glue/remote/Service.kt | 2 +- .../kr328/clash/glue/remote/StatusClient.kt | 2 +- .../kr328/clash/glue/util/Application.kt | 2 +- .../github/kr328/clash/glue/util/Remote.kt | 2 +- .../kr328/clash/service/ClashManager.kt | 2 +- .../kr328/clash/service/ClashService.kt | 2 +- .../kr328/clash/service/FilesProvider.kt | 2 +- .../kr328/clash/service/ProfileProcessor.kt | 2 +- .../kr328/clash/service/ProfileReceiver.kt | 2 +- .../kr328/clash/service/ProfileWorker.kt | 2 +- .../github/kr328/clash/service/TunService.kt | 2 +- .../kr328/clash/service/clash/ClashRuntime.kt | 2 +- .../clash/module/AppListCacheModule.kt | 2 +- .../clash/service/clash/module/CloseModule.kt | 2 +- .../clash/module/ConfigurationModule.kt | 2 +- .../clash/service/clash/module/Module.kt | 2 +- .../clash/module/NetworkObserveModule.kt | 2 +- .../service/clash/module/SuspendModule.kt | 2 +- .../clash/crash/vm/AppCrashedViewModel.kt | 2 +- .../kr328/clash/home/vm/HelpViewModel.kt | 2 +- .../kr328/clash/home/vm/HomeViewModel.kt | 2 +- .../github/kr328/clash/log/LogcatService.kt | 2 +- .../kr328/clash/log/vm/LogcatViewModel.kt | 2 +- .../kr328/clash/profile/vm/FilesViewModel.kt | 2 +- .../clash/profile/vm/NewProfileViewModel.kt | 2 +- .../clash/profile/vm/PropertiesViewModel.kt | 2 +- .../clash/profile/vm/ProvidersViewModel.kt | 2 +- .../vm/MetaFeatureSettingsViewModel.kt | 2 +- 38 files changed, 94 insertions(+), 51 deletions(-) delete mode 100644 common/src/androidMain/kotlin/com/github/kr328/clash/common/log/Log.kt create mode 100644 common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Log.kt create mode 100644 common/src/commonMain/kotlin/com/github/kr328/clash/common/util/Log.kt create mode 100644 common/src/jvmMain/kotlin/com/github/kr328/clash/common/util/Log.kt diff --git a/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainApplication.kt b/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainApplication.kt index cea6fad429..733a63e99d 100644 --- a/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainApplication.kt +++ b/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainApplication.kt @@ -3,7 +3,7 @@ package com.github.kr328.clash.app import android.app.Application import android.content.Context import com.github.kr328.clash.app.di.appModule -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.crash.di.crashModule import com.github.kr328.clash.glue.remote.Remote import com.github.kr328.clash.glue.util.clashDir diff --git a/common/src/androidMain/kotlin/com/github/kr328/clash/common/log/Log.kt b/common/src/androidMain/kotlin/com/github/kr328/clash/common/log/Log.kt deleted file mode 100644 index c35aad2328..0000000000 --- a/common/src/androidMain/kotlin/com/github/kr328/clash/common/log/Log.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.kr328.clash.common.log - -object Log { - private const val TAG = "Tabby" - - fun i(message: String, throwable: Throwable? = null) = android.util.Log.i(TAG, message, throwable) - - fun w(message: String, throwable: Throwable? = null) = android.util.Log.w(TAG, message, throwable) - - fun e(message: String, throwable: Throwable? = null) = android.util.Log.e(TAG, message, throwable) - - fun d(message: String, throwable: Throwable? = null) = android.util.Log.d(TAG, message, throwable) - - fun v(message: String, throwable: Throwable? = null) = android.util.Log.v(TAG, message, throwable) - - fun f(message: String, throwable: Throwable) = android.util.Log.wtf(message, throwable) -} diff --git a/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Log.kt b/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Log.kt new file mode 100644 index 0000000000..86965e5b03 --- /dev/null +++ b/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Log.kt @@ -0,0 +1,29 @@ +package com.github.kr328.clash.common.util + +actual object Log { + private const val TAG = "Tabby" + + actual fun i(message: String, throwable: Throwable?) { + android.util.Log.i(TAG, message, throwable) + } + + actual fun w(message: String, throwable: Throwable?) { + android.util.Log.w(TAG, message, throwable) + } + + actual fun e(message: String, throwable: Throwable?) { + android.util.Log.e(TAG, message, throwable) + } + + actual fun d(message: String, throwable: Throwable?) { + android.util.Log.d(TAG, message, throwable) + } + + actual fun v(message: String, throwable: Throwable?) { + android.util.Log.v(TAG, message, throwable) + } + + actual fun f(message: String, throwable: Throwable) { + android.util.Log.wtf(message, throwable) + } +} diff --git a/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Ticker.kt b/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Ticker.kt index ddcd96eb1e..43f328e0e1 100644 --- a/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Ticker.kt +++ b/common/src/androidMain/kotlin/com/github/kr328/clash/common/util/Ticker.kt @@ -1,6 +1,5 @@ package com.github.kr328.clash.common.util -import com.github.kr328.clash.common.log.Log import kotlin.time.Duration import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope diff --git a/common/src/commonMain/kotlin/com/github/kr328/clash/common/util/Log.kt b/common/src/commonMain/kotlin/com/github/kr328/clash/common/util/Log.kt new file mode 100644 index 0000000000..c20b10f17c --- /dev/null +++ b/common/src/commonMain/kotlin/com/github/kr328/clash/common/util/Log.kt @@ -0,0 +1,15 @@ +package com.github.kr328.clash.common.util + +expect object Log { + fun i(message: String, throwable: Throwable? = null) + + fun w(message: String, throwable: Throwable? = null) + + fun e(message: String, throwable: Throwable? = null) + + fun d(message: String, throwable: Throwable? = null) + + fun v(message: String, throwable: Throwable? = null) + + fun f(message: String, throwable: Throwable) +} diff --git a/common/src/jvmMain/kotlin/com/github/kr328/clash/common/util/Log.kt b/common/src/jvmMain/kotlin/com/github/kr328/clash/common/util/Log.kt new file mode 100644 index 0000000000..f938a0210d --- /dev/null +++ b/common/src/jvmMain/kotlin/com/github/kr328/clash/common/util/Log.kt @@ -0,0 +1,17 @@ +package com.github.kr328.clash.common.util + +actual object Log { + private const val TAG = "Tabby" + + actual fun i(message: String, throwable: Throwable?) {} + + actual fun w(message: String, throwable: Throwable?) {} + + actual fun e(message: String, throwable: Throwable?) {} + + actual fun d(message: String, throwable: Throwable?) {} + + actual fun v(message: String, throwable: Throwable?) {} + + actual fun f(message: String, throwable: Throwable) {} +} diff --git a/core/src/main/kotlin/com/github/kr328/clash/core/Clash.kt b/core/src/main/kotlin/com/github/kr328/clash/core/Clash.kt index 022a248d1f..48096484d8 100644 --- a/core/src/main/kotlin/com/github/kr328/clash/core/Clash.kt +++ b/core/src/main/kotlin/com/github/kr328/clash/core/Clash.kt @@ -1,6 +1,6 @@ package com.github.kr328.clash.core -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.bridge.Bridge import com.github.kr328.clash.core.bridge.ClashException import com.github.kr328.clash.core.bridge.FetchCallback diff --git a/core/src/main/kotlin/com/github/kr328/clash/core/bridge/Bridge.kt b/core/src/main/kotlin/com/github/kr328/clash/core/bridge/Bridge.kt index 85e49d3819..f85527e6eb 100644 --- a/core/src/main/kotlin/com/github/kr328/clash/core/bridge/Bridge.kt +++ b/core/src/main/kotlin/com/github/kr328/clash/core/bridge/Bridge.kt @@ -3,7 +3,7 @@ package com.github.kr328.clash.core.bridge import android.os.Build import android.os.ParcelFileDescriptor import androidx.annotation.Keep -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.application import java.io.File import kotlinx.coroutines.CompletableDeferred diff --git a/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Broadcasts.kt b/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Broadcasts.kt index 09245bf566..b40c4e29c6 100644 --- a/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Broadcasts.kt +++ b/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Broadcasts.kt @@ -7,7 +7,7 @@ import android.content.Intent import android.content.IntentFilter import com.github.kr328.clash.common.compat.registerReceiverCompat import com.github.kr328.clash.common.constants.Intents -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.getSerializableCompat import kotlin.uuid.Uuid import kotlinx.coroutines.flow.MutableSharedFlow diff --git a/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Remote.kt b/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Remote.kt index c89589cfe7..1132909749 100644 --- a/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Remote.kt +++ b/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Remote.kt @@ -4,7 +4,7 @@ import android.app.Application import android.content.Context import android.content.Intent import com.github.kr328.clash.common.constants.Intents -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.mainIntent import com.github.kr328.clash.glue.store.AppStore import com.github.kr328.clash.glue.util.ApplicationObserver diff --git a/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Service.kt b/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Service.kt index 37bbae72b4..45e1e4d657 100644 --- a/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Service.kt +++ b/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/Service.kt @@ -5,7 +5,7 @@ import android.content.ComponentName import android.content.Context import android.content.ServiceConnection import android.os.IBinder -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.intent import com.github.kr328.clash.glue.util.unbindServiceSilent import com.github.kr328.clash.service.RemoteService diff --git a/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/StatusClient.kt b/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/StatusClient.kt index 34358dd9c8..669607eca8 100644 --- a/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/StatusClient.kt +++ b/glue/src/main/kotlin/com/github/kr328/clash/glue/remote/StatusClient.kt @@ -3,7 +3,7 @@ package com.github.kr328.clash.glue.remote import android.content.Context import android.net.Uri import com.github.kr328.clash.common.constants.Authorities -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.service.StatusProvider class StatusClient(private val context: Context) { diff --git a/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Application.kt b/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Application.kt index d4337ea21b..7ae22e8bec 100644 --- a/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Application.kt +++ b/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Application.kt @@ -5,7 +5,7 @@ import android.app.Application import android.content.Context import android.os.Build import android.os.Bundle -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import java.io.File import java.util.zip.ZipFile diff --git a/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Remote.kt b/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Remote.kt index f59559368b..ab9de7255d 100644 --- a/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Remote.kt +++ b/glue/src/main/kotlin/com/github/kr328/clash/glue/util/Remote.kt @@ -1,7 +1,7 @@ package com.github.kr328.clash.glue.util import android.os.DeadObjectException -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.glue.remote.Remote import com.github.kr328.clash.service.remote.IClashManager import com.github.kr328.clash.service.remote.IProfileManager diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/ClashManager.kt b/service/src/main/kotlin/com/github/kr328/clash/service/ClashManager.kt index 3f280e7ac2..8977499bca 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/ClashManager.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/ClashManager.kt @@ -1,7 +1,7 @@ package com.github.kr328.clash.service import android.content.Context -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.Clash import com.github.kr328.clash.core.model.ConfigurationOverride import com.github.kr328.clash.core.model.LogMessage diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/ClashService.kt b/service/src/main/kotlin/com/github/kr328/clash/service/ClashService.kt index 77bd757d01..89ee654d94 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/ClashService.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/ClashService.kt @@ -3,7 +3,7 @@ package com.github.kr328.clash.service import android.content.Intent import android.os.Binder import android.os.IBinder -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.service.clash.clashRuntime import com.github.kr328.clash.service.clash.module.AppListCacheModule import com.github.kr328.clash.service.clash.module.CloseModule diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/FilesProvider.kt b/service/src/main/kotlin/com/github/kr328/clash/service/FilesProvider.kt index ee8ae09908..2fd3f9cb1c 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/FilesProvider.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/FilesProvider.kt @@ -8,7 +8,7 @@ import android.provider.DocumentsContract.Document as D import android.provider.DocumentsContract.Root import android.provider.DocumentsProvider import com.github.kr328.clash.common.R as CommonR -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.PatternFileName import com.github.kr328.clash.service.document.Document import com.github.kr328.clash.service.document.FileDocument diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/ProfileProcessor.kt b/service/src/main/kotlin/com/github/kr328/clash/service/ProfileProcessor.kt index 4aa4e78ce4..277f8ad180 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/ProfileProcessor.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/ProfileProcessor.kt @@ -2,7 +2,7 @@ package com.github.kr328.clash.service import android.content.Context import androidx.core.net.toUri -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.Clash import com.github.kr328.clash.core.model.FetchStatus import com.github.kr328.clash.service.data.Imported diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/ProfileReceiver.kt b/service/src/main/kotlin/com/github/kr328/clash/service/ProfileReceiver.kt index 2f94050668..49b9c4e4e9 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/ProfileReceiver.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/ProfileReceiver.kt @@ -8,7 +8,7 @@ import android.content.Intent import androidx.core.content.getSystemService import com.github.kr328.clash.common.compat.pendingIntentFlags import com.github.kr328.clash.common.constants.Intents -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.componentName import com.github.kr328.clash.common.util.setUUID import com.github.kr328.clash.service.data.Imported diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/ProfileWorker.kt b/service/src/main/kotlin/com/github/kr328/clash/service/ProfileWorker.kt index 914162a5f9..ef955ab5d8 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/ProfileWorker.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/ProfileWorker.kt @@ -13,7 +13,7 @@ import com.github.kr328.clash.common.compat.pendingIntentFlags import com.github.kr328.clash.common.compat.startForegroundCompat import com.github.kr328.clash.common.constants.Intents import com.github.kr328.clash.common.id.UndefinedIds -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.mainIntent import com.github.kr328.clash.common.util.setUUID import com.github.kr328.clash.common.util.uuid diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/TunService.kt b/service/src/main/kotlin/com/github/kr328/clash/service/TunService.kt index 35e2a99a31..e029b102c7 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/TunService.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/TunService.kt @@ -6,7 +6,7 @@ import android.net.ProxyInfo import android.net.VpnService import android.os.Build import com.github.kr328.clash.common.compat.pendingIntentFlags -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.mainIntent import com.github.kr328.clash.service.clash.clashRuntime import com.github.kr328.clash.service.clash.module.AppListCacheModule diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/clash/ClashRuntime.kt b/service/src/main/kotlin/com/github/kr328/clash/service/clash/ClashRuntime.kt index b3d4133e3e..ffb5f15dcd 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/clash/ClashRuntime.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/clash/ClashRuntime.kt @@ -1,6 +1,6 @@ package com.github.kr328.clash.service.clash -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.Clash import com.github.kr328.clash.service.clash.module.Module import kotlinx.coroutines.CoroutineScope diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt index 1c52b3f4fb..99b57d2741 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/AppListCacheModule.kt @@ -4,7 +4,7 @@ import android.app.Service import android.content.Intent import android.content.pm.PackageInfo import com.github.kr328.clash.common.compat.getInstalledPackagesCompat -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.Clash import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.channels.Channel diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/CloseModule.kt b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/CloseModule.kt index 239e731ac5..4e58332559 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/CloseModule.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/CloseModule.kt @@ -2,7 +2,7 @@ package com.github.kr328.clash.service.clash.module import android.app.Service import com.github.kr328.clash.common.constants.Intents -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log class CloseModule(service: Service) : Module(service) { object RequestClose diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/ConfigurationModule.kt b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/ConfigurationModule.kt index 4171b6c5b4..3a8e2917c1 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/ConfigurationModule.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/ConfigurationModule.kt @@ -2,7 +2,7 @@ package com.github.kr328.clash.service.clash.module import android.app.Service import com.github.kr328.clash.common.constants.Intents -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.getSerializableCompat import com.github.kr328.clash.core.Clash import com.github.kr328.clash.service.StatusProvider diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/Module.kt b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/Module.kt index 91cd8fbf5a..ec699c1e25 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/Module.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/Module.kt @@ -7,7 +7,7 @@ import android.content.Intent import android.content.IntentFilter import com.github.kr328.clash.common.compat.registerReceiverCompat import com.github.kr328.clash.common.di.AppInfoProvider.Companion.appInfoProvider -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.ReceiveChannel diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt index 4c3d8fadac..3cd5d6ce20 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/NetworkObserveModule.kt @@ -8,7 +8,7 @@ import android.net.NetworkCapabilities import android.net.NetworkRequest import android.os.Build import androidx.core.content.getSystemService -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.Clash import com.github.kr328.clash.service.util.asSocketAddressText import java.net.InetAddress diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/SuspendModule.kt b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/SuspendModule.kt index 6184029044..b61bd3edfa 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/SuspendModule.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/clash/module/SuspendModule.kt @@ -4,7 +4,7 @@ import android.app.Service import android.content.Intent import android.os.PowerManager import androidx.core.content.getSystemService -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.Clash import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.channels.Channel diff --git a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt index 06eda3ffb4..7e48dc3d74 100644 --- a/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt +++ b/ui/crash/src/androidMain/kotlin/com/github/kr328/clash/crash/vm/AppCrashedViewModel.kt @@ -3,7 +3,7 @@ package com.github.kr328.clash.crash.vm import android.app.Application import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt index b51916659f..0e8aae3073 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt @@ -4,7 +4,7 @@ import android.app.Application import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.github.kr328.clash.common.di.AppInfoProvider -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.TABBY_RELEASES_LATEST import com.github.kr328.clash.home.Res import com.github.kr328.clash.home.already_up_to_date diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt index 285d4f8e12..bdf965d228 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt @@ -9,9 +9,9 @@ import androidx.lifecycle.viewModelScope import com.github.kr328.clash.common.Res as CommonRes import com.github.kr328.clash.common.direct_mode import com.github.kr328.clash.common.global_mode -import com.github.kr328.clash.common.log.Log import com.github.kr328.clash.common.rule_mode import com.github.kr328.clash.common.unable_to_start_vpn +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.model.Traffic import com.github.kr328.clash.core.model.TunnelState import com.github.kr328.clash.core.util.trafficTotal diff --git a/ui/log/src/androidMain/kotlin/com/github/kr328/clash/log/LogcatService.kt b/ui/log/src/androidMain/kotlin/com/github/kr328/clash/log/LogcatService.kt index a1c7a54fd4..4bcc4bc563 100644 --- a/ui/log/src/androidMain/kotlin/com/github/kr328/clash/log/LogcatService.kt +++ b/ui/log/src/androidMain/kotlin/com/github/kr328/clash/log/LogcatService.kt @@ -17,8 +17,8 @@ import com.github.kr328.clash.common.compat.getColorCompat import com.github.kr328.clash.common.compat.pendingIntentFlags import com.github.kr328.clash.common.compat.startForegroundCompat import com.github.kr328.clash.common.constants.Intents -import com.github.kr328.clash.common.log.Log import com.github.kr328.clash.common.running +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.intent import com.github.kr328.clash.common.util.mainIntent import com.github.kr328.clash.core.model.LogMessage diff --git a/ui/log/src/androidMain/kotlin/com/github/kr328/clash/log/vm/LogcatViewModel.kt b/ui/log/src/androidMain/kotlin/com/github/kr328/clash/log/vm/LogcatViewModel.kt index 5df186125a..50d970139f 100644 --- a/ui/log/src/androidMain/kotlin/com/github/kr328/clash/log/vm/LogcatViewModel.kt +++ b/ui/log/src/androidMain/kotlin/com/github/kr328/clash/log/vm/LogcatViewModel.kt @@ -11,8 +11,8 @@ import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.github.kr328.clash.common.Res as CommonRes -import com.github.kr328.clash.common.log.Log import com.github.kr328.clash.common.unknown +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.common.util.intent import com.github.kr328.clash.core.model.LogMessage import com.github.kr328.clash.glue.util.logsDir diff --git a/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt index 0dff4ec5eb..e3f66ffaeb 100644 --- a/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt +++ b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/FilesViewModel.kt @@ -6,7 +6,7 @@ import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.glue.model.ConfigFile import com.github.kr328.clash.glue.remote.FilesClient import com.github.kr328.clash.glue.util.fileName diff --git a/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/NewProfileViewModel.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/NewProfileViewModel.kt index ea644e6fe1..c7deb3dcc5 100644 --- a/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/NewProfileViewModel.kt +++ b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/NewProfileViewModel.kt @@ -8,9 +8,9 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.github.kr328.clash.common.Res as CommonRes import com.github.kr328.clash.common.constants.Intents -import com.github.kr328.clash.common.log.Log import com.github.kr328.clash.common.new_profile import com.github.kr328.clash.common.unknown +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.glue.util.withProfile import com.github.kr328.clash.profile.Res import com.github.kr328.clash.profile.import_from_qr_exception diff --git a/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/PropertiesViewModel.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/PropertiesViewModel.kt index d7b33ae1dc..222376e742 100644 --- a/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/PropertiesViewModel.kt +++ b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/PropertiesViewModel.kt @@ -6,8 +6,8 @@ import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.github.kr328.clash.common.Res as CommonRes -import com.github.kr328.clash.common.log.Log import com.github.kr328.clash.common.unknown +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.model.FetchStatus import com.github.kr328.clash.glue.util.withProfile import com.github.kr328.clash.profile.Res diff --git a/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/ProvidersViewModel.kt b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/ProvidersViewModel.kt index daeb94b655..9138ab2785 100644 --- a/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/ProvidersViewModel.kt +++ b/ui/profile/src/commonMain/kotlin/com/github/kr328/clash/profile/vm/ProvidersViewModel.kt @@ -5,7 +5,7 @@ import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.model.Provider import com.github.kr328.clash.glue.remote.Remote import com.github.kr328.clash.glue.util.withClash diff --git a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt index ead5b6e127..cc0108e3b3 100644 --- a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt +++ b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/MetaFeatureSettingsViewModel.kt @@ -8,7 +8,7 @@ import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.github.kr328.clash.common.log.Log +import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.Clash import com.github.kr328.clash.core.model.ConfigurationOverride import com.github.kr328.clash.glue.util.clashDir From d136d6050fa370fdfb5ca95d37cdf0e795ae3b80 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:23:46 +0800 Subject: [PATCH 14/21] Separate home navigation by platform --- .../com/github/kr328/clash/home/HomeNav.kt | 27 +++++++++++++++++++ .../github/kr328/clash/home/di/HomeModule.kt | 0 .../github/kr328/clash/home/ui/HelpScreen.kt | 0 .../github/kr328/clash/home/ui/HomeScreen.kt | 0 .../kr328/clash/home/vm/HelpViewModel.kt | 0 .../kr328/clash/home/vm/HomeViewModel.kt | 0 .../com/github/kr328/clash/home/HomeNav.kt | 18 ++----------- .../com/github/kr328/clash/home/HomeNav.kt | 13 +++++++++ 8 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt rename ui/home/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/home/di/HomeModule.kt (100%) rename ui/home/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt (100%) rename ui/home/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt (100%) rename ui/home/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt (100%) rename ui/home/src/{commonMain => androidMain}/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt (100%) create mode 100644 ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/HomeNav.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt new file mode 100644 index 0000000000..39f0138598 --- /dev/null +++ b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt @@ -0,0 +1,27 @@ +package com.github.kr328.clash.home + +import androidx.navigation3.runtime.EntryProviderScope +import androidx.navigation3.runtime.NavKey +import com.github.kr328.clash.home.ui.HelpScreen +import com.github.kr328.clash.home.ui.HomeScreen + +actual fun EntryProviderScope.homeEntries( + onOpenProxy: () -> Unit, + onOpenProfiles: () -> Unit, + onOpenProviders: () -> Unit, + onOpenLogs: () -> Unit, + onOpenSettings: () -> Unit, + onOpenHelp: () -> Unit, +) { + entry { + HomeScreen( + onOpenProxy = onOpenProxy, + onOpenProfiles = onOpenProfiles, + onOpenProviders = onOpenProviders, + onOpenLogs = onOpenLogs, + onOpenSettings = onOpenSettings, + onOpenHelp = onOpenHelp, + ) + } + entry { HelpScreen() } +} diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt similarity index 100% rename from ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt rename to ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt similarity index 100% rename from ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt rename to ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt similarity index 100% rename from ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt rename to ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt similarity index 100% rename from ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt rename to ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt similarity index 100% rename from ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt rename to ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt index 92ba554e62..8f3659a97a 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt @@ -2,8 +2,6 @@ package com.github.kr328.clash.home import androidx.navigation3.runtime.EntryProviderScope import androidx.navigation3.runtime.NavKey -import com.github.kr328.clash.home.ui.HelpScreen -import com.github.kr328.clash.home.ui.HomeScreen import kotlinx.serialization.Serializable sealed interface HomeRoute : NavKey { @@ -12,23 +10,11 @@ sealed interface HomeRoute : NavKey { @Serializable data object Help : HomeRoute } -fun EntryProviderScope.homeEntries( +expect fun EntryProviderScope.homeEntries( onOpenProxy: () -> Unit, onOpenProfiles: () -> Unit, onOpenProviders: () -> Unit, onOpenLogs: () -> Unit, onOpenSettings: () -> Unit, onOpenHelp: () -> Unit, -) { - entry { - HomeScreen( - onOpenProxy = onOpenProxy, - onOpenProfiles = onOpenProfiles, - onOpenProviders = onOpenProviders, - onOpenLogs = onOpenLogs, - onOpenSettings = onOpenSettings, - onOpenHelp = onOpenHelp, - ) - } - entry { HelpScreen() } -} +) diff --git a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/HomeNav.kt b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/HomeNav.kt new file mode 100644 index 0000000000..6537aa8ca3 --- /dev/null +++ b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/HomeNav.kt @@ -0,0 +1,13 @@ +package com.github.kr328.clash.home + +import androidx.navigation3.runtime.EntryProviderScope +import androidx.navigation3.runtime.NavKey + +actual fun EntryProviderScope.homeEntries( + onOpenProxy: () -> Unit, + onOpenProfiles: () -> Unit, + onOpenProviders: () -> Unit, + onOpenLogs: () -> Unit, + onOpenSettings: () -> Unit, + onOpenHelp: () -> Unit, +) = Unit From 02c74b67753d65f4a153dcf608c24d23b8a9abfd Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:24:44 +0800 Subject: [PATCH 15/21] Revert "Separate home navigation by platform" This reverts commit befdbac07149baea1d3ca951e8043a875d3d1423. --- .../com/github/kr328/clash/home/HomeNav.kt | 27 ------------------- .../com/github/kr328/clash/home/HomeNav.kt | 18 +++++++++++-- .../github/kr328/clash/home/di/HomeModule.kt | 0 .../github/kr328/clash/home/ui/HelpScreen.kt | 0 .../github/kr328/clash/home/ui/HomeScreen.kt | 0 .../kr328/clash/home/vm/HelpViewModel.kt | 0 .../kr328/clash/home/vm/HomeViewModel.kt | 0 .../com/github/kr328/clash/home/HomeNav.kt | 13 --------- 8 files changed, 16 insertions(+), 42 deletions(-) delete mode 100644 ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/di/HomeModule.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt (100%) rename ui/home/src/{androidMain => commonMain}/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt (100%) delete mode 100644 ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/HomeNav.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt deleted file mode 100644 index 39f0138598..0000000000 --- a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/HomeNav.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.github.kr328.clash.home - -import androidx.navigation3.runtime.EntryProviderScope -import androidx.navigation3.runtime.NavKey -import com.github.kr328.clash.home.ui.HelpScreen -import com.github.kr328.clash.home.ui.HomeScreen - -actual fun EntryProviderScope.homeEntries( - onOpenProxy: () -> Unit, - onOpenProfiles: () -> Unit, - onOpenProviders: () -> Unit, - onOpenLogs: () -> Unit, - onOpenSettings: () -> Unit, - onOpenHelp: () -> Unit, -) { - entry { - HomeScreen( - onOpenProxy = onOpenProxy, - onOpenProfiles = onOpenProfiles, - onOpenProviders = onOpenProviders, - onOpenLogs = onOpenLogs, - onOpenSettings = onOpenSettings, - onOpenHelp = onOpenHelp, - ) - } - entry { HelpScreen() } -} diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt index 8f3659a97a..92ba554e62 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/HomeNav.kt @@ -2,6 +2,8 @@ package com.github.kr328.clash.home import androidx.navigation3.runtime.EntryProviderScope import androidx.navigation3.runtime.NavKey +import com.github.kr328.clash.home.ui.HelpScreen +import com.github.kr328.clash.home.ui.HomeScreen import kotlinx.serialization.Serializable sealed interface HomeRoute : NavKey { @@ -10,11 +12,23 @@ sealed interface HomeRoute : NavKey { @Serializable data object Help : HomeRoute } -expect fun EntryProviderScope.homeEntries( +fun EntryProviderScope.homeEntries( onOpenProxy: () -> Unit, onOpenProfiles: () -> Unit, onOpenProviders: () -> Unit, onOpenLogs: () -> Unit, onOpenSettings: () -> Unit, onOpenHelp: () -> Unit, -) +) { + entry { + HomeScreen( + onOpenProxy = onOpenProxy, + onOpenProfiles = onOpenProfiles, + onOpenProviders = onOpenProviders, + onOpenLogs = onOpenLogs, + onOpenSettings = onOpenSettings, + onOpenHelp = onOpenHelp, + ) + } + entry { HelpScreen() } +} diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/di/HomeModule.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HelpScreen.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt similarity index 100% rename from ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt rename to ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt diff --git a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/HomeNav.kt b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/HomeNav.kt deleted file mode 100644 index 6537aa8ca3..0000000000 --- a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/HomeNav.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.kr328.clash.home - -import androidx.navigation3.runtime.EntryProviderScope -import androidx.navigation3.runtime.NavKey - -actual fun EntryProviderScope.homeEntries( - onOpenProxy: () -> Unit, - onOpenProfiles: () -> Unit, - onOpenProviders: () -> Unit, - onOpenLogs: () -> Unit, - onOpenSettings: () -> Unit, - onOpenHelp: () -> Unit, -) = Unit From b3f68ce855f9542b79422bc0097306ae29aaf47a Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:26:21 +0800 Subject: [PATCH 16/21] Remove Application from HelpViewModel --- .../kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt index 0e8aae3073..1b9bdfd559 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HelpViewModel.kt @@ -1,6 +1,5 @@ package com.github.kr328.clash.home.vm -import android.app.Application import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.github.kr328.clash.common.di.AppInfoProvider @@ -20,10 +19,7 @@ import kotlinx.coroutines.withContext import net.swiftzer.semver.SemVer import org.jetbrains.compose.resources.getString -internal class HelpViewModel( - private val application: Application, - private val appInfoProvider: AppInfoProvider, -) : ViewModel() { +internal class HelpViewModel(private val appInfoProvider: AppInfoProvider) : ViewModel() { private val api = HelpApi() val uiState: StateFlow From c7f760684ed5d92adef3ef0f8e300719bec87bba Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:35:37 +0800 Subject: [PATCH 17/21] Abstract VPN permission launcher --- .../clash/home/ui/VpnPermissionLauncher.kt | 19 +++++++++++++++++++ .../github/kr328/clash/home/ui/HomeScreen.kt | 17 +++++++---------- .../clash/home/ui/VpnPermissionLauncher.kt | 10 ++++++++++ .../kr328/clash/home/vm/HomeViewModel.kt | 9 +++++---- .../clash/home/ui/VpnPermissionLauncher.kt | 8 ++++++++ .../kr328/clash/home/vm/HomeViewModelTest.kt | 4 ++-- 6 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt create mode 100644 ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt create mode 100644 ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt new file mode 100644 index 0000000000..38771f5c41 --- /dev/null +++ b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt @@ -0,0 +1,19 @@ +package com.github.kr328.clash.home.ui + +import android.app.Activity +import android.content.Intent +import androidx.activity.compose.rememberLauncherForActivityResult +import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult +import androidx.compose.runtime.Composable + +@Composable +internal actual fun rememberVpnPermissionLauncher( + onResult: (granted: Boolean) -> Unit +): (VpnPermissionRequest) -> Unit { + val launcher = + rememberLauncherForActivityResult(StartActivityForResult()) { result -> + onResult(result.resultCode == Activity.RESULT_OK) + } + + return { request -> launcher.launch(request.value as Intent) } +} diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt index eec9079560..a87556733b 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt @@ -1,8 +1,5 @@ package com.github.kr328.clash.home.ui -import android.app.Activity -import androidx.activity.compose.rememberLauncherForActivityResult -import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult import androidx.compose.animation.AnimatedVisibility import androidx.compose.foundation.Image import androidx.compose.foundation.clickable @@ -97,18 +94,18 @@ internal fun HomeScreen( val noProfileText = stringResource(Res.string.no_profile_selected) val profilesActionText = stringResource(CommonRes.string.profiles) - val vpnLauncher = - rememberLauncherForActivityResult(StartActivityForResult()) { result -> - when (result.resultCode) { - Activity.RESULT_OK -> viewModel.onVpnPermissionGranted() - else -> viewModel.onVpnPermissionDenied() - } + val vpnLauncher = rememberVpnPermissionLauncher { granted -> + if (granted) { + viewModel.onVpnPermissionGranted() + } else { + viewModel.onVpnPermissionDenied() } + } LaunchedEffect(eventState) { when (val event = eventState) { Idle -> Unit - is RequestVpnPermission -> vpnLauncher.launch(event.intent) + is RequestVpnPermission -> vpnLauncher(event.request) ShowNoProfileMessage -> { val result = snackbarHostState.showSnackbar( diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt new file mode 100644 index 0000000000..6e27ffb0c0 --- /dev/null +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt @@ -0,0 +1,10 @@ +package com.github.kr328.clash.home.ui + +import androidx.compose.runtime.Composable + +internal class VpnPermissionRequest(internal val value: Any) + +@Composable +internal expect fun rememberVpnPermissionLauncher( + onResult: (granted: Boolean) -> Unit +): (VpnPermissionRequest) -> Unit diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt index bdf965d228..293c4edfaf 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt @@ -1,7 +1,6 @@ package com.github.kr328.clash.home.vm import android.app.Application -import android.content.Intent import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModel @@ -21,6 +20,7 @@ import com.github.kr328.clash.glue.util.startClashService import com.github.kr328.clash.glue.util.stopClashService import com.github.kr328.clash.glue.util.withClash import com.github.kr328.clash.glue.util.withProfile +import com.github.kr328.clash.home.ui.VpnPermissionRequest import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.Job import kotlinx.coroutines.delay @@ -238,7 +238,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : sealed interface EventState { data object Idle : EventState - data class RequestVpnPermission(val intent: Intent) : EventState + data class RequestVpnPermission(val request: VpnPermissionRequest) : EventState data object ShowNoProfileMessage : EventState @@ -266,7 +266,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : suspend fun unableToStartVpnText(): String - fun startClashService(): Intent? + fun startClashService(): VpnPermissionRequest? fun stopClashService() } @@ -302,7 +302,8 @@ internal class AndroidDependencies(private val application: Application) : return getString(CommonRes.string.unable_to_start_vpn) } - override fun startClashService(): Intent? = application.startClashService() + override fun startClashService(): VpnPermissionRequest? = + application.startClashService()?.let(::VpnPermissionRequest) override fun stopClashService() { application.stopClashService() diff --git a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt new file mode 100644 index 0000000000..7dc292ae3b --- /dev/null +++ b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt @@ -0,0 +1,8 @@ +package com.github.kr328.clash.home.ui + +import androidx.compose.runtime.Composable + +@Composable +internal actual fun rememberVpnPermissionLauncher( + onResult: (granted: Boolean) -> Unit +): (VpnPermissionRequest) -> Unit = {} diff --git a/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt b/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt index a25f2ab712..2c76de331e 100644 --- a/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt +++ b/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt @@ -1,6 +1,5 @@ package com.github.kr328.clash.home.vm -import android.content.Intent import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry import assertk.assertThat @@ -9,6 +8,7 @@ import assertk.assertions.isNull import com.github.kr328.clash.core.model.Traffic import com.github.kr328.clash.core.model.TunnelState import com.github.kr328.clash.glue.remote.Broadcasts +import com.github.kr328.clash.home.ui.VpnPermissionRequest import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -214,7 +214,7 @@ class HomeViewModelTest : KoinComponent { override fun unableToStartVpnText(): String = "Unable to start VPN" - override fun startClashService(): Intent? = null + override fun startClashService(): VpnPermissionRequest? = null override fun stopClashService() = Unit } From ced3843bd65b91d5895319f1f7966ef982501842 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:37:36 +0800 Subject: [PATCH 18/21] Revert "Revert "Move shared models to core model module"" This reverts commit 280f5955 --- .../com/github/kr328/clash/app/MainActivity.kt | 2 +- core/build.gradle.kts | 2 ++ core/model/build.gradle.kts | 16 ++++++++++++++++ .../kr328/clash/core}/model/AccessControlMode.kt | 2 +- .../github/kr328/clash/core/model/AgeKeyPair.kt | 0 .../github/kr328/clash/core}/model/DarkMode.kt | 2 +- .../github/kr328/clash/core/model/ProxySort.kt | 0 glue/build.gradle.kts | 1 + .../com/github/kr328/clash/glue/store/UiStore.kt | 2 +- service/build.gradle.kts | 2 ++ .../kr328/clash/service/store/ServiceStore.kt | 2 +- settings.gradle.kts | 1 + ui/build.gradle.kts | 1 + .../kr328/clash/settings/ui/AppSettingsScreen.kt | 2 +- .../clash/settings/ui/NetworkSettingsScreen.kt | 2 +- .../clash/settings/vm/AppSettingsViewModel.kt | 2 +- .../settings/vm/NetworkSettingsViewModel.kt | 2 +- .../com/github/kr328/clash/ui/theme/Theme.kt | 2 +- 18 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 core/model/build.gradle.kts rename {service/src/main/kotlin/com/github/kr328/clash/service => core/model/src/commonMain/kotlin/com/github/kr328/clash/core}/model/AccessControlMode.kt (64%) rename core/{src/main => model/src/commonMain}/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt (100%) rename {common/src/commonMain/kotlin/com/github/kr328/clash/common => core/model/src/commonMain/kotlin/com/github/kr328/clash/core}/model/DarkMode.kt (57%) rename core/{src/main => model/src/commonMain}/kotlin/com/github/kr328/clash/core/model/ProxySort.kt (100%) diff --git a/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainActivity.kt b/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainActivity.kt index bf5d49c8e1..c2822a94b2 100644 --- a/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainActivity.kt +++ b/androidApp/src/main/kotlin/com/github/kr328/clash/app/MainActivity.kt @@ -38,9 +38,9 @@ import androidx.lifecycle.viewModelScope import androidx.navigation3.runtime.NavKey import androidx.navigation3.runtime.entryProvider import com.github.kr328.clash.common.constants.Intents -import com.github.kr328.clash.common.model.DarkMode import com.github.kr328.clash.common.util.mainIntent import com.github.kr328.clash.common.util.uuid +import com.github.kr328.clash.core.model.DarkMode import com.github.kr328.clash.crash.CrashRoute import com.github.kr328.clash.crash.crashEntries import com.github.kr328.clash.glue.remote.Remote diff --git a/core/build.gradle.kts b/core/build.gradle.kts index bba4105a2e..e78a89475c 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -25,6 +25,8 @@ android { } dependencies { + implementation(projects.core.model) + implementation(projects.common) implementation(libs.androidx.core) diff --git a/core/model/build.gradle.kts b/core/model/build.gradle.kts new file mode 100644 index 0000000000..5ffd06e8af --- /dev/null +++ b/core/model/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + alias(libs.plugins.android.multiplatform) + alias(libs.plugins.kotlin.serialization) +} + +kotlin { + android { + namespace = "com.github.kr328.clash.core.model" + } + + sourceSets { + commonMain.dependencies { + api(libs.kotlin.serialization.json) + } + } +} diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/model/AccessControlMode.kt b/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AccessControlMode.kt similarity index 64% rename from service/src/main/kotlin/com/github/kr328/clash/service/model/AccessControlMode.kt rename to core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AccessControlMode.kt index 26f95776f8..57838e1953 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/model/AccessControlMode.kt +++ b/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AccessControlMode.kt @@ -1,4 +1,4 @@ -package com.github.kr328.clash.service.model +package com.github.kr328.clash.core.model enum class AccessControlMode { AcceptAll, diff --git a/core/src/main/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt b/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt similarity index 100% rename from core/src/main/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt rename to core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/AgeKeyPair.kt diff --git a/common/src/commonMain/kotlin/com/github/kr328/clash/common/model/DarkMode.kt b/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/DarkMode.kt similarity index 57% rename from common/src/commonMain/kotlin/com/github/kr328/clash/common/model/DarkMode.kt rename to core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/DarkMode.kt index 399462945f..4a976c8cdb 100644 --- a/common/src/commonMain/kotlin/com/github/kr328/clash/common/model/DarkMode.kt +++ b/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/DarkMode.kt @@ -1,4 +1,4 @@ -package com.github.kr328.clash.common.model +package com.github.kr328.clash.core.model enum class DarkMode { Auto, diff --git a/core/src/main/kotlin/com/github/kr328/clash/core/model/ProxySort.kt b/core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/ProxySort.kt similarity index 100% rename from core/src/main/kotlin/com/github/kr328/clash/core/model/ProxySort.kt rename to core/model/src/commonMain/kotlin/com/github/kr328/clash/core/model/ProxySort.kt diff --git a/glue/build.gradle.kts b/glue/build.gradle.kts index 192c451dec..9d31600414 100644 --- a/glue/build.gradle.kts +++ b/glue/build.gradle.kts @@ -4,6 +4,7 @@ plugins { dependencies { api(projects.core) + api(projects.core.model) api(projects.service) api(projects.common) diff --git a/glue/src/main/kotlin/com/github/kr328/clash/glue/store/UiStore.kt b/glue/src/main/kotlin/com/github/kr328/clash/glue/store/UiStore.kt index f9baf83dac..ecc6166d21 100644 --- a/glue/src/main/kotlin/com/github/kr328/clash/glue/store/UiStore.kt +++ b/glue/src/main/kotlin/com/github/kr328/clash/glue/store/UiStore.kt @@ -5,9 +5,9 @@ import android.content.Context import android.content.SharedPreferences.OnSharedPreferenceChangeListener import android.content.pm.PackageManager import com.github.kr328.clash.common.di.AppInfoProvider -import com.github.kr328.clash.common.model.DarkMode import com.github.kr328.clash.common.store.Store import com.github.kr328.clash.common.store.asStoreProvider +import com.github.kr328.clash.core.model.DarkMode import com.github.kr328.clash.core.model.ProxySort import com.github.kr328.clash.glue.model.AppInfo import kotlin.LazyThreadSafetyMode.NONE diff --git a/service/build.gradle.kts b/service/build.gradle.kts index f71b6c5b67..d67339fd50 100644 --- a/service/build.gradle.kts +++ b/service/build.gradle.kts @@ -6,6 +6,8 @@ plugins { } dependencies { + implementation(projects.core.model) + implementation(projects.core) implementation(projects.common) diff --git a/service/src/main/kotlin/com/github/kr328/clash/service/store/ServiceStore.kt b/service/src/main/kotlin/com/github/kr328/clash/service/store/ServiceStore.kt index b6bc870cb6..d6a8c65d94 100644 --- a/service/src/main/kotlin/com/github/kr328/clash/service/store/ServiceStore.kt +++ b/service/src/main/kotlin/com/github/kr328/clash/service/store/ServiceStore.kt @@ -3,8 +3,8 @@ package com.github.kr328.clash.service.store import android.content.Context import com.github.kr328.clash.common.store.Store import com.github.kr328.clash.common.store.asStoreProvider +import com.github.kr328.clash.core.model.AccessControlMode import com.github.kr328.clash.service.PreferenceProvider -import com.github.kr328.clash.service.model.AccessControlMode import kotlin.uuid.Uuid class ServiceStore(context: Context) { diff --git a/settings.gradle.kts b/settings.gradle.kts index 3afff15feb..8ecbfadaa7 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -51,6 +51,7 @@ enableFeaturePreview("STABLE_CONFIGURATION_CACHE") include( ":androidApp", ":core", + ":core:model", ":service", ":common", ":glue", diff --git a/ui/build.gradle.kts b/ui/build.gradle.kts index d48e49cf82..403c56cafd 100644 --- a/ui/build.gradle.kts +++ b/ui/build.gradle.kts @@ -5,6 +5,7 @@ plugins { kotlin { sourceSets { commonMain.dependencies { + implementation(projects.core.model) implementation(projects.common) } } diff --git a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt index 1f554c4582..c7b7205cd1 100644 --- a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt +++ b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/AppSettingsScreen.kt @@ -10,7 +10,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.tooling.preview.PreviewWrapper import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.github.kr328.clash.common.model.DarkMode +import com.github.kr328.clash.core.model.DarkMode import com.github.kr328.clash.settings.Res import com.github.kr328.clash.settings.allow_tabby_auto_restart import com.github.kr328.clash.settings.always_dark diff --git a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt index 2ffd4182a9..982666cd7b 100644 --- a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt +++ b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/ui/NetworkSettingsScreen.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.tooling.preview.PreviewWrapper import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.github.kr328.clash.service.model.AccessControlMode +import com.github.kr328.clash.core.model.AccessControlMode import com.github.kr328.clash.settings.Res import com.github.kr328.clash.settings.access_control_mode import com.github.kr328.clash.settings.access_control_packages diff --git a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt index 1888d68543..03cf837880 100644 --- a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt +++ b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/AppSettingsViewModel.kt @@ -4,8 +4,8 @@ import android.app.Application import android.content.pm.PackageManager import androidx.lifecycle.ViewModel import com.github.kr328.clash.common.di.AppInfoProvider -import com.github.kr328.clash.common.model.DarkMode import com.github.kr328.clash.common.util.componentName +import com.github.kr328.clash.core.model.DarkMode import com.github.kr328.clash.glue.remote.Remote import com.github.kr328.clash.glue.store.UiStore import com.github.kr328.clash.glue.util.ApplicationObserver diff --git a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt index bcec61ddd7..8811178388 100644 --- a/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt +++ b/ui/settings/src/commonMain/kotlin/com/github/kr328/clash/settings/vm/NetworkSettingsViewModel.kt @@ -3,9 +3,9 @@ package com.github.kr328.clash.settings.vm import android.app.Application import android.os.Build import androidx.lifecycle.ViewModel +import com.github.kr328.clash.core.model.AccessControlMode import com.github.kr328.clash.glue.remote.Remote import com.github.kr328.clash.glue.store.UiStore -import com.github.kr328.clash.service.model.AccessControlMode import com.github.kr328.clash.service.store.ServiceStore import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow diff --git a/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt index b08352f704..0df95c6a57 100644 --- a/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt +++ b/ui/src/commonMain/kotlin/com/github/kr328/clash/ui/theme/Theme.kt @@ -14,7 +14,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewWrapperProvider import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import com.github.kr328.clash.common.model.DarkMode +import com.github.kr328.clash.core.model.DarkMode private val DarkColorScheme = darkColorScheme( From 86af3bf18443c088a9f00f8c5fc0833ee8cd5c2e Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:48:11 +0800 Subject: [PATCH 19/21] Rename --- .../com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt | 2 +- .../kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt | 2 +- .../com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt | 2 +- .../com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt index 38771f5c41..e0e6c9c067 100644 --- a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt +++ b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt @@ -7,7 +7,7 @@ import androidx.activity.result.contract.ActivityResultContracts.StartActivityFo import androidx.compose.runtime.Composable @Composable -internal actual fun rememberVpnPermissionLauncher( +internal actual fun rememberRequestVpnPermission( onResult: (granted: Boolean) -> Unit ): (VpnPermissionRequest) -> Unit { val launcher = diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt index a87556733b..bc1efe80a2 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/HomeScreen.kt @@ -94,7 +94,7 @@ internal fun HomeScreen( val noProfileText = stringResource(Res.string.no_profile_selected) val profilesActionText = stringResource(CommonRes.string.profiles) - val vpnLauncher = rememberVpnPermissionLauncher { granted -> + val vpnLauncher = rememberRequestVpnPermission { granted -> if (granted) { viewModel.onVpnPermissionGranted() } else { diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt index 6e27ffb0c0..1776326476 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt @@ -5,6 +5,6 @@ import androidx.compose.runtime.Composable internal class VpnPermissionRequest(internal val value: Any) @Composable -internal expect fun rememberVpnPermissionLauncher( +internal expect fun rememberRequestVpnPermission( onResult: (granted: Boolean) -> Unit ): (VpnPermissionRequest) -> Unit diff --git a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt index 7dc292ae3b..e98113668d 100644 --- a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt +++ b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/ui/VpnPermissionLauncher.kt @@ -3,6 +3,6 @@ package com.github.kr328.clash.home.ui import androidx.compose.runtime.Composable @Composable -internal actual fun rememberVpnPermissionLauncher( +internal actual fun rememberRequestVpnPermission( onResult: (granted: Boolean) -> Unit ): (VpnPermissionRequest) -> Unit = {} From a8ea97445318f15aeff441ad757c0f003fc0c9d3 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:51:52 +0800 Subject: [PATCH 20/21] Share home broadcast events --- .../github/kr328/clash/home/vm/Broadcasts.kt | 23 ++++++++++++++ .../github/kr328/clash/home/vm/Broadcasts.kt | 31 +++++++++++++++++++ .../kr328/clash/home/vm/HomeViewModel.kt | 25 +++++---------- .../github/kr328/clash/home/vm/Broadcasts.kt | 11 +++++++ .../kr328/clash/home/vm/HomeViewModelTest.kt | 19 +++++++----- 5 files changed, 84 insertions(+), 25 deletions(-) create mode 100644 ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt create mode 100644 ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt create mode 100644 ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt new file mode 100644 index 0000000000..4c7b5580f5 --- /dev/null +++ b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt @@ -0,0 +1,23 @@ +package com.github.kr328.clash.home.vm + +import com.github.kr328.clash.glue.remote.Broadcasts as AndroidBroadcasts +import com.github.kr328.clash.glue.remote.Remote +import kotlinx.coroutines.flow.map + +internal actual val platformBroadcasts: Broadcasts = + object : Broadcasts { + override val clashRunning = Remote.broadcasts.clashRunningFlow + override val profileLoaded = Remote.broadcasts.profileLoadedFlow + override val events = Remote.broadcasts.event.map(AndroidBroadcasts.Event::toSharedEvent) + } + +private fun AndroidBroadcasts.Event.toSharedEvent(): Event = + when (this) { + AndroidBroadcasts.Event.ServiceRecreated -> Event.ServiceRecreated + AndroidBroadcasts.Event.Started -> Event.Started + is AndroidBroadcasts.Event.Stopped -> Event.Stopped(cause) + AndroidBroadcasts.Event.ProfileChanged -> Event.ProfileChanged + is AndroidBroadcasts.Event.ProfileUpdateCompleted -> Event.ProfileUpdateCompleted(uuid) + is AndroidBroadcasts.Event.ProfileUpdateFailed -> Event.ProfileUpdateFailed(uuid, reason) + AndroidBroadcasts.Event.ProfileLoaded -> Event.ProfileLoaded + } diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt new file mode 100644 index 0000000000..cb422514d9 --- /dev/null +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt @@ -0,0 +1,31 @@ +package com.github.kr328.clash.home.vm + +import kotlin.uuid.Uuid +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.StateFlow + +internal interface Broadcasts { + val clashRunning: StateFlow + + val profileLoaded: StateFlow + + val events: Flow +} + +internal sealed interface Event { + data object ServiceRecreated : Event + + data object Started : Event + + data class Stopped(val cause: String?) : Event + + data object ProfileChanged : Event + + data class ProfileUpdateCompleted(val uuid: Uuid?) : Event + + data class ProfileUpdateFailed(val uuid: Uuid?, val reason: String?) : Event + + data object ProfileLoaded : Event +} + +internal expect val platformBroadcasts: Broadcasts diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt index 293c4edfaf..e4a15903ab 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt @@ -14,8 +14,6 @@ import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.model.Traffic import com.github.kr328.clash.core.model.TunnelState import com.github.kr328.clash.core.util.trafficTotal -import com.github.kr328.clash.glue.remote.Broadcasts -import com.github.kr328.clash.glue.remote.Remote import com.github.kr328.clash.glue.util.startClashService import com.github.kr328.clash.glue.util.stopClashService import com.github.kr328.clash.glue.util.withClash @@ -24,7 +22,6 @@ import com.github.kr328.clash.home.ui.VpnPermissionRequest import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.Job import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.update @@ -42,7 +39,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : private var transitionTimeoutJob: Job? = null private var lastClashRunning: Boolean? = null - val clashRunning: StateFlow = dependencies.clashRunning + val clashRunning: StateFlow = dependencies.broadcasts.clashRunning val uiState: StateFlow field = MutableStateFlow(UiState()) @@ -53,7 +50,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : override fun onStart(owner: LifecycleOwner) { clashRunningJob?.cancel() clashRunningJob = viewModelScope.launch { - dependencies.clashRunning.collect { running -> + dependencies.broadcasts.clashRunning.collect { running -> val last = lastClashRunning lastClashRunning = running if (last != null && last != running) { @@ -67,7 +64,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : } broadcastEventsJob?.cancel() broadcastEventsJob = viewModelScope.launch { - dependencies.events.collect { event -> + dependencies.broadcasts.events.collect { event -> when (event) { ServiceRecreated, Started, @@ -84,7 +81,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : } profileLoadedJob?.cancel() profileLoadedJob = viewModelScope.launch { - dependencies.profileLoaded.collect { loaded -> + dependencies.broadcasts.profileLoaded.collect { loaded -> if (loaded) fetch() else clearRuntimeState() } } @@ -134,7 +131,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : fetchJob = viewModelScope.launch { val profileName = dependencies.queryActiveProfileName() - if (!clashRunning.value || !dependencies.profileLoaded.value) { + if (!clashRunning.value || !dependencies.broadcasts.profileLoaded.value) { uiState.update { it.copy( mode = null, @@ -148,7 +145,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : val mode = dependencies.modeText(dependencies.queryMode()) val hasProviders = dependencies.queryHasProviders() - if (!clashRunning.value || !dependencies.profileLoaded.value) { + if (!clashRunning.value || !dependencies.broadcasts.profileLoaded.value) { uiState.update { it.copy( mode = null, @@ -246,11 +243,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : } interface Dependencies { - val clashRunning: StateFlow - - val profileLoaded: StateFlow - - val events: Flow + val broadcasts: Broadcasts suspend fun queryActiveProfileName(): String? @@ -274,9 +267,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : internal class AndroidDependencies(private val application: Application) : HomeViewModel.Dependencies { - override val clashRunning: StateFlow = Remote.broadcasts.clashRunningFlow - override val profileLoaded: StateFlow = Remote.broadcasts.profileLoadedFlow - override val events: Flow = Remote.broadcasts.event + override val broadcasts: Broadcasts = platformBroadcasts override suspend fun queryActiveProfileName(): String? = withProfile { queryActive()?.name } diff --git a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt new file mode 100644 index 0000000000..be6f780f44 --- /dev/null +++ b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt @@ -0,0 +1,11 @@ +package com.github.kr328.clash.home.vm + +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.emptyFlow + +internal actual val platformBroadcasts: Broadcasts = + object : Broadcasts { + override val clashRunning = MutableStateFlow(false) + override val profileLoaded = MutableStateFlow(false) + override val events = emptyFlow() + } diff --git a/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt b/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt index 2c76de331e..bf08538830 100644 --- a/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt +++ b/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt @@ -7,9 +7,7 @@ import assertk.assertions.isEqualTo import assertk.assertions.isNull import com.github.kr328.clash.core.model.Traffic import com.github.kr328.clash.core.model.TunnelState -import com.github.kr328.clash.glue.remote.Broadcasts import com.github.kr328.clash.home.ui.VpnPermissionRequest -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest @@ -58,7 +56,7 @@ class HomeViewModelTest : KoinComponent { try { viewModel.onStart(UnusedLifecycleOwner) - dependencies.eventsFlow.emit(Broadcasts.Event.Started) + dependencies.eventsFlow.emit(Event.Started) assertThat(viewModel.uiState.value.mode).isNull() assertThat(dependencies.queryModeCalls).isEqualTo(0) @@ -103,7 +101,7 @@ class HomeViewModelTest : KoinComponent { assertThat(viewModel.uiState.value.mode).isEqualTo("Rule Mode") dependencies.mode = TunnelState.Mode.Global - dependencies.eventsFlow.emit(Broadcasts.Event.ProfileLoaded) + dependencies.eventsFlow.emit(Event.ProfileLoaded) assertThat(viewModel.uiState.value.mode).isEqualTo("Global Mode") } finally { @@ -183,10 +181,15 @@ class HomeViewModelTest : KoinComponent { } private class TestHomeDependencies : HomeViewModel.Dependencies { - override val clashRunning = MutableStateFlow(false) - override val profileLoaded = MutableStateFlow(false) - val eventsFlow = MutableSharedFlow(extraBufferCapacity = 16) - override val events: Flow = eventsFlow + val clashRunning = MutableStateFlow(false) + val profileLoaded = MutableStateFlow(false) + val eventsFlow = MutableSharedFlow(extraBufferCapacity = 16) + override val broadcasts = + object : Broadcasts { + override val clashRunning = this@TestHomeDependencies.clashRunning + override val profileLoaded = this@TestHomeDependencies.profileLoaded + override val events = eventsFlow + } var mode: TunnelState.Mode = TunnelState.Mode.Rule var queryModeCalls = 0 From 66757faec0f4a29afaa08a5b5f47c7681e2fbe5b Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 22 Jul 2026 16:54:24 +0800 Subject: [PATCH 21/21] Revert "Share home broadcast events" This reverts commit 3a863ddc82c7bdc28085825e6c1e40a6538066ef. --- .../github/kr328/clash/home/vm/Broadcasts.kt | 23 -------------- .../github/kr328/clash/home/vm/Broadcasts.kt | 31 ------------------- .../kr328/clash/home/vm/HomeViewModel.kt | 25 ++++++++++----- .../github/kr328/clash/home/vm/Broadcasts.kt | 11 ------- .../kr328/clash/home/vm/HomeViewModelTest.kt | 19 +++++------- 5 files changed, 25 insertions(+), 84 deletions(-) delete mode 100644 ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt delete mode 100644 ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt delete mode 100644 ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt diff --git a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt b/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt deleted file mode 100644 index 4c7b5580f5..0000000000 --- a/ui/home/src/androidMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.github.kr328.clash.home.vm - -import com.github.kr328.clash.glue.remote.Broadcasts as AndroidBroadcasts -import com.github.kr328.clash.glue.remote.Remote -import kotlinx.coroutines.flow.map - -internal actual val platformBroadcasts: Broadcasts = - object : Broadcasts { - override val clashRunning = Remote.broadcasts.clashRunningFlow - override val profileLoaded = Remote.broadcasts.profileLoadedFlow - override val events = Remote.broadcasts.event.map(AndroidBroadcasts.Event::toSharedEvent) - } - -private fun AndroidBroadcasts.Event.toSharedEvent(): Event = - when (this) { - AndroidBroadcasts.Event.ServiceRecreated -> Event.ServiceRecreated - AndroidBroadcasts.Event.Started -> Event.Started - is AndroidBroadcasts.Event.Stopped -> Event.Stopped(cause) - AndroidBroadcasts.Event.ProfileChanged -> Event.ProfileChanged - is AndroidBroadcasts.Event.ProfileUpdateCompleted -> Event.ProfileUpdateCompleted(uuid) - is AndroidBroadcasts.Event.ProfileUpdateFailed -> Event.ProfileUpdateFailed(uuid, reason) - AndroidBroadcasts.Event.ProfileLoaded -> Event.ProfileLoaded - } diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt deleted file mode 100644 index cb422514d9..0000000000 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.github.kr328.clash.home.vm - -import kotlin.uuid.Uuid -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.StateFlow - -internal interface Broadcasts { - val clashRunning: StateFlow - - val profileLoaded: StateFlow - - val events: Flow -} - -internal sealed interface Event { - data object ServiceRecreated : Event - - data object Started : Event - - data class Stopped(val cause: String?) : Event - - data object ProfileChanged : Event - - data class ProfileUpdateCompleted(val uuid: Uuid?) : Event - - data class ProfileUpdateFailed(val uuid: Uuid?, val reason: String?) : Event - - data object ProfileLoaded : Event -} - -internal expect val platformBroadcasts: Broadcasts diff --git a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt index e4a15903ab..293c4edfaf 100644 --- a/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt +++ b/ui/home/src/commonMain/kotlin/com/github/kr328/clash/home/vm/HomeViewModel.kt @@ -14,6 +14,8 @@ import com.github.kr328.clash.common.util.Log import com.github.kr328.clash.core.model.Traffic import com.github.kr328.clash.core.model.TunnelState import com.github.kr328.clash.core.util.trafficTotal +import com.github.kr328.clash.glue.remote.Broadcasts +import com.github.kr328.clash.glue.remote.Remote import com.github.kr328.clash.glue.util.startClashService import com.github.kr328.clash.glue.util.stopClashService import com.github.kr328.clash.glue.util.withClash @@ -22,6 +24,7 @@ import com.github.kr328.clash.home.ui.VpnPermissionRequest import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.Job import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.update @@ -39,7 +42,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : private var transitionTimeoutJob: Job? = null private var lastClashRunning: Boolean? = null - val clashRunning: StateFlow = dependencies.broadcasts.clashRunning + val clashRunning: StateFlow = dependencies.clashRunning val uiState: StateFlow field = MutableStateFlow(UiState()) @@ -50,7 +53,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : override fun onStart(owner: LifecycleOwner) { clashRunningJob?.cancel() clashRunningJob = viewModelScope.launch { - dependencies.broadcasts.clashRunning.collect { running -> + dependencies.clashRunning.collect { running -> val last = lastClashRunning lastClashRunning = running if (last != null && last != running) { @@ -64,7 +67,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : } broadcastEventsJob?.cancel() broadcastEventsJob = viewModelScope.launch { - dependencies.broadcasts.events.collect { event -> + dependencies.events.collect { event -> when (event) { ServiceRecreated, Started, @@ -81,7 +84,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : } profileLoadedJob?.cancel() profileLoadedJob = viewModelScope.launch { - dependencies.broadcasts.profileLoaded.collect { loaded -> + dependencies.profileLoaded.collect { loaded -> if (loaded) fetch() else clearRuntimeState() } } @@ -131,7 +134,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : fetchJob = viewModelScope.launch { val profileName = dependencies.queryActiveProfileName() - if (!clashRunning.value || !dependencies.broadcasts.profileLoaded.value) { + if (!clashRunning.value || !dependencies.profileLoaded.value) { uiState.update { it.copy( mode = null, @@ -145,7 +148,7 @@ internal class HomeViewModel(private val dependencies: Dependencies) : val mode = dependencies.modeText(dependencies.queryMode()) val hasProviders = dependencies.queryHasProviders() - if (!clashRunning.value || !dependencies.broadcasts.profileLoaded.value) { + if (!clashRunning.value || !dependencies.profileLoaded.value) { uiState.update { it.copy( mode = null, @@ -243,7 +246,11 @@ internal class HomeViewModel(private val dependencies: Dependencies) : } interface Dependencies { - val broadcasts: Broadcasts + val clashRunning: StateFlow + + val profileLoaded: StateFlow + + val events: Flow suspend fun queryActiveProfileName(): String? @@ -267,7 +274,9 @@ internal class HomeViewModel(private val dependencies: Dependencies) : internal class AndroidDependencies(private val application: Application) : HomeViewModel.Dependencies { - override val broadcasts: Broadcasts = platformBroadcasts + override val clashRunning: StateFlow = Remote.broadcasts.clashRunningFlow + override val profileLoaded: StateFlow = Remote.broadcasts.profileLoadedFlow + override val events: Flow = Remote.broadcasts.event override suspend fun queryActiveProfileName(): String? = withProfile { queryActive()?.name } diff --git a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt b/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt deleted file mode 100644 index be6f780f44..0000000000 --- a/ui/home/src/jvmMain/kotlin/com/github/kr328/clash/home/vm/Broadcasts.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.kr328.clash.home.vm - -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.emptyFlow - -internal actual val platformBroadcasts: Broadcasts = - object : Broadcasts { - override val clashRunning = MutableStateFlow(false) - override val profileLoaded = MutableStateFlow(false) - override val events = emptyFlow() - } diff --git a/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt b/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt index bf08538830..2c76de331e 100644 --- a/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt +++ b/ui/home/src/test/kotlin/com/github/kr328/clash/home/vm/HomeViewModelTest.kt @@ -7,7 +7,9 @@ import assertk.assertions.isEqualTo import assertk.assertions.isNull import com.github.kr328.clash.core.model.Traffic import com.github.kr328.clash.core.model.TunnelState +import com.github.kr328.clash.glue.remote.Broadcasts import com.github.kr328.clash.home.ui.VpnPermissionRequest +import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest @@ -56,7 +58,7 @@ class HomeViewModelTest : KoinComponent { try { viewModel.onStart(UnusedLifecycleOwner) - dependencies.eventsFlow.emit(Event.Started) + dependencies.eventsFlow.emit(Broadcasts.Event.Started) assertThat(viewModel.uiState.value.mode).isNull() assertThat(dependencies.queryModeCalls).isEqualTo(0) @@ -101,7 +103,7 @@ class HomeViewModelTest : KoinComponent { assertThat(viewModel.uiState.value.mode).isEqualTo("Rule Mode") dependencies.mode = TunnelState.Mode.Global - dependencies.eventsFlow.emit(Event.ProfileLoaded) + dependencies.eventsFlow.emit(Broadcasts.Event.ProfileLoaded) assertThat(viewModel.uiState.value.mode).isEqualTo("Global Mode") } finally { @@ -181,15 +183,10 @@ class HomeViewModelTest : KoinComponent { } private class TestHomeDependencies : HomeViewModel.Dependencies { - val clashRunning = MutableStateFlow(false) - val profileLoaded = MutableStateFlow(false) - val eventsFlow = MutableSharedFlow(extraBufferCapacity = 16) - override val broadcasts = - object : Broadcasts { - override val clashRunning = this@TestHomeDependencies.clashRunning - override val profileLoaded = this@TestHomeDependencies.profileLoaded - override val events = eventsFlow - } + override val clashRunning = MutableStateFlow(false) + override val profileLoaded = MutableStateFlow(false) + val eventsFlow = MutableSharedFlow(extraBufferCapacity = 16) + override val events: Flow = eventsFlow var mode: TunnelState.Mode = TunnelState.Mode.Rule var queryModeCalls = 0