use a more materialish dialog with system theme

This commit is contained in:
tibbi 2022-07-05 23:33:54 +02:00
parent 2ac1cc1a28
commit 330a52a1c5
3 changed files with 34 additions and 13 deletions

View File

@ -2,26 +2,32 @@ package com.simplemobiletools.applauncher.dialogs
import android.app.Activity import android.app.Activity
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.AppCompatEditText
import com.simplemobiletools.applauncher.R import com.simplemobiletools.applauncher.R
import com.simplemobiletools.applauncher.extensions.dbHelper import com.simplemobiletools.applauncher.extensions.dbHelper
import com.simplemobiletools.applauncher.models.AppLauncher import com.simplemobiletools.applauncher.models.AppLauncher
import com.simplemobiletools.commons.extensions.* 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) { 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 { 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<AppCompatEditText>(R.id.edit_launcher_edittext).setText(appLauncher.title)
activity.getAlertDialogBuilder() activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.apply { .apply {
activity.setupDialogStuff(view, this, R.string.rename) { alertDialog -> 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 { alertDialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val newName = view.edit_launcher_edittext.value val newName = view.findViewById<AppCompatEditText>(R.id.edit_launcher_edittext).value
if (!newName.isEmpty()) { if (!newName.isEmpty()) {
if (activity.dbHelper.updateLauncherName(appLauncher.id, newName)) { if (activity.dbHelper.updateLauncherName(appLauncher.id, newName)) {
callback() callback()

View File

@ -23,16 +23,12 @@
android:id="@+id/sorting_dialog_radio_title" android:id="@+id/sorting_dialog_radio_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/title" /> android:text="@string/title" />
<com.simplemobiletools.commons.views.MyCompatRadioButton <com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_custom" android:id="@+id/sorting_dialog_radio_custom"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/custom" /> android:text="@string/custom" />
</RadioGroup> </RadioGroup>
@ -52,17 +48,14 @@
android:id="@+id/sorting_dialog_radio_ascending" android:id="@+id/sorting_dialog_radio_ascending"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/ascending" /> android:text="@string/ascending" />
<com.simplemobiletools.commons.views.MyCompatRadioButton <com.simplemobiletools.commons.views.MyCompatRadioButton
android:id="@+id/sorting_dialog_radio_descending" android:id="@+id/sorting_dialog_radio_descending"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/medium_margin"
android:paddingBottom="@dimen/medium_margin"
android:text="@string/descending" /> android:text="@string/descending" />
</RadioGroup> </RadioGroup>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/edit_launcher_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_margin">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/edit_launcher_hint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_launcher_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:textSize="@dimen/bigger_text_size" />
</com.google.android.material.textfield.TextInputLayout>
</FrameLayout>