Address some build warnings

This commit is contained in:
arkon 2023-07-14 23:08:45 -04:00
parent cbcec8c4d9
commit a629db2884
5 changed files with 15 additions and 27 deletions

View file

@ -41,7 +41,12 @@ internal object ExtensionLoader {
const val LIB_VERSION_MIN = 1.3
const val LIB_VERSION_MAX = 1.5
private const val PACKAGE_FLAGS = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES
private val PACKAGE_FLAGS = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNING_CERTIFICATES
} else {
@Suppress("DEPRECATION")
PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES
}
// inorichi's key
private const val officialSignature = "7ce04da7773d41b489f4693a366c36bcd0a11fc39b547168553c285bd7348e23"
@ -49,7 +54,7 @@ internal object ExtensionLoader {
/**
* List of the trusted signatures.
*/
var trustedSignatures = mutableSetOf<String>() + preferences.trustedSignatures().get() + officialSignature
var trustedSignatures = mutableSetOf(officialSignature) + preferences.trustedSignatures().get()
/**
* Return a list of all the installed extensions initialized concurrently.
@ -59,7 +64,6 @@ internal object ExtensionLoader {
fun loadExtensions(context: Context): List<LoadResult> {
val pkgManager = context.packageManager
@Suppress("DEPRECATION")
val installedPkgs = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
pkgManager.getInstalledPackages(PackageManager.PackageInfoFlags.of(PACKAGE_FLAGS.toLong()))
} else {
@ -135,7 +139,7 @@ internal object ExtensionLoader {
return LoadResult.Error
}
val signatureHash = getSignatureHash(pkgInfo)
val signatureHash = getSignatureHash(context, pkgInfo)
if (signatureHash == null) {
logcat(LogPriority.WARN) { "Package $pkgName isn't signed" }
return LoadResult.Error
@ -220,12 +224,8 @@ internal object ExtensionLoader {
*
* @param pkgInfo The package info of the application.
*/
private fun getSignatureHash(pkgInfo: PackageInfo): String? {
val signatures = pkgInfo.signatures
return if (signatures != null && signatures.isNotEmpty()) {
Hash.sha256(signatures.first().toByteArray())
} else {
null
}
private fun getSignatureHash(context: Context, pkgInfo: PackageInfo): String? {
val signatures = PackageInfoCompat.getSignatures(context.packageManager, pkgInfo.packageName)
return signatures.firstOrNull()?.let { Hash.sha256(it.toByteArray()) }
}
}

View file

@ -134,7 +134,6 @@ private fun Context.defaultBrowserPackageName(): String? {
val resolveInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
packageManager.resolveActivity(browserIntent, PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY.toLong()))
} else {
@Suppress("DEPRECATION")
packageManager.resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY)
}
return resolveInfo

View file

@ -5,10 +5,7 @@ import android.content.Context
import android.content.res.Configuration
import android.content.res.Resources
import android.os.Build
import android.view.Display
import android.view.View
import android.view.WindowManager
import androidx.core.content.getSystemService
import eu.kanade.domain.ui.UiPreferences
import eu.kanade.domain.ui.model.TabletUiMode
import uy.kohesive.injekt.Injekt
@ -67,14 +64,6 @@ fun Context.isNightMode(): Boolean {
return resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES
}
val Context.displayCompat: Display?
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
display
} else {
@Suppress("DEPRECATION")
getSystemService<WindowManager>()?.defaultDisplay
}
val Resources.isLTR
get() = configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR

View file

@ -7,6 +7,7 @@ import tachiyomi.core.util.lang.withIOContext
/**
* Util for evaluating JavaScript in sources.
*/
@Suppress("UNUSED", "UNCHECKED_CAST")
class JavaScriptEngine(context: Context) {
/**
@ -17,7 +18,6 @@ class JavaScriptEngine(context: Context) {
* @param script JavaScript to execute.
* @return Result of JavaScript code as a primitive type.
*/
@Suppress("UNUSED", "UNCHECKED_CAST")
suspend fun <T> evaluate(script: String): T = withIOContext {
QuickJs.create().use {
it.evaluate(script) as T

View file

@ -13,7 +13,7 @@ import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.TabPosition
import androidx.compose.material3.TabRowDefaults
import androidx.compose.material3.TabRowDefaults.SecondaryIndicator
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@ -50,8 +50,8 @@ fun TabIndicator(
currentTabPosition: TabPosition,
currentPageOffsetFraction: Float,
) {
TabRowDefaults.Indicator(
Modifier
SecondaryIndicator(
modifier = Modifier
.tabIndicatorOffset(currentTabPosition, currentPageOffsetFraction)
.padding(horizontal = 8.dp)
.clip(RoundedCornerShape(topStart = 3.dp, topEnd = 3.dp)),