From 5c333dec33435322a04ae927f3d6e6d5ed5bfdaa Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 9 May 2021 20:45:53 -0700 Subject: [PATCH] Minor changes --- .../com/topjohnwu/magisk/arch/BaseViewModel.kt | 15 ++++----------- .../com/topjohnwu/magisk/di/ServiceLocator.kt | 2 ++ .../magisk/ui/safetynet/CheckSafetyNetEvent.kt | 2 +- .../magisk/ui/safetynet/SafetynetViewModel.kt | 4 ++-- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/BaseViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/arch/BaseViewModel.kt index aebff32b6..6018da03b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/arch/BaseViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/arch/BaseViewModel.kt @@ -2,7 +2,6 @@ package com.topjohnwu.magisk.arch import android.Manifest import androidx.annotation.CallSuper -import androidx.core.graphics.Insets import androidx.databinding.Bindable import androidx.databinding.Observable import androidx.databinding.PropertyChangeRegistry @@ -14,8 +13,10 @@ import androidx.navigation.NavDirections import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Info -import com.topjohnwu.magisk.core.base.BaseActivity -import com.topjohnwu.magisk.events.* +import com.topjohnwu.magisk.events.BackPressEvent +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.set import kotlinx.coroutines.Job @@ -40,10 +41,6 @@ abstract class BaseViewModel( val isConnected get() = Info.isConnected val viewEvents: LiveData get() = _viewEvents - @get:Bindable - var insets = Insets.NONE - set(value) = set(value, field, { field = it }, BR.insets) - var state= initialState set(value) = set(value, field, { field = it }, BR.loading, BR.loaded, BR.loadFailed) @@ -76,10 +73,6 @@ abstract class BaseViewModel( super.onCleared() } - fun withView(action: BaseActivity.() -> Unit) { - ViewActionEvent(action).publish() - } - fun withPermission(permission: String, callback: (Boolean) -> Unit) { PermissionEvent(permission, callback).publish() } diff --git a/app/src/main/java/com/topjohnwu/magisk/di/ServiceLocator.kt b/app/src/main/java/com/topjohnwu/magisk/di/ServiceLocator.kt index f08087de6..cb79d1eaa 100644 --- a/app/src/main/java/com/topjohnwu/magisk/di/ServiceLocator.kt +++ b/app/src/main/java/com/topjohnwu/magisk/di/ServiceLocator.kt @@ -1,5 +1,6 @@ package com.topjohnwu.magisk.di +import android.annotation.SuppressLint import android.content.Context import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModelProvider @@ -25,6 +26,7 @@ import com.topjohnwu.magisk.ui.surequest.SuRequestViewModel val AppContext: Context inline get() = ServiceLocator.context +@SuppressLint("StaticFieldLeak") object ServiceLocator { lateinit var context: Context diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/CheckSafetyNetEvent.kt b/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/CheckSafetyNetEvent.kt index 969bece1e..b18426ddb 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/CheckSafetyNetEvent.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/CheckSafetyNetEvent.kt @@ -137,7 +137,7 @@ class CheckSafetyNetEvent( } private fun String.decode(): ByteArray { - return if (contains("\\+|/".toRegex())) + return if (contains("[+/]".toRegex())) Base64.decode(this, Base64.DEFAULT) else Base64.decode(this, Base64.URL_SAFE) diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/SafetynetViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/SafetynetViewModel.kt index 1a0b5dcf0..0d0938e5b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/SafetynetViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/safetynet/SafetynetViewModel.kt @@ -79,13 +79,13 @@ class SafetynetViewModel : BaseViewModel() { if (success) R.string.safetynet_attest_success else R.string.safetynet_attest_failure } - } ?: { + } ?: run { isSuccess = false ctsState = false basicIntegrityState = false evalType = "N/A" safetyNetTitle = R.string.safetynet_api_error - }() + } } companion object {