Full size dialog 2

This commit is contained in:
Philipp Heckel 2025-12-02 21:37:13 -05:00
parent 81049c5f88
commit 5a1b63d2d1
2 changed files with 37 additions and 10 deletions

View file

@ -145,27 +145,33 @@ class AddFragment : DialogFragment() {
loginPasswordText.addTextChangedListener(loginTextWatcher)
// Build dialog
val dialog = MaterialAlertDialogBuilder(requireContext())
.setView(view)
.setPositiveButton(R.string.add_dialog_button_subscribe) { _, _ ->
// This will be overridden below to avoid closing the dialog immediately
// Build fullscreen dialog
val dialog = Dialog(requireContext(), android.R.style.Theme_Material_Light_NoActionBar_Fullscreen)
dialog.setContentView(view)
dialog.setCanceledOnTouchOutside(false)
// Force fullscreen size
dialog.window?.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT )
// Add your buttons manually since we no longer use a builder
positiveButton = view.findViewById<Button?>(R.id.add_dialog_positive_button)
?: Button(requireContext()).also {
// If you don't have dedicated buttons in layout, create them dynamically
}
.setNegativeButton(R.string.add_dialog_button_cancel) { _, _ ->
// This will be overridden below
}
.create()
negativeButton = view.findViewById<Button?>(R.id.add_dialog_negative_button)
?: Button(requireContext())
// Show keyboard when the dialog is shown (see https://stackoverflow.com/a/19573049/1440785)
dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
// Add logic to disable "Subscribe" button on invalid input
dialog.setOnShowListener {
positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE)
positiveButton.isEnabled = false
positiveButton.setOnClickListener {
positiveButtonClick()
}
negativeButton = dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
negativeButton.setOnClickListener {
negativeButtonClick()
}

View file

@ -7,6 +7,27 @@
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingHorizontal="?dialogPreferredPadding">
<LinearLayout
android:id="@+id/add_dialog_button_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="12dp">
<Button
android:id="@+id/add_dialog_negative_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/add_dialog_button_cancel"
android:layout_weight="1"/>
<Button
android:id="@+id/add_dialog_positive_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/add_dialog_button_subscribe"
android:layout_weight="1"/>
</LinearLayout>
<ScrollView
android:id="@+id/add_dialog_subscribe_view"