mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-30 23:48:31 +00:00
Added custom markdown window for redesign
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.topjohnwu.magisk.Config
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.data.repository.StringRepository
|
||||
import com.topjohnwu.magisk.extensions.subscribeK
|
||||
@@ -34,7 +35,8 @@ object MarkDownWindow : KoinComponent {
|
||||
}
|
||||
|
||||
fun show(activity: Context, title: String?, content: Single<String>) {
|
||||
val mv = LayoutInflater.from(activity).inflate(R.layout.markdown_window, null)
|
||||
val mdRes = if (Config.redesign) R.layout.markdown_window_md2 else R.layout.markdown_window
|
||||
val mv = LayoutInflater.from(activity).inflate(mdRes, null)
|
||||
val tv = mv.findViewById<TextView>(R.id.md_txt)
|
||||
|
||||
content.map {
|
||||
@@ -45,11 +47,21 @@ object MarkDownWindow : KoinComponent {
|
||||
tv.setText(R.string.download_file_error)
|
||||
Completable.complete()
|
||||
}.subscribeK {
|
||||
if (Config.redesign) {
|
||||
MagiskDialog(activity)
|
||||
.applyTitle(title ?: "")
|
||||
.applyView(mv)
|
||||
.applyButton(MagiskDialog.ButtonType.NEGATIVE) {
|
||||
titleRes = android.R.string.cancel
|
||||
}
|
||||
.reveal()
|
||||
return@subscribeK
|
||||
}
|
||||
AlertDialog.Builder(activity)
|
||||
.setTitle(title)
|
||||
.setView(mv)
|
||||
.setNegativeButton(android.R.string.cancel) { dialog, _ -> dialog.dismiss() }
|
||||
.show()
|
||||
.setTitle(title)
|
||||
.setView(mv)
|
||||
.setNegativeButton(android.R.string.cancel) { dialog, _ -> dialog.dismiss() }
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user