2021-01-16 15:49:25 +00:00
|
|
|
package com.vanced.manager.model
|
|
|
|
|
|
|
|
import android.content.Context
|
2021-02-26 15:34:22 +00:00
|
|
|
import androidx.annotation.DrawableRes
|
2021-01-27 16:58:18 +00:00
|
|
|
import androidx.lifecycle.LifecycleOwner
|
2021-01-16 15:49:25 +00:00
|
|
|
import androidx.lifecycle.LiveData
|
|
|
|
import com.beust.klaxon.JsonObject
|
|
|
|
import com.vanced.manager.utils.PackageHelper
|
|
|
|
|
2021-01-17 10:54:48 +00:00
|
|
|
class RootDataModel(
|
2021-01-16 15:49:25 +00:00
|
|
|
jsonObject: LiveData<JsonObject?>,
|
2021-01-17 12:52:50 +00:00
|
|
|
context: Context,
|
|
|
|
appPkg: String,
|
|
|
|
appName: String,
|
2021-02-26 15:34:22 +00:00
|
|
|
appDescription: String,
|
|
|
|
@DrawableRes appIcon: Int,
|
2021-01-17 12:52:50 +00:00
|
|
|
//BUG THIS!
|
|
|
|
//kotlin thinks that this value is null if we use
|
|
|
|
//private val scriptName: String
|
|
|
|
//Although it's impossible for it to be null.
|
|
|
|
//Ironic, isn't it?
|
|
|
|
private val scriptName: String?
|
2021-04-19 15:57:14 +00:00
|
|
|
) : DataModel(
|
2021-10-24 20:13:03 +00:00
|
|
|
jsonObject, context, appPkg, appName, appDescription, appIcon
|
2021-01-16 15:49:25 +00:00
|
|
|
) {
|
|
|
|
|
2021-01-17 12:52:50 +00:00
|
|
|
override fun isAppInstalled(pkg: String): Boolean {
|
|
|
|
//Adapt to nullable shit
|
|
|
|
return if (scriptName?.let { PackageHelper.scriptExists(it) } == true) {
|
|
|
|
super.isAppInstalled(appPkg)
|
2021-01-16 15:49:25 +00:00
|
|
|
} else {
|
2021-01-17 12:52:50 +00:00
|
|
|
false
|
2021-01-16 15:49:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|