From 400ad1a57ebf1bee0351cf869b448ec0a3debbf6 Mon Sep 17 00:00:00 2001 From: Dima Date: Thu, 9 May 2024 15:36:36 +0900 Subject: [PATCH] Improve RemoteAttachmentDownloader handling of network errors, Fix text colors on AddByIdentifierScreen Adding arxiv.org to list of cleartextTrafficPermitted websites. Upping versionCode to 60 --- .../RemoteAttachmentDownloader.kt | 14 ++++++++++++++ .../addbyidentifier/IdentifierLookupController.kt | 12 +++++++----- .../addbyidentifier/ui/AddByIdentifierTable.kt | 3 +++ app/src/main/res/xml/network_security_config.xml | 3 +++ buildSrc/src/main/kotlin/BuildConfig.kt | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/zotero/android/attachmentdownloader/RemoteAttachmentDownloader.kt b/app/src/main/java/org/zotero/android/attachmentdownloader/RemoteAttachmentDownloader.kt index 6970c1f8..f9dbcf83 100644 --- a/app/src/main/java/org/zotero/android/attachmentdownloader/RemoteAttachmentDownloader.kt +++ b/app/src/main/java/org/zotero/android/attachmentdownloader/RemoteAttachmentDownloader.kt @@ -185,6 +185,20 @@ class RemoteAttachmentDownloader @Inject constructor( ) } } + is CustomResult.GeneralError.NetworkError -> { + this.errors[download] = Exception(result.stringResponse) + Timber.e( + result.stringResponse, + "RemoteAttachmentDownloader: failed to download attachment ${download.key}, ${download.libraryId}" + ) + attachmentDownloaderEventStream.emitAsync( + Update( + download = download, + kind = Update.Kind.failed + ) + ) + } + is CustomResult.GeneralSuccess -> { Timber.i("RemoteAttachmentDownloader: finished downloading ${download.key}") diff --git a/app/src/main/java/org/zotero/android/uicomponents/addbyidentifier/IdentifierLookupController.kt b/app/src/main/java/org/zotero/android/uicomponents/addbyidentifier/IdentifierLookupController.kt index 654ee414..f31747fa 100644 --- a/app/src/main/java/org/zotero/android/uicomponents/addbyidentifier/IdentifierLookupController.kt +++ b/app/src/main/java/org/zotero/android/uicomponents/addbyidentifier/IdentifierLookupController.kt @@ -634,12 +634,14 @@ class IdentifierLookupController @Inject constructor( remoteFileDownloader.stop() val lookupData = this.lookupData cleanupLookupIfNeeded(force = true) { - this.observable.emitAsync( - Update( - kind = Update.Kind.finishedAllLookups, - lookupData = emptyList() + if (this::observable.isInitialized) { + this.observable.emitAsync( + Update( + kind = Update.Kind.finishedAllLookups, + lookupData = emptyList() + ) ) - ) + } } val storedItemResponses = lookupData.values.mapNotNull { when (it.state) { diff --git a/app/src/main/java/org/zotero/android/uicomponents/addbyidentifier/ui/AddByIdentifierTable.kt b/app/src/main/java/org/zotero/android/uicomponents/addbyidentifier/ui/AddByIdentifierTable.kt index 70cfcdd9..f198fddd 100644 --- a/app/src/main/java/org/zotero/android/uicomponents/addbyidentifier/ui/AddByIdentifierTable.kt +++ b/app/src/main/java/org/zotero/android/uicomponents/addbyidentifier/ui/AddByIdentifierTable.kt @@ -97,6 +97,7 @@ internal fun LookupItemRow( title, HtmlCompat.FROM_HTML_MODE_LEGACY ).toString(), + color = CustomTheme.colors.primaryContent, style = CustomTheme.typography.newBody, ) NewDivider(modifier = Modifier.padding(top = 8.dp)) @@ -163,6 +164,7 @@ internal fun LookupAttachmentRow( title, HtmlCompat.FROM_HTML_MODE_LEGACY ).toString(), + color = CustomTheme.colors.primaryContent, style = CustomTheme.typography.newBody, ) NewDivider(modifier = Modifier.padding(top = 8.dp)) @@ -187,6 +189,7 @@ internal fun LookupIdentifierRow( modifier = Modifier.weight(1f), text = title, maxLines = 1, + color = CustomTheme.colors.primaryContent, overflow = TextOverflow.Ellipsis, style = CustomTheme.typography.newBody, ) diff --git a/app/src/main/res/xml/network_security_config.xml b/app/src/main/res/xml/network_security_config.xml index 05d1b3ba..cbe1bb39 100644 --- a/app/src/main/res/xml/network_security_config.xml +++ b/app/src/main/res/xml/network_security_config.xml @@ -1,5 +1,8 @@ + + arxiv.org + diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index e6fe495b..55bbd444 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -4,7 +4,7 @@ object BuildConfig { const val compileSdkVersion = 34 const val targetSdk = 33 - val versionCode = 59 // Must be updated on every build + val versionCode = 60 // Must be updated on every build val version = Version( major = 1, minor = 0,