Explicitly add READ_APP_SPECIFIC_LOCALES permission

Some devices are throwing a SecurityException (calling getApplicationLocales) for some reason.
This commit is contained in:
arkon 2022-11-25 22:32:54 -05:00
parent a8c5780963
commit 7e74949d38
3 changed files with 24 additions and 32 deletions

View file

@ -23,6 +23,7 @@
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_APP_SPECIFIC_LOCALES" />
<!-- Remove permission from Firebase dependency -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID"

View file

@ -197,7 +197,6 @@ class NotificationReceiver : BroadcastReceiver() {
* @param notificationId id of notification
*/
private fun deleteImage(context: Context, path: String, notificationId: Int) {
// Dismiss notification
dismissNotification(context, notificationId)
// Delete file

View file

@ -20,21 +20,13 @@ import eu.kanade.tachiyomi.util.system.notificationManager
*/
class SaveImageNotifier(private val context: Context) {
/**
* Notification builder.
*/
private val notificationBuilder = context.notificationBuilder(Notifications.CHANNEL_COMMON)
/**
* Id of the notification.
*/
private val notificationId: Int
get() = Notifications.ID_DOWNLOAD_IMAGE
private val notificationId: Int = Notifications.ID_DOWNLOAD_IMAGE
/**
* Called when image download/copy is complete.
*
* @param file image file containing downloaded page image.
* @param uri image file containing downloaded page image.
*/
fun onComplete(uri: Uri) {
val request = ImageRequest.Builder(context)
@ -53,6 +45,27 @@ class SaveImageNotifier(private val context: Context) {
context.imageLoader.enqueue(request)
}
/**
* Clears the notification message.
*/
fun onClear() {
context.notificationManager.cancel(notificationId)
}
/**
* Called on error while downloading image.
* @param error string containing error information.
*/
fun onError(error: String?) {
// Create notification
with(notificationBuilder) {
setContentTitle(context.getString(R.string.download_notifier_title_error))
setContentText(error ?: context.getString(R.string.unknown_error))
setSmallIcon(android.R.drawable.ic_menu_report_image)
}
updateNotification()
}
private fun showCompleteNotification(uri: Uri, image: Bitmap) {
with(notificationBuilder) {
setContentTitle(context.getString(R.string.picture_saved))
@ -82,29 +95,8 @@ class SaveImageNotifier(private val context: Context) {
}
}
/**
* Clears the notification message.
*/
fun onClear() {
context.notificationManager.cancel(notificationId)
}
private fun updateNotification() {
// Displays the progress bar on notification
context.notificationManager.notify(notificationId, notificationBuilder.build())
}
/**
* Called on error while downloading image.
* @param error string containing error information.
*/
fun onError(error: String?) {
// Create notification
with(notificationBuilder) {
setContentTitle(context.getString(R.string.download_notifier_title_error))
setContentText(error ?: context.getString(R.string.unknown_error))
setSmallIcon(android.R.drawable.ic_menu_report_image)
}
updateNotification()
}
}