Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4236 Improved download notification strings replacing default Fetch #4251

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import com.tonyodev.fetch2.Download
import com.tonyodev.fetch2.Error
import com.tonyodev.fetch2.Fetch
import com.tonyodev.fetch2.FetchListener
import com.tonyodev.fetch2.R
import com.tonyodev.fetch2.Status
import com.tonyodev.fetch2.util.DEFAULT_NOTIFICATION_TIMEOUT_AFTER_RESET
import com.tonyodev.fetch2core.DownloadBlock
Expand Down Expand Up @@ -276,7 +275,7 @@ class DownloadMonitorService : Service() {
notificationBuilder.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setSmallIcon(android.R.drawable.stat_sys_download_done)
.setContentTitle(notificationTitle)
.setContentText(getString(R.string.fetch_notification_download_complete))
.setContentText(getString(string.complete))
.setOngoing(false)
.setGroup(download.id.toString())
.setGroupSummary(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ class FetchDownloadNotificationManager @Inject constructor(
}
}

override fun getSubtitleText(
context: Context,
downloadNotification: DownloadNotification
): String {
return when {
downloadNotification.isCompleted -> context.getString(R.string.complete)
downloadNotification.isFailed -> context.getString(R.string.download_failed_state)
downloadNotification.isPaused -> context.getString(R.string.paused_state)
downloadNotification.isQueued -> context.getString(R.string.resuming_state)
downloadNotification.etaInMilliSeconds < 0 -> context.getString(R.string.downloading_state)
else -> super.getSubtitleText(context, downloadNotification)
}
}

@RequiresApi(Build.VERSION_CODES.O)
private fun createChannel(channelId: String, context: Context) =
NotificationChannel(
Expand Down Expand Up @@ -253,7 +267,7 @@ class FetchDownloadNotificationManager @Inject constructor(
return notificationBuilder.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setSmallIcon(android.R.drawable.stat_sys_download_done)
.setContentTitle(notificationTitle)
.setContentText(context.getString(string.fetch_notification_download_paused))
.setContentText(context.getString(R.string.paused_state))
// Set the ongoing true so that could not cancel the pause notification.
// However, on Android 14 and above user can cancel the notification by swipe right so we
// can't control that see https://developer.android.com/about/versions/14/behavior-changes-all#non-dismissable-notifications
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/res/values-qq/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,7 @@
<string name="go_to_settings_label">This is a text label, by clicking on this text user navigates to the app settings on their device.</string>
<string name="request_notification_permission_message">This message appears in the “Android Dialog” as an information message. When the user tries to run any functionality which requires notification access but the app does not have that access, then this message shows to the user to give notification access.</string>
<string name="empty_string">{{Ignored}}</string>
<string name="resuming_state">This text is shown to inform the user that the current state of download is resuming.</string>
<string name="downloading_state">This text is shown to inform the user that the current state of download is actively in progress.</string>
<string name="download_failed_state">This text is shown to inform the user when a download has been failed.</string>
</resources>
3 changes: 3 additions & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -402,4 +402,7 @@
<string name="donation_dialog_title">Donate Today</string>
<string name="donation_dialog_description">%s needs your help.</string>
<string name="make_donation">Make a donation</string>
<string name="resuming_state">Resuming</string>
<string name="downloading_state">Downloading</string>
<string name="download_failed_state">Failed</string>
</resources>