fixes
This commit is contained in:
parent
90e64f58f7
commit
a7de18494a
8 changed files with 99 additions and 74 deletions
|
|
@ -1087,12 +1087,8 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
|||
return dbManager.downloadDao.getDownloadIDsNotPresentInList(items.ifEmpty { listOf(-1L) }, status.map { it.toString() })
|
||||
}
|
||||
|
||||
suspend fun moveProcessingToSavedCategory(selectedItems: List<Long>?){
|
||||
if (selectedItems.isNullOrEmpty()) {
|
||||
dao.updateProcessingtoSavedStatus()
|
||||
}else {
|
||||
repository.setDownloadStatusMultiple(selectedItems, DownloadRepository.Status.Saved)
|
||||
}
|
||||
suspend fun moveProcessingToSavedCategory(){
|
||||
dao.updateProcessingtoSavedStatus()
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1210,13 +1206,14 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
|||
selectedItems
|
||||
}
|
||||
|
||||
moveProcessingToSavedCategory(selectedItems)
|
||||
moveProcessingToSavedCategory()
|
||||
|
||||
val id = System.currentTimeMillis().toInt()
|
||||
val workRequest = OneTimeWorkRequestBuilder<UpdateMultipleDownloadsFormatsWorker>()
|
||||
.setInputData(
|
||||
Data.Builder()
|
||||
.putLongArray("ids", ids.toLongArray())
|
||||
.putLongArray("other_ids_in_bundle", selectedItems?.toLongArray() ?: longArrayOf())
|
||||
.putInt("id", id)
|
||||
.build())
|
||||
.addTag("updateFormats")
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ class DownloadMultipleBottomSheetDialog : BottomSheetDialogFragment(), Configure
|
|||
private lateinit var multipleSelectHeader: ConstraintLayout
|
||||
private lateinit var selectItemsMenuBtn: MaterialButton
|
||||
private lateinit var selectRangeBtn: MaterialButton
|
||||
private lateinit var selectItemsOpenBtn: MaterialButton
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
@ -316,7 +317,7 @@ class DownloadMultipleBottomSheetDialog : BottomSheetDialogFragment(), Configure
|
|||
dd.setPositiveButton(getString(R.string.ok)) { _: DialogInterface?, _: Int ->
|
||||
lifecycleScope.launch{
|
||||
withContext(Dispatchers.IO){
|
||||
downloadViewModel.moveProcessingToSavedCategory(null)
|
||||
downloadViewModel.moveProcessingToSavedCategory()
|
||||
historyViewModel.deleteAllWithIDsCheckFiles(currentHistoryIDs)
|
||||
}
|
||||
|
||||
|
|
@ -525,25 +526,6 @@ class DownloadMultipleBottomSheetDialog : BottomSheetDialogFragment(), Configure
|
|||
intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION)
|
||||
pathResultLauncher.launch(intent)
|
||||
}
|
||||
R.id.select_items -> {
|
||||
if (listAdapter.isCheckingItems()) {
|
||||
multipleSelectHeader.isVisible = false
|
||||
view.findViewById<ConstraintLayout>(R.id.downloadHeader).isVisible = true
|
||||
filesize.isVisible = itemsFileSize > 0L
|
||||
selectRangeBtn.isVisible = false
|
||||
count.text = "${currentDownloadIDs.size} ${getString(R.string.selected)}"
|
||||
listAdapter.clearCheckedItems()
|
||||
}else {
|
||||
multipleSelectHeader.apply {
|
||||
isVisible = true
|
||||
}
|
||||
view.findViewById<ConstraintLayout>(R.id.downloadHeader).isVisible = false
|
||||
filesize.isVisible = false
|
||||
listAdapter.initCheckingItems(currentDownloadIDs)
|
||||
selectRangeBtn.isVisible = true
|
||||
count.text = "0 ${getString(R.string.selected)}"
|
||||
}
|
||||
}
|
||||
R.id.incognito -> {
|
||||
lifecycleScope.launch {
|
||||
if (m.icon!!.alpha == 255) {
|
||||
|
|
@ -812,6 +794,19 @@ class DownloadMultipleBottomSheetDialog : BottomSheetDialogFragment(), Configure
|
|||
}
|
||||
}
|
||||
|
||||
selectItemsOpenBtn = view.findViewById(R.id.selectItemsOpenBtn)
|
||||
selectItemsOpenBtn.setOnClickListener {
|
||||
multipleSelectHeader.apply {
|
||||
isVisible = true
|
||||
}
|
||||
view.findViewById<ConstraintLayout>(R.id.downloadHeader).isVisible = false
|
||||
filesize.isVisible = false
|
||||
listAdapter.initCheckingItems(currentDownloadIDs)
|
||||
selectRangeBtn.isVisible = true
|
||||
count.text = "0 ${getString(R.string.selected)}"
|
||||
selectItemsOpenBtn.isVisible = false
|
||||
}
|
||||
|
||||
multipleSelectHeader = view.findViewById(R.id.multipleSelectHeader)
|
||||
selectItemsMenuBtn = view.findViewById(R.id.selectItemsMenu)
|
||||
selectItemsMenuBtn.setOnClickListener {
|
||||
|
|
@ -892,6 +887,7 @@ class DownloadMultipleBottomSheetDialog : BottomSheetDialogFragment(), Configure
|
|||
filesize.isVisible = itemsFileSize > 0
|
||||
count.text = "${currentDownloadIDs.size} ${getString(R.string.selected)}"
|
||||
selectRangeBtn.isVisible = false
|
||||
selectItemsOpenBtn.isVisible = true
|
||||
listAdapter.clearCheckedItems()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2048,38 +2048,50 @@ object UiUtil {
|
|||
|
||||
|
||||
fun checkRanges(start: String, end: String) : Boolean {
|
||||
val res: Boolean
|
||||
|
||||
fromTextInput.error = ""
|
||||
toTextInput.error = ""
|
||||
|
||||
if (start.isBlank() || end.isBlank()) return false
|
||||
if (start.isBlank() || end.isBlank()){
|
||||
res = false
|
||||
}else{
|
||||
val startValid = kotlin.runCatching {
|
||||
start.toInt() > 0
|
||||
}.getOrElse { false }
|
||||
|
||||
val startValid = start.toInt() >= 0
|
||||
val endValid = end.toInt() <= itemCount
|
||||
val endValid = kotlin.runCatching {
|
||||
end.toInt() <= itemCount
|
||||
}.getOrElse { false }
|
||||
|
||||
if (!startValid) {
|
||||
fromTextInput.editText?.setText("")
|
||||
fromTextInput.error = "Invalid Number"
|
||||
}
|
||||
if (!endValid) {
|
||||
toTextInput.editText?.setText("")
|
||||
toTextInput.error = "Invalid Number"
|
||||
if (!startValid) {
|
||||
fromTextInput.error = "Invalid Number"
|
||||
}
|
||||
if (!endValid) {
|
||||
toTextInput.error = "Invalid Number"
|
||||
}
|
||||
|
||||
res = startValid && endValid
|
||||
}
|
||||
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = startValid && endValid
|
||||
return startValid && endValid
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).isEnabled = res
|
||||
return res
|
||||
}
|
||||
|
||||
fromTextInput.editText!!.doAfterTextChanged { editable ->
|
||||
val start = editable.toString()
|
||||
fromTextInput.editText!!.doOnTextChanged { text, _, _, _ ->
|
||||
val start = text.toString()
|
||||
val end = toTextInput.editText!!.text.toString()
|
||||
checkRanges(start, end)
|
||||
}
|
||||
|
||||
toTextInput.editText!!.doAfterTextChanged { editable ->
|
||||
toTextInput.editText!!.doOnTextChanged { text, _, _, _ ->
|
||||
val start = fromTextInput.editText!!.text.toString()
|
||||
val end = editable.toString()
|
||||
val end = text.toString()
|
||||
checkRanges(start, end)
|
||||
}
|
||||
|
||||
fromTextInput.editText!!.setText("1")
|
||||
toTextInput.editText!!.setText(itemCount.toString())
|
||||
}
|
||||
|
||||
private fun createPersonalFilenameTemplateChip(context: Activity, text: String, myChipGroup: ChipGroup, onClick: (f: Chip) -> Unit, onLongClick: (f: Chip) -> Unit) : Chip {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class UpdateMultipleDownloadsFormatsWorker(
|
|||
val vm = DownloadViewModel(App.instance)
|
||||
val notificationUtil = NotificationUtil(context)
|
||||
val ids = inputData.getLongArray("ids")!!.toMutableList()
|
||||
val otherIdsInBundle = inputData.getLongArray("other_ids_in_bundle")!!.toMutableList()
|
||||
val workID = inputData.getInt("id", 0)
|
||||
if (workID == 0) return Result.failure()
|
||||
|
||||
|
|
@ -80,7 +81,7 @@ class UpdateMultipleDownloadsFormatsWorker(
|
|||
Result.failure()
|
||||
}finally {
|
||||
if (ids.isNotEmpty()){
|
||||
notificationUtil.showFormatsUpdatedNotification(ids)
|
||||
notificationUtil.showFormatsUpdatedNotification(ids + otherIdsInBundle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/selectRangeBtn"
|
||||
app:layout_constraintEnd_toStartOf="@+id/selectActionButtons"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
|
@ -207,7 +207,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="20dp"
|
||||
android:paddingTop="10dp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
|
|
@ -231,31 +230,52 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/selectRangeBtn"
|
||||
android:visibility="gone"
|
||||
style="@style/Widget.Material3.Button.IconButton"
|
||||
<LinearLayout
|
||||
android:id="@+id/selectActionButtons"
|
||||
android:layout_width="wrap_content"
|
||||
app:icon="@drawable/baseline_format_list_numbered_24"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/select_between"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/selectItemsMenu"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/selectItemsMenu"
|
||||
android:visibility="gone"
|
||||
style="@style/Widget.Material3.Button.IconButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:contentDescription="@string/settings"
|
||||
app:icon="@drawable/baseline_more_vert_24"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/selectRangeBtn"
|
||||
android:visibility="gone"
|
||||
style="@style/Widget.Material3.Button.IconButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/select_between"
|
||||
app:icon="@drawable/baseline_format_list_numbered_24"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/selectItemsMenu"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="HardcodedText" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/selectItemsOpenBtn"
|
||||
style="@style/Widget.Material3.Button.IconButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/select"
|
||||
app:icon="@drawable/ic_select_all"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/selectItemsMenu"
|
||||
android:visibility="gone"
|
||||
style="@style/Widget.Material3.Button.IconButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/settings"
|
||||
app:icon="@drawable/baseline_more_vert_24"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
@ -265,7 +285,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="85dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="45"
|
||||
app:errorTextAppearance="@style/MyZeroSizeTextAppearance"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:hint="@string/start">
|
||||
|
||||
|
|
@ -36,6 +37,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/end"
|
||||
app:errorTextAppearance="@style/MyZeroSizeTextAppearance"
|
||||
android:layout_weight="45"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/colon">
|
||||
|
|
|
|||
|
|
@ -28,13 +28,6 @@
|
|||
app:actionLayout="@layout/bottom_app_bar_text"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
|
||||
<item
|
||||
android:id="@+id/select_items"
|
||||
android:title="@string/select"
|
||||
android:icon="@drawable/ic_select_all"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/incognito"
|
||||
android:title="@string/incognito"
|
||||
|
|
|
|||
|
|
@ -71,4 +71,9 @@
|
|||
<style name="PreferenceTheme" parent="PreferenceThemeOverlay">
|
||||
<item name="singleLineTitle">false</item>
|
||||
</style>
|
||||
|
||||
<style name="MyZeroSizeTextAppearance">
|
||||
<item name="android:textSize">0sp</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in a new issue