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