Fixed issues after merge

This commit is contained in:
Viktor De Pasquale 2019-11-21 18:07:13 +01:00
parent 4f0e1c6c61
commit e82bc1b7bc
12 changed files with 23 additions and 137 deletions

View File

@ -8,6 +8,8 @@ import com.topjohnwu.magisk.model.entity.module.Repo
abstract class RepoDatabase : RoomDatabase() {
abstract fun repoDao() : RepoDao
abstract fun repoByUpdatedDao(): RepoByUpdatedDao
abstract fun repoByNameDao(): RepoByNameDao
}
@Dao

View File

@ -1,14 +0,0 @@
package com.topjohnwu.magisk.data.database
import androidx.room.Database
import androidx.room.RoomDatabase
import com.topjohnwu.magisk.model.entity.module.Repo
@Database(version = 6, entities = [Repo::class, RepoEtag::class])
abstract class RepoDatabase : RoomDatabase() {
abstract fun repoDao(): RepoDao
abstract fun repoByUpdatedDao(): RepoByUpdatedDao
abstract fun repoByNameDao(): RepoByNameDao
}

View File

@ -54,7 +54,7 @@ fun <T> Single<T>.subscribeK(
onError: OnErrorListener = { it.printStackTrace() },
onNext: OnSuccessListener<T> = {}
) = applySchedulers()
.subscribe(onSuccess, onError)
.subscribe(onNext, onError)
fun <T> Maybe<T>.subscribeK(
onError: OnErrorListener = { it.printStackTrace() },

View File

@ -81,7 +81,7 @@ class LogItem(val item: MagiskLog) : ObservableItem<LogItem>() {
override val layoutRes = R.layout.item_log_access_md2
val date = item.date.time.toTime(timeDateFormat)
val date = item.time.toTime(timeDateFormat)
var isTop = false
@Bindable get
set(value) {
@ -103,7 +103,7 @@ class LogItem(val item: MagiskLog) : ObservableItem<LogItem>() {
item.packageName == other.item.packageName &&
item.command == other.item.command &&
item.action == other.item.action &&
item.date == other.item.date &&
item.time == other.item.time &&
isTop == other.isTop &&
isBottom == other.isBottom
}

View File

@ -27,7 +27,7 @@ class InstallExternalModuleEvent : ViewEvent(), ActivityExecutor {
fun onActivityResult(context: Context, requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == Const.ID.FETCH_ZIP && resultCode == Activity.RESULT_OK && data != null) {
// Get the URI of the selected file
val intent = context.intent(FlashActivity::class.java)
val intent = context.intent<FlashActivity>()
intent.setData(data.data).putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_ZIP)
context.startActivity(intent)
}

View File

@ -1,5 +1,6 @@
package com.topjohnwu.magisk.model.events
import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
@ -10,11 +11,11 @@ import com.karumi.dexter.listener.PermissionRequest
import com.karumi.dexter.listener.multi.MultiplePermissionsListener
import com.topjohnwu.magisk.Const
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.base.BaseActivity
import com.topjohnwu.magisk.data.repository.MagiskRepository
import com.topjohnwu.magisk.extensions.DynamicClassLoader
import com.topjohnwu.magisk.extensions.subscribeK
import com.topjohnwu.magisk.extensions.writeTo
import com.topjohnwu.magisk.base.BaseActivity
import com.topjohnwu.magisk.model.entity.module.Repo
import com.topjohnwu.magisk.model.permissions.PermissionRequestBuilder
import com.topjohnwu.magisk.utils.RxBus
@ -136,7 +137,7 @@ class UpdateSafetyNetEvent : ViewEvent(), ContextExecutor, KoinComponent, Safety
}
class ViewActionEvent(val action: BaseActivity<*, *>.() -> Unit) : ViewEvent(), ActivityExecutor {
override fun invoke(activity: AppCompatActivity) = activity.run(action)
override fun invoke(activity: AppCompatActivity) = (activity as BaseActivity<*, *>).run(action)
}
class OpenFilePickerEvent : ViewEvent()

View File

@ -1,10 +1,9 @@
package com.topjohnwu.magisk.model.events.dialog
import android.os.Handler
import androidx.appcompat.app.AppCompatActivity
import androidx.biometric.BiometricPrompt
import com.topjohnwu.magisk.model.events.ActivityExecutor
import com.topjohnwu.magisk.model.events.ViewEvent
import com.topjohnwu.magisk.utils.BiometricHelper
class BiometricDialog(
builder: Builder.() -> Unit
@ -18,26 +17,11 @@ class BiometricDialog(
}
override fun invoke(activity: AppCompatActivity) {
val handler = Handler()
val prompt = BiometricPrompt.PromptInfo.Builder()
.setNegativeButtonText(activity.getString(android.R.string.cancel))
.build()
val callback = object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
listenerOnFailure()
}
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
listenerOnSuccess()
}
override fun onAuthenticationFailed() {
listenerOnFailure()
}
}
BiometricPrompt(activity, { handler.post(it) }, callback)
.authenticate(prompt/*launch with no crypto for now*/)
BiometricHelper.authenticate(
activity,
onError = listenerOnFailure,
onSuccess = listenerOnSuccess
)
}
inner class Builder internal constructor() {

View File

@ -1,82 +0,0 @@
package com.topjohnwu.magisk.model.events.dialog
import android.hardware.fingerprint.FingerprintManager
import android.widget.Toast
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.utils.FingerprintHelper
import com.topjohnwu.magisk.utils.Utils
import com.topjohnwu.magisk.view.MagiskDialog
import timber.log.Timber
@Deprecated(
"Use Biometrics instead",
ReplaceWith(
"BiometricDialog",
imports = ["com.topjohnwu.magisk.model.events.dialog.BiometricDialog"]
)
)
class FingerprintDialog(
builder: Builder.() -> Unit
) : DialogEvent() {
private val callbacks = Builder().apply(builder)
private var helper: Helper? = null
get() {
if (field == null) {
runCatching { field = Helper() }.onFailure { Timber.e(it) }
}
return field
}
override fun build(dialog: MagiskDialog) {
dialog.applyIcon(R.drawable.ic_fingerprint)
.applyTitle(R.string.auth_fingerprint)
.cancellable(false) //possible fix for devices that have flawed under-screen sensor implementation
.applyButton(MagiskDialog.ButtonType.POSITIVE) {
titleRes = android.R.string.cancel
onClick {
callbacks.listenerOnFailure()
helper?.cancel()
}
}
.onShow {
helper?.authenticate() ?: it.let {
callbacks.listenerOnFailure()
Utils.toast(R.string.auth_fail, Toast.LENGTH_SHORT)
it.dismiss()
}
}
}
inner class Builder internal constructor() {
internal var listenerOnFailure: GenericDialogListener = {}
internal var listenerOnSuccess: GenericDialogListener = {}
fun onFailure(listener: GenericDialogListener) {
listenerOnFailure = listener
}
fun onSuccess(listener: GenericDialogListener) {
listenerOnSuccess = listener
}
}
private inner class Helper @Throws(Exception::class) constructor() : FingerprintHelper() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
dialog.applyMessage(errString)
}
override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence) {
dialog.applyMessage(helpString)
}
override fun onAuthenticationFailed() {
dialog.applyMessage(R.string.auth_fail)
}
override fun onAuthenticationSucceeded(result: FingerprintManager.AuthenticationResult) {
callbacks.listenerOnSuccess()
dialog.dismiss()
}
}
}

View File

@ -111,12 +111,10 @@ object Navigation {
// redesign starts here
fun start(launchIntent: Intent, context: Context) {
val destination = when {
Config.redesign -> RedesignActivity::class.java
else -> MainActivity::class.java
}
context.intent(destination)
.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
when {
Config.redesign -> context.intent<RedesignActivity>()
else -> context.intent<MainActivity>()
}.putExtra(Const.Key.OPEN_SECTION, launchIntent.getStringExtra(Const.Key.OPEN_SECTION))
.putExtra(
Const.Key.OPEN_SETTINGS,
launchIntent.action == ACTION_APPLICATION_PREFERENCES

View File

@ -114,9 +114,6 @@ class HideViewModel(
fun toggleItem(item: HideProcessItem) = magiskRepo
.toggleHide(item.isHidden.value, item.item.packageName, item.item.name)
// might wanna reorder the list to display the item at the top
.subscribeK()
.add()
fun toggle(item: KObservableField<Boolean>) = item.toggle()

View File

@ -58,6 +58,7 @@ class LogViewModel(
.ignoreElement()
val console = repo.fetchMagiskLogs()
.toList()
.map { it.map { ConsoleRvItem(it) } }
.observeOn(Schedulers.computation())
.map { it to itemsConsole.calculateDiff(it) }
@ -90,7 +91,6 @@ class LogViewModel(
}
fun clearMagiskLog() = repo.clearMagiskLogs()
.ignoreElement()
.subscribeK {
SnackbarEvent(R.string.logs_cleared).publish()
requestRefresh()

View File

@ -18,8 +18,8 @@ import com.topjohnwu.magisk.model.events.dialog.SuperuserRevokeDialog
import com.topjohnwu.magisk.model.navigation.Navigation
import com.topjohnwu.magisk.redesign.compat.CompatViewModel
import com.topjohnwu.magisk.redesign.home.itemBindingOf
import com.topjohnwu.magisk.utils.BiometricHelper
import com.topjohnwu.magisk.utils.DiffObservableList
import com.topjohnwu.magisk.utils.FingerprintHelper
import com.topjohnwu.magisk.utils.RxBus
import com.topjohnwu.magisk.utils.currentLocale
import io.reactivex.Single
@ -71,7 +71,7 @@ class SuperuserViewModel(
.subscribeK { items.removeAll { it.itemSameAs(item) } }
.add()
if (FingerprintHelper.useFingerprint()) {
if (BiometricHelper.isEnabled) {
BiometricDialog {
onSuccess { updateState() }
}.publish()
@ -115,7 +115,7 @@ class SuperuserViewModel(
.add()
}
if (FingerprintHelper.useFingerprint()) {
if (BiometricHelper.isEnabled) {
BiometricDialog {
onSuccess { updateState() }
onFailure { item.isEnabled.toggle() }