feat: compact book library and catalog cards
This commit is contained in:
@@ -19,8 +19,8 @@ android {
|
||||
applicationId = "com.aletheia.app"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 48
|
||||
versionName = "2.37"
|
||||
versionCode = 50
|
||||
versionName = "2.39"
|
||||
|
||||
buildConfigField(
|
||||
"String",
|
||||
|
||||
@@ -90,7 +90,6 @@ class QBooksCatalogAdapter(
|
||||
val formatText = context.getString(R.string.qbooks_format_label, book.format.uppercase())
|
||||
binding.bookTitle.text = book.title
|
||||
binding.bookAuthor.text = book.author
|
||||
binding.bookFormat.text = formatText
|
||||
binding.bookCover.setBookCover(book.coverImage, R.drawable.default_cover)
|
||||
binding.root.contentDescription = context.getString(
|
||||
R.string.a11y_qbooks_book_card,
|
||||
|
||||
@@ -154,15 +154,6 @@ class QBooksLibraryFragment : Fragment() {
|
||||
val pageUrl = if (reset) null else nextPageUrl
|
||||
val query = currentSearchQuery()
|
||||
isLoading = true
|
||||
setOverview(
|
||||
getString(
|
||||
if (reset) R.string.qbooks_catalog_overview_loading_title
|
||||
else R.string.qbooks_catalog_overview_loading_more_title
|
||||
),
|
||||
getString(if (reset) R.string.qbooks_catalog_loading else R.string.qbooks_catalog_loading_more),
|
||||
query.takeIf(String::isNotBlank)?.let { getString(R.string.qbooks_catalog_query_meta, it) }
|
||||
)
|
||||
|
||||
loadJob = viewLifecycleOwner.lifecycleScope.launch {
|
||||
val cached = app.qBooksService.getCachedCatalogPage(query, pageToLoad, PAGE_SIZE, pageUrl)
|
||||
if (_binding == null || generation != requestGeneration) return@launch
|
||||
@@ -226,17 +217,6 @@ class QBooksLibraryFragment : Fragment() {
|
||||
} else {
|
||||
getString(R.string.qbooks_catalog_empty_query, query)
|
||||
}
|
||||
val detail = if (query.isBlank()) {
|
||||
resources.getQuantityString(R.plurals.qbooks_catalog_summary, count, count)
|
||||
} else {
|
||||
resources.getQuantityString(R.plurals.qbooks_catalog_search_summary, count, count, query)
|
||||
}
|
||||
val hint = if (hasMoreBooks) R.string.qbooks_catalog_more_hint else R.string.qbooks_catalog_end_hint
|
||||
setOverview(
|
||||
getString(R.string.qbooks_catalog_overview_title),
|
||||
detail,
|
||||
if (count == 0) null else getString(hint)
|
||||
)
|
||||
}
|
||||
|
||||
private fun renderError(message: String) {
|
||||
@@ -247,20 +227,11 @@ class QBooksLibraryFragment : Fragment() {
|
||||
binding.notConfiguredCard.visibility = if (isConfigured) View.GONE else View.VISIBLE
|
||||
binding.errorCard.visibility = if (isConfigured) View.VISIBLE else View.GONE
|
||||
binding.errorText.text = message
|
||||
binding.catalogOverviewCard.visibility = View.GONE
|
||||
binding.emptyResultsCard.visibility = View.GONE
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
isLoading = false
|
||||
}
|
||||
|
||||
private fun setOverview(title: String, detail: String, meta: String?) {
|
||||
binding.catalogOverviewCard.visibility = View.VISIBLE
|
||||
binding.catalogOverviewTitleText.text = title
|
||||
binding.catalogStatusText.text = detail
|
||||
binding.catalogOverviewMetaText.text = meta.orEmpty()
|
||||
binding.catalogOverviewMetaText.visibility = if (meta.isNullOrBlank()) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
private fun loadMetadataAndCovers(books: List<QBooksBook>, generation: Int) {
|
||||
books.forEach { book ->
|
||||
coverJobs += viewLifecycleOwner.lifecycleScope.launch {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z" />
|
||||
</vector>
|
||||
@@ -75,9 +75,11 @@
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/bookshelf_panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:layout_marginTop="14dp"
|
||||
android:visibility="gone"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="0dp"
|
||||
@@ -88,32 +90,66 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="18dp">
|
||||
android:paddingStart="14dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingEnd="14dp"
|
||||
android:paddingBottom="14dp">
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="@font/open_sans_semibold"
|
||||
android:text="@string/library_shelf_section"
|
||||
android:textColor="@color/ink_color"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/local_shelf_all_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="44dp"
|
||||
android:gravity="center"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:text="@string/action_show_all"
|
||||
android:textColor="@color/accent_color" />
|
||||
</LinearLayout>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/open_sans_semibold"
|
||||
android:text="@string/library_goal_title"
|
||||
android:textColor="@color/ink_color"
|
||||
android:textSize="18sp" />
|
||||
android:layout_marginTop="4dp"
|
||||
android:scrollbars="none">
|
||||
|
||||
<TextView
|
||||
<com.google.android.material.chip.ChipGroup
|
||||
android:id="@+id/library_filter_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:chipSpacingHorizontal="8dp"
|
||||
app:selectionRequired="true"
|
||||
app:singleSelection="true"
|
||||
app:singleLine="true">
|
||||
<com.google.android.material.chip.Chip android:id="@+id/library_filter_all" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:text="@string/library_filter_all" />
|
||||
<com.google.android.material.chip.Chip android:id="@+id/library_filter_reading" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/library_filter_reading" />
|
||||
<com.google.android.material.chip.Chip android:id="@+id/library_filter_downloaded" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/library_filter_downloaded" />
|
||||
<com.google.android.material.chip.Chip android:id="@+id/library_filter_finished" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/library_filter_finished" />
|
||||
</com.google.android.material.chip.ChipGroup>
|
||||
</HorizontalScrollView>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/books_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="@string/library_goal_subtitle"
|
||||
android:textColor="@color/ink_soft_color"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="5dp"
|
||||
android:layout_marginTop="14dp"
|
||||
android:max="7"
|
||||
android:progress="1"
|
||||
android:progressTint="@color/accent_color" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:clipToPadding="false"
|
||||
android:contentDescription="@string/a11y_books_list"
|
||||
android:scrollbars="none" />
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
@@ -196,85 +232,6 @@
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:scrollbars="none">
|
||||
|
||||
<com.google.android.material.chip.ChipGroup
|
||||
android:id="@+id/library_filter_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:chipSpacingHorizontal="8dp"
|
||||
app:selectionRequired="true"
|
||||
app:singleSelection="true"
|
||||
app:singleLine="true">
|
||||
<com.google.android.material.chip.Chip android:id="@+id/library_filter_all" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true" android:text="@string/library_filter_all" />
|
||||
<com.google.android.material.chip.Chip android:id="@+id/library_filter_reading" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/library_filter_reading" />
|
||||
<com.google.android.material.chip.Chip android:id="@+id/library_filter_downloaded" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/library_filter_downloaded" />
|
||||
<com.google.android.material.chip.Chip android:id="@+id/library_filter_finished" style="@style/Widget.Material3.Chip.Filter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/library_filter_finished" />
|
||||
</com.google.android.material.chip.ChipGroup>
|
||||
</HorizontalScrollView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/bookshelf_panel"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="14dp"
|
||||
android:visibility="gone"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardCornerRadius="20dp"
|
||||
app:cardElevation="0dp"
|
||||
app:strokeColor="@color/border_color"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="14dp"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingEnd="14dp"
|
||||
android:paddingBottom="14dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="@font/open_sans_semibold"
|
||||
android:text="@string/library_shelf_section"
|
||||
android:textColor="@color/ink_color"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/local_shelf_all_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="44dp"
|
||||
android:gravity="center"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="10dp"
|
||||
android:text="@string/action_show_all"
|
||||
android:textColor="@color/accent_color" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/books_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:clipToPadding="false"
|
||||
android:contentDescription="@string/a11y_books_list"
|
||||
android:scrollbars="none" />
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/empty_library_card"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -134,51 +134,6 @@
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/catalog_overview_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:cardBackgroundColor="@color/white"
|
||||
app:cardCornerRadius="14dp"
|
||||
app:cardElevation="0dp"
|
||||
app:strokeColor="@color/border_color"
|
||||
app:strokeWidth="1dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/catalog_overview_title_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/open_sans_semibold"
|
||||
android:textColor="@color/ink_color"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/catalog_status_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
android:textColor="@color/ink_soft_color"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/catalog_overview_meta_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:textColor="@color/accent_color"
|
||||
android:textSize="11sp" />
|
||||
</LinearLayout>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/download_status_card"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -50,9 +50,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="@font/open_sans_semibold"
|
||||
android:maxLines="2"
|
||||
android:maxLines="3"
|
||||
android:textColor="@color/ink_color"
|
||||
android:textSize="17sp" />
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/book_author"
|
||||
@@ -64,32 +64,23 @@
|
||||
android:textColor="@color/ink_soft_color"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/book_format"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="6dp"
|
||||
android:background="@drawable/bg_format_chip"
|
||||
android:fontFamily="@font/open_sans_semibold"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:textColor="@color/accent_dark_color"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/download_button"
|
||||
style="@style/Widget.Aletheia.Button.Primary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:minWidth="94dp"
|
||||
android:paddingStart="14dp"
|
||||
android:paddingEnd="14dp"
|
||||
android:text="@string/action_download" />
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:insetTop="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:minWidth="40dp"
|
||||
android:minHeight="40dp"
|
||||
android:padding="8dp"
|
||||
app:icon="@drawable/ic_download"
|
||||
app:iconGravity="textStart"
|
||||
app:iconPadding="0dp" />
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
Reference in New Issue
Block a user