mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-10 07:01:55 +00:00
Updated Hide screen with new arch
This commit is contained in:
@@ -8,6 +8,8 @@ import androidx.appcompat.widget.Toolbar
|
||||
import androidx.databinding.BindingAdapter
|
||||
import androidx.drawerlayout.widget.DrawerLayout
|
||||
import com.google.android.material.navigation.NavigationView
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.model.entity.state.IndeterminateState
|
||||
|
||||
|
||||
@BindingAdapter("onNavigationClick")
|
||||
@@ -35,3 +37,23 @@ fun setImageResource(view: AppCompatImageView, @DrawableRes resId: Int) {
|
||||
fun setTint(view: AppCompatImageView, @ColorInt tint: Int) {
|
||||
view.setColorFilter(tint)
|
||||
}
|
||||
|
||||
@BindingAdapter("isChecked")
|
||||
fun setChecked(view: AppCompatImageView, isChecked: Boolean) {
|
||||
val state = when (isChecked) {
|
||||
true -> IndeterminateState.CHECKED
|
||||
else -> IndeterminateState.UNCHECKED
|
||||
}
|
||||
setChecked(view, state)
|
||||
}
|
||||
|
||||
@BindingAdapter("isChecked")
|
||||
fun setChecked(view: AppCompatImageView, isChecked: IndeterminateState) {
|
||||
view.setImageResource(
|
||||
when (isChecked) {
|
||||
IndeterminateState.INDETERMINATE -> R.drawable.ic_indeterminate
|
||||
IndeterminateState.CHECKED -> R.drawable.ic_checked
|
||||
IndeterminateState.UNCHECKED -> R.drawable.ic_unchecked
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
50
app/src/main/java/com/topjohnwu/magisk/utils/XAndroid.kt
Normal file
50
app/src/main/java/com/topjohnwu/magisk/utils/XAndroid.kt
Normal file
@@ -0,0 +1,50 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.content.pm.ComponentInfo
|
||||
import android.content.pm.PackageInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.PackageManager.*
|
||||
|
||||
val PackageInfo.processes
|
||||
get() = activities?.processNames.orEmpty() +
|
||||
services?.processNames.orEmpty() +
|
||||
receivers?.processNames.orEmpty() +
|
||||
providers?.processNames.orEmpty()
|
||||
|
||||
val Array<out ComponentInfo>.processNames get() = mapNotNull { it.processName }
|
||||
|
||||
val ApplicationInfo.packageInfo: PackageInfo?
|
||||
get() {
|
||||
val pm: PackageManager by inject()
|
||||
|
||||
return try {
|
||||
val request = GET_ACTIVITIES or
|
||||
GET_SERVICES or
|
||||
GET_RECEIVERS or
|
||||
GET_PROVIDERS
|
||||
pm.getPackageInfo(packageName, request)
|
||||
} catch (e1: Exception) {
|
||||
try {
|
||||
pm.activities(packageName).apply {
|
||||
services = pm.services(packageName)
|
||||
receivers = pm.receivers(packageName)
|
||||
providers = pm.providers(packageName)
|
||||
}
|
||||
} catch (e2: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun PackageManager.activities(packageName: String) =
|
||||
getPackageInfo(packageName, GET_ACTIVITIES)
|
||||
|
||||
fun PackageManager.services(packageName: String) =
|
||||
getPackageInfo(packageName, GET_SERVICES).services
|
||||
|
||||
fun PackageManager.receivers(packageName: String) =
|
||||
getPackageInfo(packageName, GET_RECEIVERS).receivers
|
||||
|
||||
fun PackageManager.providers(packageName: String) =
|
||||
getPackageInfo(packageName, GET_PROVIDERS).providers
|
||||
20
app/src/main/java/com/topjohnwu/magisk/utils/XKoin.kt
Normal file
20
app/src/main/java/com/topjohnwu/magisk/utils/XKoin.kt
Normal file
@@ -0,0 +1,20 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import org.koin.core.context.GlobalContext
|
||||
import org.koin.core.parameter.ParametersDefinition
|
||||
import org.koin.core.qualifier.Qualifier
|
||||
import org.koin.core.scope.Scope
|
||||
|
||||
fun getKoin() = GlobalContext.get().koin
|
||||
|
||||
inline fun <reified T : Any> inject(
|
||||
qualifier: Qualifier? = null,
|
||||
scope: Scope? = null,
|
||||
noinline parameters: ParametersDefinition? = null
|
||||
) = lazy { get<T>(qualifier, scope, parameters) }
|
||||
|
||||
inline fun <reified T : Any> get(
|
||||
qualifier: Qualifier? = null,
|
||||
scope: Scope? = null,
|
||||
noinline parameters: ParametersDefinition? = null
|
||||
): T = getKoin().get(qualifier, scope, parameters)
|
||||
5
app/src/main/java/com/topjohnwu/magisk/utils/XRx.kt
Normal file
5
app/src/main/java/com/topjohnwu/magisk/utils/XRx.kt
Normal file
@@ -0,0 +1,5 @@
|
||||
package com.topjohnwu.magisk.utils
|
||||
|
||||
import io.reactivex.Single
|
||||
|
||||
fun <T : Any> T.toSingle() = Single.just(this)
|
||||
Reference in New Issue
Block a user