Skip to content

Commit

Permalink
fix(java): properly name default resource name for android and androi…
Browse files Browse the repository at this point in the history
…d-uploader
  • Loading branch information
ThibaultBee committed Aug 8, 2023
1 parent 792c9d6 commit dc0a697
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 44 deletions.
12 changes: 6 additions & 6 deletions templates/java/android/services/UploadService.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ import java.util.concurrent.Future
open class UploadService(
private val notificationId: Int = DEFAULT_NOTIFICATION_ID,
protected val channelId: String = DEFAULT_NOTIFICATION_SERVICE_CHANNEL_ID,
@StringRes private val channelNameResourceId: Int = R.string.channel_name,
@StringRes private val channelNameResourceId: Int = R.string.upload_notification_channel_name,
@StringRes private val channelDescriptionResourceId: Int = 0,
@DrawableRes protected val notificationIconResourceId: Int = R.drawable.ic_api_video_logo,
@ColorRes protected val notificationColorResourceId: Int = R.color.primary_orange
@DrawableRes protected val notificationIconResourceId: Int = R.drawable.ic_upload_notification,
@ColorRes protected val notificationColorResourceId: Int = R.color.upload_notification_color
) : Service() {
private val uploadFuturesMap = ConcurrentHashMap<String, Future<Video>>()
private val binder = UploadServiceBinder()
Expand Down Expand Up @@ -219,7 +219,7 @@ open class UploadService(
open fun onUploadErrorNotification(id: String, e: Exception): Notification? {
return NotificationCompat.Builder(this, channelId)
.setStyle(this, notificationIconResourceId, notificationColorResourceId)
.setContentTitle(getString(R.string.notification_error_title))
.setContentTitle(getString(R.string.upload_notification_error_title))
.setContentText(e.localizedMessage)
.build()
}
Expand All @@ -237,10 +237,10 @@ open class UploadService(
return NotificationCompat.Builder(this, channelId)
.setStyle(this, notificationIconResourceId, notificationColorResourceId)
.setOngoing(true)
.setContentTitle(getString(R.string.notification_progress_title))
.setContentTitle(getString(R.string.upload_notification_progress_title))
.setContentText(
getString(
R.string.notification_progress_text,
R.string.upload_notification_progress_text,
numOfUploaded,
totalNumOfUploads - numOfCancelled
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object NotificationConfigurationStore {
*/
@JvmStatic
@StringRes
var channelNameResourceId: Int = R.string.channel_name
var channelNameResourceId: Int = R.string.upload_notification_channel_name
/**
* A string resource identifier for the user visible description of the notification channel, or 0 if no description is provided.
Expand All @@ -42,12 +42,12 @@ object NotificationConfigurationStore {
*/
@JvmStatic
@DrawableRes
var notificationIconResourceId: Int = R.drawable.ic_api_video_logo
var notificationIconResourceId: Int = R.drawable.ic_upload_notification
/**
* The color id of the notification.
*/
@JvmStatic
@ColorRes
var notificationColorResourceId: Int = R.color.primary_orange
var notificationColorResourceId: Int = R.color.upload_notification_color
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ abstract class AbstractUploadWorker(
open fun onUploadStarted(): Notification {
return NotificationCompat.Builder(applicationContext, channelId)
.setStyle(applicationContext, notificationIconResourceId, notificationColorResourceId)
.setContentTitle(applicationContext.getString(R.string.notification_upload_started_title))
.setContentTitle(applicationContext.getString(R.string.upload_notification_upload_started_title))
.build()
}

Expand All @@ -95,7 +95,7 @@ abstract class AbstractUploadWorker(
open fun onUploadError(e: Exception): Notification? {
return NotificationCompat.Builder(applicationContext, channelId)
.setStyle(applicationContext, notificationIconResourceId, notificationColorResourceId)
.setContentTitle(applicationContext.getString(R.string.notification_error_title))
.setContentTitle(applicationContext.getString(R.string.upload_notification_error_title))
.setContentText(e.localizedMessage)
.build()
}
Expand All @@ -120,17 +120,17 @@ abstract class AbstractUploadWorker(
notificationColorResourceId
)
.setOngoing(true)
.setContentTitle(applicationContext.getString(R.string.notification_progress_title))
.setContentTitle(applicationContext.getString(R.string.upload_notification_progress_title))
.setContentText(
applicationContext.getString(
R.string.notification_current_progress_text,
R.string.upload_notification_current_progress_text,
progress
)
)
.setProgress(100, progress, false)
.addAction(
android.R.drawable.ic_delete,
applicationContext.getString(R.string.notification_cancel),
applicationContext.getString(R.string.upload_notification_cancel),
intent
)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import video.api.uploader.api.services.UploadService
class CustomUploaderService : UploadService(
notificationId = DEFAULT_NOTIFICATION_ID,
channelId = DEFAULT_NOTIFICATION_CHANNEL_ID,
channelNameResourceId = R.string.channel_name,
channelNameResourceId = R.string.upload_notification_channel_name,
) {
companion object {
const val DEFAULT_NOTIFICATION_CHANNEL_ID =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary_orange">#FA5B30</color>
<color name="secondary_orange">#FFB39E</color>
<color name="light_blue">#D9E1EC</color>
<color name="dark_blue">#414F6E</color>
<color name="black">#0B0F17</color>
<color name="white">#FFFFFF</color>
<color name="transparent_white">#66FFFFFF</color>
<color name="upload_notification_color">#FA5B30</color>
</resources>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="channel_name">api.video</string>
<string name="notification_progress_title">Uploading</string>
<string name="notification_progress_text">Uploaded %1d of %1d</string>
<string name="notification_current_progress_text">%1d %%</string>
<string name="notification_error_title">Upload error</string>
<string name="notification_upload_started_title">Upload starting…</string>
<string name="notification_cancel">Cancel</string>
<string name="upload_notification_channel_name">api.video</string>
<string name="upload_notification_progress_title">Uploading</string>
<string name="upload_notification_progress_text">Uploaded %1d of %1d</string>
<string name="upload_notification_current_progress_text">%1d %%</string>
<string name="upload_notification_error_title">Upload error</string>
<string name="upload_notification_upload_started_title">Upload starting…</string>
<string name="upload_notification_cancel">Cancel</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import video.api.client.api.services.UploadService
class CustomUploaderService : UploadService(
notificationId = DEFAULT_NOTIFICATION_ID,
channelId = DEFAULT_NOTIFICATION_CHANNEL_ID,
channelNameResourceId = R.string.channel_name,
channelNameResourceId = R.string.upload_notification_channel_name,
) {
companion object {
const val DEFAULT_NOTIFICATION_CHANNEL_ID =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary_orange">#FA5B30</color>
<color name="secondary_orange">#FFB39E</color>
<color name="light_blue">#D9E1EC</color>
<color name="dark_blue">#414F6E</color>
<color name="black">#0B0F17</color>
<color name="white">#FFFFFF</color>
<color name="transparent_white">#66FFFFFF</color>
<color name="upload_notification_color">#FA5B30</color>
</resources>
14 changes: 7 additions & 7 deletions templates/java/statics/android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="channel_name">api.video</string>
<string name="notification_progress_title">Uploading</string>
<string name="notification_progress_text">Uploaded %1d of %1d</string>
<string name="notification_current_progress_text">%1d %%</string>
<string name="notification_error_title">Upload error</string>
<string name="notification_upload_started_title">Upload starting…</string>
<string name="notification_cancel">Cancel</string>
<string name="upload_notification_channel_name">api.video</string>
<string name="upload_notification_progress_title">Uploading</string>
<string name="upload_notification_progress_text">Uploaded %1d of %1d</string>
<string name="upload_notification_current_progress_text">%1d %%</string>
<string name="upload_notification_error_title">Upload error</string>
<string name="upload_notification_upload_started_title">Upload starting…</string>
<string name="upload_notification_cancel">Cancel</string>
</resources>

0 comments on commit dc0a697

Please sign in to comment.