X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/3f2081e6073bd0c11d672890f350da80abc554b2..4c50eb4d2dd1fba177d743315ae52223430db8cb:/src/com/owncloud/android/ui/fragment/FileDetailFragment.java diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 9338b93f..47e75d37 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -191,7 +191,7 @@ public class FileDetailFragment extends SherlockFragment implements mPreview = (ImageView)mView.findViewById(R.id.fdPreview); } - updateFileDetails(); + updateFileDetails(false); return view; } @@ -274,7 +274,6 @@ public class FileDetailFragment extends SherlockFragment implements public void onClick(View v) { switch (v.getId()) { case R.id.fdDownloadBtn: { - //if (FileDownloader.isDownloading(mAccount, mFile.getRemotePath())) { FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder(); FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder(); if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, mFile)) { @@ -342,8 +341,7 @@ public class FileDetailFragment extends SherlockFragment implements break; } case R.id.fdRenameBtn: { - EditNameDialog dialog = EditNameDialog.newInstance(mFile.getFileName()); - dialog.setOnDismissListener(this); + EditNameDialog dialog = EditNameDialog.newInstance(getString(R.string.rename_dialog_title), mFile.getFileName(), this); dialog.show(getFragmentManager(), "nameeditdialog"); break; } @@ -374,8 +372,13 @@ public class FileDetailFragment extends SherlockFragment implements try { 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://"+ encodedStoragePath), mimeType); + if (mimeType == null || !mimeType.equals(mFile.getMimetype())) { + if (mimeType != null) { + i.setDataAndType(Uri.parse("file://"+ encodedStoragePath), mimeType); + } else { + // desperate try + i.setDataAndType(Uri.parse("file://"+ encodedStoragePath), "*/*"); + } i.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); startActivity(i); toastIt = false; @@ -475,14 +478,21 @@ public class FileDetailFragment extends SherlockFragment implements mStorageManager = new FileDataStorageManager(ocAccount, getActivity().getApplicationContext().getContentResolver()); } mAccount = ocAccount; - updateFileDetails(); + updateFileDetails(false); } /** * Updates the view with all relevant details about that file. + * + * TODO Remove parameter when the transferring state of files is kept in database. + * + * @param transferring Flag signaling if the file should be considered as downloading or uploading, + * although {@link FileDownloaderBinder#isDownloading(Account, OCFile)} and + * {@link FileUploaderBinder#isUploading(Account, OCFile)} return false. + * */ - public void updateFileDetails() { + public void updateFileDetails(boolean transferring) { if (mFile != null && mAccount != null && mLayout == R.layout.file_details_fragment) { @@ -504,7 +514,7 @@ public class FileDetailFragment extends SherlockFragment implements //if (FileDownloader.isDownloading(mAccount, mFile.getRemotePath()) || FileUploader.isUploading(mAccount, mFile.getRemotePath())) { FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder(); FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder(); - if ((downloaderBinder != null && downloaderBinder.isDownloading(mAccount, mFile)) || (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile))) { + if (transferring || (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, mFile)) || (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile))) { setButtonsForTransferring(); } else if (mFile.isDown()) { @@ -517,9 +527,11 @@ public class FileDetailFragment extends SherlockFragment implements setButtonsForDown(); } else { + // TODO load default preview image; when the local file is removed, the preview remains there setButtonsForRemote(); } } + getView().invalidate(); } @@ -602,7 +614,6 @@ public class FileDetailFragment extends SherlockFragment implements if (!isEmpty()) { Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn); downloadButton.setText(R.string.filedetails_sync_file); - //downloadButton.setEnabled(true); ((Button) getView().findViewById(R.id.fdOpenBtn)).setEnabled(true); ((Button) getView().findViewById(R.id.fdRenameBtn)).setEnabled(true); @@ -687,7 +698,7 @@ public class FileDetailFragment extends SherlockFragment implements if (downloadWasFine) { mFile = mStorageManager.getFileByPath(downloadedRemotePath); } - updateFileDetails(); // it updates the buttons; must be called although !downloadWasFine + updateFileDetails(false); // it updates the buttons; must be called although !downloadWasFine } } } @@ -707,7 +718,6 @@ public class FileDetailFragment extends SherlockFragment implements private class UploadFinishReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - Log.d(TAG, "Received broacast! : " + intent.getStringExtra(FileUploader.EXTRA_REMOTE_PATH)); String accountName = intent.getStringExtra(FileUploader.ACCOUNT_NAME); if (!isEmpty() && accountName.equals(mAccount.name)) { @@ -724,7 +734,7 @@ public class FileDetailFragment extends SherlockFragment implements Toast msg = Toast.makeText(getActivity().getApplicationContext(), String.format(getString(R.string.filedetails_renamed_in_upload_msg), newName), Toast.LENGTH_LONG); msg.show(); } - updateFileDetails(); // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server + updateFileDetails(false); // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server } } } @@ -840,6 +850,7 @@ public class FileDetailFragment extends SherlockFragment implements String newFilename = dialog.getNewFilename(); Log.d(TAG, "name edit dialog dismissed with new name " + newFilename); mLastRemoteOperation = new RenameFileOperation( mFile, + mAccount, newFilename, new FileDataStorageManager(mAccount, getActivity().getContentResolver())); WebdavClient wc = OwnCloudClientUtils.createOwnCloudClient(mAccount, getSherlockActivity().getApplicationContext());