Merge pull request #1199 from owncloud/display_thumbnails_details_view_PR_1065

Display thumbnails details view pr 1065
This commit is contained in:
Maria Asensio 2015-10-16 09:03:34 +02:00
commit be3b6a53b9
2 changed files with 45 additions and 5 deletions

View file

@ -1541,6 +1541,7 @@ public class FileDisplayActivity extends HookActivity
OCFile syncedFile = operation.getLocalFile();
onTransferStateChanged(syncedFile, true, true);
invalidateOptionsMenu();
refreshShowDetails();
}
}
}

View file

@ -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;
@ -339,7 +342,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());
@ -393,20 +396,56 @@ 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) {
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));
}
}
}
/**
* Updates the file size in view