Skip to content

Commit

Permalink
Use translated channel name strings where possible to update them whe…
Browse files Browse the repository at this point in the history
…n language changes (#4833)

* Use translated channel name strings where possible to update them when language changes

* Update sensor worker channel name to be more user friendly
  • Loading branch information
dshokouhi authored Nov 21, 2024
1 parent a918482 commit 8c6afda
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,12 @@ class WebsocketManager(
*/
private suspend fun createNotification(): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
var notificationChannel =
notificationManager.getNotificationChannel(CHANNEL_WEBSOCKET)
if (notificationChannel == null) {
notificationChannel = NotificationChannel(
CHANNEL_WEBSOCKET,
applicationContext.getString(R.string.websocket_setting_name),
NotificationManager.IMPORTANCE_LOW
)
notificationManager.createNotificationChannel(notificationChannel)
}
val notificationChannel = NotificationChannel(
CHANNEL_WEBSOCKET,
applicationContext.getString(R.string.websocket_setting_name),
NotificationManager.IMPORTANCE_LOW
)
notificationManager.createNotificationChannel(notificationChannel)
}

val intent = WebViewActivity.newInstance(applicationContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fun handleChannel(
): String {
// Define some values for a default channel
var channelID = CHANNEL_GENERAL
var channelName = "General"
var channelName = context.getString(R.string.general)

if (!data[NotificationData.CHANNEL].isNullOrEmpty()) {
channelID = createChannelID(data[NotificationData.CHANNEL].toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,12 @@ abstract class SensorWorkerBase(

protected fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
var notificationChannel =
notificationManager.getNotificationChannel(CHANNEL_SENSOR_WORKER)
if (notificationChannel == null) {
notificationChannel = NotificationChannel(
CHANNEL_SENSOR_WORKER,
TAG,
NotificationManager.IMPORTANCE_LOW
)
notificationManager.createNotificationChannel(notificationChannel)
}
val notificationChannel = NotificationChannel(
CHANNEL_SENSOR_WORKER,
appContext.getString(commonR.string.sensor_updates),
NotificationManager.IMPORTANCE_LOW
)
notificationManager.createNotificationChannel(notificationChannel)
}
}
}
2 changes: 2 additions & 0 deletions common/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1313,4 +1313,6 @@
<string name="sensor_description_steps">Total steps taken since midnight from Health Connect</string>
<string name="basic_sensor_name_blood_glucose">Blood glucose</string>
<string name="sensor_description_blood_glucose">Last recorded blood glucose reading in milligrams per deciliter from Health Connect</string>
<string name="general">General</string>
<string name="sensor_updates">Sensor updates</string>
</resources>

0 comments on commit 8c6afda

Please sign in to comment.