mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
feat: Update notification locale on locale change
This commit is contained in:
parent
3afc6a4053
commit
2439f42f42
@ -8,7 +8,7 @@
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
|
||||
<application
|
||||
android:name=".RunningApp"
|
||||
android:name=".UpdateSettingsApp"
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
@ -29,6 +29,14 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<receiver
|
||||
android:name=".receivers.LocalChangeReceiver"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.LOCALE_CHANGED" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<service android:name=".services.RecorderService" android:foregroundServiceType="microphone" />
|
||||
</application>
|
||||
|
||||
|
22
app/src/main/java/app/myzel394/alibi/NotificationHelper.kt
Normal file
22
app/src/main/java/app/myzel394/alibi/NotificationHelper.kt
Normal file
@ -0,0 +1,22 @@
|
||||
package app.myzel394.alibi
|
||||
|
||||
import android.app.NotificationChannel
|
||||
import android.app.NotificationManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
object NotificationHelper {
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
fun createChannels(context: Context) {
|
||||
val channel = NotificationChannel(
|
||||
"recorder",
|
||||
context.resources.getString(R.string.notificationChannels_recorder_name),
|
||||
android.app.NotificationManager.IMPORTANCE_LOW,
|
||||
)
|
||||
channel.description = context.resources.getString(R.string.notificationChannels_recorder_description)
|
||||
|
||||
val notificationManager = context.getSystemService(NotificationManager::class.java)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package app.myzel394.alibi
|
||||
|
||||
import android.app.Application
|
||||
import android.app.NotificationChannel
|
||||
import android.os.Build
|
||||
|
||||
class RunningApp: Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channel = NotificationChannel(
|
||||
"recorder",
|
||||
"Recorder",
|
||||
android.app.NotificationManager.IMPORTANCE_LOW,
|
||||
)
|
||||
val notificationManager = getSystemService(android.app.NotificationManager::class.java)
|
||||
notificationManager.createNotificationChannel(channel)
|
||||
}
|
||||
}
|
||||
}
|
16
app/src/main/java/app/myzel394/alibi/UpdateSettingsApp.kt
Normal file
16
app/src/main/java/app/myzel394/alibi/UpdateSettingsApp.kt
Normal file
@ -0,0 +1,16 @@
|
||||
package app.myzel394.alibi
|
||||
|
||||
import android.app.Application
|
||||
import android.app.NotificationChannel
|
||||
import android.os.Build
|
||||
import androidx.compose.ui.res.stringResource
|
||||
|
||||
class UpdateSettingsApp: Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationHelper.createChannels(this)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package app.myzel394.alibi.receivers
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import app.myzel394.alibi.NotificationHelper
|
||||
|
||||
class LocalChangeReceiver: BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, p1: Intent?) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationHelper.createChannels(context!!)
|
||||
}
|
||||
}
|
||||
}
|
@ -11,6 +11,9 @@
|
||||
<string name="form_error_value_notInRange">Please enter a number between <xliff:g name="min">%s</xliff:g> and <xliff:g name="max">%s</xliff:g></string>
|
||||
<string name="form_error_value_mustBeGreaterThan">Please enter a number greater than <xliff:g name="min">%s</xliff:g></string>
|
||||
|
||||
<string name="notificationChannels_recorder_name">Recorder</string>
|
||||
<string name="notificationChannels_recorder_description">Shows the current recording status</string>
|
||||
|
||||
<string name="ui_permissions_request_title">Permission denied</string>
|
||||
<string name="ui_permissions_request_message">Please grant the permission to continue. You will be redirected to the app settings to grant the permission there.</string>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user