Skip to content

Commit

Permalink
Merge pull request amir1376#209 from amir1376/feature/add-auto-show-p…
Browse files Browse the repository at this point in the history
…rogress-dialog

add auto show download progress dialog option
  • Loading branch information
amir1376 authored Nov 21, 2024
2 parents de45c34 + cda0546 commit c4e608f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,11 @@ class AppComponent(
openDownloadDialog(it.downloadItem.id)
}
}
if (it is DownloadManagerEvents.OnJobStarting) {
if (appSettings.autoShowDownloadProgressDialog.value) {
openDownloadDialog(it.downloadItem.id)
}
}
}

override suspend fun openDownloadItem(id: Long) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ fun showDownloadFinishWindow(settingsStorage: AppSettingsStorage): BooleanConfig
)
}

fun autoShowDownloadProgressWindow(settingsStorage: AppSettingsStorage): BooleanConfigurable {
return BooleanConfigurable(
title = Res.string.settings_show_download_progress_dialog.asStringSource(),
description = Res.string.settings_show_download_progress_dialog_description.asStringSource(),
backedBy = settingsStorage.autoShowDownloadProgressDialog,
describe = {
(if (it) Res.string.enabled else Res.string.disabled).asStringSource()
},
)
}

fun speedLimitConfig(appRepository: AppRepository): SpeedLimitConfigurable {
return SpeedLimitConfigurable(
title = Res.string.settings_global_speed_limiter.asStringSource(),
Expand Down Expand Up @@ -385,6 +396,7 @@ class SettingsComponent(
speedLimitConfig(appRepository),
threadCountConfig(appRepository),
dynamicPartDownloadConfig(appRepository),
autoShowDownloadProgressWindow(appSettings),
showDownloadFinishWindow(appSettings),
useServerLastModified(appRepository),
useSparseFileAllocation(appRepository),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ data class AppSettingsModel(
val useServerLastModifiedTime: Boolean = false,
val useSparseFileAllocation: Boolean = true,
val useAverageSpeed: Boolean = true,
val autoShowDownloadProgressDialog: Boolean = true,
val showCompletionDialog: Boolean = true,
val speedLimit: Long = 0,
val autoStartOnBoot: Boolean = true,
Expand All @@ -45,6 +46,7 @@ data class AppSettingsModel(
val useServerLastModifiedTime = booleanKeyOf("useServerLastModifiedTime")
val useSparseFileAllocation = booleanKeyOf("useSparseFileAllocation")
val useAverageSpeed = booleanKeyOf("useAverageSpeed")
val autoShowDownloadProgressDialog = booleanKeyOf("autoShowDownloadProgressDialog")
val showCompletionDialog = booleanKeyOf("showCompletionDialog")
val speedLimit = longKeyOf("speedLimit")
val autoStartOnBoot = booleanKeyOf("autoStartOnBoot")
Expand All @@ -68,6 +70,8 @@ data class AppSettingsModel(
?: default.useServerLastModifiedTime,
useSparseFileAllocation = source.get(Keys.useSparseFileAllocation) ?: default.useSparseFileAllocation,
useAverageSpeed = source.get(Keys.useAverageSpeed) ?: default.useAverageSpeed,
autoShowDownloadProgressDialog = source.get(Keys.autoShowDownloadProgressDialog)
?: default.autoShowDownloadProgressDialog,
showCompletionDialog = source.get(Keys.showCompletionDialog)
?: default.showCompletionDialog,
speedLimit = source.get(Keys.speedLimit) ?: default.speedLimit,
Expand All @@ -90,6 +94,7 @@ data class AppSettingsModel(
put(Keys.useServerLastModifiedTime, focus.useServerLastModifiedTime)
put(Keys.useSparseFileAllocation, focus.useSparseFileAllocation)
put(Keys.useAverageSpeed, focus.useAverageSpeed)
put(Keys.autoShowDownloadProgressDialog, focus.autoShowDownloadProgressDialog)
put(Keys.showCompletionDialog, focus.showCompletionDialog)
put(Keys.speedLimit, focus.speedLimit)
put(Keys.autoStartOnBoot, focus.autoStartOnBoot)
Expand All @@ -115,6 +120,7 @@ class AppSettingsStorage(
val useServerLastModifiedTime = from(AppSettingsModel.useServerLastModifiedTime)
val useSparseFileAllocation = from(AppSettingsModel.useSparseFileAllocation)
val useAverageSpeed = from(AppSettingsModel.useAverageSpeed)
val autoShowDownloadProgressDialog = from(AppSettingsModel.autoShowDownloadProgressDialog)
val showCompletionDialog = from(AppSettingsModel.showCompletionDialog)
val speedLimit = from(AppSettingsModel.speedLimit)
val autoStartOnBoot = from(AppSettingsModel.autoStartOnBoot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ settings_dynamic_part_creation=Dynamic part creation
settings_dynamic_part_creation_description=When a part is finished create another part by splitting other parts to improve download speed
settings_show_completion_dialog=Show Download Completion dialog
settings_show_completion_dialog_description=Automatically show "Download Completion" dialog when a download finished
settings_show_download_progress_dialog=Show Download Progress dialog
settings_show_download_progress_dialog_description=Automatically show "Download Progress" dialog when a download started
download_item_settings_speed_limit=Speed Limit
download_item_settings_speed_limit_description=Limit download speed for this item
download_item_settings_show_completion_dialog=Show Completion dialog
Expand Down

0 comments on commit c4e608f

Please sign in to comment.