Added custom markdown window for redesign

This commit is contained in:
Viktor De Pasquale 2019-11-19 17:41:24 +01:00
parent 35475e1d25
commit c5385b5b4c
2 changed files with 32 additions and 5 deletions

View File

@ -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,6 +47,16 @@ 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)

View 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>