From 330a52a1c5e0d99c92a090761ea08ad667bd95b1 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 5 Jul 2022 23:33:54 +0200 Subject: [PATCH] use a more materialish dialog with system theme --- .../applauncher/dialogs/EditDialog.kt | 16 +++++++++----- .../main/res/layout/dialog_change_sorting.xml | 9 +------- .../layout/dialog_edit_launcher_material.xml | 22 +++++++++++++++++++ 3 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 app/src/main/res/layout/dialog_edit_launcher_material.xml diff --git a/app/src/main/kotlin/com/simplemobiletools/applauncher/dialogs/EditDialog.kt b/app/src/main/kotlin/com/simplemobiletools/applauncher/dialogs/EditDialog.kt index 918e252..35c8be3 100644 --- a/app/src/main/kotlin/com/simplemobiletools/applauncher/dialogs/EditDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/applauncher/dialogs/EditDialog.kt @@ -2,26 +2,32 @@ package com.simplemobiletools.applauncher.dialogs import android.app.Activity import android.view.ViewGroup +import androidx.appcompat.widget.AppCompatEditText import com.simplemobiletools.applauncher.R import com.simplemobiletools.applauncher.extensions.dbHelper import com.simplemobiletools.applauncher.models.AppLauncher import com.simplemobiletools.commons.extensions.* -import kotlinx.android.synthetic.main.dialog_edit_launcher.view.* class EditDialog(val activity: Activity, val appLauncher: AppLauncher, val callback: () -> Unit) { - private var view = (activity.layoutInflater.inflate(R.layout.dialog_edit_launcher, null) as ViewGroup) init { - view.edit_launcher_edittext.setText(appLauncher.title) + val layoutId = if (activity.baseConfig.isUsingSystemTheme) { + R.layout.dialog_edit_launcher_material + } else { + R.layout.dialog_edit_launcher + } + + val view = (activity.layoutInflater.inflate(layoutId, null) as ViewGroup) + view.findViewById(R.id.edit_launcher_edittext).setText(appLauncher.title) activity.getAlertDialogBuilder() .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) .apply { activity.setupDialogStuff(view, this, R.string.rename) { alertDialog -> - alertDialog.showKeyboard(view.edit_launcher_edittext) + alertDialog.showKeyboard(view.findViewById(R.id.edit_launcher_edittext)) alertDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener { - val newName = view.edit_launcher_edittext.value + val newName = view.findViewById(R.id.edit_launcher_edittext).value if (!newName.isEmpty()) { if (activity.dbHelper.updateLauncherName(appLauncher.id, newName)) { callback() diff --git a/app/src/main/res/layout/dialog_change_sorting.xml b/app/src/main/res/layout/dialog_change_sorting.xml index f163678..9842dfb 100644 --- a/app/src/main/res/layout/dialog_change_sorting.xml +++ b/app/src/main/res/layout/dialog_change_sorting.xml @@ -23,16 +23,12 @@ android:id="@+id/sorting_dialog_radio_title" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="@dimen/medium_margin" - android:paddingBottom="@dimen/medium_margin" android:text="@string/title" /> @@ -52,17 +48,14 @@ android:id="@+id/sorting_dialog_radio_ascending" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="@dimen/medium_margin" - android:paddingBottom="@dimen/medium_margin" android:text="@string/ascending" /> + diff --git a/app/src/main/res/layout/dialog_edit_launcher_material.xml b/app/src/main/res/layout/dialog_edit_launcher_material.xml new file mode 100644 index 0000000..1df3817 --- /dev/null +++ b/app/src/main/res/layout/dialog_edit_launcher_material.xml @@ -0,0 +1,22 @@ + + + + + + + + +