X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/557126eecf185d6b537e4bb05393b6c37ab261f8..76ba00b2b23f5c2079a6635dc5e661850c3c5dfb:/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 9dfb4508..5b76c018 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -242,17 +242,29 @@ public class FileDetailFragment extends SherlockFragment implements public void onClick(View v) { switch (v.getId()) { case R.id.fdDownloadBtn: { - 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.getRemotePath()); - i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength()); + if (FileDownloader.isDownloading(mAccount, mFile.getRemotePath())) { + + // TODO cancelar descarga + + if (mFile.isDown()) { + setButtonsForDown(); + } else { + setButtonsForRemote(); + } + + } else { + 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.getRemotePath()); + i.putExtra(FileDownloader.EXTRA_FILE_SIZE, mFile.getFileLength()); - // update ui - setButtonsForTransferring(); + // update ui + setButtonsForTransferring(); - getActivity().startService(i); - mContainerActivity.onFileStateChanged(); // this is not working; it is performed before the fileDownloadService registers it as 'in progress' + getActivity().startService(i); + mContainerActivity.onFileStateChanged(); // this is not working; it is performed before the fileDownloadService registers it as 'in progress' + } break; } case R.id.fdKeepInSync: { @@ -508,8 +520,8 @@ public class FileDetailFragment extends SherlockFragment implements private void setButtonsForTransferring() { if (!isEmpty()) { Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn); - //downloadButton.setText(R.string.filedetails_download_in_progress); // ugly - downloadButton.setEnabled(false); // TODO replace it with a 'cancel download' button + downloadButton.setText(R.string.common_cancel); + //downloadButton.setEnabled(false); // let's protect the user from himself ;) ((Button) getView().findViewById(R.id.fdOpenBtn)).setEnabled(false); @@ -524,8 +536,8 @@ public class FileDetailFragment extends SherlockFragment implements private void setButtonsForDown() { if (!isEmpty()) { Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn); - //downloadButton.setText(R.string.filedetails_redownload); // ugly - downloadButton.setEnabled(true); + downloadButton.setText(R.string.filedetails_redownload); + //downloadButton.setEnabled(true); ((Button) getView().findViewById(R.id.fdOpenBtn)).setEnabled(true); ((Button) getView().findViewById(R.id.fdRenameBtn)).setEnabled(true); @@ -539,8 +551,7 @@ public class FileDetailFragment extends SherlockFragment implements private void setButtonsForRemote() { if (!isEmpty()) { Button downloadButton = (Button) getView().findViewById(R.id.fdDownloadBtn); - //downloadButton.setText(R.string.filedetails_download); // unnecessary - downloadButton.setEnabled(true); + downloadButton.setText(R.string.filedetails_download); ((Button) getView().findViewById(R.id.fdOpenBtn)).setEnabled(false); ((Button) getView().findViewById(R.id.fdRenameBtn)).setEnabled(true);