You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Merge remote-tracking branch 'john/master' into feature/redesign
# Conflicts: # app/build.gradle # app/src/main/AndroidManifest.xml # app/src/main/java/com/topjohnwu/magisk/model/events/ViewEvents.kt # app/src/main/java/com/topjohnwu/magisk/model/navigation/MagiskNavigationEvent.kt # app/src/main/java/com/topjohnwu/magisk/ui/SplashActivity.kt # app/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsFragment.kt # app/src/main/java/com/topjohnwu/magisk/view/MagiskDialog.kt # app/src/main/res/layout/dialog_magisk_base.xml
This commit is contained in:
@@ -4,23 +4,22 @@ import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.skoumal.teanity.extensions.subscribeK
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.data.repository.StringRepository
|
||||
import com.topjohnwu.magisk.extensions.inject
|
||||
import com.topjohnwu.magisk.extensions.subscribeK
|
||||
import io.noties.markwon.Markwon
|
||||
import io.reactivex.Completable
|
||||
import io.reactivex.Single
|
||||
import ru.noties.markwon.Markwon
|
||||
import ru.noties.markwon.html.HtmlPlugin
|
||||
import ru.noties.markwon.image.ImagesPlugin
|
||||
import ru.noties.markwon.image.svg.SvgPlugin
|
||||
import org.koin.core.KoinComponent
|
||||
import org.koin.core.inject
|
||||
import timber.log.Timber
|
||||
import java.io.InputStream
|
||||
import java.util.*
|
||||
|
||||
object MarkDownWindow {
|
||||
object MarkDownWindow : KoinComponent {
|
||||
|
||||
private val stringRepo: StringRepository by inject()
|
||||
private val markwon: Markwon by inject()
|
||||
|
||||
fun show(activity: Context, title: String?, url: String) {
|
||||
show(activity, title, stringRepo.getString(url))
|
||||
@@ -35,25 +34,14 @@ object MarkDownWindow {
|
||||
}
|
||||
|
||||
fun show(activity: Context, title: String?, content: Single<String>) {
|
||||
val markwon = Markwon.builder(activity)
|
||||
.usePlugin(HtmlPlugin.create())
|
||||
.usePlugin(ImagesPlugin.create(activity))
|
||||
.usePlugin(SvgPlugin.create(activity.resources))
|
||||
.build()
|
||||
val mv = LayoutInflater.from(activity).inflate(R.layout.markdown_window, null)
|
||||
val tv = mv.findViewById<TextView>(R.id.md_txt)
|
||||
|
||||
content.map {
|
||||
runCatching {
|
||||
markwon.setMarkdown(tv, it)
|
||||
}.onFailure {
|
||||
Timber.e(it)
|
||||
// Always wrap the actual exception as it could be ExceptionInInitializerError,
|
||||
// which is a fatal error and RxJava will send it to the global handler and crash
|
||||
throw MarkwonException(it)
|
||||
}
|
||||
markwon.setMarkdown(tv, it)
|
||||
}.ignoreElement().onErrorResumeNext {
|
||||
// Nothing we can actually do other than show error message
|
||||
Timber.e(it)
|
||||
tv.setText(R.string.download_file_error)
|
||||
Completable.complete()
|
||||
}.subscribeK {
|
||||
@@ -64,6 +52,4 @@ object MarkDownWindow {
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
class MarkwonException(e: Throwable): Exception(e)
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import com.topjohnwu.magisk.Info
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.extensions.cachedFile
|
||||
import com.topjohnwu.magisk.extensions.reboot
|
||||
import com.topjohnwu.magisk.net.Networking
|
||||
import com.topjohnwu.magisk.tasks.MagiskInstaller
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
import com.topjohnwu.magisk.net.Networking
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import com.topjohnwu.superuser.ShellUtils
|
||||
import com.topjohnwu.superuser.internal.UiThreadHandler
|
||||
|
||||
@@ -7,13 +7,13 @@ import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.topjohnwu.magisk.Const
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
import com.topjohnwu.magisk.model.download.DownloadService
|
||||
import com.topjohnwu.magisk.model.entity.internal.Configuration
|
||||
import com.topjohnwu.magisk.model.entity.internal.DownloadSubject
|
||||
import com.topjohnwu.magisk.ui.base.MagiskActivity
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
|
||||
internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List<String>) :
|
||||
internal class InstallMethodDialog(activity: BaseActivity<*, *>, options: List<String>) :
|
||||
AlertDialog.Builder(activity) {
|
||||
|
||||
init {
|
||||
@@ -28,11 +28,11 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
|
||||
}
|
||||
}
|
||||
|
||||
private fun flash(activity: MagiskActivity<*, *>) = DownloadService(activity) {
|
||||
private fun flash(activity: BaseActivity<*, *>) = DownloadService(activity) {
|
||||
subject = DownloadSubject.Magisk(Configuration.Flash.Primary)
|
||||
}
|
||||
|
||||
private fun patchBoot(activity: MagiskActivity<*, *>) = activity.withExternalRW {
|
||||
private fun patchBoot(activity: BaseActivity<*, *>) = activity.withExternalRW {
|
||||
onSuccess {
|
||||
Utils.toast(R.string.patch_file_msg, Toast.LENGTH_LONG)
|
||||
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
||||
@@ -49,7 +49,7 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
|
||||
}
|
||||
}
|
||||
|
||||
private fun downloadOnly(activity: MagiskActivity<*, *>) = activity.withExternalRW {
|
||||
private fun downloadOnly(activity: BaseActivity<*, *>) = activity.withExternalRW {
|
||||
onSuccess {
|
||||
DownloadService(activity) {
|
||||
subject = DownloadSubject.Magisk(Configuration.Download)
|
||||
@@ -57,7 +57,7 @@ internal class InstallMethodDialog(activity: MagiskActivity<*, *>, options: List
|
||||
}
|
||||
}
|
||||
|
||||
private fun installInactiveSlot(activity: MagiskActivity<*, *>) {
|
||||
private fun installInactiveSlot(activity: BaseActivity<*, *>) {
|
||||
CustomAlertDialog(activity)
|
||||
.setTitle(R.string.warning)
|
||||
.setMessage(R.string.install_inactive_slot_msg)
|
||||
|
||||
@@ -3,14 +3,14 @@ package com.topjohnwu.magisk.view.dialogs
|
||||
import android.net.Uri
|
||||
import com.topjohnwu.magisk.Info
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.ui.base.MagiskActivity
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
import com.topjohnwu.magisk.utils.Utils
|
||||
import com.topjohnwu.magisk.view.MarkDownWindow
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import com.topjohnwu.superuser.ShellUtils
|
||||
import java.util.*
|
||||
|
||||
class MagiskInstallDialog(a: MagiskActivity<*, *>) : CustomAlertDialog(a) {
|
||||
class MagiskInstallDialog(a: BaseActivity<*, *>) : CustomAlertDialog(a) {
|
||||
init {
|
||||
val filename = "Magisk v${Info.remote.magisk.version}" +
|
||||
"(${Info.remote.magisk.versionCode})"
|
||||
|
||||
Reference in New Issue
Block a user