Added most of the remaining functionality for Magisk install dialog

This commit is contained in:
Viktor De Pasquale
2019-10-21 19:22:16 +02:00
parent dc09ec7598
commit 8a014ff786
3 changed files with 114 additions and 20 deletions
@@ -177,7 +177,9 @@ fun Intent.toCommand(args: MutableList<String>) {
val sb = StringBuilder()
val len = java.lang.reflect.Array.getLength(v)
for (i in 0 until len) {
sb.append(java.lang.reflect.Array.get(v, i)!!.toString().replace(",", "\\,"))
sb.append(
java.lang.reflect.Array.get(v, i)!!.toString().replace(",", "\\,")
)
sb.append(',')
}
// Remove trailing comma
@@ -262,10 +264,10 @@ fun Context.startEndToLeftRight(start: Int, end: Int): Pair<Int, Int> {
fun Context.openUrl(url: String) = Utils.openLink(this, url.toUri())
@Suppress("FunctionName")
inline fun <reified T> T.DynamicClassLoader(apk: File)
= DynamicClassLoader(apk, T::class.java.classLoader)
inline fun <reified T> T.DynamicClassLoader(apk: File) =
DynamicClassLoader(apk, T::class.java.classLoader)
fun Context.unwrap() : Context {
fun Context.unwrap(): Context {
var context = this
while (true) {
if (context is ContextWrapper)
@@ -275,3 +277,7 @@ fun Context.unwrap() : Context {
}
return context
}
fun Context.hasPermissions(vararg permissions: String) = permissions.all {
ContextCompat.checkSelfPermission(this, it) == PERMISSION_GRANTED
}