From: tobiasKaminsky Date: Mon, 2 Nov 2015 08:38:24 +0000 (+0100) Subject: Merge branch 'setAsWallpaper' into beta X-Git-Tag: beta-20151122~45^2~8 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/fdf892fed3acab6f994a6393ad9426595b97c625?ds=inline;hp=-c Merge branch 'setAsWallpaper' into beta --- fdf892fed3acab6f994a6393ad9426595b97c625 diff --combined res/menu/file_actions_menu.xml index 9b742d12,e95f945d..44caabfd --- a/res/menu/file_actions_menu.xml +++ b/res/menu/file_actions_menu.xml @@@ -1,5 -1,4 +1,5 @@@ - All files - + On device Settings Logs Close @@@ -204,11 -205,11 +204,11 @@@ Unfavorite Rename Remove - "Do you really want to remove %1$s?" + "Do you really want to remove %1$s?" "Do you really want to remove %1$s and its contents?" Local only Local only - From server + From server Remote & local "Removal succeeded" "Removal failed" @@@ -261,11 -262,9 +261,11 @@@ 389 KB 2012/05/18 12:23 PM 12:23:45 - - Upload pictures via WiFi only - Upload videos via WiFi only + + Upload pictures via wifi only + Upload when charging only + Upload videos via wifi only + Upload when charging only /InstantUpload File conflict Which files do you want to keep? If you select both versions, the local file will have a number added to its name. @@@ -277,7 -276,7 +277,7 @@@ This image cannot be shown %1$s could not be copied to %2$s local folder - Upload Path + Upload path Sorry, sharing is not enabled on your server. Please contact your administrator. @@@ -342,8 -341,7 +342,8 @@@ Instant Uploads Security - Upload Video Path + Upload video path + Download of %1$s folder could not be completed Synchronization of %1$s folder could not be completed shared @@@ -366,26 -364,6 +366,27 @@@ %1$d files %1$d files, 1 folder %1$d files, %2$d folders + Switch to grid view + Switch to list view + Common + Cache size + Upload file to server and ... + Behaviour + Copy file + Move file + + do nothing + copy file to OC folder + move file to OC folder + delete origin file + Do you really want to remove selected items? + Do you really want to remove a folder and its content? + selected items + Exit + Send Log + Error Log + Stream file with external player + Do you want to stream this file with an external app?\n\nCAUTION: This may expose your password! + Set picture as diff --combined src/com/owncloud/android/files/FileOperationsHelper.java index e799e176,a4e23ae8..8722ccfc --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@@ -27,17 -27,14 +27,17 @@@ import android.content.Context import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.graphics.Bitmap; import android.net.Uri; import android.support.v4.app.DialogFragment; import android.webkit.MimeTypeMap; import android.widget.Toast; +import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.datamodel.ThumbnailsCacheManager; import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; import com.owncloud.android.lib.common.network.WebdavUtils; @@@ -46,21 -43,13 +46,22 @@@ import com.owncloud.android.lib.resourc import com.owncloud.android.services.OperationsService; import com.owncloud.android.services.observer.FileObserverService; import com.owncloud.android.ui.activity.FileActivity; +import com.owncloud.android.ui.adapter.DiskLruImageCacheFileProvider; import com.owncloud.android.ui.dialog.ShareLinkToDialog; import org.apache.http.protocol.HTTP; + import java.io.File; import java.util.List; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; + +import java.util.ArrayList; + /** * */ @@@ -248,30 -237,34 +249,43 @@@ public class FileOperationsHelper } } + public void setPictureAs(OCFile file) { ++ if (file != null || file.isDown()) { ++ File externalFile=new File(file.getStoragePath()); ++ Uri sendUri = Uri.fromFile(externalFile); ++ Intent intent = new Intent(Intent.ACTION_ATTACH_DATA); ++ intent.setDataAndType(sendUri, file.getMimetype()); ++ intent.putExtra("mimeType", file.getMimetype()); ++ mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200); ++ } else { ++ Log_OC.wtf(TAG, "Trying to send a NULL OCFile"); ++ } ++ } ++ + public void sendCachedImage(OCFile file) { if (file != null) { - if (file.isDown()) { - File externalFile=new File(file.getStoragePath()); - Uri sendUri = Uri.fromFile(externalFile); - Intent intent = new Intent(Intent.ACTION_ATTACH_DATA); - intent.setDataAndType(sendUri, file.getMimetype()); - intent.putExtra("mimeType", file.getMimetype()); - mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200); - } else { - // TODO re-enable after resized images is available -// Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); -// // set MimeType -// sendIntent.setType(file.getMimetype()); -//// sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.getRemoteId() + "#" + file.getFileName())); -// sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath())); -// sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action -// -// // Show dialog, without the own app -// String[] packagesToExclude = new String[] { mFileActivity.getPackageName() }; -// DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file); -// chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG); - } + Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); + // set MimeType + sendIntent.setType(file.getMimetype()); +// sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.getRemoteId() + "#" + file.getFileName())); + sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath())); + sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action + + // Show dialog, without the own app + String[] packagesToExclude = new String[] { mFileActivity.getPackageName() }; + DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file); + chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG); } else { Log_OC.wtf(TAG, "Trying to send a NULL OCFile"); } } + public void syncFiles(ArrayList files) { + for (OCFile file: files) { + syncFile(file); + } + } + /** * Request the synchronization of a file or folder with the OC server, including its contents. * @@@ -286,7 -279,7 +300,7 @@@ intent.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true); mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent); mFileActivity.showLoadingDialog(); - + } else { Intent intent = new Intent(mFileActivity, OperationsService.class); intent.setAction(OperationsService.ACTION_SYNC_FOLDER); @@@ -297,12 -290,6 +311,12 @@@ } } + public void toggleFavorites(ArrayList files, boolean isFavorite){ + for (OCFile file: files) { + toggleFavorite(file, isFavorite); + } + } + public void toggleFavorite(OCFile file, boolean isFavorite) { file.setFavorite(isFavorite); mFileActivity.getStorageManager().saveFile(file); @@@ -398,8 -385,7 +412,8 @@@ service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount()); mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service); - mFileActivity.showLoadingDialog(); + // TODO Tobi loading dialog? + // mFileActivity.showLoadingDialog(); } /** diff --combined src/com/owncloud/android/ui/preview/PreviewImageFragment.java index dc96b9f2,3ad1f8ba..2e4ffb55 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@@ -41,10 -41,8 +41,10 @@@ 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.OCFile; +import com.owncloud.android.datamodel.ThumbnailsCacheManager; import com.owncloud.android.files.FileMenuFilter; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment; @@@ -71,14 -69,11 +71,14 @@@ public class PreviewImageFragment exten private static final String ARG_FILE = "FILE"; private static final String ARG_IGNORE_FIRST = "IGNORE_FIRST"; + private static final String ARG_SHOW_RESIZED_IMAGE = "SHOW_RESIZED_IMAGE"; private TouchImageViewCustom mImageView; private TextView mMessageView; private ProgressBar mProgressWheel; + private Boolean mShowResizedImage = false; + public Bitmap mBitmap = null; private static final String TAG = PreviewImageFragment.class.getSimpleName(); @@@ -102,14 -97,11 +102,14 @@@ * {@link FragmentStatePagerAdapter} * ; TODO better solution */ - public static PreviewImageFragment newInstance(OCFile imageFile, boolean ignoreFirstSavedState){ + public static PreviewImageFragment newInstance(OCFile imageFile, boolean ignoreFirstSavedState, + boolean showResizedImage){ PreviewImageFragment frag = new PreviewImageFragment(); + frag.mShowResizedImage = showResizedImage; Bundle args = new Bundle(); args.putParcelable(ARG_FILE, imageFile); args.putBoolean(ARG_IGNORE_FIRST, ignoreFirstSavedState); + args.putBoolean(ARG_SHOW_RESIZED_IMAGE, showResizedImage); frag.setArguments(args); return frag; } @@@ -142,7 -134,6 +142,7 @@@ // not right now mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST); + mShowResizedImage = args.getBoolean(ARG_SHOW_RESIZED_IMAGE); setHasOptionsMenu(true); } @@@ -188,6 -179,9 +188,6 @@@ if (getFile() == null) { throw new IllegalStateException("Instanced with a NULL OCFile"); } - if (!getFile().isDown()) { - throw new IllegalStateException("There is no local file to preview"); - } } @@@ -205,44 -199,10 +205,44 @@@ public void onStart() { super.onStart(); if (getFile() != null) { - mLoadBitmapTask = new LoadBitmapTask(mImageView, mMessageView, mProgressWheel); - //mLoadBitmapTask.execute(new String[]{getFile().getStoragePath()}); -// mLoadBitmapTask.execute(getFile().getStoragePath()); - mLoadBitmapTask.execute(getFile()); + mImageView.setTag(getFile().getFileId()); + + if (mShowResizedImage){ + Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache( + String.valueOf("r" + getFile().getRemoteId()) + ); + + if (thumbnail != null && !getFile().needsUpdateThumbnail()){ + mProgressWheel.setVisibility(View.GONE); + mImageView.setImageBitmap(thumbnail); + mImageView.setVisibility(View.VISIBLE); + mBitmap = thumbnail; + } else { + // generate new Thumbnail + if (ThumbnailsCacheManager.cancelPotentialWork(getFile(), mImageView) && + mContainerActivity.getStorageManager() != null) { + final ThumbnailsCacheManager.ThumbnailGenerationTask task = + new ThumbnailsCacheManager.ThumbnailGenerationTask( + mImageView, mContainerActivity.getStorageManager(), + mContainerActivity.getStorageManager().getAccount(), + mProgressWheel); + if (thumbnail == null) { + thumbnail = ThumbnailsCacheManager.mDefaultImg; + } + final ThumbnailsCacheManager.AsyncDrawable asyncDrawable = + new ThumbnailsCacheManager.AsyncDrawable( + MainApp.getAppContext().getResources(), + thumbnail, + task + ); + mImageView.setImageDrawable(asyncDrawable); + task.execute(getFile(), false); + } + } + } else { + mLoadBitmapTask = new LoadBitmapTask(mImageView, mMessageView, mProgressWheel); + mLoadBitmapTask.execute(getFile()); + } } } @@@ -347,13 -307,8 +347,13 @@@ return true; } case R.id.action_send_file: { - mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile()); - return true; + if (getFile().isImage() && !getFile().isDown()){ + mContainerActivity.getFileOperationsHelper().sendCachedImage(getFile()); + return true; + } else { + mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile()); + return true; + } } case R.id.action_sync_file: { mContainerActivity.getFileOperationsHelper().syncFile(getFile()); @@@ -367,6 -322,10 +367,10 @@@ mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), false); return true; } + case R.id.action_set_as_wallpaper:{ + mContainerActivity.getFileOperationsHelper().setPictureAs(getFile()); + return true; + } default: return false; } @@@ -554,12 -513,7 +558,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 }