From: tobiasKaminsky Date: Fri, 21 Aug 2015 15:48:58 +0000 (+0200) Subject: Merge branch 'develop' of github.com:owncloud/android into svgTransparentBackground X-Git-Tag: oc-android-1.8~41^2~1 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/8e3787909f253c66a91c137d25cb2b430cfe9dc3?hp=-c Merge branch 'develop' of github.com:owncloud/android into svgTransparentBackground --- 8e3787909f253c66a91c137d25cb2b430cfe9dc3 diff --combined src/com/owncloud/android/ui/adapter/FileListListAdapter.java index a2f0942b,33fa57fd..0c72052a --- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java +++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java @@@ -30,7 -30,6 +30,7 @@@ import android.accounts.Account import android.content.Context; import android.content.SharedPreferences; import android.graphics.Bitmap; +import android.graphics.drawable.Drawable; import android.os.Build; import android.preference.PreferenceManager; import android.text.format.DateUtils; @@@ -269,15 -268,14 +269,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; @@@ -287,7 -285,7 +286,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); @@@ -322,13 -320,6 +321,13 @@@ task.execute(file); } } + + if (file.getMimetype().equalsIgnoreCase("image/png")){ + Drawable backrepeat = mContext.getResources(). + getDrawable(R.drawable.backrepeat); + fileIcon.setBackground(backrepeat); + } + } else { fileIcon.setImageResource(DisplayUtils.getFileTypeIconId(file.getMimetype(), file.getFileName())); diff --combined src/com/owncloud/android/ui/preview/PreviewImageFragment.java index 394bc4d1,7ca1cfbb..6ce592a7 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@@ -26,7 -26,6 +26,7 @@@ import android.annotation.SuppressLint import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Point; +import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.FragmentStatePagerAdapter; @@@ -201,8 -200,7 +201,8 @@@ public class PreviewImageFragment exten if (getFile() != null) { mLoadBitmapTask = new LoadBitmapTask(mImageView, mMessageView, mProgressWheel); //mLoadBitmapTask.execute(new String[]{getFile().getStoragePath()}); - mLoadBitmapTask.execute(getFile().getStoragePath()); +// mLoadBitmapTask.execute(getFile().getStoragePath()); + mLoadBitmapTask.execute(getFile()); } } @@@ -308,7 -306,14 +308,14 @@@ mContainerActivity.getFileOperationsHelper().syncFile(getFile()); return true; } - + case R.id.action_favorite_file:{ + mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), true); + return true; + } + case R.id.action_unfavorite_file:{ + mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), false); + return true; + } default: return false; } @@@ -353,7 -358,7 +360,7 @@@ } - private class LoadBitmapTask extends AsyncTask { + private class LoadBitmapTask extends AsyncTask { /** * Weak reference to the target {@link ImageView} where the bitmap will be loaded into. @@@ -399,12 -404,12 +406,12 @@@ mProgressWheelRef = new WeakReference(progressWheel); } - @Override - protected Bitmap doInBackground(String... params) { + protected LoadImage doInBackground(OCFile... params) { Bitmap result = null; if (params.length != 1) return null; - String storagePath = params[0]; + OCFile ocFile = params[0]; + String storagePath = ocFile.getStoragePath(); try { int maxDownScale = 3; // could be a parameter passed to doInBackground(...) @@@ -417,7 -422,7 +424,7 @@@ result = BitmapUtils.decodeSampledBitmapFromFile(storagePath, minWidth, minHeight); - if (isCancelled()) return result; + if (isCancelled()) return new LoadImage(result, ocFile); if (result == null) { mErrorMessageId = R.string.preview_image_error_unknown_format; @@@ -457,46 -462,40 +464,46 @@@ Log_OC.e(TAG, "Unexpected error loading " + getFile().getStoragePath(), t); } - - return result; + return new LoadImage(result, ocFile); } @Override - protected void onCancelled(Bitmap result) { - if (result != null) { - result.recycle(); + protected void onCancelled(LoadImage result) { + if (result.bitmap != null) { + result.bitmap.recycle(); } } @Override - protected void onPostExecute(Bitmap result) { + protected void onPostExecute(LoadImage result) { hideProgressWheel(); - if (result != null) { + if (result.bitmap != null) { showLoadedImage(result); } else { showErrorMessage(); } - if (result != null && mBitmap != result) { + if (result.bitmap != null && mBitmap != result.bitmap) { // unused bitmap, release it! (just in case) - result.recycle(); + result.bitmap.recycle(); } } @SuppressLint("InlinedApi") - private void showLoadedImage(Bitmap result) { + private void showLoadedImage(LoadImage result) { final ImageViewCustom imageView = mImageViewRef.get(); + Bitmap bitmap = result.bitmap; if (imageView != null) { - Log_OC.d(TAG, "Showing image with resolution " + result.getWidth() + "x" + - result.getHeight()); - imageView.setImageBitmap(result); + Log_OC.d(TAG, "Showing image with resolution " + bitmap.getWidth() + "x" + + bitmap.getHeight()); + + if (result.ocFile.getMimetype().equalsIgnoreCase("image/png")){ + Drawable backrepeat = getResources().getDrawable(R.drawable.backrepeat); + imageView.setBackground(backrepeat); + } + + imageView.setImageBitmap(bitmap); imageView.setVisibility(View.VISIBLE); - mBitmap = result; // needs to be kept for recycling when not useful + mBitmap = bitmap; // needs to be kept for recycling when not useful } final TextView messageView = mMessageViewRef.get(); @@@ -552,15 -551,4 +559,15 @@@ return mImageView; } + private class LoadImage { + private Bitmap bitmap; + private OCFile ocFile; + + public LoadImage(Bitmap bitmap, OCFile ocFile){ + this.bitmap = bitmap; + this.ocFile = ocFile; + } + + } + }