Skip to content

Commit

Permalink
Fix: Enable multi-line support for the deck picker footer
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya13s committed Dec 14, 2024
1 parent 47f6c8b commit c895a76
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
16 changes: 14 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2207,12 +2208,23 @@ 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 make sure to execute logic before view is drawn
reviewSummaryTextView.viewTreeObserver.addOnPreDrawListener {
// 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
}
true
}
}
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

0 comments on commit c895a76

Please sign in to comment.