Skip to content

Commit f5544b9

Browse files
committed
Eliminate some dead code. Re-attach missing SAML download.
1 parent 86a9ab3 commit f5544b9

File tree

4 files changed

+8
-121
lines changed

4 files changed

+8
-121
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ POM_SCM_CONNECTION=scm:git:git://github.com/ThePalaceProject/android-core
1111
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/ThePalaceProject/android-core
1212
POM_SCM_URL=http://github.com/ThePalaceProject/android-core
1313
POM_URL=http://github.com/ThePalaceProject/android-core
14-
VERSION_NAME=1.16.0
14+
VERSION_NAME=1.16.1
1515
VERSION_CODE_BASE=70000
1616

1717
android.useAndroidX=true

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

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class CatalogFeedPagingDataAdapter(
6565
private val onBookViewerOpen: (Book, BookFormat) -> Unit,
6666
private val onBookDelete: (CatalogBookStatus<*>) -> Unit,
6767
private val onShowTaskError: (TaskResult.Failure<*>) -> Unit,
68-
) : PagingDataAdapter<FeedEntry, CatalogFeedPagingDataAdapter.ViewHolder>(org.nypl.simplified.ui.catalog.CatalogFeedPagingDataAdapter.Companion.diffCallback) {
68+
) : PagingDataAdapter<FeedEntry, CatalogFeedPagingDataAdapter.ViewHolder>(diffCallback) {
6969

7070
companion object {
7171
private val loanEndFormatter =
@@ -785,26 +785,6 @@ class CatalogFeedPagingDataAdapter(
785785
this.idleButtons.removeAllViews()
786786
}
787787

788-
/**
789-
* XXX: This information really should be available somewhere else. This was ported from
790-
* existing code.
791-
*/
792-
793-
private fun getLoanDurationText(
794-
book: Book
795-
): String {
796-
val endDate = this.getLoanDuration(book)
797-
return if (endDate != null) {
798-
CatalogBookAvailabilityStrings.intervalStringLoanDuration(
799-
this.view.context.resources,
800-
DateTime.now(),
801-
endDate
802-
)
803-
} else {
804-
""
805-
}
806-
}
807-
808788
private fun getLoanDuration(
809789
book: Book
810790
): DateTime? {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class CatalogFeedViewDetails2(
9191
private val covers: BookCoverProviderType,
9292
private val onToolbarBackPressed: () -> Unit,
9393
private val onShowErrorDetails: (TaskResult.Failure<*>) -> Unit,
94+
private val onBookSAMLDownloadRequested: (CatalogBookStatus<DownloadWaitingForExternalAuthentication>) -> Unit,
9495
private val onBookBorrowRequested: (CatalogBorrowParameters) -> Unit,
9596
private val onBookBorrowCancelRequested: (CatalogBookStatus<*>) -> Unit,
9697
private val onBookCanBeRevoked: (CatalogBookStatus<*>) -> Boolean,
@@ -761,6 +762,7 @@ class CatalogFeedViewDetails2(
761762
container: ViewGroup,
762763
covers: BookCoverProviderType,
763764
onShowErrorDetails: (TaskResult.Failure<*>) -> Unit,
765+
onBookSAMLDownloadRequested: (CatalogBookStatus<DownloadWaitingForExternalAuthentication>) -> Unit,
764766
onBookBorrowRequested: (CatalogBorrowParameters) -> Unit,
765767
onBookBorrowCancelRequested: (CatalogBookStatus<*>) -> Unit,
766768
onBookCanBeRevoked: (CatalogBookStatus<*>) -> Boolean,
@@ -777,6 +779,7 @@ class CatalogFeedViewDetails2(
777779
layoutInflater = layoutInflater,
778780
covers = covers,
779781
onToolbarBackPressed = onToolbarBackPressed,
782+
onBookSAMLDownloadRequested = onBookSAMLDownloadRequested,
780783
onShowErrorDetails = onShowErrorDetails,
781784
onBookBorrowRequested = onBookBorrowRequested,
782785
onBookBorrowCancelRequested = onBookBorrowCancelRequested,
@@ -1376,6 +1379,8 @@ class CatalogFeedViewDetails2(
13761379
this.setProgress(0.0)
13771380
}
13781381
}
1382+
1383+
this.onBookSAMLDownloadRequested(status)
13791384
}
13801385

13811386
private fun onBookStatusDownloadExternalAuthenticationInProgress(

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

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ import org.nypl.simplified.feeds.api.FeedEntry
3636
import org.nypl.simplified.feeds.api.FeedFacet
3737
import org.nypl.simplified.feeds.api.FeedLoaderType
3838
import org.nypl.simplified.feeds.api.FeedSearch
39-
import org.nypl.simplified.opds.core.OPDSAvailabilityHeld
40-
import org.nypl.simplified.opds.core.OPDSAvailabilityHeldReady
41-
import org.nypl.simplified.opds.core.OPDSAvailabilityHoldable
42-
import org.nypl.simplified.opds.core.OPDSAvailabilityLoanable
43-
import org.nypl.simplified.opds.core.OPDSAvailabilityLoaned
44-
import org.nypl.simplified.opds.core.OPDSAvailabilityMatcherType
45-
import org.nypl.simplified.opds.core.OPDSAvailabilityOpenAccess
46-
import org.nypl.simplified.opds.core.OPDSAvailabilityRevoked
4739
import org.nypl.simplified.profiles.controller.api.ProfileFeedRequest
4840
import org.nypl.simplified.profiles.controller.api.ProfilesControllerType
4941
import org.nypl.simplified.taskrecorder.api.TaskResult
@@ -320,6 +312,7 @@ sealed class CatalogFragment : Fragment(), MainBackButtonConsumerType {
320312
screenSize = this.screenSize,
321313
container = this.contentContainer,
322314
covers = this.covers,
315+
onBookSAMLDownloadRequested = this::onBookSAMLDownloadRequested,
323316
onShowErrorDetails = this::onShowErrorDetails,
324317
onBookBorrowRequested = this::onBookBorrowRequested,
325318
onBookBorrowCancelRequested = this::onBookBorrowCancelRequested,
@@ -373,8 +366,6 @@ sealed class CatalogFragment : Fragment(), MainBackButtonConsumerType {
373366
}
374367
}
375368

376-
this.onStateChangeToDetailsConfigureToolbar(newState, view)
377-
378369
/*
379370
* Subscribe to the entry on the OPDS client. We'll receive the initial
380371
* entry on subscription.
@@ -478,25 +469,6 @@ sealed class CatalogFragment : Fragment(), MainBackButtonConsumerType {
478469
}
479470
}
480471

481-
private fun onStateChangeToDetailsConfigureToolbar(
482-
newState: LoadedFeedEntry,
483-
view: CatalogFeedViewDetails2
484-
) {
485-
try {
486-
val account =
487-
this.profiles.profileCurrent()
488-
.account(newState.request.entry.accountID)
489-
490-
val title =
491-
when (val e = newState.request.entry) {
492-
is FeedEntry.FeedEntryCorrupt -> ""
493-
is FeedEntry.FeedEntryOPDS -> e.feedEntry.title
494-
}
495-
} catch (e: Throwable) {
496-
// Nothing sensible we can do about this.
497-
}
498-
}
499-
500472
private fun onBookBorrowRequested(
501473
parameters: CatalogBorrowParameters
502474
) {
@@ -577,64 +549,6 @@ sealed class CatalogFragment : Fragment(), MainBackButtonConsumerType {
577549
}
578550
}
579551

580-
/**
581-
* Determine whether or not a book can be "deleted".
582-
*
583-
* A book can be deleted if:
584-
*
585-
* * It is loaned, downloaded, and not revocable (because otherwise, a revocation is needed).
586-
* * It is loanable, but there is a book database entry for it
587-
* * It is open access but there is a book database entry for it
588-
*/
589-
590-
private fun onBookCanBeDeleted(
591-
status: CatalogBookStatus<*>
592-
): Boolean {
593-
return try {
594-
val services =
595-
Services.serviceDirectory()
596-
val profiles =
597-
services.requireService(ProfilesControllerType::class.java)
598-
val book =
599-
status.book
600-
val profile =
601-
profiles.profileCurrent()
602-
val account =
603-
profile.account(book.account)
604-
605-
return if (account.bookDatabase.books().contains(book.id)) {
606-
book.entry.availability.matchAvailability(
607-
object : OPDSAvailabilityMatcherType<Boolean, Exception> {
608-
override fun onHeldReady(availability: OPDSAvailabilityHeldReady): Boolean =
609-
false
610-
611-
override fun onHeld(availability: OPDSAvailabilityHeld): Boolean =
612-
false
613-
614-
override fun onHoldable(availability: OPDSAvailabilityHoldable): Boolean =
615-
false
616-
617-
override fun onLoaned(availability: OPDSAvailabilityLoaned): Boolean =
618-
availability.revoke.isNone && book.isDownloaded
619-
620-
override fun onLoanable(availability: OPDSAvailabilityLoanable): Boolean =
621-
true
622-
623-
override fun onOpenAccess(availability: OPDSAvailabilityOpenAccess): Boolean =
624-
true
625-
626-
override fun onRevoked(availability: OPDSAvailabilityRevoked): Boolean =
627-
false
628-
})
629-
} else {
630-
false
631-
}
632-
} catch (e: Throwable) {
633-
this.logger.debug("could not determine if the book could be deleted: ", e)
634-
false
635-
}
636-
}
637-
638552
private fun onBookCanBeRevoked(
639553
status: CatalogBookStatus<*>
640554
): Boolean {
@@ -702,12 +616,6 @@ sealed class CatalogFragment : Fragment(), MainBackButtonConsumerType {
702616
)
703617
}
704618

705-
private fun onBookResetStatusInitial(
706-
status: CatalogBookStatus<*>
707-
) {
708-
// XXX: Unclear what the point of this method ever was...
709-
}
710-
711619
private fun onBookViewerOpen(
712620
book: Book,
713621
bookFormat: BookFormat
@@ -725,12 +633,6 @@ sealed class CatalogFragment : Fragment(), MainBackButtonConsumerType {
725633
)
726634
}
727635

728-
private fun onBookReserveRequested(
729-
parameters: CatalogBorrowParameters
730-
) {
731-
this.onBookBorrowRequested(parameters)
732-
}
733-
734636
private fun onStateChangedToGroups(
735637
newState: LoadedFeedWithGroups
736638
) {

0 commit comments

Comments
 (0)