Batch add fix (#486)
This commit is contained in:
parent
ab863c5bc9
commit
f4a0342007
@ -3,14 +3,18 @@ package exh.ui.batchadd
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.databinding.EhFragmentBatchAddBinding
|
import eu.kanade.tachiyomi.databinding.EhFragmentBatchAddBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||||
import eu.kanade.tachiyomi.util.lang.combineLatest
|
import eu.kanade.tachiyomi.util.lang.combineLatest
|
||||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import reactivecircus.flowbinding.android.view.clicks
|
import reactivecircus.flowbinding.android.view.clicks
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
import rx.subscriptions.CompositeSubscription
|
import rx.subscriptions.CompositeSubscription
|
||||||
@ -40,6 +44,12 @@ class BatchAddController : NucleusController<EhFragmentBatchAddBinding, BatchAdd
|
|||||||
}
|
}
|
||||||
.launchIn(viewScope)
|
.launchIn(viewScope)
|
||||||
|
|
||||||
|
binding.scrollView.applyInsetter {
|
||||||
|
type(navigationBars = true) {
|
||||||
|
padding()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val progressSubscriptions = CompositeSubscription()
|
val progressSubscriptions = CompositeSubscription()
|
||||||
|
|
||||||
presenter.currentlyAddingRelay
|
presenter.currentlyAddingRelay
|
||||||
@ -54,13 +64,7 @@ class BatchAddController : NucleusController<EhFragmentBatchAddBinding, BatchAdd
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.combineLatest(presenter.progressTotalRelay) { progress, total ->
|
.combineLatest(presenter.progressTotalRelay) { progress, total ->
|
||||||
// Show hide dismiss button
|
// Show hide dismiss button
|
||||||
binding.progressDismissBtn.visibility =
|
binding.progressDismissBtn.isVisible = progress == total
|
||||||
if (progress == total) {
|
|
||||||
View.VISIBLE
|
|
||||||
} else {
|
|
||||||
View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
formatProgress(progress, total)
|
formatProgress(progress, total)
|
||||||
}.subscribeUntilDestroy {
|
}.subscribeUntilDestroy {
|
||||||
binding.progressText.text = it
|
binding.progressText.text = it
|
||||||
@ -98,10 +102,9 @@ class BatchAddController : NucleusController<EhFragmentBatchAddBinding, BatchAdd
|
|||||||
private val EhFragmentBatchAddBinding.progressViews
|
private val EhFragmentBatchAddBinding.progressViews
|
||||||
get() = listOf(
|
get() = listOf(
|
||||||
progressTitleView,
|
progressTitleView,
|
||||||
progressLogWrapper,
|
progressLog,
|
||||||
progressBar,
|
progressBar,
|
||||||
progressText,
|
progressText,
|
||||||
progressDismissBtn
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private val EhFragmentBatchAddBinding.inputViews
|
private val EhFragmentBatchAddBinding.inputViews
|
||||||
@ -111,21 +114,30 @@ class BatchAddController : NucleusController<EhFragmentBatchAddBinding, BatchAdd
|
|||||||
btnAddGalleries
|
btnAddGalleries
|
||||||
)
|
)
|
||||||
|
|
||||||
private var List<View>.visibility: Int
|
private var List<View>.isVisible: Boolean
|
||||||
get() = throw UnsupportedOperationException()
|
get() = throw UnsupportedOperationException()
|
||||||
set(v) { forEach { it.visibility = v } }
|
set(v) {
|
||||||
|
forEach { it.isVisible = v }
|
||||||
|
}
|
||||||
|
|
||||||
private fun showProgress(target: EhFragmentBatchAddBinding = binding) {
|
private fun showProgress(target: EhFragmentBatchAddBinding = binding) {
|
||||||
target.apply {
|
target.apply {
|
||||||
progressViews.visibility = View.VISIBLE
|
viewScope.launch {
|
||||||
inputViews.visibility = View.GONE
|
inputViews.isVisible = false
|
||||||
|
delay(250L)
|
||||||
|
progressViews.isVisible = true
|
||||||
|
}
|
||||||
}.progressLog.text = ""
|
}.progressLog.text = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideProgress(target: EhFragmentBatchAddBinding = binding) {
|
private fun hideProgress(target: EhFragmentBatchAddBinding = binding) {
|
||||||
target.apply {
|
target.apply {
|
||||||
progressViews.visibility = View.GONE
|
viewScope.launch {
|
||||||
inputViews.visibility = View.VISIBLE
|
progressViews.isVisible = false
|
||||||
|
binding.progressDismissBtn.isVisible = false
|
||||||
|
delay(250L)
|
||||||
|
inputViews.isVisible = true
|
||||||
|
}
|
||||||
}.galleriesBox.setText("", TextView.BufferType.EDITABLE)
|
}.galleriesBox.setText("", TextView.BufferType.EDITABLE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
|
android:id="@+id/scroll_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
android:padding="16dp">
|
android:padding="16dp"
|
||||||
|
>
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/input_title_view"
|
android:id="@+id/input_title_view"
|
||||||
@ -22,112 +28,93 @@
|
|||||||
android:text="@string/eh_batch_add_title"
|
android:text="@string/eh_batch_add_title"
|
||||||
android:textAppearance="?attr/textAppearanceTitleLarge"
|
android:textAppearance="?attr/textAppearanceTitleLarge"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<eu.kanade.tachiyomi.widget.TachiyomiTextInputEditText
|
<eu.kanade.tachiyomi.widget.TachiyomiTextInputEditText
|
||||||
android:id="@+id/galleries_box"
|
android:id="@+id/galleries_box"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:gravity="top"
|
android:gravity="top"
|
||||||
android:hint="@string/eh_batch_add_description"
|
android:hint="@string/eh_batch_add_description"
|
||||||
android:inputType="textUri|textMultiLine|textNoSuggestions"
|
android:inputType="textUri|textMultiLine|textNoSuggestions"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/btn_add_galleries"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="@+id/input_title_view"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="@+id/input_title_view"
|
app:layout_constraintTop_toBottomOf="@+id/input_title_view"/>
|
||||||
app:layout_constraintTop_toBottomOf="@+id/input_title_view" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_add_galleries"
|
android:id="@+id/btn_add_galleries"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
android:text="@string/eh_batch_add_button"
|
android:text="@string/eh_batch_add_button"
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="@+id/galleries_box"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="@+id/galleries_box" />
|
app:layout_constraintTop_toBottomOf="@+id/galleries_box"/>
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/progress_title_view"
|
android:id="@+id/progress_title_view"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginLeft="0dp"
|
|
||||||
android:layout_marginTop="0dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:layout_marginRight="0dp"
|
|
||||||
android:text="@string/eh_batch_add_adding_galleries"
|
android:text="@string/eh_batch_add_adding_galleries"
|
||||||
android:textAppearance="?attr/textAppearanceTitleLarge"
|
android:textAppearance="?attr/textAppearanceTitleLarge"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
<LinearLayout
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="0dp"
|
android:orientation="horizontal"
|
||||||
android:visibility="gone"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/progress_dismiss_btn"
|
app:layout_constraintTop_toBottomOf="@+id/progress_title_view">
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
|
||||||
app:layout_constraintLeft_toLeftOf="@+id/progress_log_wrapper"
|
<ProgressBar
|
||||||
app:layout_constraintRight_toLeftOf="@+id/progress_text" />
|
android:id="@+id/progress_bar"
|
||||||
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingTop="2dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/progress_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.15"
|
||||||
|
android:background="#00000000"
|
||||||
|
android:scrollHorizontally="false"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/progress_text"
|
android:id="@+id/progress_log"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="end"
|
android:layout_marginTop="12dp"
|
||||||
android:singleLine="true"
|
android:textAlignment="center"
|
||||||
android:text=""
|
android:textAppearance="?attr/textAppearanceBodyMedium"
|
||||||
android:textAlignment="textEnd"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintRight_toRightOf="@+id/progress_log_wrapper"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/progress_bar" />
|
app:layout_constraintTop_toBottomOf="@+id/progress_bar_text"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/progress_dismiss_btn"
|
android:id="@+id/progress_dismiss_btn"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="0dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginRight="0dp"
|
|
||||||
android:layout_marginBottom="0dp"
|
|
||||||
android:text="@string/eh_batch_add_finish"
|
android:text="@string/eh_batch_add_finish"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/btn_add_galleries"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintTop_toBottomOf="@+id/progress_log"/>
|
||||||
app:layout_constraintLeft_toLeftOf="@+id/progress_log_wrapper"
|
|
||||||
app:layout_constraintRight_toRightOf="@+id/progress_log_wrapper" />
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:id="@+id/progress_log_wrapper"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/progress_bar"
|
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
|
||||||
app:layout_constraintLeft_toLeftOf="@+id/progress_title_view"
|
|
||||||
app:layout_constraintRight_toRightOf="@+id/progress_title_view"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/progress_title_view"
|
|
||||||
app:layout_constraintVertical_bias="0.0">
|
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
|
||||||
android:id="@+id/progress_log"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textAppearance="?attr/textAppearanceBodyMedium"
|
|
||||||
android:visibility="visible" />
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user