Skip to content

Commit

Permalink
Displaying the progress percentage along with a progress bar allows t…
Browse files Browse the repository at this point in the history
…he user to track the completion status.
  • Loading branch information
MohitMaliDeveloper committed Jan 26, 2024
1 parent d22555e commit 608c97f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class LocalLibraryFragment : BaseFragment() {
fragmentDestinationLibraryBinding?.scanningProgressView?.apply {
progress = it
// hide this progress bar when scanning is complete.
visibility = if (it == MAX_PROGRESS) GONE else VISIBLE
showHideProgressViewsWithPercentage(it != MAX_PROGRESS, it)
// enable if the previous scanning is completes.
fragmentDestinationLibraryBinding?.zimSwiperefresh?.isEnabled = it == MAX_PROGRESS
}
Expand Down Expand Up @@ -276,6 +276,22 @@ class LocalLibraryFragment : BaseFragment() {
)
}

private fun showHideProgressViewsWithPercentage(
showProgressViews: Boolean,
percentage: Int = 0
) {
if (showProgressViews) {
fragmentDestinationLibraryBinding?.scanningProgressView?.visibility = VISIBLE
fragmentDestinationLibraryBinding?.progressText?.apply {
visibility = VISIBLE
text = getString(R.string.percentage, percentage)
}
} else {
fragmentDestinationLibraryBinding?.scanningProgressView?.visibility = GONE
fragmentDestinationLibraryBinding?.progressText?.visibility = GONE
}
}

private fun setUpSwipeRefreshLayout() {
fragmentDestinationLibraryBinding?.zimSwiperefresh?.setOnRefreshListener {
if (permissionDeniedLayoutShowing) {
Expand All @@ -296,10 +312,7 @@ class LocalLibraryFragment : BaseFragment() {
// to avoid multiple scanning.
isEnabled = false
}
fragmentDestinationLibraryBinding?.scanningProgressView?.apply {
visibility = VISIBLE
progress = 0
}
showHideProgressViewsWithPercentage(true)
requestFileSystemCheck()
}
}
Expand Down
53 changes: 37 additions & 16 deletions app/src/main/res/layout/fragment_destination_library.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@
android:layout_height="wrap_content">

<include layout="@layout/layout_scrolling_toolbar" />

<androidx.core.widget.ContentLoadingProgressBar
android:id="@+id/scanning_progress_view"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/progress_view_height"
android:indeterminate="false"
android:max="100"
android:theme="@style/ThemeOverlay.KiwixTheme.ProgressBar"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@+id/toolbar"
tools:progress="70" />
</com.google.android.material.appbar.AppBarLayout>


Expand All @@ -58,12 +46,45 @@
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/zimfilelist"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/item_book" />
android:layout_height="match_parent">

<ProgressBar
android:id="@+id/scanning_progress_view"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:indeterminate="false"
android:max="100"
android:layout_gravity="center"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_margin="3dp"
app:layout_constraintEnd_toStartOf="@+id/progressText"
android:theme="@style/ThemeOverlay.KiwixTheme.ProgressBar"
android:visibility="gone"
tools:progress="0" />

<TextView
android:id="@+id/progressText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginEnd="3dp"
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="wrap_content" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/zimfilelist"
android:layout_width="0dp"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/scanning_progress_view"
tools:listitem="@layout/item_book" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</org.kiwix.kiwixmobile.core.utils.NestedCoordinatorLayout>
Expand Down

0 comments on commit 608c97f

Please sign in to comment.