fix: change DeArrow title submission default

This commit is contained in:
Ajay 2024-04-15 14:22:33 -04:00 committed by Bnyro
parent 964f47c70a
commit 58e901d72c
2 changed files with 16 additions and 10 deletions

View File

@ -3,6 +3,7 @@ package com.github.libretube.ui.dialogs
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.widget.CompoundButton
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.R
@ -41,13 +42,6 @@ class SubmitDeArrowDialog: DialogFragment() {
binding.dearrowTitle.typingEnabled = true
binding.thumbnailTime.setText(currentPosition.toString())
binding.titleCheckbox.setOnCheckedChangeListener { _, isChecked ->
binding.dearrowTitle.isEnabled = isChecked
}
binding.thumbnailTimeCheckbox.setOnCheckedChangeListener { _, isChecked ->
binding.thumbnailTimeInputLayout.isEnabled = isChecked
}
lifecycleScope.launch { fetchDeArrowData() }
return MaterialAlertDialogBuilder(requireContext())
@ -56,7 +50,19 @@ class SubmitDeArrowDialog: DialogFragment() {
.setNegativeButton(R.string.cancel, null)
.show()
.apply {
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
val positiveButton = getButton(DialogInterface.BUTTON_POSITIVE)
positiveButton.isEnabled = false
binding.titleCheckbox.setOnCheckedChangeListener { _, isChecked ->
binding.dearrowTitle.isEnabled = isChecked
positiveButton.isEnabled = isChecked || binding.thumbnailTimeCheckbox.isChecked
}
binding.thumbnailTimeCheckbox.setOnCheckedChangeListener { _, isChecked ->
binding.thumbnailTimeInputLayout.isEnabled = isChecked
positiveButton.isEnabled = binding.titleCheckbox.isChecked || isChecked
}
positiveButton.setOnClickListener {
lifecycleScope.launch { submitDeArrow() }
}
}

View File

@ -24,7 +24,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:checked="true"
android:checked="false"
android:text="@string/title" />
<com.google.android.material.checkbox.MaterialCheckBox
@ -47,13 +47,13 @@
android:id="@+id/thumbnail_time_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:hint="@string/thumbnail_time">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/thumbnail_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:inputType="numberDecimal" />
</com.google.android.material.textfield.TextInputLayout>