From 363f5fdd1ecda1a5dea10b6885bb59b374d4807a Mon Sep 17 00:00:00 2001 From: Aditya Date: Sat, 11 Jan 2025 15:15:40 +0530 Subject: [PATCH] Fix: Enable multi-line support for the deck picker footer --- .../src/main/java/com/ichi2/anki/DeckPicker.kt | 15 +++++++++++++-- AnkiDroid/src/main/res/layout/deck_picker.xml | 4 ++++ .../src/main/res/layout/floating_add_button.xml | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt index 4c521e62abec..6c9dcbf4f3dc 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt @@ -58,6 +58,7 @@ import androidx.appcompat.app.AlertDialog import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.TooltipCompat +import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback import androidx.core.content.edit @@ -69,6 +70,7 @@ import androidx.core.util.component1 import androidx.core.util.component2 import androidx.core.view.MenuItemCompat import androidx.core.view.OnReceiveContentListener +import androidx.core.view.doOnLayout import androidx.core.view.isVisible import androidx.draganddrop.DropHelper import androidx.fragment.app.commit @@ -2245,12 +2247,21 @@ open class DeckPicker : dueTree = result launchCatchingTask { renderPage(collectionHasNoCards) } // Update the mini statistics bar as well - reviewSummaryTextView.setSingleLine() launchCatchingTask { reviewSummaryTextView.text = withCol { - sched.studiedToday() + // Backend returns studiedToday() with newlines for HTML formatting,so we replace them with spaces. + sched.studiedToday().replace("\n", " ") } + val fabLinearLayout = findViewById(R.id.fabLinearLayout) + // Adjust bottom margin of fabLinearLayout based on reviewSummaryTextView height + reviewSummaryTextView.doOnLayout { + if (reviewSummaryTextView.lineCount > 1) { + val layoutParams = fabLinearLayout.layoutParams as CoordinatorLayout.LayoutParams + layoutParams.setMargins(0, 0, 0, reviewSummaryTextView.height / 2) + fabLinearLayout.layoutParams = layoutParams + } + } } Timber.d("Startup - Deck List UI Completed") } diff --git a/AnkiDroid/src/main/res/layout/deck_picker.xml b/AnkiDroid/src/main/res/layout/deck_picker.xml index 1d31f141cfad..f5bce585d22f 100644 --- a/AnkiDroid/src/main/res/layout/deck_picker.xml +++ b/AnkiDroid/src/main/res/layout/deck_picker.xml @@ -46,6 +46,10 @@