Skip to content

Commit 360eca7

Browse files
committed
Adjust loan due date display in feeds (PP-2631).
1 parent 90b6405 commit 360eca7

File tree

4 files changed

+57
-13
lines changed

4 files changed

+57
-13
lines changed

README-CHANGES.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@
694694
</c:change>
695695
</c:changes>
696696
</c:release>
697-
<c:release date="2025-08-13T19:01:43+00:00" is-open="true" ticket-system="org.lyrasis.jira" version="1.17.0">
697+
<c:release date="2025-08-18T10:41:58+00:00" is-open="true" ticket-system="org.lyrasis.jira" version="1.17.0">
698698
<c:changes>
699699
<c:change date="2025-07-15T00:00:00+00:00" summary="Add support for Boundless DRM."/>
700700
<c:change date="2025-07-15T00:00:00+00:00" summary="Respect book cover aspect ratios.">
@@ -737,16 +737,21 @@
737737
<c:ticket id="PP-2779"/>
738738
</c:tickets>
739739
</c:change>
740-
<c:change date="2025-08-13T14:21:08+00:00" summary="Implement a new and improved bottom drawer on book details pages.">
740+
<c:change date="2025-08-13T00:00:00+00:00" summary="Implement a new and improved bottom drawer on book details pages.">
741741
<c:tickets>
742742
<c:ticket id="PP-2753"/>
743743
</c:tickets>
744744
</c:change>
745-
<c:change date="2025-08-13T19:01:43+00:00" summary="Ensure Download button is shown for borrowed books.">
745+
<c:change date="2025-08-13T00:00:00+00:00" summary="Ensure Download button is shown for borrowed books.">
746746
<c:tickets>
747747
<c:ticket id="PP-2809"/>
748748
</c:tickets>
749749
</c:change>
750+
<c:change date="2025-08-18T10:41:58+00:00" summary="Adjust loan due date display in feeds.">
751+
<c:tickets>
752+
<c:ticket id="PP-2631"/>
753+
</c:tickets>
754+
</c:change>
750755
</c:changes>
751756
</c:release>
752757
</c:releases>

simplified-ui/src/main/java/org/nypl/simplified/ui/catalog/CatalogFeedPagingDataAdapter.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
1717
import com.google.common.util.concurrent.MoreExecutors
1818
import io.reactivex.disposables.Disposable
1919
import org.joda.time.DateTime
20+
import org.joda.time.Days
2021
import org.joda.time.format.DateTimeFormat
2122
import org.librarysimplified.ui.R
2223
import org.nypl.simplified.books.api.Book
@@ -116,6 +117,8 @@ class CatalogFeedPagingDataAdapter(
116117
this.idle.findViewById<TextView>(R.id.bookCellIdleTitle)
117118
private val idleTime =
118119
this.idle.findViewById<TextView>(R.id.bookCellIdleTime)
120+
private val idleTimeDays =
121+
this.idle.findViewById<TextView>(R.id.bookCellIdleTimeDays)
119122
private val idleAuthor =
120123
this.idle.findViewById<TextView>(R.id.bookCellIdleAuthor)
121124
private val idleButtons =
@@ -203,6 +206,7 @@ class CatalogFeedPagingDataAdapter(
203206
this.idleTitle.text = item.feedEntry.title
204207
this.idleAuthor.text = item.feedEntry.authorsCommaSeparated
205208
this.idleTime.text = ""
209+
this.idleTimeDays.text = ""
206210

207211
val f =
208212
this@CatalogFeedPagingDataAdapter.covers.loadThumbnailInto(
@@ -522,6 +526,7 @@ class CatalogFeedPagingDataAdapter(
522526
R.string.catalogBookAvailabilityHeldQueue,
523527
position
524528
)
529+
this.idleTimeDays.text = ""
525530
}
526531
}
527532

@@ -666,12 +671,22 @@ class CatalogFeedPagingDataAdapter(
666671
loanDuration: DateTime?
667672
) {
668673
if (loanDuration != null) {
674+
val now = DateTime.now()
675+
val days = Days.daysBetween(now, loanDuration)
676+
669677
this.idleTime.text =
670678
this.idleTime.resources.getString(
671679
R.string.catalogBookCellBorrowingUntil,
672-
org.nypl.simplified.ui.catalog.CatalogFeedPagingDataAdapter.Companion.loanEndFormatter.print(loanDuration)
680+
loanEndFormatter.print(loanDuration)
681+
)
682+
this.idleTimeDays.text =
683+
this.idleTime.resources.getString(
684+
R.string.catalogBookCellBorrowingDays,
685+
days.days
673686
)
687+
674688
this.setVisible(this.idleTime, true)
689+
this.setVisible(this.idleTimeDays, true)
675690
} else {
676691
this.hideIdleTime()
677692
}
@@ -680,6 +695,8 @@ class CatalogFeedPagingDataAdapter(
680695
private fun hideIdleTime() {
681696
this.idleTime.text = ""
682697
this.idleTime.visibility = GONE
698+
this.idleTimeDays.text = ""
699+
this.idleTimeDays.visibility = GONE
683700
}
684701

685702
private fun onBookStatusLoanedNotDownloaded(

simplified-ui/src/main/res/layout/book_cell_idle.xml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,40 @@
105105
android:text="@string/catalogRetry" />
106106
</LinearLayout>
107107

108-
<TextView
109-
android:id="@+id/bookCellIdleTime"
108+
<androidx.constraintlayout.widget.ConstraintLayout
110109
android:layout_width="match_parent"
111110
android:layout_height="wrap_content"
112111
android:layout_marginTop="8dp"
113-
android:alpha="0.75"
114-
android:ellipsize="end"
115-
android:maxLines="1"
116-
android:textSize="12sp"
112+
android:orientation="horizontal"
117113
app:layout_constraintBottom_toBottomOf="parent"
118114
app:layout_constraintEnd_toEndOf="parent"
119-
app:layout_constraintStart_toEndOf="@id/bookCellIdleCover"
120-
tools:text="Borrowed until 31st February 1976" />
115+
app:layout_constraintStart_toEndOf="@id/bookCellIdleCover">
116+
117+
<TextView
118+
android:id="@+id/bookCellIdleTime"
119+
android:layout_width="0dp"
120+
android:layout_height="wrap_content"
121+
android:alpha="0.75"
122+
android:ellipsize="end"
123+
android:maxLines="1"
124+
android:textSize="12sp"
125+
app:layout_constraintBottom_toBottomOf="parent"
126+
app:layout_constraintStart_toStartOf="parent"
127+
tools:text="Borrowed until 31st February 1976" />
128+
129+
<TextView
130+
android:id="@+id/bookCellIdleTimeDays"
131+
android:layout_width="0dp"
132+
android:layout_height="wrap_content"
133+
android:ellipsize="end"
134+
android:maxLines="1"
135+
android:textSize="12sp"
136+
android:textStyle="bold"
137+
app:layout_constraintBottom_toBottomOf="parent"
138+
app:layout_constraintEnd_toEndOf="parent"
139+
tools:text="3 Days" />
140+
141+
</androidx.constraintlayout.widget.ConstraintLayout>
121142
</LinearLayout>
122143

123144
</androidx.constraintlayout.widget.ConstraintLayout>

simplified-ui/src/main/res/values/stringsCatalog.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
<string name="catalogSearch">Search</string>
9595
<string name="catalogDurationFormat">%1$s hours, %2$s minutes</string>
9696

97-
<string name="catalogBookCellBorrowingUntil">Borrowed until %1$s</string>
97+
<string name="catalogBookCellBorrowingUntil">Due %1$s</string>
98+
<string name="catalogBookCellBorrowingDays">%1$d Days</string>
9899

99100
<string name="catalogBookDetailBorrowingFor">Borrowing for</string>
100101
<string name="catalogBookDetailBorrowedUntil">Borrowed until</string>

0 commit comments

Comments
 (0)