From 3eaa48fa460c017ec5b0438e3fcbdaa26638efe9 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 22 Dec 2018 13:02:45 +0100 Subject: [PATCH] added epub and azw mime types. try to resolve application/octet-stream by file extension instead. added preview icons for ebooks --- .../persistance/FileBackend.java | 2 +- .../AttachFileToConversationRunnable.java | 2 +- .../services/MessageArchiveService.java | 1 + .../ui/adapter/MediaAdapter.java | 2 ++ .../conversations/ui/util/Attachment.java | 4 +-- .../siacs/conversations/utils/MimeUtils.java | 26 ++++++++++++++++-- .../siacs/conversations/utils/UIHelper.java | 2 ++ .../res/drawable-hdpi/ic_book_black_48dp.png | Bin 0 -> 278 bytes .../res/drawable-hdpi/ic_book_white_48dp.png | Bin 0 -> 283 bytes .../res/drawable-mdpi/ic_book_black_48dp.png | Bin 0 -> 201 bytes .../res/drawable-mdpi/ic_book_white_48dp.png | Bin 0 -> 197 bytes .../res/drawable-xhdpi/ic_book_black_48dp.png | Bin 0 -> 340 bytes .../res/drawable-xhdpi/ic_book_white_48dp.png | Bin 0 -> 350 bytes .../drawable-xxhdpi/ic_book_black_48dp.png | Bin 0 -> 516 bytes .../drawable-xxhdpi/ic_book_white_48dp.png | Bin 0 -> 532 bytes .../drawable-xxxhdpi/ic_book_black_48dp.png | Bin 0 -> 750 bytes .../drawable-xxxhdpi/ic_book_white_48dp.png | Bin 0 -> 766 bytes src/main/res/values/attrs.xml | 1 + src/main/res/values/strings.xml | 1 + src/main/res/values/themes.xml | 2 ++ 20 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 src/main/res/drawable-hdpi/ic_book_black_48dp.png create mode 100644 src/main/res/drawable-hdpi/ic_book_white_48dp.png create mode 100644 src/main/res/drawable-mdpi/ic_book_black_48dp.png create mode 100644 src/main/res/drawable-mdpi/ic_book_white_48dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_book_black_48dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_book_white_48dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_book_black_48dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_book_white_48dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_book_black_48dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_book_white_48dp.png diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index df3b63bf9..16412c985 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -570,7 +570,7 @@ public class FileBackend { } public void copyFileToPrivateStorage(Message message, Uri uri, String type) throws FileCopyException { - String mime = type != null ? type : MimeUtils.guessMimeTypeFromUri(mXmppConnectionService, uri); + String mime = MimeUtils.guessMimeTypeFromUriAndMime(mXmppConnectionService, uri, type); Log.d(Config.LOGTAG, "copy " + uri.toString() + " to private storage (mime=" + mime + ")"); String extension = MimeUtils.guessExtensionFromMimeType(mime); if (extension == null) { diff --git a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java index 506d812dd..330e4cb8a 100644 --- a/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java +++ b/src/main/java/eu/siacs/conversations/services/AttachFileToConversationRunnable.java @@ -47,7 +47,7 @@ public class AttachFileToConversationRunnable implements Runnable, MediaTranscod this.mXmppConnectionService = xmppConnectionService; this.message = message; this.callback = callback; - final String mimeType = type != null ? type : MimeUtils.guessMimeTypeFromUri(mXmppConnectionService, uri); + final String mimeType = MimeUtils.guessMimeTypeFromUriAndMime(mXmppConnectionService, uri, type); final int autoAcceptFileSize = mXmppConnectionService.getResources().getInteger(R.integer.auto_accept_filesize); this.originalFileSize = FileBackend.getFileSize(mXmppConnectionService,uri); this.isVideoMessage = (mimeType != null && mimeType.startsWith("video/")) && originalFileSize > autoAcceptFileSize; diff --git a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java index 0b139c0e6..5dce21e95 100644 --- a/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java +++ b/src/main/java/eu/siacs/conversations/services/MessageArchiveService.java @@ -337,6 +337,7 @@ public class MessageArchiveService implements OnAdvancedStreamFeaturesLoaded { query.getConversation().setFirstMamReference(first == null ? null : first.getContent()); } if (complete || relevant == null || abort) { + //TODO: FIX done logic to look at complete. using count is probably unreliable because it can be ommited and doesn’t work with paging. boolean done; if (query.isCatchup()) { done = false; diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MediaAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MediaAdapter.java index 8adb55415..63d9b2447 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MediaAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MediaAdapter.java @@ -77,6 +77,8 @@ public class MediaAdapter extends RecyclerView.Adapterx}QyzBzMfal)5EsVEiFS9x}uqZqfU$x`;wVEGXrB0fmrtT?Eys9qA z>3lH}xwdH%&$i1!6OvUWa}Q69Rgqk$y!)bv$>h6NMM{)+zd!$9Z>o<%Ba4s+m{{)_E&e@6MNB5f=5uwWT;DLe(5^t_$|lLeIE^(6lb?M%;$NxsD8MW9jWApAMdhxv S$r?b9GI+ZBxvXyxf>|;CZvqG}%v%={nh;9nE!Se|EfIynmfWBa4uS0)+U- zr4sO9>IT_>CtN;9bQ`|S`SI$=J~fRG=jP78Td917(RH0ozS1>@sp=CPm^f8n#8kBj z4*hFoKUnGPe$w0*G3}EhuX0%JgVS=HY|7`jfp%wDTrk=kW-Klw7tUpLYd=uy1@+Pp W$9+fZ#ZCf!%i!ti=d#Wzp$Py;&~)Gc literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-mdpi/ic_book_black_48dp.png b/src/main/res/drawable-mdpi/ic_book_black_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..00f29d339f7c4ca43dd9c8adf4e39d4dacf05655 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0D37#&FAr*{ouN(3;IS8~q-2X&I zBt?I7`6Xf92bEtq+88*WW+Wyi9y+m!bJq8Nb^B9xJ6bRFy$V)vNOx@434gSl)rF2}b#EEeKrpYx4D=}Ro(boFyt=akR{0DUe@ AQ2+n{ literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-mdpi/ic_book_white_48dp.png b/src/main/res/drawable-mdpi/ic_book_white_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..5a5ee30413ad39c997b57f58a6e150ec9d5eb729 GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0D9#0p?kch)?uUqpuIEc6Jr@ieytY^0oV1HIPtBo$fsv_>>C8U< v3Aea3{>U}jZoD}+(lGYF4A|R(F zss5`B=PNNudE3kT@k;NPke_z{+ch@i>K$s+*rIp-t^3Aa6P4@2tlQOgCI=pv_hg+b zqxhum-M+fw4+EK4I0O_N8Wm;kPvmrpzA` zn7_Ve&TB8;f7@`c-h+1qa_?P!J2fZ?V;BN4mXlN90dt3Q;DNp;yB0O5o;2-You9b( z@ErN1wI_m(PSeQB2TaC@KsA@y?3?Oh+#|Gw2ebLLFjkx6ab z<@4^&HMY*`N;H47nYDV^+QkcHxHmkQ-N85IF~c{Pt+UCv=(Ps-Ie#xO;u<3;!O7zZVj65;;z$#wSZ6V|1j?vy_N?%2fATXk#--&lN#K<@g$ ZzT42zhf;RvF literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxhdpi/ic_book_black_48dp.png b/src/main/res/drawable-xxhdpi/ic_book_black_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..ac4437d17c29bd7842232707aebc0b5a8beee100 GIT binary patch literal 516 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q1xWh(YZ)^zFrM~waSW+oe0$eEPuNk${bTqu zk(2N49cSm55Zv%YKx&82kI9!rw^?{)OgPL~AhL0T)T*gXDZQ&_-ktw#Z@&Fe_g`0= zXM#cN>c?%e{9l<$_HrZ@Y<4*lAhj%xBU+&aeuX997ml!MA5gQFhRVy~~oqmo!v6 zE{&3NX8QYRj#jNA>s@!PD~2tsQact@m@hdH9lR$tW5Ifn_lhPL_`9yRv;Fe@cn(SLLLf@XoLW!5Q>TgmpQL&OmtSiu<_iF1Hzq0gx^~VzxW?kqi%cKR=aVYe3;cH z-nkBs6J_sLN086NBm5VW(nxwRGHwwghuqD z@d)5Q!9tYKQ>kda{gP&rjgXroBRgu_f8B8eOLT4yU9-O+JR+1&2=wY<7Z@p|!_ zGG>B7pkeyqX>H!C7p5K7R$Eg1ZchJloy?tIqU;L3+c(JF6kaOp@6CL+li0z2pbZ2aYw z9&?gK$U~tKnczU-p-FURm8?cLNBh|{V=js%AMrO?S}@@MhPGp7Tnip1e(lR;acD%h9A@1vWEa5% zv5UPhpP2oLxmLZXv~Iz9m%O?1FTR@EE5CByGWm}~r)psIlq#O;^4|W$-*bL7^MCrk zT71bQhtBjjOuergL!>keAKKQQ(SCh&gaxzE+p zKg8Ib>s9fb1V)$sXKA<3Or3bUL{q*dHgD4j9rl~2+FvZMIq!T*>Yd&FO_Nvso^#n| z`I?Wr=A=yV`fWH}llP6%+=E5H6YHWtA!P zK;!Bc%laiI+wOnX6g53*v~*!?s`b>Zw*?M{*7>#i7F|5?@uuI>-l92qXXEYMe@oBam4+0)g} JWt~$(698N&1hW7D literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxxhdpi/ic_book_white_48dp.png b/src/main/res/drawable-xxxhdpi/ic_book_white_48dp.png new file mode 100644 index 0000000000000000000000000000000000000000..12f649c036c88d3bcecefd2d01b787d5e93c4eec GIT binary patch literal 766 zcmeAS@N?(olHy`uVBq!ia0vp^2SAvE1xWt5x}=AJf$6BHi(^OyXtt?bW7B%{xNAn7wriuyIg%q*~SCV0QG;w!2l)00p7$XH7mRM>{$MI?e)UrErRVi6U6o(S+xDIYQIi0f6RufW(Ty=Z8o1NopUK$ zG+}nOQpwQ;t_}TngqCXVUdxzM?7d_ePZU$danp;t7G38%ASq~_$(qofu5`^XgZaUv z6}?dm73Y-$XK##?f6#G4_6oa%;LgO_2F{7n*V%Wd7hV3vAUkpPb@qytTOMqk#=yj( z&_FZdz$WG|KR;#HGG;M+`Ef>=!M|pa`howfHy*R^|3252QH*v82*$*JlGP9G00aC^!LRC&l)%ctSb$0_pz6Pcd$FaOiS zC9F_y^E7>mXM+_d4Sj(pe83^OLm3pP!b;}r_zjeb4*z0kcgfptcYuxGCHGiVZNm}P zKx_4_3>#eCk39Qwo55p_(8lB-ZHCn~%2Dx=nd}ON30_O`Zm4W!nQ(*GrQk4oP&Pv+ zW4PnF^vPG092Ontls$cCPI8z>DdQ(;gQR0dW{>CCb%t;*NO&z{kaA{D z(|cXA + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index dd616212f..f0fbe841e 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -804,4 +804,5 @@ Start Orbot No market app installed. This group chat will make your Jabber ID public + e-book diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 5532817e9..70841d057 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -72,6 +72,7 @@ @drawable/ic_android_black_48dp @drawable/ic_event_black_48dp @drawable/ic_archive_black_48dp + @drawable/ic_book_black_48dp @drawable/ic_help_black_48dp @drawable/ic_group_add_white_24dp @@ -184,6 +185,7 @@ @drawable/ic_android_white_48dp @drawable/ic_event_white_48dp @drawable/ic_archive_white_48dp + @drawable/ic_book_white_48dp @drawable/ic_help_white_48dp @drawable/ic_group_add_white_24dp