UI Fixing

Fixed source migration being clipped
Fixed shadow of unread badge being clipped
This commit is contained in:
Jay 2020-03-14 17:27:39 -07:00
parent 93cb8f649e
commit d62c0f00c4
9 changed files with 58 additions and 36 deletions

View File

@ -73,6 +73,8 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
var customTitle = "" var customTitle = ""
var showingExtenions = false
/** /**
* Called when controller is initialized. * Called when controller is initialized.
*/ */
@ -87,7 +89,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
* @return title. * @return title.
*/ */
override fun getTitle(): String? { override fun getTitle(): String? {
return if (ext_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) return if (showingExtenions)
applicationContext?.getString(R.string.label_extensions) applicationContext?.getString(R.string.label_extensions)
else applicationContext?.getString(R.string.label_catalogues) else applicationContext?.getString(R.string.label_catalogues)
} }
@ -144,24 +146,36 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
shadow2.alpha = (1 - max(0f, progress)) * 0.25f shadow2.alpha = (1 - max(0f, progress)) * 0.25f
sheet_layout.alpha = 1 - progress sheet_layout.alpha = 1 - progress
activity?.appbar?.y = max(activity!!.appbar.y, -headerHeight * (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) { override fun onStateChanged(p0: View, state: Int) {
if (state == BottomSheetBehavior.STATE_EXPANDED) activity?.appbar?.y = 0f if (state == BottomSheetBehavior.STATE_EXPANDED) activity?.appbar?.y = 0f
if (state == BottomSheetBehavior.STATE_EXPANDED || if (state == BottomSheetBehavior.STATE_EXPANDED ||
state == BottomSheetBehavior.STATE_COLLAPSED) state == BottomSheetBehavior.STATE_COLLAPSED) {
sheet_layout.alpha = sheet_layout.alpha =
if (state == BottomSheetBehavior.STATE_COLLAPSED) 1f else 0f if (state == BottomSheetBehavior.STATE_COLLAPSED) 1f else 0f
showingExtenions = state == BottomSheetBehavior.STATE_EXPANDED
setTitle()
activity?.invalidateOptionsMenu()
}
retainViewMode = if (state == BottomSheetBehavior.STATE_EXPANDED) retainViewMode = if (state == BottomSheetBehavior.STATE_EXPANDED)
RetainViewMode.RETAIN_DETACH else RetainViewMode.RELEASE_DETACH RetainViewMode.RETAIN_DETACH else RetainViewMode.RELEASE_DETACH
activity?.invalidateOptionsMenu()
setTitle()
sheet_layout.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED sheet_layout.isClickable = state == BottomSheetBehavior.STATE_COLLAPSED
sheet_layout.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED sheet_layout.isFocusable = state == BottomSheetBehavior.STATE_COLLAPSED
} }
}) })
if (showingExtenions) {
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
}
} }
fun toggleExtensions() { fun toggleExtensions() {
@ -253,7 +267,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
* @param inflater used to load the menu xml. * @param inflater used to load the menu xml.
*/ */
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
if (ext_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) { if (showingExtenions) {
// Inflate menu // Inflate menu
inflater.inflate(R.menu.extension_main, menu) inflater.inflate(R.menu.extension_main, menu)
@ -305,7 +319,7 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
// Initialize option to open catalogue settings. // Initialize option to open catalogue settings.
R.id.action_filter -> { R.id.action_filter -> {
val controller = val controller =
if (ext_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) if (showingExtenions)
SettingsExtensionsController() SettingsExtensionsController()
else SettingsSourcesController() else SettingsSourcesController()
router.pushController( router.pushController(

View File

@ -314,8 +314,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
override fun layoutView(view: View) { override fun layoutView(view: View) {
adapter = LibraryCategoryAdapter(this) adapter = LibraryCategoryAdapter(this)
if (libraryLayout == 0)recycler.spanCount = 1 setRecyclerLayout()
else recycler.columnWidth = (90 + (preferences.gridSize().getOrDefault() * 30)).dpToPx
recycler.manager.spanSizeLookup = (object : GridLayoutManager.SpanSizeLookup() { recycler.manager.spanSizeLookup = (object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int { override fun getSpanSize(position: Int): Int {
if (libraryLayout == 0) return 1 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) { override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
super.onChangeStarted(handler, type) super.onChangeStarted(handler, type)
if (type.isEnter) { if (type.isEnter) {
@ -475,8 +485,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
override fun reattachAdapter() { override fun reattachAdapter() {
libraryLayout = preferences.libraryLayout().getOrDefault() libraryLayout = preferences.libraryLayout().getOrDefault()
if (libraryLayout == 0) recycler.spanCount = 1 setRecyclerLayout()
else recycler.columnWidth = (90 + (preferences.gridSize().getOrDefault() * 30)).dpToPx
val position = val position =
(recycler.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition() (recycler.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
recycler.adapter = adapter recycler.adapter = adapter

View File

@ -210,7 +210,6 @@ fun View.doOnApplyWindowInsets(f: (View, WindowInsets, ViewPaddingState) -> Unit
} }
fun View.applyWindowInsetsForController() { fun View.applyWindowInsetsForController() {
// Create a snapshot of the view's padding state
setOnApplyWindowInsetsListener(ControllerViewWindowInsetsListener) setOnApplyWindowInsetsListener(ControllerViewWindowInsetsListener)
requestApplyInsetsWhenAttached() requestApplyInsetsWhenAttached()
} }

View File

@ -21,9 +21,9 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_marginStart="8dp" android:layout_marginStart="10dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="10dp"
app:layout_constraintBottom_toTopOf="@+id/text_layout" app:layout_constraintBottom_toTopOf="@+id/text_layout"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
@ -113,6 +113,7 @@
<include <include
layout="@layout/unread_download_badge" layout="@layout/unread_download_badge"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_marginStart="2dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/badge_guide" app:layout_constraintBottom_toBottomOf="@id/badge_guide"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
@ -123,17 +124,15 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="8dp" android:layout_marginStart="10dp"
android:layout_marginBottom="8dp" android:layout_marginEnd="10dp"
android:orientation="vertical" android:orientation="vertical"
android:layout_height="30sp"> android:layout_height="30sp">
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/title" android:id="@+id/title"
style="@style/TextAppearance.Regular.Body1.Light" style="@style/TextAppearance.MaterialComponents.Body1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
@ -143,12 +142,10 @@
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/subtitle" android:id="@+id/subtitle"
style="@style/TextAppearance.Regular.Body1.Light" style="@style/TextAppearance.MaterialComponents.Body1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="-1dp" android:layout_marginTop="-1dp"
android:layout_marginEnd="8dp"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"

View File

@ -6,15 +6,15 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:background="?attr/selectable_list_drawable" android:background="?attr/selectable_list_drawable"
android:minHeight="@dimen/material_component_lists_single_line_with_avatar_height" android:minHeight="@dimen/material_component_lists_single_line_with_avatar_height">
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="25dp">
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/card" android:id="@+id/card"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="6dp" android:layout_marginTop="6dp"
android:layout_marginBottom="6dp"
android:layout_marginStart="8dp"
app:layout_constrainedHeight="true" app:layout_constrainedHeight="true"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
@ -95,7 +95,7 @@
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/subtitle" android:id="@+id/subtitle"
style="@style/TextAppearance.Regular.Body1.Light" style="@style/TextAppearance.MaterialComponents.Body1"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"

View File

@ -1,8 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.recyclerview.widget.RecyclerView <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/migration_layout"
android:id="@+id/migration_recycler"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:fitsSystemWindows="true"
android:clipToPadding="false"/> <androidx.recyclerview.widget.RecyclerView
android:id="@+id/migration_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"/>
</FrameLayout>

View File

@ -11,7 +11,7 @@
app:actionViewClass="androidx.appcompat.widget.SearchView"/> app:actionViewClass="androidx.appcompat.widget.SearchView"/>
<item android:id="@+id/action_filter" <item android:id="@+id/action_filter"
android:title="@string/action_view_all_sources" android:title="@string/action_change_sources"
android:icon="@drawable/ic_filter_list_white_24dp" android:icon="@drawable/ic_filter_list_white_24dp"
app:showAsAction="never"/> app:showAsAction="never"/>

View File

@ -42,7 +42,7 @@
<!-- Actions --> <!-- Actions -->
<string name="action_filter">Filter</string> <string name="action_filter">Filter</string>
<string name="action_view_all_sources">View all sources</string> <string name="action_change_sources">Change sources</string>
<string name="action_view_options">View options</string> <string name="action_view_options">View options</string>
<string name="action_filter_downloaded">Downloaded</string> <string name="action_filter_downloaded">Downloaded</string>
<string name="action_filter_not_downloaded">Not downloaded</string> <string name="action_filter_not_downloaded">Not downloaded</string>
@ -109,7 +109,7 @@
<string name="action_add_to_home_screen">Add to home screen</string> <string name="action_add_to_home_screen">Add to home screen</string>
<string name="action_display_mode">Display mode</string> <string name="action_display_mode">Display mode</string>
<string name="action_display">Display</string> <string name="action_display">Display</string>
<string name="action_display_comfy_grid">Comfy Grid</string> <string name="action_display_comfy_grid">Comfortable Grid</string>
<string name="action_display_grid">Compact Grid</string> <string name="action_display_grid">Compact Grid</string>
<string name="action_display_list">List</string> <string name="action_display_list">List</string>
<string name="action_display_download_badge">Download badges</string> <string name="action_display_download_badge">Download badges</string>

View File

@ -180,7 +180,6 @@
</style> </style>
<style name="Theme.Widget.GridView.Catalogue"> <style name="Theme.Widget.GridView.Catalogue">
<item name="android:padding">5dp</item>
<item name="android:gravity">top|left</item> <item name="android:gravity">top|left</item>
<item name="android:smoothScrollbar">true</item> <item name="android:smoothScrollbar">true</item>
<item name="android:cacheColorHint">?android:attr/textColorHint</item> <item name="android:cacheColorHint">?android:attr/textColorHint</item>