X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/90161386e25c0760bdf75b9e6b4355a61f65f42e..c6b553f635c7cbb4f21d41a6fa82e204447c16cf:/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java index db916414..7eb0c1b8 100644 --- a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java +++ b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java @@ -95,6 +95,7 @@ import eu.alefzero.owncloud.files.services.FileDownloader; import eu.alefzero.owncloud.ui.activity.FileDisplayActivity; import eu.alefzero.owncloud.utils.OwnCloudVersion; import eu.alefzero.webdav.WebdavClient; +import eu.alefzero.webdav.WebdavUtils; /** * This Fragment is used to display the details about a file. @@ -205,7 +206,6 @@ public class FileDetailFragment extends SherlockFragment implements mDownloadFinishReceiver = null; if (mPreview != null) { mPreview = null; - System.gc(); } } @@ -224,7 +224,7 @@ public class FileDetailFragment extends SherlockFragment implements Intent i = new Intent(getActivity(), FileDownloader.class); i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount); i.putExtra(FileDownloader.EXTRA_REMOTE_PATH, mFile.getRemotePath()); - i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getURLDecodedRemotePath()); + i.putExtra(FileDownloader.EXTRA_FILE_PATH, mFile.getRemotePath()); i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength()); v.setEnabled(false); getActivity().startService(i); @@ -603,7 +603,7 @@ public class FileDetailFragment extends SherlockFragment implements if (!newFilename.equals(mFile.getFileName())) { FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver()); if (fdsm.getFileById(mFile.getFileId()) != null) { - OCFile newFile = new OCFile(fdsm.getFileById(mFile.getParentId()).getRemotePath()+"/"+newFilename); + OCFile newFile = new OCFile(fdsm.getFileById(mFile.getParentId()).getRemotePath() + OCFile.PATH_SEPARATOR + newFilename); newFile.setCreationTimestamp(mFile.getCreationTimestamp()); newFile.setFileId(mFile.getFileId()); newFile.setFileLength(mFile.getFileLength()); @@ -644,11 +644,11 @@ public class FileDetailFragment extends SherlockFragment implements String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL); OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION)); String webdav_path = AccountUtils.getWebdavPath(ocv); - Log.d("ASD", ""+baseUrl + webdav_path + mOld.getRemotePath()); + Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encode(mOld.getRemotePath())); - Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + mNew.getRemotePath()); - LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + mOld.getRemotePath(), - Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + mNew.getRemotePath()); + Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encode(mNew.getRemotePath())); + LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + WebdavUtils.encode(mOld.getRemotePath()), + Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encode(mNew.getRemotePath())); try { int status = wc.executeMethod(move); @@ -772,9 +772,9 @@ public class FileDetailFragment extends SherlockFragment implements String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL); OwnCloudVersion ocv = new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION)); String webdav_path = AccountUtils.getWebdavPath(ocv); - Log.d("ASD", ""+baseUrl + webdav_path + mFileToRemove.getRemotePath()); + Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encode(mFileToRemove.getRemotePath())); - DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + mFileToRemove.getRemotePath()); + DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + WebdavUtils.encode(mFileToRemove.getRemotePath())); HttpMethodParams params = delete.getParams(); params.setSoTimeout(1000); delete.setParams(params); @@ -848,6 +848,7 @@ public class FileDetailFragment extends SherlockFragment implements BitmapFactory.Options options = new Options(); options.inScaled = true; options.inPurgeable = true; + options.inJustDecodeBounds = true; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) { options.inPreferQualityOverSpeed = false; } @@ -856,39 +857,36 @@ public class FileDetailFragment extends SherlockFragment implements } result = BitmapFactory.decodeFile(storagePath, options); + options.inJustDecodeBounds = false; + + int width = options.outWidth; + int height = options.outHeight; + int scale = 1; + boolean recycle = false; + if (width >= 2048 || height >= 2048) { + scale = (int) Math.ceil((Math.ceil(Math.max(height, width) / 2048.))); + options.inSampleSize = scale; + } + Display display = getActivity().getWindowManager().getDefaultDisplay(); + Point size = new Point(); + int screenwidth; + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) { + display.getSize(size); + screenwidth = size.x; + } else { + screenwidth = display.getWidth(); + } - if (result != null) { - int width = options.outWidth; - int height = options.outHeight; - int scale = 1; - boolean recycle = false; - if (width >= 2048 || height >= 2048) { - scale = (int) (Math.ceil(Math.max(height, width) / 2048.)); - options.inSampleSize = scale; - recycle = true; - } - Display display = getActivity().getWindowManager().getDefaultDisplay(); - Point size = new Point(); - int screenwidth; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) { - display.getSize(size); - screenwidth = size.x; - } else { - screenwidth = display.getWidth(); - } + Log.e("ASD", "W " + width + " SW " + screenwidth); - Log.e("ASD", "W " + width + " SW " + screenwidth); + if (width > screenwidth) { + scale = (int) Math.ceil((float)width / screenwidth); + options.inSampleSize = scale; + } - if (width > screenwidth) { - scale = (int) (Math.ceil(Math.max(height, width) / screenwidth)); - options.inSampleSize = scale; - recycle = true; - } + result = BitmapFactory.decodeFile(storagePath, options); - if (recycle) - result.recycle(); - result = BitmapFactory.decodeFile(storagePath, options); - } + Log.e("ASD", "W " + options.outWidth + " SW " + options.outHeight); } catch (OutOfMemoryError e) { result = null;