Address some warnings and deprecations (#18436)
* Address some warnings and deprecations * Add back `AndroidConfig.targetSdk`
This commit is contained in:
parent
1c8478fcca
commit
7eb7c2567a
|
@ -21,5 +21,5 @@ allprojects {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register<Delete>("clean") {
|
tasks.register<Delete>("clean") {
|
||||||
delete(rootProject.buildDir)
|
delete(rootProject.layout.buildDirectory.asFile.get())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
object AndroidConfig {
|
object AndroidConfig {
|
||||||
const val compileSdk = 34
|
const val compileSdk = 34
|
||||||
const val minSdk = 21
|
const val minSdk = 21
|
||||||
|
@Suppress("UNUSED")
|
||||||
const val targetSdk = 34
|
const val targetSdk = 34
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ android {
|
||||||
|
|
||||||
namespace = "eu.kanade.tachiyomi.extension"
|
namespace = "eu.kanade.tachiyomi.extension"
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
sourceSets {
|
sourceSets {
|
||||||
named("main") {
|
named("main") {
|
||||||
manifest.srcFile("AndroidManifest.xml")
|
manifest.srcFile("AndroidManifest.xml")
|
||||||
|
|
|
@ -8,7 +8,6 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = AndroidConfig.minSdk
|
minSdk = AndroidConfig.minSdk
|
||||||
targetSdk = AndroidConfig.targetSdk
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace = "eu.kanade.tachiyomi.lib.cryptoaes"
|
namespace = "eu.kanade.tachiyomi.lib.cryptoaes"
|
||||||
|
|
|
@ -11,7 +11,6 @@ import javax.crypto.spec.SecretKeySpec
|
||||||
/**
|
/**
|
||||||
* Conforming with CryptoJS AES method
|
* Conforming with CryptoJS AES method
|
||||||
*/
|
*/
|
||||||
@Suppress("unused", "FunctionName")
|
|
||||||
object CryptoAES {
|
object CryptoAES {
|
||||||
|
|
||||||
private const val KEY_SIZE = 256
|
private const val KEY_SIZE = 256
|
||||||
|
@ -29,17 +28,17 @@ object CryptoAES {
|
||||||
* @param password passphrase
|
* @param password passphrase
|
||||||
*/
|
*/
|
||||||
fun decrypt(cipherText: String, password: String): String {
|
fun decrypt(cipherText: String, password: String): String {
|
||||||
try {
|
return try {
|
||||||
val ctBytes = Base64.decode(cipherText, Base64.DEFAULT)
|
val ctBytes = Base64.decode(cipherText, Base64.DEFAULT)
|
||||||
val saltBytes = Arrays.copyOfRange(ctBytes, 8, 16)
|
val saltBytes = Arrays.copyOfRange(ctBytes, 8, 16)
|
||||||
val cipherTextBytes = Arrays.copyOfRange(ctBytes, 16, ctBytes.size)
|
val cipherTextBytes = Arrays.copyOfRange(ctBytes, 16, ctBytes.size)
|
||||||
val md5: MessageDigest = MessageDigest.getInstance("MD5")
|
val md5: MessageDigest = MessageDigest.getInstance("MD5")
|
||||||
val keyAndIV = generateKeyAndIV(32, 16, 1, saltBytes, password.toByteArray(Charsets.UTF_8), md5)
|
val keyAndIV = generateKeyAndIV(32, 16, 1, saltBytes, password.toByteArray(Charsets.UTF_8), md5)
|
||||||
return decryptAES(cipherTextBytes,
|
decryptAES(cipherTextBytes,
|
||||||
keyAndIV?.get(0) ?: ByteArray(32),
|
keyAndIV?.get(0) ?: ByteArray(32),
|
||||||
keyAndIV?.get(1) ?: ByteArray(16))
|
keyAndIV?.get(1) ?: ByteArray(16))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
return ""
|
""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +92,7 @@ object CryptoAES {
|
||||||
* @param md the message digest algorithm to use
|
* @param md the message digest algorithm to use
|
||||||
* @return an two-element array with the generated key and IV
|
* @return an two-element array with the generated key and IV
|
||||||
*/
|
*/
|
||||||
|
@Suppress("SameParameterValue")
|
||||||
private fun generateKeyAndIV(keyLength: Int, ivLength: Int, iterations: Int, salt: ByteArray, password: ByteArray, md: MessageDigest): Array<ByteArray?>? {
|
private fun generateKeyAndIV(keyLength: Int, ivLength: Int, iterations: Int, salt: ByteArray, password: ByteArray, md: MessageDigest): Array<ByteArray?>? {
|
||||||
val digestLength = md.digestLength
|
val digestLength = md.digestLength
|
||||||
val requiredLength = (keyLength + ivLength + digestLength - 1) / digestLength * digestLength
|
val requiredLength = (keyLength + ivLength + digestLength - 1) / digestLength * digestLength
|
||||||
|
@ -107,7 +107,7 @@ object CryptoAES {
|
||||||
// Digest data (last digest if available, password data, salt if available)
|
// Digest data (last digest if available, password data, salt if available)
|
||||||
if (generatedLength > 0) md.update(generatedData, generatedLength - digestLength, digestLength)
|
if (generatedLength > 0) md.update(generatedData, generatedLength - digestLength, digestLength)
|
||||||
md.update(password)
|
md.update(password)
|
||||||
if (salt != null) md.update(salt, 0, 8)
|
md.update(salt, 0, 8)
|
||||||
md.digest(generatedData, generatedLength, digestLength)
|
md.digest(generatedData, generatedLength, digestLength)
|
||||||
|
|
||||||
// additional rounds
|
// additional rounds
|
||||||
|
|
|
@ -9,8 +9,8 @@ package eu.kanade.tachiyomi.lib.cryptoaes
|
||||||
object Deobfuscator {
|
object Deobfuscator {
|
||||||
fun deobfuscateJsPassword(inputString: String): String {
|
fun deobfuscateJsPassword(inputString: String): String {
|
||||||
var idx = 0
|
var idx = 0
|
||||||
val brackets = listOf<Char>('[', '(')
|
val brackets = listOf('[', '(')
|
||||||
var evaluatedString = StringBuilder()
|
val evaluatedString = StringBuilder()
|
||||||
while (idx < inputString.length) {
|
while (idx < inputString.length) {
|
||||||
val chr = inputString[idx]
|
val chr = inputString[idx]
|
||||||
if (chr !in brackets) {
|
if (chr !in brackets) {
|
||||||
|
@ -60,9 +60,9 @@ object Deobfuscator {
|
||||||
therefore '!+[]' count equals the digit
|
therefore '!+[]' count equals the digit
|
||||||
if count equals 0, check for '+[]' just to be sure
|
if count equals 0, check for '+[]' just to be sure
|
||||||
*/
|
*/
|
||||||
val digit = "\\!\\+\\[\\]".toRegex().findAll(inputSubString).count() // matches '!+[]'
|
val digit = "!\\+\\[]".toRegex().findAll(inputSubString).count() // matches '!+[]'
|
||||||
if (digit == 0) {
|
if (digit == 0) {
|
||||||
if ("\\+\\[\\]".toRegex().findAll(inputSubString).count() == 1) { // matches '+[]'
|
if ("\\+\\[]".toRegex().findAll(inputSubString).count() == 1) { // matches '+[]'
|
||||||
return '0'
|
return '0'
|
||||||
}
|
}
|
||||||
} else if (digit in 1..9) {
|
} else if (digit in 1..9) {
|
||||||
|
|
|
@ -8,7 +8,6 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = AndroidConfig.minSdk
|
minSdk = AndroidConfig.minSdk
|
||||||
targetSdk = AndroidConfig.targetSdk
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace = "eu.kanade.tachiyomi.lib.dataimage"
|
namespace = "eu.kanade.tachiyomi.lib.dataimage"
|
||||||
|
|
|
@ -8,7 +8,6 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = AndroidConfig.minSdk
|
minSdk = AndroidConfig.minSdk
|
||||||
targetSdk = AndroidConfig.targetSdk
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace = "eu.kanade.tachiyomi.lib.i18n"
|
namespace = "eu.kanade.tachiyomi.lib.i18n"
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package eu.kanade.tachiyomi.lib.i18n
|
package eu.kanade.tachiyomi.lib.i18n
|
||||||
|
|
||||||
import org.jetbrains.annotations.NonNls
|
|
||||||
import org.jetbrains.annotations.PropertyKey
|
import org.jetbrains.annotations.PropertyKey
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
import java.text.Collator
|
import java.text.Collator
|
||||||
import java.text.MessageFormat
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.PropertyResourceBundle
|
import java.util.PropertyResourceBundle
|
||||||
|
|
||||||
|
@ -23,9 +21,9 @@ import java.util.PropertyResourceBundle
|
||||||
* on how to do so.
|
* on how to do so.
|
||||||
*/
|
*/
|
||||||
class Intl(
|
class Intl(
|
||||||
private val language: String,
|
language: String,
|
||||||
|
availableLanguages: Set<String>,
|
||||||
private val baseLanguage: String,
|
private val baseLanguage: String,
|
||||||
private val availableLanguages: Set<String>,
|
|
||||||
private val classLoader: ClassLoader,
|
private val classLoader: ClassLoader,
|
||||||
private val createMessageFileName: (String) -> String = { createDefaultMessageFileName(it) }
|
private val createMessageFileName: (String) -> String = { createDefaultMessageFileName(it) }
|
||||||
) {
|
) {
|
||||||
|
@ -50,6 +48,7 @@ class Intl(
|
||||||
* in the current language, the English value will be returned. If the [key]
|
* in the current language, the English value will be returned. If the [key]
|
||||||
* is also not present in English, the [key] surrounded by brackets will be returned.
|
* is also not present in English, the [key] surrounded by brackets will be returned.
|
||||||
*/
|
*/
|
||||||
|
@Suppress("InvalidBundleOrProperty")
|
||||||
operator fun get(@PropertyKey(resourceBundle = "i18n.messages") key: String): String = when {
|
operator fun get(@PropertyKey(resourceBundle = "i18n.messages") key: String): String = when {
|
||||||
bundle.containsKey(key) -> bundle.getString(key)
|
bundle.containsKey(key) -> bundle.getString(key)
|
||||||
baseBundle.containsKey(key) -> baseBundle.getString(key)
|
baseBundle.containsKey(key) -> baseBundle.getString(key)
|
||||||
|
@ -60,6 +59,7 @@ class Intl(
|
||||||
* Uses the string as a format string and returns a string obtained by
|
* Uses the string as a format string and returns a string obtained by
|
||||||
* substituting the specified arguments, using the instance locale.
|
* substituting the specified arguments, using the instance locale.
|
||||||
*/
|
*/
|
||||||
|
@Suppress("InvalidBundleOrProperty")
|
||||||
fun format(@PropertyKey(resourceBundle = "i18n.messages") key: String, vararg args: Any?) =
|
fun format(@PropertyKey(resourceBundle = "i18n.messages") key: String, vararg args: Any?) =
|
||||||
get(key).format(locale, *args)
|
get(key).format(locale, *args)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = AndroidConfig.minSdk
|
minSdk = AndroidConfig.minSdk
|
||||||
targetSdk = AndroidConfig.targetSdk
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace = "eu.kanade.tachiyomi.lib.randomua"
|
namespace = "eu.kanade.tachiyomi.lib.randomua"
|
||||||
|
|
|
@ -8,7 +8,6 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = AndroidConfig.minSdk
|
minSdk = AndroidConfig.minSdk
|
||||||
targetSdk = AndroidConfig.targetSdk
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace = "eu.kanade.tachiyomi.lib.synchrony"
|
namespace = "eu.kanade.tachiyomi.lib.synchrony"
|
||||||
|
|
|
@ -33,7 +33,6 @@ object Deobfuscator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused")
|
|
||||||
private interface TestInterface {
|
private interface TestInterface {
|
||||||
fun getValue(): String
|
fun getValue(): String
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = AndroidConfig.minSdk
|
minSdk = AndroidConfig.minSdk
|
||||||
targetSdk = AndroidConfig.targetSdk
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace = "eu.kanade.tachiyomi.lib.textinterceptor"
|
namespace = "eu.kanade.tachiyomi.lib.textinterceptor"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.lib.textinterceptor
|
package eu.kanade.tachiyomi.lib.textinterceptor
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
@ -53,7 +54,7 @@ class TextInterceptor : Interceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
val heading: StaticLayout = StaticLayout(
|
val heading = StaticLayout(
|
||||||
creator, paintHeading, (WIDTH - 2 * X_PADDING).toInt(),
|
creator, paintHeading, (WIDTH - 2 * X_PADDING).toInt(),
|
||||||
Layout.Alignment.ALIGN_NORMAL, SPACING_MULT, SPACING_ADD, true
|
Layout.Alignment.ALIGN_NORMAL, SPACING_MULT, SPACING_ADD, true
|
||||||
)
|
)
|
||||||
|
@ -67,7 +68,7 @@ class TextInterceptor : Interceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
val body: StaticLayout = StaticLayout(
|
val body = StaticLayout(
|
||||||
story, paintBody, (WIDTH - 2 * X_PADDING).toInt(),
|
story, paintBody, (WIDTH - 2 * X_PADDING).toInt(),
|
||||||
Layout.Alignment.ALIGN_NORMAL, SPACING_MULT, SPACING_ADD, true
|
Layout.Alignment.ALIGN_NORMAL, SPACING_MULT, SPACING_ADD, true
|
||||||
)
|
)
|
||||||
|
@ -75,12 +76,12 @@ class TextInterceptor : Interceptor {
|
||||||
// Image building
|
// Image building
|
||||||
val imgHeight: Int = (heading.height + body.height + 2 * Y_PADDING).toInt()
|
val imgHeight: Int = (heading.height + body.height + 2 * Y_PADDING).toInt()
|
||||||
val bitmap: Bitmap = Bitmap.createBitmap(WIDTH, imgHeight, Bitmap.Config.ARGB_8888)
|
val bitmap: Bitmap = Bitmap.createBitmap(WIDTH, imgHeight, Bitmap.Config.ARGB_8888)
|
||||||
val canvas: Canvas = Canvas(bitmap)
|
|
||||||
|
|
||||||
// Image drawing
|
Canvas(bitmap).apply {
|
||||||
canvas.drawColor(Color.WHITE)
|
drawColor(Color.WHITE)
|
||||||
heading.draw(canvas, X_PADDING, Y_PADDING)
|
heading.draw(this, X_PADDING, Y_PADDING)
|
||||||
body.draw(canvas, X_PADDING, Y_PADDING + heading.height.toFloat())
|
body.draw(this, X_PADDING, Y_PADDING + heading.height.toFloat())
|
||||||
|
}
|
||||||
|
|
||||||
// Image converting & returning
|
// Image converting & returning
|
||||||
val stream = ByteArrayOutputStream()
|
val stream = ByteArrayOutputStream()
|
||||||
|
@ -95,14 +96,17 @@ class TextInterceptor : Interceptor {
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ObsoleteSdkInt")
|
||||||
private fun textFixer(htmlString: String): String {
|
private fun textFixer(htmlString: String): String {
|
||||||
return if (Build.VERSION.SDK_INT >= 24) {
|
return if (Build.VERSION.SDK_INT >= 24) {
|
||||||
Html.fromHtml(htmlString , Html.FROM_HTML_MODE_LEGACY).toString()
|
Html.fromHtml(htmlString , Html.FROM_HTML_MODE_LEGACY).toString()
|
||||||
} else {
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
Html.fromHtml(htmlString).toString()
|
Html.fromHtml(htmlString).toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("SameParameterValue")
|
||||||
private fun StaticLayout.draw(canvas: Canvas, x: Float, y: Float) {
|
private fun StaticLayout.draw(canvas: Canvas, x: Float, y: Float) {
|
||||||
canvas.save()
|
canvas.save()
|
||||||
canvas.translate(x, y)
|
canvas.translate(x, y)
|
||||||
|
|
|
@ -9,7 +9,6 @@ android {
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdk = 29
|
minSdk = 29
|
||||||
targetSdk = AndroidConfig.targetSdk
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace = "eu.kanade.tachiyomi.lib.themesources"
|
namespace = "eu.kanade.tachiyomi.lib.themesources"
|
||||||
|
@ -42,6 +41,7 @@ dependencies {
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
register<JavaExec>("generateExtensions") {
|
register<JavaExec>("generateExtensions") {
|
||||||
|
val buildDir = layout.buildDirectory.asFile.get()
|
||||||
classpath = configurations.compileOnly.get() +
|
classpath = configurations.compileOnly.get() +
|
||||||
configurations.androidApis.get() + // android.jar path
|
configurations.androidApis.get() + // android.jar path
|
||||||
files("$buildDir/intermediates/aar_main_jar/debug/classes.jar") // jar made from this module
|
files("$buildDir/intermediates/aar_main_jar/debug/classes.jar") // jar made from this module
|
||||||
|
|
Loading…
Reference in New Issue