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) {
handleSelectedChange(it)
binding?.downloadDeleteToolbar?.btnDelete?.text =
binding?.btnDelete?.text =
getString(R.string.delete_count).format(it.count())
}
@ -203,26 +203,26 @@ class DownloadFragment : Fragment() {
private fun handleSelectedChange(selected: HashMap<Int, String>) {
val adapter = binding?.downloadList?.adapter as? DownloadAdapter
if (selected.isNotEmpty()) {
binding?.downloadDeleteToolbar?.downloadDeleteToolbar?.isVisible = true
binding?.downloadDeleteAppbar?.isVisible = true
binding?.downloadStorageAppbar?.isVisible = false
binding?.downloadDeleteToolbar?.btnDelete?.setOnClickListener {
binding?.btnDelete?.setOnClickListener {
context?.let { ctx -> downloadsViewModel.handleMultiDelete(ctx) }
}
binding?.downloadDeleteToolbar?.btnCancel?.setOnClickListener {
binding?.btnCancel?.setOnClickListener {
adapter?.setIsMultiDeleteState(false)
downloadsViewModel.clearSelectedIds()
}
binding?.downloadDeleteToolbar?.btnSelectAll?.setOnClickListener {
binding?.btnSelectAll?.setOnClickListener {
adapter?.selectAllItems()
downloadsViewModel.selectAllItems()
}
adapter?.setIsMultiDeleteState(true)
} else {
binding?.downloadDeleteToolbar?.downloadDeleteToolbar?.isVisible = false
binding?.downloadDeleteAppbar?.isVisible = false
binding?.downloadStorageAppbar?.isVisible =
// Make sure we don't display it early
!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"
tools:context=".ui.download.DownloadFragment">
<include
layout="@layout/download_delete_toolbar"
android:id="@+id/download_delete_toolbar" />
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -21,115 +17,164 @@
For Scroll add to LinearLayout
app:layout_scrollFlags="scroll|enterAlways"
-->
<LinearLayout
android:id="@+id/download_storage_appbar"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
<LinearLayout
android:id="@+id/download_delete_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/download_storage_text"
android:textColor="?attr/textColor" />
android:orientation="horizontal"
android:background="?attr/colorPrimary"
android:padding="8dp"
android:visibility="gone">
<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">
<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>
<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
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
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" />
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:id="@+id/download_app"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.10"
android:background="@drawable/storage_bar_mid" />
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:id="@+id/download_free"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.10"
android:background="@drawable/storage_bar_right" />
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>
</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>
</FrameLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
@ -141,7 +186,7 @@
android:background="?attr/primaryBlackBackground"
android:descendantFocusability="afterDescendants"
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"
tools:listitem="@layout/download_header_episode" />
@ -186,15 +231,10 @@
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" />
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
@ -205,24 +245,24 @@
android:orientation="vertical"
android:layout_gravity="bottom|end">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/open_local_video_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?attr/floatingActionButtonSmallStyle"
android:backgroundTint="?attr/primaryGrayBackground"
android:src="@drawable/netflix_play"
android:layout_marginEnd="16dp"
android:tooltipText="@string/open_local_video"
android:layout_gravity="bottom|end"
android:contentDescription="@string/open_local_video" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/open_local_video_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?attr/floatingActionButtonSmallStyle"
android:backgroundTint="?attr/primaryGrayBackground"
android:src="@drawable/netflix_play"
android:layout_marginEnd="16dp"
android:tooltipText="@string/open_local_video"
android:layout_gravity="bottom|end"
android:contentDescription="@string/open_local_video" />
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/download_stream_button"
style="@style/ExtendedFloatingActionButton"
android:text="@string/stream"
android:textColor="?attr/textColor"
app:icon="@drawable/ic_network_stream"
android:contentDescription="@string/stream" />
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/download_stream_button"
style="@style/ExtendedFloatingActionButton"
android:text="@string/stream"
android:textColor="?attr/textColor"
app:icon="@drawable/ic_network_stream"
android:contentDescription="@string/stream" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>