Minor changes

This commit is contained in:
topjohnwu 2021-05-09 20:45:53 -07:00
parent 775d095b3c
commit 5c333dec33
4 changed files with 9 additions and 14 deletions

View File

@ -2,7 +2,6 @@ package com.topjohnwu.magisk.arch
import android.Manifest import android.Manifest
import androidx.annotation.CallSuper import androidx.annotation.CallSuper
import androidx.core.graphics.Insets
import androidx.databinding.Bindable import androidx.databinding.Bindable
import androidx.databinding.Observable import androidx.databinding.Observable
import androidx.databinding.PropertyChangeRegistry import androidx.databinding.PropertyChangeRegistry
@ -14,8 +13,10 @@ import androidx.navigation.NavDirections
import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.R import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.Info
import com.topjohnwu.magisk.core.base.BaseActivity import com.topjohnwu.magisk.events.BackPressEvent
import com.topjohnwu.magisk.events.* import com.topjohnwu.magisk.events.NavigationEvent
import com.topjohnwu.magisk.events.PermissionEvent
import com.topjohnwu.magisk.events.SnackbarEvent
import com.topjohnwu.magisk.utils.ObservableHost import com.topjohnwu.magisk.utils.ObservableHost
import com.topjohnwu.magisk.utils.set import com.topjohnwu.magisk.utils.set
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
@ -40,10 +41,6 @@ abstract class BaseViewModel(
val isConnected get() = Info.isConnected val isConnected get() = Info.isConnected
val viewEvents: LiveData<ViewEvent> get() = _viewEvents val viewEvents: LiveData<ViewEvent> get() = _viewEvents
@get:Bindable
var insets = Insets.NONE
set(value) = set(value, field, { field = it }, BR.insets)
var state= initialState var state= initialState
set(value) = set(value, field, { field = it }, BR.loading, BR.loaded, BR.loadFailed) set(value) = set(value, field, { field = it }, BR.loading, BR.loaded, BR.loadFailed)
@ -76,10 +73,6 @@ abstract class BaseViewModel(
super.onCleared() super.onCleared()
} }
fun withView(action: BaseActivity.() -> Unit) {
ViewActionEvent(action).publish()
}
fun withPermission(permission: String, callback: (Boolean) -> Unit) { fun withPermission(permission: String, callback: (Boolean) -> Unit) {
PermissionEvent(permission, callback).publish() PermissionEvent(permission, callback).publish()
} }

View File

@ -1,5 +1,6 @@
package com.topjohnwu.magisk.di package com.topjohnwu.magisk.di
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
@ -25,6 +26,7 @@ import com.topjohnwu.magisk.ui.surequest.SuRequestViewModel
val AppContext: Context inline get() = ServiceLocator.context val AppContext: Context inline get() = ServiceLocator.context
@SuppressLint("StaticFieldLeak")
object ServiceLocator { object ServiceLocator {
lateinit var context: Context lateinit var context: Context

View File

@ -137,7 +137,7 @@ class CheckSafetyNetEvent(
} }
private fun String.decode(): ByteArray { private fun String.decode(): ByteArray {
return if (contains("\\+|/".toRegex())) return if (contains("[+/]".toRegex()))
Base64.decode(this, Base64.DEFAULT) Base64.decode(this, Base64.DEFAULT)
else else
Base64.decode(this, Base64.URL_SAFE) Base64.decode(this, Base64.URL_SAFE)

View File

@ -79,13 +79,13 @@ class SafetynetViewModel : BaseViewModel() {
if (success) R.string.safetynet_attest_success if (success) R.string.safetynet_attest_success
else R.string.safetynet_attest_failure else R.string.safetynet_attest_failure
} }
} ?: { } ?: run {
isSuccess = false isSuccess = false
ctsState = false ctsState = false
basicIntegrityState = false basicIntegrityState = false
evalType = "N/A" evalType = "N/A"
safetyNetTitle = R.string.safetynet_api_error safetyNetTitle = R.string.safetynet_api_error
}() }
} }
companion object { companion object {