Skip to content

Commit

Permalink
fix: change DeArrow title submission default
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy authored and Bnyro committed Apr 17, 2024
1 parent 964f47c commit 58e901d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 6 in app/src/main/java/com/github/libretube/ui/dialogs/SubmitDeArrowDialog.kt

View workflow job for this annotation

GitHub Actions / Check Code Quality

[ktlint] reported by reviewdog 🐶 Unused import Raw Output: app/src/main/java/com/github/libretube/ui/dialogs/SubmitDeArrowDialog.kt:6:1: error: Unused import (standard:no-unused-imports)
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.R
Expand Down Expand Up @@ -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())
Expand All @@ -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() }
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/dialog_submit_dearrow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>

Expand Down

0 comments on commit 58e901d

Please sign in to comment.