From c0b7590a039837b1ee174fa1853d3fd67549a8d8 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Sat, 27 Jun 2015 21:51:49 +0200 Subject: [PATCH 01/14] enable video thumbnail --- src/com/owncloud/android/ui/adapter/FileListListAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index c6ea0344d1..6c677988e6 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -294,7 +294,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { // No Folder if (!file.isFolder()) { - if (file.isImage() && file.getRemoteId() != null){ + if ((file.isImage() || file.isVideo()) && file.getRemoteId() != null){ // Thumbnail in Cache? Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache( String.valueOf(file.getRemoteId()) From 921e38f13d40ce9bc288c3ad9453e16e4ba1d411 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Sun, 28 Jun 2015 08:52:38 +0200 Subject: [PATCH 02/14] fallback if server does not support video thumbnails --- .../ui/adapter/FileListListAdapter.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 6c677988e6..a589512eb1 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -308,17 +308,19 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { new ThumbnailsCacheManager.ThumbnailGenerationTask( fileIcon, mStorageManager, mAccount ); - if (thumbnail == null) { - thumbnail = ThumbnailsCacheManager.mDefaultImg; + if (thumbnail != null) { + final ThumbnailsCacheManager.AsyncDrawable asyncDrawable = + new ThumbnailsCacheManager.AsyncDrawable( + mContext.getResources(), + thumbnail, + task + ); + fileIcon.setImageDrawable(asyncDrawable); + task.execute(file); + } else { + fileIcon.setImageResource(DisplayUtils.getFileTypeIconId( + file.getMimetype(), file.getFileName())); } - final ThumbnailsCacheManager.AsyncDrawable asyncDrawable = - new ThumbnailsCacheManager.AsyncDrawable( - mContext.getResources(), - thumbnail, - task - ); - fileIcon.setImageDrawable(asyncDrawable); - task.execute(file); } } } else { From 924bc65a54ae5484c45626375da77a3436c2bf52 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Sun, 28 Jun 2015 09:10:41 +0200 Subject: [PATCH 03/14] fallback if server does not support video thumbnails --- .../android/ui/adapter/FileListListAdapter.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 6c677988e6..b81e1a54ad 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -30,6 +30,7 @@ import android.accounts.Account; import android.content.Context; import android.content.SharedPreferences; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.os.Build; import android.preference.PreferenceManager; import android.text.format.DateUtils; @@ -309,12 +310,15 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { fileIcon, mStorageManager, mAccount ); if (thumbnail == null) { - thumbnail = ThumbnailsCacheManager.mDefaultImg; +// thumbnail = ThumbnailsCacheManager.mDefaultImg; + Integer id = DisplayUtils.getFileTypeIconId(file.getMimetype(), + file.getFileName()); + thumbnail = BitmapFactory.decodeResource(mContext.getResources(), id); } final ThumbnailsCacheManager.AsyncDrawable asyncDrawable = new ThumbnailsCacheManager.AsyncDrawable( - mContext.getResources(), - thumbnail, + mContext.getResources(), + thumbnail, task ); fileIcon.setImageDrawable(asyncDrawable); From e14533e3873ac4f799fe18d0eb6a75e0420f6529 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Fri, 24 Jul 2015 18:29:24 +0200 Subject: [PATCH 04/14] overlay is added also when downloading new thumbnails --- res/drawable/view_play.png | Bin 0 -> 154 bytes .../datamodel/ThumbnailsCacheManager.java | 41 ++++++++++++++++++ .../ui/adapter/FileListListAdapter.java | 10 ++++- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 res/drawable/view_play.png diff --git a/res/drawable/view_play.png b/res/drawable/view_play.png new file mode 100644 index 0000000000000000000000000000000000000000..c506815c0cfb13f1a0fee40a5bdb97910fbac03c GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnH3?%tPCZz)@o&cW^*Z)Z1>r%dApg40$kY6x^ z!-0v}p4mXIm8Xkih{WaIbBcTn4jjym|JMJy8{8dL7`k8 bitmapWorkerTaskReference; diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index b81e1a54ad..3869497f94 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -31,6 +31,8 @@ import android.content.Context; import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Paint; import android.os.Build; import android.preference.PreferenceManager; import android.text.format.DateUtils; @@ -301,7 +303,13 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { String.valueOf(file.getRemoteId()) ); if (thumbnail != null && !file.needsUpdateThumbnail()){ - fileIcon.setImageBitmap(thumbnail); + + if (file.isVideo()) { + Bitmap withOverlay = ThumbnailsCacheManager.addVideoOverlay(thumbnail); + fileIcon.setImageBitmap(withOverlay); + } else { + fileIcon.setImageBitmap(thumbnail); + } } else { // generate new Thumbnail if (ThumbnailsCacheManager.cancelPotentialWork(file, fileIcon)) { From 689199a0b54471c4c0311b50197e247bc1d145ec Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 30 Jul 2015 21:38:13 +0200 Subject: [PATCH 05/14] wip --- .../datamodel/ThumbnailsCacheManager.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index ce60cfe88e..e3144a4edd 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -379,10 +379,10 @@ public class ThumbnailsCacheManager { } public static Bitmap addVideoOverlay(Bitmap thumbnail){ - Bitmap bitmap2 = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(), - R.drawable.view_play); + Bitmap playButton = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(), + R.drawable.view_play); - Bitmap resized = Bitmap.createScaledBitmap(bitmap2, + Bitmap resizedPlayButton = Bitmap.createScaledBitmap(playButton, (int) (thumbnail.getWidth() * 0.6), (int) (thumbnail.getHeight() * 0.6), true); @@ -392,13 +392,29 @@ public class ThumbnailsCacheManager { Canvas c = new Canvas(resultBitmap); + // compute visual center of play button, according to resized image + int x1 = resizedPlayButton.getWidth(); + int y1 = resizedPlayButton.getHeight() / 2; + int x2 = 0; + int y2 = resizedPlayButton.getWidth(); + int x3 = 0; + int y3 = 0; + + double ym = ( ((Math.pow(x3,2) - Math.pow(x1,2) + Math.pow(y3,2) - Math.pow(y1,2)) * (x2 - x1)) - (Math.pow(x2,2) - Math.pow(x1,2) + Math.pow(y2,2) - Math.pow(y1,2)) * (x3 - x1) ) / (2 * ( ((y3 - y1) * (x2 - x1)) - ((y2 - y1) * (x3 - x1)) )); + double xm = ( (Math.pow(x2,2) - Math.pow(x1,2)) + (Math.pow(y2,2) - Math.pow(y1,2)) - (2*ym*(y2 - y1)) ) / (2*(x2 - x1)); + + // offset to top left + double ox = - xm; + double oy = thumbnail.getHeight() - ym; + + c.drawBitmap(thumbnail, 0, 0, null); Paint p = new Paint(); p.setAlpha(230); - c.drawBitmap(resized, (thumbnail.getWidth() - resized.getWidth()) / 2, - (thumbnail.getHeight() - resized.getHeight()) / 2, p); + c.drawBitmap(resizedPlayButton, (float) ((thumbnail.getWidth() / 2) - ox), + (float) ((thumbnail.getHeight() / 2) + ym), p); return resultBitmap; } From 608febb1c698a2f8e8c392ed159427cdc514ab68 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Fri, 31 Jul 2015 18:40:49 +0200 Subject: [PATCH 06/14] wip --- owncloud-android-library | 2 +- .../owncloud/android/datamodel/ThumbnailsCacheManager.java | 4 ++-- src/com/owncloud/android/ui/fragment/OCFileListFragment.java | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/owncloud-android-library b/owncloud-android-library index f5fbca24be..02c24c8a3b 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit f5fbca24becbb01660abe2a7013c1b536ea8a301 +Subproject commit 02c24c8a3bd87382590ece0e0744ad430718b51a diff --git a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index e3144a4edd..5dc633767d 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -413,8 +413,8 @@ public class ThumbnailsCacheManager { Paint p = new Paint(); p.setAlpha(230); - c.drawBitmap(resizedPlayButton, (float) ((thumbnail.getWidth() / 2) - ox), - (float) ((thumbnail.getHeight() / 2) + ym), p); + c.drawBitmap(resizedPlayButton, (float) ((thumbnail.getWidth() / 2) + ox), + (float) ((thumbnail.getHeight() / 2) - ym), p); return resultBitmap; } diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 68deb031be..158d04600d 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -421,7 +421,7 @@ public class OCFileListFragment extends ExtendedListFragment { foldersCount++; } else { filesCount++; - if (file.isImage()){ + if (file.isImage() || file.isVideo()){ imagesCount++; } } @@ -437,6 +437,7 @@ public class OCFileListFragment extends ExtendedListFragment { switchToGridView(); } else { switchToListView(); +// switchToGridView(); } } } From 8fab264a05c7d7beb46bd2ae9e54bef7eb96f21d Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Sun, 2 Aug 2015 08:33:07 +0200 Subject: [PATCH 07/14] resized video overlay removed empty image parts --- res/drawable/view_play.png | Bin 154 -> 197 bytes .../datamodel/ThumbnailsCacheManager.java | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/res/drawable/view_play.png b/res/drawable/view_play.png index c506815c0cfb13f1a0fee40a5bdb97910fbac03c..50038300a137b8277d9bfd4ef24fc82fec10af49 100644 GIT binary patch literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^;y^6H#0(^Jg!-NVDb4_&5ZC`O(C78^A5f67B*-tA z!Qt7BG!Q4r+uensgH_f8q`bf*vY3H^TNs2H8D`Cq01C2~c>21s-{)XrlN2!j?{p6+ zWa{bS7{YPg_uNiS1_Oa34%4?CwF;WbrhQTM^nu#+=hsaqc&G?r%dApg40$kY6x^ z!-0v}p4mXIm8Xkih{WaIbBcTn4jjym|JMJy8{8dL7`k8 Date: Sun, 2 Aug 2015 08:40:14 +0200 Subject: [PATCH 08/14] fixed line break --- .../android/datamodel/ThumbnailsCacheManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 8a6971e8b4..07849e184c 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -400,8 +400,12 @@ public class ThumbnailsCacheManager { int x3 = 0; int y3 = 0; - double ym = ( ((Math.pow(x3,2) - Math.pow(x1,2) + Math.pow(y3,2) - Math.pow(y1,2)) * (x2 - x1)) - (Math.pow(x2,2) - Math.pow(x1,2) + Math.pow(y2,2) - Math.pow(y1,2)) * (x3 - x1) ) / (2 * ( ((y3 - y1) * (x2 - x1)) - ((y2 - y1) * (x3 - x1)) )); - double xm = ( (Math.pow(x2,2) - Math.pow(x1,2)) + (Math.pow(y2,2) - Math.pow(y1,2)) - (2*ym*(y2 - y1)) ) / (2*(x2 - x1)); + double ym = ( ((Math.pow(x3,2) - Math.pow(x1,2) + Math.pow(y3,2) - Math.pow(y1,2)) * + (x2 - x1)) - (Math.pow(x2,2) - Math.pow(x1,2) + Math.pow(y2,2) - + Math.pow(y1,2)) * (x3 - x1) ) / (2 * ( ((y3 - y1) * (x2 - x1)) - + ((y2 - y1) * (x3 - x1)) )); + double xm = ( (Math.pow(x2,2) - Math.pow(x1,2)) + (Math.pow(y2,2) - Math.pow(y1,2)) - + (2*ym*(y2 - y1)) ) / (2*(x2 - x1)); // offset to top left double ox = - xm; From 928ce1a8b618416022b71ec96a2a212f64fe5955 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 10 Aug 2015 15:56:51 +0200 Subject: [PATCH 09/14] play icon (from google's material icon set) for the various resolutions #1035 --- res/drawable-hdpi/view_play.png | Bin 0 -> 195 bytes res/drawable-mdpi/view_play.png | Bin 0 -> 157 bytes res/drawable-xhdpi/view_play.png | Bin 0 -> 220 bytes res/drawable-xxhdpi/view_play.png | Bin 0 -> 283 bytes res/drawable-xxxhdpi/view_play.png | Bin 0 -> 343 bytes res/drawable/view_play.png | Bin 197 -> 0 bytes 6 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 res/drawable-hdpi/view_play.png create mode 100644 res/drawable-mdpi/view_play.png create mode 100644 res/drawable-xhdpi/view_play.png create mode 100644 res/drawable-xxhdpi/view_play.png create mode 100644 res/drawable-xxxhdpi/view_play.png delete mode 100644 res/drawable/view_play.png diff --git a/res/drawable-hdpi/view_play.png b/res/drawable-hdpi/view_play.png new file mode 100644 index 0000000000000000000000000000000000000000..57c9fa5460323823edb0289c1d15f0f561e0c06e GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8K8m#2$kh{y4_Q_k`_IEb*R=ADxY zV6uJDq_v_+Z-tYfR|K!cZcn#wZ_1w*Zwfx3^1JLFH&cH)|4gqfmxMH3rgg?BZ~AgX zO7P4Ssfnoy7dsLbs)cmuJnq)8IA+UruCTi)d!Bot@+%Rg#TB=_7E65dSjDj^h($AU t;!LNFTjoCMkvN)I{QpIN|NiIvIZ;mvueQI+xBzq&gQu&X%Q~loCIB@QN?HH_ literal 0 HcmV?d00001 diff --git a/res/drawable-mdpi/view_play.png b/res/drawable-mdpi/view_play.png new file mode 100644 index 0000000000000000000000000000000000000000..c61e948bbf7441fd3825bdeffd615dfe30964dc8 GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_+i6i*k&5R21qFBu9p2MDlS@OSQP z(BP0-#3b6u9UvHUOCMtu*=z2v@^=eS1UZ1g)78&qol`;+ E0Fs_H=>Px# literal 0 HcmV?d00001 diff --git a/res/drawable-xhdpi/view_play.png b/res/drawable-xhdpi/view_play.png new file mode 100644 index 0000000000000000000000000000000000000000..a3c80e73daa9dc4b85cddf9421b7127a4e18ac5d GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0D#hxyXAr*{ouNm?la*%QRSeCek zK}3Xig#+sj2GIvh!e1Mh%dY8tm)JkC<%w#{kNWLqKY43+mi=hInq~SfM{=M2eECLk zbvI##h#NZ@*2LVfaQK$+p6S94LraHmPZSsgTe~DWM4fm)lPg literal 0 HcmV?d00001 diff --git a/res/drawable-xxhdpi/view_play.png b/res/drawable-xxhdpi/view_play.png new file mode 100644 index 0000000000000000000000000000000000000000..547ef30aacdebbd5bc27a3831971aa49be8813f7 GIT binary patch literal 283 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhaw9(lSrhEy=Vy|FR(PyjfM61bK%=q7O8Xj0w7EPdhfr5^#S_IEwe==vgFzHZ{arrqiL9p^2}oCQR8HlO`a zfBt>_q&-EaGMH-9&z)oSy0%IOibq!5=i7xQ8?znl*Ho#q?l1C zmLwh%pdb>pKr}hv!ldkF|5nzo_`k zc}eR_hl%VF4-<)DT=alRfHl0KMErSu6_?hE1x;YW&OCE+==ML_XMw(D@O1TaS?83{ F1OO`naDo5; literal 0 HcmV?d00001 diff --git a/res/drawable-xxxhdpi/view_play.png b/res/drawable-xxxhdpi/view_play.png new file mode 100644 index 0000000000000000000000000000000000000000..be5c062b5feeba5eff766b2fdae6dccb60cb4b0e GIT binary patch literal 343 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%&M7z$oYG;uuoF`1aODUuH)UwnS^i z62=e)(*V{`2k`*b5=Y_d%(4?EPx_&_WMu+pnDW{BolE^Uxj)}+yLIc`8R zg{90Lt0f&`?lL^eViO2AZ`iSm@yJ!6R31a2DNst&xD8@?udTeN#I8%r_sg2!eom$?*X_%R&Z!t~|1-cBYK4gm#+1_nk5gW={^?qALV VOCpPJ@c;vi!PC{xWt~$(69D@(h;je` literal 0 HcmV?d00001 diff --git a/res/drawable/view_play.png b/res/drawable/view_play.png deleted file mode 100644 index 50038300a137b8277d9bfd4ef24fc82fec10af49..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 197 zcmeAS@N?(olHy`uVBq!ia0vp^;y^6H#0(^Jg!-NVDb4_&5ZC`O(C78^A5f67B*-tA z!Qt7BG!Q4r+uensgH_f8q`bf*vY3H^TNs2H8D`Cq01C2~c>21s-{)XrlN2!j?{p6+ zWa{bS7{YPg_uNiS1_Oa34%4?CwF;WbrhQTM^nu#+=hsaqc&G? Date: Fri, 14 Aug 2015 16:55:36 +0200 Subject: [PATCH 10/14] changed back to latest owncloud-android-library --- owncloud-android-library | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/owncloud-android-library b/owncloud-android-library index 4eb9ce4ba2..c8f6e5ad57 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit 4eb9ce4ba2d9272de561954b3638f5acde8b2ca5 +Subproject commit c8f6e5ad57ee27fdac39c7b14eb6ab1942a92d49 From a48db2f8e3ec526f22625852755ec202037b53fd Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 5 Oct 2015 07:53:10 +0200 Subject: [PATCH 11/14] show big thumbnails for videos --- src/com/owncloud/android/ui/adapter/FileListListAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 5e94e0f27f..cb0bc89f01 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -154,7 +154,7 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { ViewType viewType; if (!mGridMode){ viewType = ViewType.LIST_ITEM; - } else if (file.isImage()){ + } else if (file.isImage() || file.isVideo()){ viewType = ViewType.GRID_IMAGE; } else { viewType = ViewType.GRID_ITEM; From e9bf119fa40ab59e44e712fc4e0bf49478683fb8 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Wed, 2 Dec 2015 20:23:07 +0100 Subject: [PATCH 12/14] avoid NPE --- .../owncloud/android/datamodel/ThumbnailsCacheManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 5806a4082d..68910a282c 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -182,7 +182,7 @@ public class ThumbnailsCacheManager { if (mFile instanceof OCFile) { thumbnail = doOCFileInBackground(); - if (((OCFile) mFile).isVideo()){ + if (((OCFile) mFile).isVideo() && thumbnail != null){ thumbnail = addVideoOverlay(thumbnail); } } else if (mFile instanceof File) { @@ -191,7 +191,7 @@ public class ThumbnailsCacheManager { String url = ((File) mFile).getAbsolutePath(); String mMimeType = FileStorageUtils.getMimeTypeFromName(url); - if (mMimeType != null && mMimeType.startsWith("video/")){ + if (mMimeType != null && mMimeType.startsWith("video/") && thumbnail != null){ thumbnail = addVideoOverlay(thumbnail); } //} else { do nothing From d2e05d11841a1f38483fbb04d47ad93fe2048393 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 20 Jun 2016 21:24:14 +0200 Subject: [PATCH 13/14] remove commented line --- src/com/owncloud/android/ui/fragment/OCFileListFragment.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index f5d1fb3b6e..74872c4779 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -720,7 +720,6 @@ public class OCFileListFragment extends ExtendedListFragment registerLongClickListener(); } else { switchToListView(); -// switchToGridView(); } } } From 644f2552389a1057d2b3afdf91336089f7529884 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Sat, 2 Jul 2016 18:06:00 +0200 Subject: [PATCH 14/14] show video placeholder correctly --- .../android/datamodel/ThumbnailsCacheManager.java | 6 ++++++ .../ui/adapter/ExpandableUploadListAdapter.java | 13 +++++++++++-- .../android/ui/adapter/FileListListAdapter.java | 6 +++++- .../android/ui/adapter/LocalFileListAdapter.java | 6 +++++- .../android/ui/adapter/UploaderAdapter.java | 6 +++++- src/com/owncloud/android/utils/BitmapUtils.java | 13 +++++++++++++ 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index f96eef58b3..c7d6774cd1 100644 --- a/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -91,6 +91,12 @@ public class ThumbnailsCacheManager { R.drawable.file_image ); + public static Bitmap mDefaultVideo = + BitmapFactory.decodeResource( + MainApp.getAppContext().getResources(), + R.drawable.file_movie + ); + public static class InitDiskCacheTask extends AsyncTask { diff --git a/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java b/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java index 99a2bbcba2..c43b99335d 100755 --- a/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java @@ -46,6 +46,7 @@ import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.activity.FileActivity; +import com.owncloud.android.utils.BitmapUtils; import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.MimetypeIconUtil; @@ -413,7 +414,11 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple fileIcon, mParentActivity.getStorageManager(), mParentActivity.getAccount() ); if (thumbnail == null) { - thumbnail = ThumbnailsCacheManager.mDefaultImg; + if (fakeFileToCheatThumbnailsCacheManagerInterface.isVideo()) { + thumbnail = ThumbnailsCacheManager.mDefaultVideo; + } else { + thumbnail = ThumbnailsCacheManager.mDefaultImg; + } } final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable = new ThumbnailsCacheManager.AsyncThumbnailDrawable( @@ -445,7 +450,11 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple final ThumbnailsCacheManager.ThumbnailGenerationTask task = new ThumbnailsCacheManager.ThumbnailGenerationTask(fileIcon); if (thumbnail == null) { - thumbnail = ThumbnailsCacheManager.mDefaultImg; + if (BitmapUtils.isVideo(file)) { + thumbnail = ThumbnailsCacheManager.mDefaultVideo; + } else { + thumbnail = ThumbnailsCacheManager.mDefaultImg; + } } final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable = new ThumbnailsCacheManager.AsyncThumbnailDrawable( diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 6199c3dddd..a1d810ce56 100644 --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@ -326,7 +326,11 @@ public class FileListListAdapter extends BaseAdapter implements ListAdapter { fileIcon, mStorageManager, mAccount ); if (thumbnail == null) { - thumbnail = ThumbnailsCacheManager.mDefaultImg; + if (file.isVideo()) { + thumbnail = ThumbnailsCacheManager.mDefaultVideo; + } else { + thumbnail = ThumbnailsCacheManager.mDefaultImg; + } } final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable = new ThumbnailsCacheManager.AsyncThumbnailDrawable( diff --git a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java index 908cc549fa..88a1e4a631 100644 --- a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java @@ -159,7 +159,11 @@ public class LocalFileListAdapter extends BaseAdapter implements ListAdapter { final ThumbnailsCacheManager.ThumbnailGenerationTask task = new ThumbnailsCacheManager.ThumbnailGenerationTask(fileIcon); if (thumbnail == null) { - thumbnail = ThumbnailsCacheManager.mDefaultImg; + if (BitmapUtils.isVideo(file)) { + thumbnail = ThumbnailsCacheManager.mDefaultVideo; + } else { + thumbnail = ThumbnailsCacheManager.mDefaultImg; + } } final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable = new ThumbnailsCacheManager.AsyncThumbnailDrawable( diff --git a/src/com/owncloud/android/ui/adapter/UploaderAdapter.java b/src/com/owncloud/android/ui/adapter/UploaderAdapter.java index 2f98af8aa7..a897edbc85 100644 --- a/src/com/owncloud/android/ui/adapter/UploaderAdapter.java +++ b/src/com/owncloud/android/ui/adapter/UploaderAdapter.java @@ -105,7 +105,11 @@ public class UploaderAdapter extends SimpleAdapter { new ThumbnailsCacheManager.ThumbnailGenerationTask(fileIcon, mStorageManager, mAccount); if (thumbnail == null) { - thumbnail = ThumbnailsCacheManager.mDefaultImg; + if (file.isVideo()) { + thumbnail = ThumbnailsCacheManager.mDefaultVideo; + } else { + thumbnail = ThumbnailsCacheManager.mDefaultImg; + } } final AsyncThumbnailDrawable asyncDrawable = new AsyncThumbnailDrawable( mContext.getResources(), diff --git a/src/com/owncloud/android/utils/BitmapUtils.java b/src/com/owncloud/android/utils/BitmapUtils.java index ded5427c40..6fe4eee144 100644 --- a/src/com/owncloud/android/utils/BitmapUtils.java +++ b/src/com/owncloud/android/utils/BitmapUtils.java @@ -275,6 +275,19 @@ public class BitmapUtils { return (mimeType != null && mimeType.startsWith("image/")); } + /** + * Checks if file passed is a video + * @param file + * @return true/false + */ + public static boolean isVideo(File file) { + Uri selectedUri = Uri.fromFile(file); + String fileExtension = MimeTypeMap.getFileExtensionFromUrl(selectedUri.toString().toLowerCase()); + String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension); + + return (mimeType != null && mimeType.startsWith("video/")); + } + /** * calculates the RGB value based on a given account name. *