mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
fix: submit segment dialog closes when there are no segments yet
This commit is contained in:
parent
81bdd71558
commit
a47eac5352
@ -5,9 +5,9 @@ import android.os.Bundle
|
|||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.github.libretube.BuildConfig
|
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.JsonHelper
|
import com.github.libretube.api.JsonHelper
|
||||||
import com.github.libretube.api.RetrofitInstance
|
import com.github.libretube.api.RetrofitInstance
|
||||||
@ -148,7 +148,7 @@ class SubmitSegmentDialog : DialogFragment() {
|
|||||||
val binding = _binding ?: return@withContext
|
val binding = _binding ?: return@withContext
|
||||||
|
|
||||||
if (segments.isEmpty()) {
|
if (segments.isEmpty()) {
|
||||||
dismiss()
|
binding.voteSegmentContainer.isGone = true
|
||||||
Toast.makeText(context, R.string.no_segments_found, Toast.LENGTH_SHORT).show()
|
Toast.makeText(context, R.string.no_segments_found, Toast.LENGTH_SHORT).show()
|
||||||
return@withContext
|
return@withContext
|
||||||
}
|
}
|
||||||
|
@ -7,111 +7,127 @@
|
|||||||
android:paddingHorizontal="15dp"
|
android:paddingHorizontal="15dp"
|
||||||
android:paddingTop="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
|
<LinearLayout
|
||||||
|
android:id="@+id/create_segment_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:baselineAligned="false"
|
android:orientation="vertical">
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<TextView
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:text="@string/sb_create_segment"
|
||||||
android:hint="@string/start_time">
|
android:textSize="24sp" />
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<LinearLayout
|
||||||
android:id="@+id/start_time"
|
android:layout_width="match_parent"
|
||||||
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_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:baselineAligned="false"
|
||||||
android:layout_weight="1"
|
android:orientation="horizontal">
|
||||||
android:hint="@string/end_time">
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/end_time"
|
android:layout_width="0dp"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="numberDecimal" />
|
android:layout_weight="1"
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
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.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>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.github.libretube.ui.views.DropdownMenu
|
<LinearLayout
|
||||||
android:id="@+id/segment_category"
|
android:id="@+id/vote_segment_container"
|
||||||
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" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:text="@string/vote_for_segment"
|
android:orientation="vertical">
|
||||||
android:textSize="24sp" />
|
|
||||||
|
|
||||||
<com.github.libretube.ui.views.DropdownMenu
|
<TextView
|
||||||
android:id="@+id/segments_dropdown"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:text="@string/vote_for_segment"
|
||||||
app:hint="@string/segment"
|
android:textSize="24sp" />
|
||||||
app:icon="@drawable/ic_frame" />
|
|
||||||
|
|
||||||
<RadioGroup
|
<com.github.libretube.ui.views.DropdownMenu
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/segments_dropdown"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="end"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
app:hint="@string/segment"
|
||||||
|
app:icon="@drawable/ic_frame" />
|
||||||
|
|
||||||
<RadioButton
|
<RadioGroup
|
||||||
android:id="@+id/upvote"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="5dp"
|
android:layout_gravity="end"
|
||||||
android:checked="true"
|
android:orientation="horizontal">
|
||||||
android:text="@string/upvote" />
|
|
||||||
|
|
||||||
<RadioButton
|
<RadioButton
|
||||||
android:id="@+id/downvote"
|
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/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_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="5dp"
|
android:layout_gravity="end"
|
||||||
android:text="@string/downvote" />
|
android:drawableStart="@drawable/ic_copy"
|
||||||
|
android:text="@string/vote_for_segment" />
|
||||||
|
|
||||||
<RadioButton
|
</LinearLayout>
|
||||||
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:layout_gravity="end"
|
|
||||||
android:drawableStart="@drawable/ic_copy"
|
|
||||||
android:text="@string/vote_for_segment" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user