Skip to content

Commit

Permalink
Merge pull request #5902 from Bnyro/master
Browse files Browse the repository at this point in the history
fix: submit segment dialog closes when there are no segments yet
  • Loading branch information
Bnyro authored Apr 14, 2024
2 parents 9a69260 + a47eac5 commit 2205043
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import android.os.Bundle
import android.text.format.DateUtils
import android.util.Log
import android.widget.Toast
import androidx.core.view.isGone
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.BuildConfig
import com.github.libretube.R
import com.github.libretube.api.JsonHelper
import com.github.libretube.api.RetrofitInstance
Expand Down Expand Up @@ -148,7 +148,7 @@ class SubmitSegmentDialog : DialogFragment() {
val binding = _binding ?: return@withContext

if (segments.isEmpty()) {
dismiss()
binding.voteSegmentContainer.isGone = true
Toast.makeText(context, R.string.no_segments_found, Toast.LENGTH_SHORT).show()
return@withContext
}
Expand Down
178 changes: 97 additions & 81 deletions app/src/main/res/layout/dialog_submit_segment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,111 +7,127 @@
android:paddingHorizontal="15dp"
android:paddingTop="15dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sb_create_segment"
android:textSize="24sp" />

<LinearLayout
android:id="@+id/create_segment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
android:orientation="vertical">

<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/start_time">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/start_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
</com.google.android.material.textfield.TextInputLayout>
android:text="@string/sb_create_segment"
android:textSize="24sp" />

<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:hint="@string/end_time">
android:baselineAligned="false"
android:orientation="horizontal">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/end_time"
android:layout_width="match_parent"
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
</com.google.android.material.textfield.TextInputLayout>

</LinearLayout>
android:layout_weight="1"
android:hint="@string/start_time">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/start_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:hint="@string/end_time">

<com.google.android.material.textfield.TextInputEditText
android:id="@+id/end_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="numberDecimal" />
</com.google.android.material.textfield.TextInputLayout>

</LinearLayout>

<com.github.libretube.ui.views.DropdownMenu
android:id="@+id/segment_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="@string/segment_type"
app:icon="@drawable/ic_frame" />

<com.github.libretube.ui.views.DropdownMenu
android:id="@+id/segment_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="@string/segment_type"
app:icon="@drawable/ic_frame" />
<com.google.android.material.button.MaterialButton
android:id="@+id/create_segment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:drawableStart="@drawable/ic_copy"
android:text="@string/sb_create_segment" />

<com.google.android.material.button.MaterialButton
android:id="@+id/create_segment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:drawableStart="@drawable/ic_copy"
android:text="@string/sb_create_segment" />
</LinearLayout>

<TextView
<LinearLayout
android:id="@+id/vote_segment_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/vote_for_segment"
android:textSize="24sp" />
android:orientation="vertical">

<com.github.libretube.ui.views.DropdownMenu
android:id="@+id/segments_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="@string/segment"
app:icon="@drawable/ic_frame" />

<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/vote_for_segment"
android:textSize="24sp" />

<RadioButton
android:id="@+id/upvote"
android:layout_width="wrap_content"
<com.github.libretube.ui.views.DropdownMenu
android:id="@+id/segments_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:checked="true"
android:text="@string/upvote" />
app:hint="@string/segment"
app:icon="@drawable/ic_frame" />

<RadioButton
android:id="@+id/downvote"
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:text="@string/downvote" />
android:layout_gravity="end"
android:orientation="horizontal">

<RadioButton
android:id="@+id/upvote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:checked="true"
android:text="@string/upvote" />

<RadioButton
android:id="@+id/undo"
<RadioButton
android:id="@+id/downvote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:text="@string/downvote" />

<RadioButton
android:id="@+id/undo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/undo" />

</RadioGroup>

<com.google.android.material.button.MaterialButton
android:id="@+id/vote_segment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/undo" />

</RadioGroup>
android:layout_gravity="end"
android:drawableStart="@drawable/ic_copy"
android:text="@string/vote_for_segment" />

<com.google.android.material.button.MaterialButton
android:id="@+id/vote_segment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:drawableStart="@drawable/ic_copy"
android:text="@string/vote_for_segment" />
</LinearLayout>

</LinearLayout>

0 comments on commit 2205043

Please sign in to comment.