X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/c6b553f635c7cbb4f21d41a6fa82e204447c16cf..3cf90ff17d160fa84cfee67889ec2055ba7a896d:/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 7eb0c1b8..34a82cba 100644 --- a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java +++ b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java @@ -197,6 +197,7 @@ public class FileDetailFragment extends SherlockFragment implements IntentFilter filter = new IntentFilter( FileDownloader.DOWNLOAD_FINISH_MESSAGE); getActivity().registerReceiver(mDownloadFinishReceiver, filter); + mPreview = (ImageView)mView.findViewById(R.id.fdPreview); } @Override @@ -235,7 +236,7 @@ public class FileDetailFragment extends SherlockFragment implements mFile.setKeepInSync(cb.isChecked()); FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver()); fdsm.saveFile(mFile); - if (mFile.keepInSync() && !mFile.isDownloaded()) { + if (mFile.keepInSync()) { onClick(getView().findViewById(R.id.fdDownloadBtn)); } break; @@ -340,9 +341,10 @@ public class FileDetailFragment extends SherlockFragment implements @Override public void onClick(View v) { String storagePath = mFile.getStoragePath(); + String encodedStoragePath = WebdavUtils.encodePath(storagePath); try { Intent i = new Intent(Intent.ACTION_VIEW); - i.setDataAndType(Uri.parse("file://"+ storagePath), mFile.getMimetype()); + i.setDataAndType(Uri.parse("file://"+ encodedStoragePath), mFile.getMimetype()); i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); startActivity(i); @@ -354,7 +356,7 @@ public class FileDetailFragment extends SherlockFragment implements Intent i = new Intent(Intent.ACTION_VIEW); mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1)); if (mimeType != null && !mimeType.equals(mFile.getMimetype())) { - i.setDataAndType(Uri.parse("file://"+mFile.getStoragePath()), mimeType); + i.setDataAndType(Uri.parse("file://"+ encodedStoragePath), mimeType); i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); startActivity(i); toastIt = false; @@ -595,7 +597,6 @@ public class FileDetailFragment extends SherlockFragment implements } public void onDismiss(EditNameFragment dialog) { - Log.e("ASD","ondismiss"); if (dialog instanceof EditNameFragment) { if (((EditNameFragment)dialog).getResult()) { String newFilename = ((EditNameFragment)dialog).getNewFilename(); @@ -612,7 +613,13 @@ public class FileDetailFragment extends SherlockFragment implements newFile.setMimetype(mFile.getMimetype()); newFile.setModificationTimestamp(mFile.getModificationTimestamp()); newFile.setParentId(mFile.getParentId()); - newFile.setStoragePath(mFile.getStoragePath()); + if (mFile.isDownloaded()) { + File f = new File(mFile.getStoragePath()); + Log.e(TAG, f.getAbsolutePath()+""); + f.renameTo(new File(f.getParent()+"/"+newFilename)); + Log.e(TAG, f.getAbsolutePath()+""); + newFile.setStoragePath(f.getAbsolutePath()); + } new Thread(new RenameRunnable(mFile, newFile, mAccount, new Handler())).start(); @@ -644,11 +651,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 + WebdavUtils.encode(mOld.getRemotePath())); + Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encodePath(mOld.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())); + Log.e("ASD", Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encodePath(mNew.getRemotePath())); + LocalMoveMethod move = new LocalMoveMethod(baseUrl + webdav_path + WebdavUtils.encodePath(mOld.getRemotePath()), + Uri.parse(baseUrl).getPath() == null ? "" : Uri.parse(baseUrl).getPath() + webdav_path + WebdavUtils.encodePath(mNew.getRemotePath())); try { int status = wc.executeMethod(move); @@ -753,9 +760,11 @@ public class FileDetailFragment extends SherlockFragment implements } - private class RemoveRunnable implements Runnable { + /** Arbitrary timeout for deletion */ + public final static int DELETION_TIMEOUT = 5000; + Account mAccount; OCFile mFileToRemove; Handler mHandler; @@ -772,16 +781,13 @@ 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 + WebdavUtils.encode(mFileToRemove.getRemotePath())); + Log.d("ASD", ""+baseUrl + webdav_path + WebdavUtils.encodePath(mFileToRemove.getRemotePath())); - DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + WebdavUtils.encode(mFileToRemove.getRemotePath())); - HttpMethodParams params = delete.getParams(); - params.setSoTimeout(1000); - delete.setParams(params); + DeleteMethod delete = new DeleteMethod(baseUrl + webdav_path + WebdavUtils.encodePath(mFileToRemove.getRemotePath())); boolean success = false; try { - int status = wc.executeMethod(delete); + int status = wc.executeMethod(delete, DELETION_TIMEOUT); if (delete.succeeded()) { FileDataStorageManager fdsm = new FileDataStorageManager(mAccount, getActivity().getContentResolver()); fdsm.removeFile(mFileToRemove); @@ -904,7 +910,7 @@ public class FileDetailFragment extends SherlockFragment implements } @Override protected void onPostExecute(Bitmap result) { - if (result != null) { + if (result != null && mPreview != null) { mPreview.setImageBitmap(result); } }