small design tinkering

This commit is contained in:
deniscerri 2025-08-26 16:24:17 +02:00
parent 56976125cf
commit b727be0076
No known key found for this signature in database
GPG key ID: 95C43D517D830350
12 changed files with 25 additions and 18 deletions

View file

@ -45,8 +45,8 @@ class FormatViewModel(private val application: Application) : AndroidViewModel(a
val selectedItems = MutableStateFlow(listOf<DownloadItem>())
val selectedItemsSharedFlow = MutableSharedFlow<List<DownloadItem>>(replay = 1)
var formats : Flow<List<FormatRecyclerView>>
var showFilterBtn = MutableStateFlow(false)
var showRefreshBtn = MutableStateFlow(false)
var showFilterBtn = MutableSharedFlow<Boolean>(1)
var showRefreshBtn = MutableSharedFlow<Boolean>(1)
private var canUpdate = true
var canMultiSelectAudio = MutableStateFlow(false)
var isMissingFormats = MutableStateFlow(false)
@ -114,12 +114,10 @@ class FormatViewModel(private val application: Application) : AndroidViewModel(a
showFilterBtn.apply {
val vl = chosenFormats.isNotEmpty() || items.all { it.url.isYoutubeURL() }
value = vl
emit(vl)
}
showRefreshBtn.apply {
val vl = (isMissingFormats.value || items.isEmpty() || items.first().url.isEmpty()) && canUpdate
value = vl
emit(vl)
}
@ -214,21 +212,21 @@ class FormatViewModel(private val application: Application) : AndroidViewModel(a
}
fun setItems(list: List<DownloadItem>, updateFormats: Boolean? = null) = viewModelScope.launch {
canUpdate = updateFormats ?: canUpdate
selectedItems.apply {
value = list
emit(list)
}
selectedItemsSharedFlow.emit(list)
canUpdate = updateFormats ?: canUpdate
}
fun setItem(item: DownloadItem, updateFormats: Boolean? = null) = viewModelScope.launch {
canUpdate = updateFormats ?: canUpdate
selectedItems.apply {
value = listOf(item)
emit(listOf(item))
}
selectedItemsSharedFlow.emit(listOf(item))
canUpdate = updateFormats ?: canUpdate
}

View file

@ -138,11 +138,11 @@ class FormatAdapter(onItemClickListener: OnItemClickListener, activity: Activity
companion object {
private val DIFF_CALLBACK: DiffUtil.ItemCallback<FormatRecyclerView> = object : DiffUtil.ItemCallback<FormatRecyclerView>() {
override fun areItemsTheSame(oldItem: FormatRecyclerView, newItem: FormatRecyclerView): Boolean {
return oldItem.label == newItem.label && oldItem.format?.format_id == newItem.format?.format_id
return oldItem.label == newItem.label && oldItem.format?.format_id == newItem.format?.format_id && oldItem.format?.format_note == newItem.format?.format_note
}
override fun areContentsTheSame(oldItem: FormatRecyclerView, newItem: FormatRecyclerView): Boolean {
return oldItem.label == newItem.label && oldItem.format?.format_id == newItem.format?.format_id
return oldItem.label == newItem.label && oldItem.format?.format_id == newItem.format?.format_id && oldItem.format?.format_note == newItem.format?.format_note
}
}
}

View file

@ -225,7 +225,7 @@ class FormatSelectionBottomSheetDialog(
items.first().allFormats.addAll(chosenFormats)
withContext(Dispatchers.Main){
formatViewModel.setItem(items.first())
formatViewModel.setItem(items.first(), false)
listener.onFormatsUpdated(res)
}
}.onFailure { err ->
@ -269,12 +269,13 @@ class FormatSelectionBottomSheetDialog(
}
}
formatViewModel.setItems(items)
formatViewModel.setItems(items, false)
}
withContext(Dispatchers.Main){
filterBtn.isEnabled = true
okBtn.isEnabled = true
refreshBtn.isEnabled = true
}
}catch (e: Exception){
withContext(Dispatchers.Main) {

View file

@ -339,6 +339,12 @@ class NewPipeUtil(context: Context) {
formats.add(formatObj)
}
val hasDefaultFormat = formats.firstOrNull { it.format_note.contains("ORIGINAL", true) }
if (hasDefaultFormat != null) {
formats.remove(hasDefaultFormat)
formats.add(0, hasDefaultFormat)
}
}
if (stream.videoStreams.isNotEmpty()){
@ -385,7 +391,6 @@ class NewPipeUtil(context: Context) {
defaultLang?.format_id = (defaultLang?.format_id?.split("-")?.get(0) ?: "") + "-${it.value.size-1}"
}
}
formats.sortByDescending { it.filesize }
}
val chapters = ArrayList<ChapterItem>()

View file

@ -20,7 +20,7 @@
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="20dp"
app:cardElevation="10dp"
app:cardElevation="0dp"
app:cardMaxElevation="12dp"
android:checkable="true"
app:strokeWidth="0dp"

View file

@ -39,6 +39,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:outlineProvider="none"
android:visibility="gone"
android:text="@string/crop_thumb"/>

View file

@ -64,6 +64,7 @@
android:id="@+id/format_filter"
style="@style/Widget.Material3.Button.IconButton.Filled"
android:layout_width="wrap_content"
android:stateListAnimator="@null"
android:layout_height="wrap_content"
app:icon="@drawable/baseline_align_horizontal_left_24"
app:layout_constraintBottom_toBottomOf="@id/format_refresh"
@ -76,6 +77,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="all"
android:stateListAnimator="@null"
android:text="@string/update"
android:contentDescription="@string/update_formats"
android:layout_marginStart="10dp"

View file

@ -17,7 +17,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="20dp"
app:cardElevation="5dp"
app:cardElevation="0dp"
app:checkedIcon="@null"
app:cardMaxElevation="12dp"
android:checkable="true"

View file

@ -25,7 +25,7 @@
android:layout_marginVertical="5dp"
android:checkable="false"
app:cardCornerRadius="15dp"
app:cardElevation="5dp"
app:cardElevation="0dp"
app:cardMaxElevation="12dp"
app:cardPreventCornerOverlap="true"
app:checkedIcon="@null"
@ -39,7 +39,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="20dp"
app:cardElevation="5dp"
app:cardElevation="0dp"
app:checkedIcon="@null"
app:cardMaxElevation="12dp"
android:checkable="true"

View file

@ -20,7 +20,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="20dp"
app:cardElevation="5dp"
app:cardElevation="0dp"
app:strokeColor="?attr/colorPrimary"
app:checkedIconTint="?attr/colorPrimary"
app:cardMaxElevation="12dp"

View file

@ -20,7 +20,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="20dp"
app:cardElevation="5dp"
app:cardElevation="0dp"
app:cardBackgroundColor="?attr/colorSurfaceContainer"
app:strokeColor="?attr/colorPrimary"
app:checkedIconTint="?attr/colorPrimary"

View file

@ -16,7 +16,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="20dp"
app:cardElevation="10dp"
app:cardElevation="0dp"
app:cardMaxElevation="12dp"
app:cardBackgroundColor="@color/grey"
app:cardPreventCornerOverlap="true"