diff options
author | Stefan Niedermann <info@niedermann.it> | 2021-03-10 12:51:40 +0300 |
---|---|---|
committer | Niedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com> | 2021-03-10 18:16:20 +0300 |
commit | 8c0b34adcb59b81446b2e7aea160731bca7803cc (patch) | |
tree | 339e39c9c907c26dbd9e4d0026341bc4724a0d0a /app | |
parent | 9d6a6bc1a92ef706833506b8553fe702b50a48e9 (diff) |
Extract fileId from attachments
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app')
4 files changed, 13 insertions, 20 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java b/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java index 791b7a4c6..e57ebe27c 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/api/JsonToEntityParser.java @@ -469,6 +469,7 @@ public class JsonToEntityParser { JsonObject extendedData = e.getAsJsonObject("extendedData").getAsJsonObject(); a.setFilesize(extendedData.get("filesize").getAsLong()); a.setMimetype(extendedData.get("mimetype").getAsString()); + a.setFileid(extendedData.get("fileid").getAsLong()); if (extendedData.has("info") && !extendedData.get("info").isJsonNull()) { JsonObject info = extendedData.getAsJsonObject("info").getAsJsonObject(); a.setDirname(info.get("dirname").getAsString()); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/Attachment.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/Attachment.java index ec41d4ef7..cbcd8f4bf 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/model/Attachment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/Attachment.java @@ -1,8 +1,8 @@ package it.niedermann.nextcloud.deck.model; +import androidx.annotation.Nullable; import androidx.room.Entity; import androidx.room.ForeignKey; -import androidx.room.Ignore; import androidx.room.Index; import java.io.Serializable; @@ -38,9 +38,8 @@ public class Attachment extends AbstractRemoteEntity implements Comparable<Attac private String extension; private String filename; private String localPath; - // TODO should probably be a Long... depends on https://github.com/nextcloud/deck/pull/2638 - @Ignore - private String fileId; + @Nullable + private Long fileid; public long getCardId() { return cardId; @@ -146,20 +145,13 @@ public class Attachment extends AbstractRemoteEntity implements Comparable<Attac this.localPath = localPath; } - /** - * TODO depends on https://github.com/nextcloud/deck/pull/2638 - */ - @Ignore - public String getFileId() { - return this.fileId; + @Nullable + public Long getFileid() { + return this.fileid; } - /** - * TODO depends on https://github.com/nextcloud/deck/pull/2638 - */ - @Ignore - public void setFileId(String fileId) { - this.fileId = fileId; + public void setFileid(@Nullable Long fileid) { + this.fileid = fileid; } @Override diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/util/AttachmentUtil.java b/app/src/main/java/it/niedermann/nextcloud/deck/util/AttachmentUtil.java index d6d8dcb50..d41fa92f1 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/util/AttachmentUtil.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/util/AttachmentUtil.java @@ -42,8 +42,8 @@ public class AttachmentUtil { public static String getThumbnailUrl(@NonNull Version version, @NonNull String accountUrl, @NonNull Long cardRemoteId, @NonNull Attachment attachment, @Px int previewSize) { return version.supportsFileAttachments() && EAttachmentType.FILE.equals(attachment.getType()) && - !TextUtils.isEmpty(attachment.getFileId()) - ? accountUrl + "/index.php/core/preview?fileId=" + attachment.getFileId() + "&x=" + previewSize + "&y=" + previewSize + !TextUtils.isEmpty(attachment.getFileid()) + ? accountUrl + "/index.php/core/preview?fileId=" + attachment.getFileid() + "&x=" + previewSize + "&y=" + previewSize : getRemoteOrLocalUrl(accountUrl, cardRemoteId, attachment); } diff --git a/app/src/test/java/it/niedermann/nextcloud/deck/util/AttachmentUtilTest.java b/app/src/test/java/it/niedermann/nextcloud/deck/util/AttachmentUtilTest.java index 782c319c3..020063c7b 100644 --- a/app/src/test/java/it/niedermann/nextcloud/deck/util/AttachmentUtilTest.java +++ b/app/src/test/java/it/niedermann/nextcloud/deck/util/AttachmentUtilTest.java @@ -36,7 +36,7 @@ public class AttachmentUtilTest { // Given there is an invalid fileId... final Attachment attachment3 = new Attachment(); attachment3.setId(999L); - attachment3.setFileId(""); + attachment3.setFileid(""); final String thumbnailUrl3 = AttachmentUtil.getThumbnailUrl(versionThatDoesSupportFileAttachments, accountUrl, 15L, attachment3, 205); // ... a fallback to the attachment itself should be returned assertEquals("https://example.com/index.php/apps/deck/cards/15/attachment/999", thumbnailUrl3); @@ -44,7 +44,7 @@ public class AttachmentUtilTest { // Given the server version does not support file attachments yet... final Attachment attachment4 = new Attachment(); attachment4.setId(111L); - attachment4.setFileId("222"); + attachment4.setFileid("222"); final String thumbnailUrl4 = AttachmentUtil.getThumbnailUrl(versionThatDoesNotSupportFileAttachments, accountUrl, 333L, attachment4, 444); // ... a fallback to the attachment itself should be returned assertEquals("https://example.com/index.php/apps/deck/cards/333/attachment/111", thumbnailUrl4); |