mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-28 15:48:15 +00:00
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.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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
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…
x
Reference in New Issue
Block a user