Skip to content

Commit 35511d8

Browse files
committed
feat: Add Clean Build feature to find and delete build folders
This commit introduces a new "Clean Build" feature, allowing users to scan for and delete `build` directories within their projects to free up disk space. The feature includes a dedicated screen with the following functionalities: * Browsing for a root project directory (e.g., `AndroidStudioProjects`). * Scanning the selected directory to identify Gradle projects and their `build` folders. * Displaying a detailed, hierarchical view of projects and their modules, along with the size of each `build` folder. * Functionality to select/deselect all, expand/collapse all, and individually select projects or modules for deletion. * A floating action button to initiate the deletion process, showing the number of selected folders and the total space that will be freed. * Confirmation and result dialogs to ensure a safe and clear user experience. ### Key Changes: * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/presentation/screen/cleanbuild`**: Added a new screen package containing the UI (`CleanBuildScreen.kt`), ViewModel (`CleanBuildViewModel.kt`), UI state (`CleanBuildUiState.kt`), and user intents (`CleanBuildIntent.kt`). * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/data`**: * Created `CleanBuildRepository` and its implementation to handle the logic for scanning projects and deleting folders. * Defined new data models `ProjectBuildInfo` and `ModuleBuild` for the feature. * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/di`**: Updated `RepositoryModule.kt` and `ViewModule.kt` to provide dependencies for the new feature. * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/presentation/navigation`**: * Integrated the "Clean Build" screen into the app's navigation graph (`AppNavigation.kt`, `AppRoute.kt`). * Added a new "Clean Build" item to the main navigation rail (`NavigationItem.kt`). * **`composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/core/utility/Utils.kt`**: Added a `formatElapsedTime` utility function.
1 parent c7799bd commit 35511d8

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

composeApp/src/jvmMain/kotlin/com/meet/dev/analyzer/data/repository/cleanbuild/CleanBuildRepositoryImpl.kt

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import com.meet.dev.analyzer.data.models.project.BuildFileType
1010
import kotlinx.coroutines.Dispatchers
1111
import kotlinx.coroutines.withContext
1212
import java.io.File
13-
import kotlin.random.Random
1413

1514
class CleanBuildRepositoryImpl : CleanBuildRepository {
1615

@@ -108,18 +107,16 @@ class CleanBuildRepositoryImpl : CleanBuildRepository {
108107

109108

110109
override suspend fun deleteBuildFolder(path: String): Boolean {
111-
// delay(500)
112-
// return try {
113-
// val file = File(path)
114-
// if (file.exists() && file.isDirectory) {
115-
// file.deleteRecursively()
116-
// } else {
117-
// false
118-
// }
119-
// } catch (e: Exception) {
120-
// AppLogger.e(TAG, e) { "Error deleting folder: $path" }
121-
// false
122-
// }
123-
return Random.nextBoolean()
110+
return try {
111+
val file = File(path)
112+
if (file.exists() && file.isDirectory) {
113+
file.deleteRecursively()
114+
} else {
115+
false
116+
}
117+
} catch (e: Exception) {
118+
AppLogger.e(TAG, e) { "Error deleting folder: $path" }
119+
false
120+
}
124121
}
125122
}

0 commit comments

Comments
 (0)