FINALLY fix UI bug

This commit is contained in:
Luna712 2024-07-07 14:38:58 -06:00 committed by GitHub
parent 0f04e20637
commit 9a1949e452
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 167 additions and 182 deletions

View file

@ -112,7 +112,7 @@ class DownloadFragment : Fragment() {
} }
observe(downloadsViewModel.selectedIds) { observe(downloadsViewModel.selectedIds) {
handleSelectedChange(it) handleSelectedChange(it)
binding?.downloadDeleteToolbar?.btnDelete?.text = binding?.btnDelete?.text =
getString(R.string.delete_count).format(it.count()) getString(R.string.delete_count).format(it.count())
} }
@ -203,26 +203,26 @@ class DownloadFragment : Fragment() {
private fun handleSelectedChange(selected: HashMap<Int, String>) { private fun handleSelectedChange(selected: HashMap<Int, String>) {
val adapter = binding?.downloadList?.adapter as? DownloadAdapter val adapter = binding?.downloadList?.adapter as? DownloadAdapter
if (selected.isNotEmpty()) { if (selected.isNotEmpty()) {
binding?.downloadDeleteToolbar?.downloadDeleteToolbar?.isVisible = true binding?.downloadDeleteAppbar?.isVisible = true
binding?.downloadStorageAppbar?.isVisible = false binding?.downloadStorageAppbar?.isVisible = false
binding?.downloadDeleteToolbar?.btnDelete?.setOnClickListener { binding?.btnDelete?.setOnClickListener {
context?.let { ctx -> downloadsViewModel.handleMultiDelete(ctx) } context?.let { ctx -> downloadsViewModel.handleMultiDelete(ctx) }
} }
binding?.downloadDeleteToolbar?.btnCancel?.setOnClickListener { binding?.btnCancel?.setOnClickListener {
adapter?.setIsMultiDeleteState(false) adapter?.setIsMultiDeleteState(false)
downloadsViewModel.clearSelectedIds() downloadsViewModel.clearSelectedIds()
} }
binding?.downloadDeleteToolbar?.btnSelectAll?.setOnClickListener { binding?.btnSelectAll?.setOnClickListener {
adapter?.selectAllItems() adapter?.selectAllItems()
downloadsViewModel.selectAllItems() downloadsViewModel.selectAllItems()
} }
adapter?.setIsMultiDeleteState(true) adapter?.setIsMultiDeleteState(true)
} else { } else {
binding?.downloadDeleteToolbar?.downloadDeleteToolbar?.isVisible = false binding?.downloadDeleteAppbar?.isVisible = false
binding?.downloadStorageAppbar?.isVisible = binding?.downloadStorageAppbar?.isVisible =
// Make sure we don't display it early // Make sure we don't display it early
!downloadsViewModel.headerCards.value.isNullOrEmpty() && !downloadsViewModel.headerCards.value.isNullOrEmpty() &&

View file

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.appbar.AppBarLayout
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="wrap_content"
android:background="?attr/primaryGrayBackground"
tools:layout_height="100dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?attr/colorPrimary"
android:padding="8dp"
android:id="@+id/download_delete_toolbar"
android:visibility="gone">
<ImageView
android:id="@+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_close_24"
android:contentDescription="@string/cancel"
android:padding="8dp"
android:layout_gravity="center_vertical"
app:tint="@android:color/white" />
<Button
android:id="@+id/btnDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/delete"
android:textColor="@android:color/white"
android:layout_gravity="center_vertical" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="@+id/btnSelectAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/select_all"
android:textColor="@android:color/white"
android:layout_marginEnd="8dp" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>

View file

@ -8,10 +8,6 @@
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.download.DownloadFragment"> tools:context=".ui.download.DownloadFragment">
<include
layout="@layout/download_delete_toolbar"
android:id="@+id/download_delete_toolbar" />
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -21,115 +17,164 @@
For Scroll add to LinearLayout For Scroll add to LinearLayout
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"
--> -->
<LinearLayout
android:id="@+id/download_storage_appbar" <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content">
android:layout_margin="10dp"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<TextView <LinearLayout
android:layout_width="wrap_content" android:id="@+id/download_delete_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="5dp" android:orientation="horizontal"
android:text="@string/download_storage_text" android:background="?attr/colorPrimary"
android:textColor="?attr/textColor" /> android:padding="8dp"
android:visibility="gone">
<androidx.cardview.widget.CardView <ImageView
android:layout_width="fill_parent" android:id="@+id/btnCancel"
android:layout_height="12dp" android:layout_width="wrap_content"
android:layout_marginBottom="5dp" android:layout_height="wrap_content"
android:elevation="0dp" android:src="@drawable/ic_baseline_close_24"
app:cardCornerRadius="@dimen/storage_radius" android:contentDescription="@string/cancel"
app:cardElevation="0dp" android:padding="8dp"
app:cardMaxElevation="0dp"> android:layout_gravity="center_vertical"
app:tint="@android:color/white" />
<Button
android:id="@+id/btnDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/delete"
android:textColor="@android:color/white"
android:layout_gravity="center_vertical" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="@+id/btnSelectAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/select_all"
android:textColor="@android:color/white"
android:layout_marginEnd="8dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/download_storage_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/download_storage_text"
android:textColor="?attr/textColor" />
<androidx.cardview.widget.CardView
android:layout_width="fill_parent"
android:layout_height="12dp"
android:layout_marginBottom="5dp"
android:elevation="0dp"
app:cardCornerRadius="@dimen/storage_radius"
app:cardElevation="0dp"
app:cardMaxElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<View
android:id="@+id/download_used"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="@drawable/storage_bar_left" />
<View
android:id="@+id/download_app"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.10"
android:background="@drawable/storage_bar_mid" />
<View
android:id="@+id/download_free"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.10"
android:background="@drawable/storage_bar_right" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<View <View
android:id="@+id/download_used" android:layout_width="10dp"
android:layout_width="0dp" android:layout_height="10dp"
android:layout_height="match_parent" android:layout_gravity="center_vertical"
android:layout_weight="0.5" android:layout_marginTop="5dp"
android:background="@drawable/storage_bar_left" /> android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/storage_bar_left_box" />
<TextView
android:id="@+id/download_used_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="Used • 30.58GB" />
<View <View
android:id="@+id/download_app" android:layout_width="10dp"
android:layout_width="0dp" android:layout_height="10dp"
android:layout_height="match_parent" android:layout_gravity="center_vertical"
android:layout_weight="0.10" android:layout_margin="5dp"
android:background="@drawable/storage_bar_mid" /> android:background="@drawable/storage_bar_mid_box" />
<TextView
android:id="@+id/download_app_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="App • 30.58GB" />
<View <View
android:id="@+id/download_free" android:layout_width="10dp"
android:layout_width="0dp" android:layout_height="10dp"
android:layout_height="match_parent" android:layout_gravity="center_vertical"
android:layout_weight="0.10" android:layout_margin="5dp"
android:background="@drawable/storage_bar_right" /> android:background="@drawable/storage_bar_right_box" />
<TextView
android:id="@+id/download_free_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="Free • 30.58GB" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center_vertical"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/storage_bar_left_box" />
<TextView
android:id="@+id/download_used_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="Used • 30.58GB" />
<View
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="@drawable/storage_bar_mid_box" />
<TextView
android:id="@+id/download_app_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="App • 30.58GB" />
<View
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="@drawable/storage_bar_right_box" />
<TextView
android:id="@+id/download_free_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="Free • 30.58GB" />
</LinearLayout> </LinearLayout>
</LinearLayout> </FrameLayout>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
@ -141,7 +186,7 @@
android:background="?attr/primaryBlackBackground" android:background="?attr/primaryBlackBackground"
android:descendantFocusability="afterDescendants" android:descendantFocusability="afterDescendants"
android:nextFocusLeft="@id/nav_rail_view" android:nextFocusLeft="@id/nav_rail_view"
android:tag = "@string/tv_no_focus_tag" android:tag="@string/tv_no_focus_tag"
app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:listitem="@layout/download_header_episode" /> tools:listitem="@layout/download_header_episode" />
@ -186,15 +231,10 @@
android:orientation="vertical"> android:orientation="vertical">
<include layout="@layout/loading_downloads" /> <include layout="@layout/loading_downloads" />
<include layout="@layout/loading_downloads" /> <include layout="@layout/loading_downloads" />
<include layout="@layout/loading_downloads" /> <include layout="@layout/loading_downloads" />
<include layout="@layout/loading_downloads" /> <include layout="@layout/loading_downloads" />
<include layout="@layout/loading_downloads" /> <include layout="@layout/loading_downloads" />
<include layout="@layout/loading_downloads" /> <include layout="@layout/loading_downloads" />
</LinearLayout> </LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout> </com.facebook.shimmer.ShimmerFrameLayout>
@ -205,24 +245,24 @@
android:orientation="vertical" android:orientation="vertical"
android:layout_gravity="bottom|end"> android:layout_gravity="bottom|end">
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/open_local_video_button" android:id="@+id/open_local_video_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
style="?attr/floatingActionButtonSmallStyle" style="?attr/floatingActionButtonSmallStyle"
android:backgroundTint="?attr/primaryGrayBackground" android:backgroundTint="?attr/primaryGrayBackground"
android:src="@drawable/netflix_play" android:src="@drawable/netflix_play"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:tooltipText="@string/open_local_video" android:tooltipText="@string/open_local_video"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:contentDescription="@string/open_local_video" /> android:contentDescription="@string/open_local_video" />
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/download_stream_button" android:id="@+id/download_stream_button"
style="@style/ExtendedFloatingActionButton" style="@style/ExtendedFloatingActionButton"
android:text="@string/stream" android:text="@string/stream"
android:textColor="?attr/textColor" android:textColor="?attr/textColor"
app:icon="@drawable/ic_network_stream" app:icon="@drawable/ic_network_stream"
android:contentDescription="@string/stream" /> android:contentDescription="@string/stream" />
</LinearLayout> </LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>