Address some build warnings

This commit is contained in:
arkon
2023-12-25 16:31:40 -05:00
parent 80d6d412f3
commit 2d7650537d
33 changed files with 102 additions and 144 deletions

View File

@@ -20,17 +20,20 @@ class BackupDecoder(
* Decode a potentially-gzipped backup.
*/
fun decode(uri: Uri): Backup {
val backupStringSource = context.contentResolver.openInputStream(uri)!!.source().buffer()
return context.contentResolver.openInputStream(uri)!!.use { inputStream ->
val source = inputStream.source().buffer()
val peeked = backupStringSource.peek()
peeked.require(2)
val id1id2 = peeked.readShort()
val backupString = if (id1id2.toInt() == 0x1f8b) { // 0x1f8b is gzip magic bytes
backupStringSource.gzip().buffer()
} else {
backupStringSource
}.use { it.readByteArray() }
val peeked = source.peek().apply {
require(2)
}
val id1id2 = peeked.readShort()
val backupString = if (id1id2.toInt() == 0x1f8b) { // 0x1f8b is gzip magic bytes
source.gzip().buffer()
} else {
source
}.use { it.readByteArray() }
return parser.decodeFromByteArray(BackupSerializer, backupString)
parser.decodeFromByteArray(BackupSerializer, backupString)
}
}
}

View File

@@ -68,7 +68,7 @@ class BackupCreator(
.forEach { it.delete() }
// Create new file to place backup
dir?.createFile(BackupCreator.getFilename())
dir?.createFile(getFilename())
} else {
UniFile.fromUri(context, uri)
}

View File

@@ -25,7 +25,7 @@ class DownloadProvider(
private val storageManager: StorageManager = Injekt.get(),
) {
val downloadsDir: UniFile?
private val downloadsDir: UniFile?
get() = storageManager.getDownloadsDirectory()
/**

View File

@@ -246,7 +246,7 @@ class LibraryUpdateNotifier(private val context: Context) {
// Mark chapters as read action
addAction(
R.drawable.ic_glasses_24dp,
R.drawable.ic_done_24dp,
context.stringResource(MR.strings.action_mark_as_read),
NotificationReceiver.markAsReadPendingBroadcast(
context,

View File

@@ -235,7 +235,6 @@ class NotificationReceiver : BroadcastReceiver() {
private const val NAME = "NotificationReceiver"
private const val ACTION_SHARE_IMAGE = "$ID.$NAME.SHARE_IMAGE"
private const val ACTION_DELETE_IMAGE = "$ID.$NAME.DELETE_IMAGE"
private const val ACTION_SHARE_BACKUP = "$ID.$NAME.SEND_BACKUP"
@@ -256,7 +255,6 @@ class NotificationReceiver : BroadcastReceiver() {
private const val ACTION_DISMISS_NOTIFICATION = "$ID.$NAME.ACTION_DISMISS_NOTIFICATION"
private const val EXTRA_FILE_LOCATION = "$ID.$NAME.FILE_LOCATION"
private const val EXTRA_URI = "$ID.$NAME.URI"
private const val EXTRA_NOTIFICATION_ID = "$ID.$NAME.NOTIFICATION_ID"
private const val EXTRA_GROUP_ID = "$ID.$NAME.EXTRA_GROUP_ID"
@@ -361,7 +359,7 @@ class NotificationReceiver : BroadcastReceiver() {
it.id == notificationId
}?.groupKey
if (groupId != null && groupId != 0 && groupKey != null && groupKey.isNotEmpty()) {
if (groupId != null && groupId != 0 && !groupKey.isNullOrEmpty()) {
val notifications = context.notificationManager.activeNotifications.filter {
it.groupKey == groupKey
}

View File

@@ -6,7 +6,7 @@ import okhttp3.Interceptor
import okhttp3.Response
import uy.kohesive.injekt.injectLazy
class BangumiInterceptor(val bangumi: Bangumi) : Interceptor {
class BangumiInterceptor(private val bangumi: Bangumi) : Interceptor {
private val json: Json by injectLazy()

View File

@@ -62,12 +62,3 @@ fun Track.toBangumiStatus() = when (status) {
Bangumi.PLAN_TO_READ -> "wish"
else -> throw NotImplementedError("Unknown status: $status")
}
fun toTrackStatus(status: String) = when (status) {
"do" -> Bangumi.READING
"collect" -> Bangumi.COMPLETED
"on_hold" -> Bangumi.ON_HOLD
"dropped" -> Bangumi.DROPPED
"wish" -> Bangumi.PLAN_TO_READ
else -> throw NotImplementedError("Unknown status: $status")
}

View File

@@ -5,7 +5,7 @@ import okhttp3.Interceptor
import okhttp3.Response
import uy.kohesive.injekt.injectLazy
class KitsuInterceptor(val kitsu: Kitsu) : Interceptor {
class KitsuInterceptor(private val kitsu: Kitsu) : Interceptor {
private val json: Json by injectLazy()

View File

@@ -5,7 +5,7 @@ import okhttp3.Interceptor
import okhttp3.Response
import uy.kohesive.injekt.injectLazy
class ShikimoriInterceptor(val shikimori: Shikimori) : Interceptor {
class ShikimoriInterceptor(private val shikimori: Shikimori) : Interceptor {
private val json: Json by injectLazy()