X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/97da4d5c8a771bffe239d9d10a237909a8b32574..c54d7e35d0efb3d1352ff6d1330cac185bef0a21:/src/com/owncloud/android/ui/fragment/FileDetailFragment.java diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index b5fce44e..6aafbf76 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -22,6 +22,7 @@ package com.owncloud.android.ui.fragment; import android.accounts.Account; +import android.graphics.Bitmap; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; @@ -35,9 +36,11 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; +import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.datamodel.ThumbnailsCacheManager; import com.owncloud.android.files.FileMenuFilter; import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; @@ -48,6 +51,7 @@ import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.dialog.RemoveFileDialogFragment; import com.owncloud.android.ui.dialog.RenameFileDialogFragment; import com.owncloud.android.utils.DisplayUtils; +import com.owncloud.android.utils.MimetypeIconUtil; import java.lang.ref.WeakReference; @@ -131,6 +135,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener if (mLayout == R.layout.file_details_fragment) { mView.findViewById(R.id.fdFavorite).setOnClickListener(this); ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.fdProgressBar); + DisplayUtils.colorPreLollipopHorizontalProgressBar(progressBar); mProgressListener = new ProgressListener(progressBar); mView.findViewById(R.id.fdCancelBtn).setOnClickListener(this); } @@ -243,9 +248,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener dialog.show(getFragmentManager(), FTAG_RENAME_FILE); return true; } - case R.id.action_cancel_download: - case R.id.action_cancel_upload: { - ((FileDisplayActivity) mContainerActivity).cancelTransference(getFile()); + case R.id.action_cancel_sync: { + ((FileDisplayActivity)mContainerActivity).cancelTransference(getFile()); return true; } case R.id.action_download_file: @@ -295,7 +299,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener } } - /** * Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced. * @@ -337,7 +340,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener // set file details setFilename(file.getFileName()); - setFiletype(file.getMimetype(), file.getFileName()); + setFiletype(file); setFilesize(file.getFileLength()); setTimeModified(file.getModificationTimestamp()); @@ -391,18 +394,54 @@ public class FileDetailFragment extends FileFragment implements OnClickListener /** * Updates the MIME type in view - * @param mimetype MIME type to set - * @param filename Name of the file, to deduce the icon to use in case the MIME type is not precise enough + * @param file : An {@link OCFile} */ - private void setFiletype(String mimetype, String filename) { + private void setFiletype(OCFile file) { + String mimetype = file.getMimetype(); TextView tv = (TextView) getView().findViewById(R.id.fdType); if (tv != null) { + // mimetype MIME type to set String printableMimetype = DisplayUtils.convertMIMEtoPrettyPrint(mimetype); tv.setText(printableMimetype); } + ImageView iv = (ImageView) getView().findViewById(R.id.fdIcon); + if (iv != null) { - iv.setImageResource(DisplayUtils.getFileTypeIconId(mimetype, filename)); + Bitmap thumbnail; + iv.setTag(file.getFileId()); + + if (file.isImage()) { + String tagId = String.valueOf(file.getRemoteId()); + thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(tagId); + + if (thumbnail != null && !file.needsUpdateThumbnail()) { + iv.setImageBitmap(thumbnail); + } else { + // generate new Thumbnail + if (ThumbnailsCacheManager.cancelPotentialWork(file, iv)) { + final ThumbnailsCacheManager.ThumbnailGenerationTask task = + new ThumbnailsCacheManager.ThumbnailGenerationTask( + iv, mContainerActivity.getStorageManager(), mAccount + ); + if (thumbnail == null) { + thumbnail = ThumbnailsCacheManager.mDefaultImg; + } + final ThumbnailsCacheManager.AsyncDrawable asyncDrawable = + new ThumbnailsCacheManager.AsyncDrawable( + MainApp.getAppContext().getResources(), + thumbnail, + task + ); + iv.setImageDrawable(asyncDrawable); + task.execute(file); + } + } + } else { + // Name of the file, to deduce the icon to use in case the MIME type is not precise enough + String filename = file.getFileName(); + iv.setImageResource(MimetypeIconUtil.getFileTypeIconId(mimetype, filename)); + } } }