Skip to content

Commit

Permalink
Improve Notifications
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Mayer <[email protected]>
  • Loading branch information
JonasMayerDev authored and alperozturk96 committed Jan 10, 2024
1 parent 14b096d commit 252d7de
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,16 @@ class DownloadNotificationManager(
val fileName: String = filePath.substring(filePath.lastIndexOf(FileUtils.PATH_SEPARATOR) + 1)
val text =
String.format(context.getString(R.string.downloader_download_in_progress_content), percent, fileName)
updateNotificationText(text, false)
val title =
context.getString(R.string.downloader_download_in_progress_ticker)
updateNotificationText(title, text, false)
}
}

@Suppress("MagicNumber")
fun showCompleteNotification(text: String) {
Handler(Looper.getMainLooper()).postDelayed({
updateNotificationText(text, true)
updateNotificationText(null,text, true)
dismissNotification()
}, 3000)
}
Expand All @@ -126,17 +128,19 @@ class DownloadNotificationManager(

notificationBuilder.run {
setProgress(0, 0, false)
setContentTitle(null)
setContentText(text)
setOngoing(false)
notificationManager.notify(notifyId, this.build())
}
}

private fun updateNotificationText(text: String, cancelProgressBar: Boolean) {
private fun updateNotificationText(title: String?, text: String, cancelProgressBar: Boolean) {
notificationBuilder.run {
if (cancelProgressBar) {
setProgress(0, 0, false)
}

setContentTitle(title)
setContentText(text)
notificationManager.notify(id, this.build())
}
Expand Down

0 comments on commit 252d7de

Please sign in to comment.