Refactoring
parent
3ed9ed8cab
commit
a89ff4d15d
@ -1,27 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.utils
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.res.Resources
|
|
||||||
|
|
||||||
object InternalResourceHelper {
|
|
||||||
|
|
||||||
fun getBoolean(context: Context, resName: String, defaultValue: Boolean): Boolean {
|
|
||||||
val id = getResourceId(resName, "bool")
|
|
||||||
return if (id != 0) {
|
|
||||||
context.createPackageContext("android", 0).resources.getBoolean(id)
|
|
||||||
} else {
|
|
||||||
defaultValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get resource id from system resources
|
|
||||||
* @param resName resource name to get
|
|
||||||
* @param type resource type of [resName] to get
|
|
||||||
* @return 0 if not available
|
|
||||||
*/
|
|
||||||
private fun getResourceId(resName: String, type: String): Int {
|
|
||||||
return Resources.getSystem().getIdentifier(resName, type, "android")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.utils
|
|
||||||
|
|
||||||
import android.util.Base64
|
|
||||||
import java.security.SecureRandom
|
|
||||||
|
|
||||||
object PKCEGenerator {
|
|
||||||
|
|
||||||
private const val PKCE_BASE64_ENCODE_SETTINGS = Base64.NO_WRAP or Base64.NO_PADDING or Base64.URL_SAFE
|
|
||||||
|
|
||||||
fun generateCodeVerifier(): String {
|
|
||||||
val codeVerifier = ByteArray(50)
|
|
||||||
SecureRandom().nextBytes(codeVerifier)
|
|
||||||
return Base64.encodeToString(codeVerifier, PKCE_BASE64_ENCODE_SETTINGS)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue