From: tobiasKaminsky Date: Tue, 27 Oct 2015 20:24:36 +0000 (+0100) Subject: Merge remote-tracking branch 'remotes/upstream/master' into animatedGif X-Git-Tag: beta-20151122~97^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/a7c041ce0034cc3b7b02f71357463e8ba9b142ee?hp=-c Merge remote-tracking branch 'remotes/upstream/master' into animatedGif --- a7c041ce0034cc3b7b02f71357463e8ba9b142ee diff --combined src/com/owncloud/android/ui/preview/PreviewImageFragment.java index 7672d2f1,e61e3355..107a2225 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@@ -75,11 -75,11 +75,11 @@@ public class PreviewImageFragment exten private ProgressBar mProgressWheel; public Bitmap mBitmap = null; - + private static final String TAG = PreviewImageFragment.class.getSimpleName(); private boolean mIgnoreFirstSavedState; - + private LoadBitmapTask mLoadBitmapTask = null; @@@ -106,7 -106,7 +106,7 @@@ return frag; } - + /** * Creates an empty fragment for image previews. @@@ -120,8 -120,8 +120,8 @@@ public PreviewImageFragment() { mIgnoreFirstSavedState = false; } - - + + /** * {@inheritDoc} */ @@@ -136,14 -136,14 +136,14 @@@ mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST); setHasOptionsMenu(true); } - + /** * {@inheritDoc} */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.preview_image_fragment, container, false); mImageView = (TouchImageViewCustom) view.findViewById(R.id.image); @@@ -183,7 -183,7 +183,7 @@@ throw new IllegalStateException("There is no local file to preview"); } } - + /** * {@inheritDoc} @@@ -193,7 -193,7 +193,7 @@@ super.onSaveInstanceState(outState); outState.putParcelable(PreviewImageFragment.EXTRA_FILE, getFile()); } - + @Override public void onStart() { @@@ -205,8 -205,8 +205,8 @@@ mLoadBitmapTask.execute(getFile()); } } - - + + @Override public void onStop() { Log_OC.d(TAG, "onStop starts"); @@@ -216,7 -216,7 +216,7 @@@ } super.onStop(); } - + /** * {@inheritDoc} */ @@@ -232,11 -232,11 +232,11 @@@ @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - + if (mContainerActivity.getStorageManager() != null) { // Update the file setFile(mContainerActivity.getStorageManager().getFileById(getFile().getFileId())); - + FileMenuFilter mf = new FileMenuFilter( getFile(), mContainerActivity.getStorageManager().getAccount(), @@@ -245,7 -245,7 +245,7 @@@ ); mf.filter(menu); } - + // additional restriction for this fragment // TODO allow renaming in PreviewImageFragment MenuItem item = menu.findItem(R.id.action_rename_file); @@@ -253,7 -253,7 +253,7 @@@ item.setVisible(false); item.setEnabled(false); } - + // additional restriction for this fragment // TODO allow refresh file in PreviewImageFragment item = menu.findItem(R.id.action_sync_file); @@@ -268,11 -268,17 +268,17 @@@ item.setVisible(false); item.setEnabled(false); } - + + // additional restriction for this fragment + item = menu.findItem(R.id.action_copy); + if (item != null) { + item.setVisible(false); + item.setEnabled(false); + } + } - - + /** * {@inheritDoc} */ @@@ -320,10 -326,10 +326,10 @@@ return false; } } - + private void seeDetails() { - mContainerActivity.showDetails(getFile()); + mContainerActivity.showDetails(getFile()); } @@@ -350,7 -356,7 +356,7 @@@ super.onDestroy(); } - + /** * Opens the previewed image with an external application. */ @@@ -358,7 -364,7 +364,7 @@@ mContainerActivity.getFileOperationsHelper().openFile(getFile()); finish(); } - + private class LoadBitmapTask extends AsyncTask { @@@ -378,7 -384,7 +384,7 @@@ */ private final WeakReference mMessageViewRef; - + /** * Weak reference to the target {@link ProgressBar} shown while the load is in progress. * @@@ -387,17 -393,17 +393,17 @@@ */ private final WeakReference mProgressWheelRef; - + /** - * Error message to show when a load fails + * Error message to show when a load fails */ private int mErrorMessageId; - - + + /** * Constructor. - * - * @param imageView Target {@link ImageView} where the bitmap will be loaded into. + * + * @param imageView Target {@link ImageView} where the bitmap will be loaded into. */ public LoadBitmapTask(ImageViewCustom imageView, TextView messageView, ProgressBar progressWheel) { @@@ -405,7 -411,7 +411,7 @@@ mMessageViewRef = new WeakReference(messageView); mProgressWheelRef = new WeakReference(progressWheel); } - + @Override protected LoadImage doInBackground(OCFile... params) { Bitmap result = null; @@@ -456,20 -462,21 +462,21 @@@ } catch (NoSuchFieldError e) { mErrorMessageId = R.string.common_error_unknown; - Log_OC.e(TAG, "Error from access to unexisting field despite protection; file " - + storagePath, e); - + Log_OC.e(TAG, "Error from access to unexisting field despite protection; file " + + storagePath, e); + } catch (Throwable t) { mErrorMessageId = R.string.common_error_unknown; Log_OC.e(TAG, "Unexpected error loading " + getFile().getStoragePath(), t); - + } + return new LoadImage(result, ocFile); } - + @Override protected void onCancelled(LoadImage result) { - if (result.bitmap != null) { + if (result != null && result.bitmap != null) { result.bitmap.recycle(); } } @@@ -479,7 -486,8 +486,8 @@@ hideProgressWheel(); if (result.bitmap != null) { showLoadedImage(result); - } else { + } + else { showErrorMessage(); } if (result.bitmap != null && mBitmap != result.bitmap) { @@@ -487,7 -495,7 +495,7 @@@ result.bitmap.recycle(); } } - + @SuppressLint("InlinedApi") private void showLoadedImage(LoadImage result) { final ImageViewCustom imageView = mImageViewRef.get(); @@@ -501,12 -509,7 +509,12 @@@ imageView.setBackground(backrepeat); } - imageView.setImageBitmap(bitmap); + if (result.ocFile.getMimetype().equalsIgnoreCase("image/gif")){ + imageView.setGifImage(result.ocFile); + } else { + imageView.setImageBitmap(bitmap); + } + imageView.setVisibility(View.VISIBLE); mBitmap = bitmap; // needs to be kept for recycling when not useful } @@@ -516,7 -519,7 +524,7 @@@ messageView.setVisibility(View.GONE); } // else , silently finish, the fragment was destroyed } - + private void showErrorMessage() { final ImageView imageView = mImageViewRef.get(); if (imageView != null) { @@@ -530,14 -533,14 +538,14 @@@ messageView.setVisibility(View.VISIBLE); } // else , silently finish, the fragment was destroyed } - + private void hideProgressWheel() { final ProgressBar progressWheel = mProgressWheelRef.get(); if (progressWheel != null) { progressWheel.setVisibility(View.GONE); } } - + } /** @@@ -551,7 -554,7 +559,7 @@@ return (file != null && file.isImage()); } - + /** * Finishes the preview */ @@@ -559,7 -562,7 +567,7 @@@ Activity container = getActivity(); container.finish(); } - + public TouchImageViewCustom getImageView() { return mImageView; }