Added custom markdown window for redesign
This commit is contained in:
parent
35475e1d25
commit
c5385b5b4c
@ -4,6 +4,7 @@ import android.content.Context
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import com.topjohnwu.magisk.Config
|
||||||
import com.topjohnwu.magisk.R
|
import com.topjohnwu.magisk.R
|
||||||
import com.topjohnwu.magisk.data.repository.StringRepository
|
import com.topjohnwu.magisk.data.repository.StringRepository
|
||||||
import com.topjohnwu.magisk.extensions.subscribeK
|
import com.topjohnwu.magisk.extensions.subscribeK
|
||||||
@ -34,7 +35,8 @@ object MarkDownWindow : KoinComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun show(activity: Context, title: String?, content: Single<String>) {
|
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)
|
val tv = mv.findViewById<TextView>(R.id.md_txt)
|
||||||
|
|
||||||
content.map {
|
content.map {
|
||||||
@ -45,6 +47,16 @@ object MarkDownWindow : KoinComponent {
|
|||||||
tv.setText(R.string.download_file_error)
|
tv.setText(R.string.download_file_error)
|
||||||
Completable.complete()
|
Completable.complete()
|
||||||
}.subscribeK {
|
}.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)
|
AlertDialog.Builder(activity)
|
||||||
.setTitle(title)
|
.setTitle(title)
|
||||||
.setView(mv)
|
.setView(mv)
|
||||||
|
15
app/src/main/res/layout/markdown_window_md2.xml
Normal file
15
app/src/main/res/layout/markdown_window_md2.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/md_txt"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="15dp"
|
||||||
|
android:layout_marginEnd="15dp"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:textAppearance="?appearanceTextCaptionNormal" />
|
||||||
|
|
||||||
|
</ScrollView>
|
Loading…
Reference in New Issue
Block a user