From: Andy Scherzinger Date: Mon, 10 Aug 2015 14:02:02 +0000 (+0200) Subject: Merge branch 'master' of https://github.com/owncloud/android into video_thumbnail X-Git-Tag: beta-20151202~1^2~2^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/a1b24dea37013fec794ecee6a6ef2f3fedefc0a3?ds=inline;hp=-c Merge branch 'master' of https://github.com/owncloud/android into video_thumbnail --- a1b24dea37013fec794ecee6a6ef2f3fedefc0a3 diff --combined src/com/owncloud/android/ui/adapter/FileListListAdapter.java index 3869497f,33fa57fd..5c0e8e8c --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@@ -30,9 -30,6 +30,9 @@@ import android.accounts.Account 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; @@@ -271,15 -268,14 +271,14 @@@ public class FileListListAdapter extend } // share with me icon - if (!file.isFolder()) { - ImageView sharedWithMeIconV = (ImageView) - view.findViewById(R.id.sharedWithMeIcon); - sharedWithMeIconV.bringToFront(); - if (checkIfFileIsSharedWithMe(file)) { - sharedWithMeIconV.setVisibility(View.VISIBLE); - } else { - sharedWithMeIconV.setVisibility(View.GONE); - } + ImageView sharedWithMeIconV = (ImageView) + view.findViewById(R.id.sharedWithMeIcon); + sharedWithMeIconV.bringToFront(); + if (checkIfFileIsSharedWithMe(file) && + (!file.isFolder() || !mGridMode)) { + sharedWithMeIconV.setVisibility(View.VISIBLE); + } else { + sharedWithMeIconV.setVisibility(View.GONE); } break; @@@ -289,7 -285,7 +288,7 @@@ // this if-else is needed even though favorite icon is visible by default // because android reuses views in listview - if (!file.keepInSync()) { + if (!file.isFavorite()) { view.findViewById(R.id.favoriteIcon).setVisibility(View.GONE); } else { view.findViewById(R.id.favoriteIcon).setVisibility(View.VISIBLE); @@@ -297,19 -293,13 +296,19 @@@ // 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()) ); 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)) { @@@ -318,15 -308,12 +317,15 @@@ 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); diff --combined src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 158d0460,47d99925..5dfb329d --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@@ -341,6 -341,14 +341,14 @@@ public class OCFileListFragment extend getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES); return true; } + case R.id.action_favorite_file:{ + mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, true); + return true; + } + case R.id.action_unfavorite_file:{ + mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, false); + return true; + } default: return super.onContextItemSelected(item); } @@@ -421,7 -429,7 +429,7 @@@ foldersCount++; } else { filesCount++; - if (file.isImage()){ + if (file.isImage() || file.isVideo()){ imagesCount++; } } @@@ -437,29 -445,47 +445,48 @@@ switchToGridView(); } else { switchToListView(); +// switchToGridView(); } } } private String generateFooterText(int filesCount, int foldersCount) { - String output = ""; - if (filesCount > 0){ - if (filesCount == 1) { - output = output + filesCount + " " + getResources().getString(R.string.file_list_file); - } else { - output = output + filesCount + " " + getResources().getString(R.string.file_list_files); + String output; + if (filesCount <= 0) { + if (foldersCount <= 0) { + output = ""; + + } else if (foldersCount == 1) { + output = getResources().getString(R.string.file_list__footer__folder); + + } else { // foldersCount > 1 + output = getResources().getString(R.string.file_list__footer__folders, foldersCount); } - } - if (foldersCount > 0 && filesCount > 0){ - output = output + ", "; - } - if (foldersCount == 1) { - output = output + foldersCount + " " + getResources().getString(R.string.file_list_folder); - } else if (foldersCount > 1) { - output = output + foldersCount + " " + getResources().getString(R.string.file_list_folders); - } + } else if (filesCount == 1) { + if (foldersCount <= 0) { + output = getResources().getString(R.string.file_list__footer__file); + + } else if (foldersCount == 1) { + output = getResources().getString(R.string.file_list__footer__file_and_folder); + + } else { // foldersCount > 1 + output = getResources().getString(R.string.file_list__footer__file_and_folders, foldersCount); + } + } else { // filesCount > 1 + if (foldersCount <= 0) { + output = getResources().getString(R.string.file_list__footer__files, filesCount); + + } else if (foldersCount == 1) { + output = getResources().getString(R.string.file_list__footer__files_and_folder, filesCount); + + } else { // foldersCount > 1 + output = getResources().getString( + R.string.file_list__footer__files_and_folders, filesCount, foldersCount + ); + + } + } return output; } @@@ -474,8 -500,7 +501,7 @@@ public void sortBySize(boolean descending) { mAdapter.setSortOrder(FileStorageUtils.SORT_SIZE, descending); - } - - + } + }