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