From d62c0f00c4865aeb7cbb5b95957c660f4c5283fd Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 14 Mar 2020 17:27:39 -0700 Subject: [PATCH] UI Fixing Fixed source migration being clipped Fixed shadow of unread badge being clipped --- .../ui/catalogue/CatalogueController.kt | 26 ++++++++++++++----- .../ui/library/LibraryListController.kt | 17 +++++++++--- .../tachiyomi/util/view/ViewExtensions.kt | 1 - .../main/res/layout/catalogue_grid_item.xml | 17 +++++------- .../main/res/layout/catalogue_list_item.xml | 10 +++---- .../main/res/layout/migration_controller.xml | 16 +++++++----- app/src/main/res/menu/catalogue_main.xml | 2 +- app/src/main/res/values/strings.xml | 4 +-- app/src/main/res/values/styles.xml | 1 - 9 files changed, 58 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt index 956a87ba7d..e162ddd127 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/CatalogueController.kt @@ -73,6 +73,8 @@ class CatalogueController : NucleusController(), var customTitle = "" + var showingExtenions = false + /** * Called when controller is initialized. */ @@ -87,7 +89,7 @@ class CatalogueController : NucleusController(), * @return title. */ override fun getTitle(): String? { - return if (ext_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) + return if (showingExtenions) applicationContext?.getString(R.string.label_extensions) else applicationContext?.getString(R.string.label_catalogues) } @@ -144,24 +146,36 @@ class CatalogueController : NucleusController(), shadow2.alpha = (1 - max(0f, progress)) * 0.25f sheet_layout.alpha = 1 - progress activity?.appbar?.y = max(activity!!.appbar.y, -headerHeight * (1 - progress)) + val oldShow = showingExtenions + showingExtenions = progress > 0.92f + if (oldShow != showingExtenions) { + setTitle() + activity?.invalidateOptionsMenu() + } } override fun onStateChanged(p0: View, state: Int) { if (state == BottomSheetBehavior.STATE_EXPANDED) activity?.appbar?.y = 0f if (state == BottomSheetBehavior.STATE_EXPANDED || - state == BottomSheetBehavior.STATE_COLLAPSED) + state == BottomSheetBehavior.STATE_COLLAPSED) { sheet_layout.alpha = if (state == BottomSheetBehavior.STATE_COLLAPSED) 1f else 0f + showingExtenions = state == BottomSheetBehavior.STATE_EXPANDED + setTitle() + activity?.invalidateOptionsMenu() + } retainViewMode = if (state == BottomSheetBehavior.STATE_EXPANDED) RetainViewMode.RETAIN_DETACH else RetainViewMode.RELEASE_DETACH - activity?.invalidateOptionsMenu() - setTitle() sheet_layout.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED sheet_layout.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED } }) + if (showingExtenions) { + ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED + } + } fun toggleExtensions() { @@ -253,7 +267,7 @@ class CatalogueController : NucleusController(), * @param inflater used to load the menu xml. */ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { - if (ext_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) { + if (showingExtenions) { // Inflate menu inflater.inflate(R.menu.extension_main, menu) @@ -305,7 +319,7 @@ class CatalogueController : NucleusController(), // Initialize option to open catalogue settings. R.id.action_filter -> { val controller = - if (ext_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) + if (showingExtenions) SettingsExtensionsController() else SettingsSourcesController() router.pushController( diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListController.kt index 6eee7949b1..f9518fec2b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListController.kt @@ -314,8 +314,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle), override fun layoutView(view: View) { adapter = LibraryCategoryAdapter(this) - if (libraryLayout == 0)recycler.spanCount = 1 - else recycler.columnWidth = (90 + (preferences.gridSize().getOrDefault() * 30)).dpToPx + setRecyclerLayout() recycler.manager.spanSizeLookup = (object : GridLayoutManager.SpanSizeLookup() { override fun getSpanSize(position: Int): Int { if (libraryLayout == 0) return 1 @@ -353,6 +352,17 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle), } } + private fun setRecyclerLayout() { + if (libraryLayout == 0) { + recycler.spanCount = 1 + recycler.setPaddingRelative(0,0,0,0) + } + else { + recycler.columnWidth = (90 + (preferences.gridSize().getOrDefault() * 30)).dpToPx + recycler.setPaddingRelative(3.dpToPx,0,3.dpToPx, 0) + } + } + override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) { super.onChangeStarted(handler, type) if (type.isEnter) { @@ -475,8 +485,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle), override fun reattachAdapter() { libraryLayout = preferences.libraryLayout().getOrDefault() - if (libraryLayout == 0) recycler.spanCount = 1 - else recycler.columnWidth = (90 + (preferences.gridSize().getOrDefault() * 30)).dpToPx + setRecyclerLayout() val position = (recycler.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() recycler.adapter = adapter diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index 2525655f38..0c56b76d5d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -210,7 +210,6 @@ fun View.doOnApplyWindowInsets(f: (View, WindowInsets, ViewPaddingState) -> Unit } fun View.applyWindowInsetsForController() { - // Create a snapshot of the view's padding state setOnApplyWindowInsetsListener(ControllerViewWindowInsetsListener) requestApplyInsetsWhenAttached() } diff --git a/app/src/main/res/layout/catalogue_grid_item.xml b/app/src/main/res/layout/catalogue_grid_item.xml index 94bd935885..e269449f5c 100644 --- a/app/src/main/res/layout/catalogue_grid_item.xml +++ b/app/src/main/res/layout/catalogue_grid_item.xml @@ -21,9 +21,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" - android:layout_marginStart="8dp" + android:layout_marginStart="10dp" android:layout_marginTop="10dp" - android:layout_marginEnd="8dp" + android:layout_marginEnd="10dp" app:layout_constraintBottom_toTopOf="@+id/text_layout" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -113,6 +113,7 @@ @@ -123,17 +124,15 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintBottom_toBottomOf="parent" - android:layout_marginTop="8dp" - android:layout_marginBottom="8dp" + android:layout_marginStart="10dp" + android:layout_marginEnd="10dp" android:orientation="vertical" android:layout_height="30sp"> + android:minHeight="@dimen/material_component_lists_single_line_with_avatar_height"> - + android:layout_height="match_parent"> + + + \ No newline at end of file diff --git a/app/src/main/res/menu/catalogue_main.xml b/app/src/main/res/menu/catalogue_main.xml index 2b29f01aee..2051f9b853 100644 --- a/app/src/main/res/menu/catalogue_main.xml +++ b/app/src/main/res/menu/catalogue_main.xml @@ -11,7 +11,7 @@ app:actionViewClass="androidx.appcompat.widget.SearchView"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 25ee1ce0c2..ac5440994e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -42,7 +42,7 @@ Filter - View all sources + Change sources View options Downloaded Not downloaded @@ -109,7 +109,7 @@ Add to home screen Display mode Display - Comfy Grid + Comfortable Grid Compact Grid List Download badges diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 0342499a8f..04e59dfc98 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -180,7 +180,6 @@