From c5385b5b4c75c2bbc18f71a0ee705df9f13d0996 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Tue, 19 Nov 2019 17:41:24 +0100 Subject: [PATCH] Added custom markdown window for redesign --- .../topjohnwu/magisk/view/MarkDownWindow.kt | 22 ++++++++++++++----- .../main/res/layout/markdown_window_md2.xml | 15 +++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 app/src/main/res/layout/markdown_window_md2.xml diff --git a/app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt b/app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt index d5b844b92..6b323a34c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt +++ b/app/src/main/java/com/topjohnwu/magisk/view/MarkDownWindow.kt @@ -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) { - 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(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() } } } diff --git a/app/src/main/res/layout/markdown_window_md2.xml b/app/src/main/res/layout/markdown_window_md2.xml new file mode 100644 index 000000000..4d9941eac --- /dev/null +++ b/app/src/main/res/layout/markdown_window_md2.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file