Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Enable multi-line support for the deck picker footer #17349

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewPropertyAnimator
import android.view.ViewTreeObserver
import android.widget.Filterable
import android.widget.ImageView
import android.widget.LinearLayout
Expand All @@ -58,6 +59,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
Expand Down Expand Up @@ -2207,12 +2209,30 @@ 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<LinearLayout>(R.id.fabLinearLayout)
// OnPreDrawListener adjusts the FAB's margin before the view is drawn
val preDrawListener =
object : ViewTreeObserver.OnPreDrawListener {
override fun onPreDraw(): Boolean {
// Adjust bottom margin of fabLinearLayout based on reviewSummaryTextView height
if (reviewSummaryTextView.lineCount > 1) {
val layoutParams = fabLinearLayout.layoutParams as CoordinatorLayout.LayoutParams
layoutParams.setMargins(0, 0, 0, reviewSummaryTextView.height / 2)
fabLinearLayout.layoutParams = layoutParams
}
// Remove the listener after it runs
reviewSummaryTextView.viewTreeObserver.removeOnPreDrawListener(this)
return true
}
}
// Attach the listener to the view
reviewSummaryTextView.viewTreeObserver.addOnPreDrawListener(preDrawListener)
}
Timber.d("Startup - Deck List UI Completed")
}
Expand Down
4 changes: 4 additions & 0 deletions AnkiDroid/src/main/res/layout/deck_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<com.ichi2.ui.FixedTextView
android:id="@+id/today_stats_text_view"
android:layout_width="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="4dp"
Expand Down
1 change: 1 addition & 0 deletions AnkiDroid/src/main/res/layout/floating_add_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/>

<LinearLayout
android:id="@+id/fabLinearLayout"
android:layout_width="wrap_content"
android:orientation="vertical"
android:padding="12dp"
Expand Down
Loading