From: Jorge Antonio Diaz-Benito Soriano Date: Mon, 17 Aug 2015 16:10:21 +0000 (+0200) Subject: Fixes the last reported bugs X-Git-Tag: oc-android-1.8~22^2~4 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/97da4d5c8a771bffe239d9d10a237909a8b32574 Fixes the last reported bugs --- diff --git a/src/com/owncloud/android/files/FileMenuFilter.java b/src/com/owncloud/android/files/FileMenuFilter.java index 2c2754cc..f7fee626 100644 --- a/src/com/owncloud/android/files/FileMenuFilter.java +++ b/src/com/owncloud/android/files/FileMenuFilter.java @@ -39,7 +39,7 @@ import com.owncloud.android.services.OperationsService.OperationsServiceBinder; import com.owncloud.android.ui.activity.ComponentsGetter; /** - * Filters out the file actions available in a given {@link Menu} for a given {@link OCFile} + * Filters out the file actions available in a given {@link Menu} for a given {@link OCFile} * according to the current state of the latest. */ public class FileMenuFilter { @@ -48,10 +48,10 @@ public class FileMenuFilter { private ComponentsGetter mComponentsGetter; private Account mAccount; private Context mContext; - + /** * Constructor - * + * * @param targetFile {@link OCFile} target of the action to filter in the {@link Menu}. * @param account ownCloud {@link Account} holding targetFile. * @param cg Accessor to app components, needed to access the @@ -64,20 +64,20 @@ public class FileMenuFilter { mComponentsGetter = cg; mContext = context; } - - + + /** * Filters out the file actions available in the passed {@link Menu} taken into account * the state of the {@link OCFile} held by the filter. - * + * * @param menu Options or context menu to filter. */ public void filter(Menu menu) { - List toShow = new ArrayList(); - List toHide = new ArrayList(); - + List toShow = new ArrayList(); + List toHide = new ArrayList(); + filter(toShow, toHide); - + MenuItem item = null; for (int i : toShow) { item = menu.findItem(i); @@ -86,7 +86,7 @@ public class FileMenuFilter { item.setEnabled(true); } } - + for (int i : toHide) { item = menu.findItem(i); if (item != null) { @@ -99,10 +99,10 @@ public class FileMenuFilter { /** * Performs the real filtering, to be applied in the {@link Menu} by the caller methods. - * + * * Decides what actions must be shown and hidden. - * - * @param toShow List to save the options that must be shown in the menu. + * + * @param toShow List to save the options that must be shown in the menu. * @param toHide List to save the options that must be shown in the menu. */ private void filter(List toShow, List toHide) { @@ -116,71 +116,72 @@ public class FileMenuFilter { FileUploaderBinder uploaderBinder = mComponentsGetter.getFileUploaderBinder(); uploading = (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile)); } - + /// decision is taken for each possible action on a file in the menu - + // DOWNLOAD if (mFile == null || mFile.isDown() || downloading || uploading) { toHide.add(R.id.action_download_file); - + } else { toShow.add(R.id.action_download_file); } - + // RENAME if (mFile == null || downloading || uploading) { toHide.add(R.id.action_rename_file); - + } else { toShow.add(R.id.action_rename_file); } - // MOVE + // MOVE & COPY if (mFile == null || downloading || uploading) { toHide.add(R.id.action_move); - + toHide.add(R.id.action_copy); } else { toShow.add(R.id.action_move); + toShow.add(R.id.action_copy); } - + // REMOVE if (mFile == null || downloading || uploading) { toHide.add(R.id.action_remove_file); - + } else { toShow.add(R.id.action_remove_file); } - + // OPEN WITH (different to preview!) if (mFile == null || mFile.isFolder() || !mFile.isDown() || downloading || uploading) { toHide.add(R.id.action_open_file_with); - + } else { toShow.add(R.id.action_open_file_with); } - - + + // CANCEL DOWNLOAD if (mFile == null || !downloading) { toHide.add(R.id.action_cancel_download); } else { toShow.add(R.id.action_cancel_download); } - + // CANCEL UPLOAD if (mFile == null || !uploading || mFile.isFolder()) { toHide.add(R.id.action_cancel_upload); } else { toShow.add(R.id.action_cancel_upload); } - + // SYNC FILE CONTENTS if (mFile == null || mFile.isFolder() || !mFile.isDown() || downloading || uploading) { toHide.add(R.id.action_sync_file); } else { toShow.add(R.id.action_sync_file); } - + // SHARE FILE // TODO add check on SHARE available on server side? boolean shareAllowed = (mContext != null && @@ -190,7 +191,7 @@ public class FileMenuFilter { } else { toShow.add(R.id.action_share_file); } - + // UNSHARE FILE // TODO add check on SHARE available on server side? if ( !shareAllowed || (mFile == null || !mFile.isShareByLink())) { @@ -205,7 +206,7 @@ public class FileMenuFilter { } else { toShow.add(R.id.action_see_details); } - + // SEND boolean sendAllowed = (mContext != null && mContext.getString(R.string.send_files_to_other_apps).equalsIgnoreCase("on")); diff --git a/src/com/owncloud/android/operations/CopyFileOperation.java b/src/com/owncloud/android/operations/CopyFileOperation.java index 77d2458f..77a9a071 100644 --- a/src/com/owncloud/android/operations/CopyFileOperation.java +++ b/src/com/owncloud/android/operations/CopyFileOperation.java @@ -71,7 +71,7 @@ public class CopyFileOperation extends SyncOperation { /// 1. check copy validity if (mTargetParentPath.startsWith(mSrcPath)) { - return new RemoteOperationResult(ResultCode.INVALID_MOVE_INTO_DESCENDANT); + return new RemoteOperationResult(ResultCode.INVALID_COPY_INTO_DESCENDANT); } mFile = getStorageManager().getFileByPath(mSrcPath); if (mFile == null) { diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 9916a3d0..b5fce44e 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -21,10 +21,7 @@ */ package com.owncloud.android.ui.fragment; -import java.lang.ref.WeakReference; - import android.accounts.Account; -import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; @@ -46,13 +43,14 @@ import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; import com.owncloud.android.lib.common.utils.Log_OC; -import com.owncloud.android.services.observer.FileObserverService; import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.dialog.RemoveFileDialogFragment; import com.owncloud.android.ui.dialog.RenameFileDialogFragment; import com.owncloud.android.utils.DisplayUtils; +import java.lang.ref.WeakReference; + /** * This Fragment is used to display the details about a file. @@ -62,9 +60,9 @@ public class FileDetailFragment extends FileFragment implements OnClickListener private int mLayout; private View mView; private Account mAccount; - + public ProgressListener mProgressListener; - + private static final String TAG = FileDetailFragment.class.getSimpleName(); public static final String FTAG_CONFIRMATION = "REMOVE_CONFIRMATION_FRAGMENT"; public static final String FTAG_RENAME_FILE = "RENAME_FILE_FRAGMENT"; @@ -103,14 +101,14 @@ public class FileDetailFragment extends FileFragment implements OnClickListener mLayout = R.layout.file_details_empty; mProgressListener = null; } - + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); } - + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -120,14 +118,14 @@ public class FileDetailFragment extends FileFragment implements OnClickListener mAccount = getArguments().getParcelable(ARG_ACCOUNT); if (savedInstanceState != null) { - setFile((OCFile)savedInstanceState.getParcelable(FileActivity.EXTRA_FILE)); + setFile((OCFile) savedInstanceState.getParcelable(FileActivity.EXTRA_FILE)); mAccount = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT); } - - if(getFile() != null && mAccount != null) { + + if (getFile() != null && mAccount != null) { mLayout = R.layout.file_details_fragment; } - + mView = inflater.inflate(mLayout, null); if (mLayout == R.layout.file_details_fragment) { @@ -153,20 +151,20 @@ public class FileDetailFragment extends FileFragment implements OnClickListener super.onStart(); listenForTransferProgress(); } - + @Override public void onStop() { leaveTransferProgress(); super.onStop(); } - + @Override public View getView() { return super.getView() == null ? mView : super.getView(); } - + /** * {@inheritDoc} */ @@ -174,16 +172,16 @@ public class FileDetailFragment extends FileFragment implements OnClickListener public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.file_actions_menu, menu); - } + } + - /** * {@inheritDoc} */ @Override - public void onPrepareOptionsMenu (Menu menu) { + public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - + if (mContainerActivity.getStorageManager() != null) { FileMenuFilter mf = new FileMenuFilter( getFile(), @@ -193,7 +191,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener ); mf.filter(menu); } - + // additional restriction for this fragment MenuItem item = menu.findItem(R.id.action_see_details); if (item != null) { @@ -207,9 +205,16 @@ public class FileDetailFragment extends FileFragment implements OnClickListener item.setVisible(false); item.setEnabled(false); } + + // additional restriction for this fragment + item = menu.findItem(R.id.action_copy); + if (item != null) { + item.setVisible(false); + item.setEnabled(false); + } } - + /** * {@inheritDoc} */ @@ -240,10 +245,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener } case R.id.action_cancel_download: case R.id.action_cancel_upload: { - ((FileDisplayActivity)mContainerActivity).cancelTransference(getFile()); + ((FileDisplayActivity) mContainerActivity).cancelTransference(getFile()); return true; } - case R.id.action_download_file: + case R.id.action_download_file: case R.id.action_sync_file: { mContainerActivity.getFileOperationsHelper().syncFile(getFile()); return true; @@ -252,9 +257,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener // Obtain the file if (!getFile().isDown()) { // Download the file Log_OC.d(TAG, getFile().getRemotePath() + " : File must be downloaded"); - ((FileDisplayActivity)mContainerActivity).startDownloadForSending(getFile()); - - } else { + ((FileDisplayActivity) mContainerActivity).startDownloadForSending(getFile()); + + } + else { mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile()); } return true; @@ -281,7 +287,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener break; } case R.id.fdCancelBtn: { - ((FileDisplayActivity)mContainerActivity).cancelTransference(getFile()); + ((FileDisplayActivity) mContainerActivity).cancelTransference(getFile()); break; } default: @@ -292,17 +298,17 @@ public class FileDetailFragment extends FileFragment implements OnClickListener /** * Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced. - * - * @return True when the fragment was created with the empty layout. + * + * @return True when the fragment was created with the empty layout. */ public boolean isEmpty() { return (mLayout == R.layout.file_details_empty || getFile() == null || mAccount == null); } - + /** * Use this method to signal this Activity that it shall update its view. - * + * * @param file : An {@link OCFile} */ public void updateFileDetails(OCFile file, Account ocAccount) { @@ -313,14 +319,13 @@ public class FileDetailFragment extends FileFragment implements OnClickListener /** * Updates the view with all relevant details about that file. + *

+ * TODO Remove parameter when the transferring state of files is kept in database. * - * 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. - * - * @param refresh If 'true', try to refresh the whole file from the 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. + * @param refresh If 'true', try to refresh the whole file from the database */ public void updateFileDetails(boolean transferring, boolean refresh) { if (readyToShow()) { @@ -329,7 +334,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener setFile(storageManager.getFileByPath(getFile().getRemotePath())); } OCFile file = getFile(); - + // set file details setFilename(file.getFileName()); setFiletype(file.getMimetype(), file.getFileName()); @@ -348,7 +353,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) ) { setButtonsForTransferring(); - + } else if (file.isDown()) { setButtonsForDown(); @@ -361,25 +366,27 @@ public class FileDetailFragment extends FileFragment implements OnClickListener } getView().invalidate(); } - + /** * Checks if the fragment is ready to show details of a OCFile - * - * @return 'True' when the fragment is ready to show details of a file + * + * @return 'True' when the fragment is ready to show details of a file */ private boolean readyToShow() { - return (getFile() != null && mAccount != null && mLayout == R.layout.file_details_fragment); + return (getFile() != null && mAccount != null && mLayout == R.layout.file_details_fragment); } /** * Updates the filename in view + * * @param filename to set */ private void setFilename(String filename) { TextView tv = (TextView) getView().findViewById(R.id.fdFilename); - if (tv != null) + if (tv != null) { tv.setText(filename); + } } /** @@ -401,25 +408,28 @@ public class FileDetailFragment extends FileFragment implements OnClickListener /** * Updates the file size in view + * * @param filesize in bytes to set */ private void setFilesize(long filesize) { TextView tv = (TextView) getView().findViewById(R.id.fdSize); - if (tv != null) + if (tv != null) { tv.setText(DisplayUtils.bytesToHumanReadable(filesize)); + } } - + /** * Updates the time that the file was last modified + * * @param milliseconds Unix time to set */ - private void setTimeModified(long milliseconds){ + private void setTimeModified(long milliseconds) { TextView tv = (TextView) getView().findViewById(R.id.fdModified); - if(tv != null){ + if (tv != null) { tv.setText(DisplayUtils.unixTimeToHumanReadable(milliseconds)); } } - + /** * Enables or disables buttons for a file being downloaded */ @@ -430,21 +440,24 @@ public class FileDetailFragment extends FileFragment implements OnClickListener // show the progress bar for the transfer getView().findViewById(R.id.fdProgressBlock).setVisibility(View.VISIBLE); - TextView progressText = (TextView)getView().findViewById(R.id.fdProgressText); + TextView progressText = (TextView) getView().findViewById(R.id.fdProgressText); progressText.setVisibility(View.VISIBLE); FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder(); FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder(); //if (getFile().isDownloading()) { if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) { progressText.setText(R.string.downloader_download_in_progress_ticker); - } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) { - progressText.setText(R.string.uploader_upload_in_progress_ticker); + } + else { + if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) { + progressText.setText(R.string.uploader_upload_in_progress_ticker); + } } } } /** - * Enables or disables buttons for a file locally available + * Enables or disables buttons for a file locally available */ private void setButtonsForDown() { if (!isEmpty()) { @@ -452,13 +465,13 @@ public class FileDetailFragment extends FileFragment implements OnClickListener // hides the progress bar getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE); - TextView progressText = (TextView)getView().findViewById(R.id.fdProgressText); + TextView progressText = (TextView) getView().findViewById(R.id.fdProgressText); progressText.setVisibility(View.GONE); } } /** - * Enables or disables buttons for a file not locally available + * Enables or disables buttons for a file not locally available */ private void setButtonsForRemote() { if (!isEmpty()) { @@ -466,11 +479,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener // hides the progress bar getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE); - TextView progressText = (TextView)getView().findViewById(R.id.fdProgressText); + TextView progressText = (TextView) getView().findViewById(R.id.fdProgressText); progressText.setVisibility(View.GONE); } } - + public void listenForTransferProgress() { if (mProgressListener != null) { @@ -484,8 +497,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener } } } - - + + public void leaveTransferProgress() { if (mProgressListener != null) { if (mContainerActivity.getFileDownloaderBinder() != null) { @@ -500,7 +513,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener } - /** * Helper class responsible for updating the progress bar shown for file uploading or * downloading @@ -508,11 +520,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener private class ProgressListener implements OnDatatransferProgressListener { int mLastPercent = 0; WeakReference mProgressBar = null; - + ProgressListener(ProgressBar progressBar) { mProgressBar = new WeakReference(progressBar); } - + @Override public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String filename) { diff --git a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java b/src/com/owncloud/android/ui/preview/FileDownloadFragment.java index 631a8367..957d3384 100644 --- a/src/com/owncloud/android/ui/preview/FileDownloadFragment.java +++ b/src/com/owncloud/android/ui/preview/FileDownloadFragment.java @@ -36,8 +36,13 @@ import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.TextView; +import com.owncloud.android.R; +import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; import com.owncloud.android.lib.common.utils.Log_OC; +import com.owncloud.android.ui.fragment.FileFragment; + +import java.lang.ref.WeakReference; /** @@ -58,9 +63,9 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene public ProgressListener mProgressListener; private boolean mListening; - + private static final String TAG = FileDownloadFragment.class.getSimpleName(); - + private boolean mIgnoreFirstSavedState; private boolean mError; @@ -117,30 +122,31 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST); mAccount = args.getParcelable(ARG_ACCOUNT); } - + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); - + if (savedInstanceState != null) { if (!mIgnoreFirstSavedState) { - setFile((OCFile)savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_FILE)); + setFile((OCFile) savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_FILE)); mAccount = savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_ACCOUNT); mError = savedInstanceState.getBoolean(FileDownloadFragment.EXTRA_ERROR); - } else { + } + else { mIgnoreFirstSavedState = false; } } - + View view = null; view = inflater.inflate(R.layout.file_download_fragment, container, false); mView = view; - - ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.progressBar); + + ProgressBar progressBar = (ProgressBar) mView.findViewById(R.id.progressBar); mProgressListener = new ProgressListener(progressBar); - + (mView.findViewById(R.id.cancelBtn)).setOnClickListener(this); (mView.findViewById(R.id.fileDownloadLL)).setOnClickListener(new OnClickListener() { @@ -152,13 +158,14 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene if (mError) { setButtonsForRemote(); - } else { + } + else { setButtonsForTransferring(); } - + return view; } - + @Override public void onSaveInstanceState(Bundle outState) { @@ -173,7 +180,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene super.onStart(); listenForTransferProgress(); } - + @Override public void onResume() { super.onResume(); @@ -185,19 +192,19 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene super.onPause(); } - + @Override public void onStop() { leaveTransferProgress(); super.onStop(); } - + @Override public void onDestroy() { super.onDestroy(); } - - + + @Override public View getView() { if (!mListening) { @@ -206,7 +213,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene return super.getView() == null ? mView : super.getView(); } - + @Override public void onClick(View v) { switch (v.getId()) { @@ -220,53 +227,52 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene } } - + /** * Enables or disables buttons for a file being downloaded */ private void setButtonsForTransferring() { getView().findViewById(R.id.cancelBtn).setVisibility(View.VISIBLE); - + // show the progress bar for the transfer getView().findViewById(R.id.progressBar).setVisibility(View.VISIBLE); - TextView progressText = (TextView)getView().findViewById(R.id.progressText); + TextView progressText = (TextView) getView().findViewById(R.id.progressText); progressText.setText(R.string.downloader_download_in_progress_ticker); progressText.setVisibility(View.VISIBLE); - + // hides the error icon getView().findViewById(R.id.errorText).setVisibility(View.GONE); getView().findViewById(R.id.error_image).setVisibility(View.GONE); } - /** - * Enables or disables buttons for a file locally available + * Enables or disables buttons for a file locally available */ private void setButtonsForDown() { getView().findViewById(R.id.cancelBtn).setVisibility(View.GONE); - + // hides the progress bar getView().findViewById(R.id.progressBar).setVisibility(View.GONE); - + // updates the text message - TextView progressText = (TextView)getView().findViewById(R.id.progressText); + TextView progressText = (TextView) getView().findViewById(R.id.progressText); progressText.setText(R.string.common_loading); progressText.setVisibility(View.VISIBLE); - + // hides the error icon getView().findViewById(R.id.errorText).setVisibility(View.GONE); getView().findViewById(R.id.error_image).setVisibility(View.GONE); } - + /** - * Enables or disables buttons for a file not locally available - * + * Enables or disables buttons for a file not locally available + *

* Currently, this is only used when a download was failed */ private void setButtonsForRemote() { getView().findViewById(R.id.cancelBtn).setVisibility(View.GONE); - + // hides the progress bar and message getView().findViewById(R.id.progressBar).setVisibility(View.GONE); getView().findViewById(R.id.progressText).setVisibility(View.GONE); @@ -275,7 +281,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene getView().findViewById(R.id.errorText).setVisibility(View.VISIBLE); getView().findViewById(R.id.error_image).setVisibility(View.VISIBLE); } - + public void listenForTransferProgress() { if (mProgressListener != null && !mListening) { @@ -288,8 +294,8 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene } } } - - + + public void leaveTransferProgress() { if (mProgressListener != null) { if (mContainerActivity.getFileDownloaderBinder() != null) { @@ -308,11 +314,11 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene private class ProgressListener implements OnDatatransferProgressListener { int mLastPercent = 0; WeakReference mProgressBar = null; - + ProgressListener(ProgressBar progressBar) { mProgressBar = new WeakReference(progressBar); } - + @Override public void onTransferProgress( long progressRate, long totalTransferredSoFar, long totalToTransfer, String filename @@ -333,8 +339,9 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene public void setError(boolean error) { mError = error; - }; - + } + + ; } diff --git a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java index 7ca1cfbb..6dd18658 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -74,11 +74,11 @@ public class PreviewImageFragment extends FileFragment { private ProgressBar mProgressWheel; public Bitmap mBitmap = null; - + private static final String TAG = PreviewImageFragment.class.getSimpleName(); private boolean mIgnoreFirstSavedState; - + private LoadBitmapTask mLoadBitmapTask = null; @@ -105,7 +105,7 @@ public class PreviewImageFragment extends FileFragment { return frag; } - + /** * Creates an empty fragment for image previews. @@ -119,8 +119,8 @@ public class PreviewImageFragment extends FileFragment { public PreviewImageFragment() { mIgnoreFirstSavedState = false; } - - + + /** * {@inheritDoc} */ @@ -135,14 +135,14 @@ public class PreviewImageFragment extends FileFragment { mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST); setHasOptionsMenu(true); } - + /** * {@inheritDoc} */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.preview_image_fragment, container, false); mImageView = (TouchImageViewCustom) view.findViewById(R.id.image); @@ -182,7 +182,7 @@ public class PreviewImageFragment extends FileFragment { throw new IllegalStateException("There is no local file to preview"); } } - + /** * {@inheritDoc} @@ -192,7 +192,7 @@ public class PreviewImageFragment extends FileFragment { super.onSaveInstanceState(outState); outState.putParcelable(PreviewImageFragment.EXTRA_FILE, getFile()); } - + @Override public void onStart() { @@ -203,8 +203,8 @@ public class PreviewImageFragment extends FileFragment { mLoadBitmapTask.execute(getFile().getStoragePath()); } } - - + + @Override public void onStop() { Log_OC.d(TAG, "onStop starts"); @@ -214,7 +214,7 @@ public class PreviewImageFragment extends FileFragment { } super.onStop(); } - + /** * {@inheritDoc} */ @@ -230,11 +230,11 @@ public class PreviewImageFragment extends FileFragment { @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - + if (mContainerActivity.getStorageManager() != null) { // Update the file setFile(mContainerActivity.getStorageManager().getFileById(getFile().getFileId())); - + FileMenuFilter mf = new FileMenuFilter( getFile(), mContainerActivity.getStorageManager().getAccount(), @@ -243,7 +243,7 @@ public class PreviewImageFragment extends FileFragment { ); mf.filter(menu); } - + // additional restriction for this fragment // TODO allow renaming in PreviewImageFragment MenuItem item = menu.findItem(R.id.action_rename_file); @@ -251,7 +251,7 @@ public class PreviewImageFragment extends FileFragment { item.setVisible(false); item.setEnabled(false); } - + // additional restriction for this fragment // TODO allow refresh file in PreviewImageFragment item = menu.findItem(R.id.action_sync_file); @@ -266,11 +266,17 @@ public class PreviewImageFragment extends FileFragment { item.setVisible(false); item.setEnabled(false); } - + + // additional restriction for this fragment + item = menu.findItem(R.id.action_copy); + if (item != null) { + item.setVisible(false); + item.setEnabled(false); + } + } - - + /** * {@inheritDoc} */ @@ -318,10 +324,10 @@ public class PreviewImageFragment extends FileFragment { return false; } } - + private void seeDetails() { - mContainerActivity.showDetails(getFile()); + mContainerActivity.showDetails(getFile()); } @@ -348,7 +354,7 @@ public class PreviewImageFragment extends FileFragment { super.onDestroy(); } - + /** * Opens the previewed image with an external application. */ @@ -356,8 +362,8 @@ public class PreviewImageFragment extends FileFragment { mContainerActivity.getFileOperationsHelper().openFile(getFile()); finish(); } - - + + private class LoadBitmapTask extends AsyncTask { /** @@ -376,7 +382,7 @@ public class PreviewImageFragment extends FileFragment { */ private final WeakReference mMessageViewRef; - + /** * Weak reference to the target {@link ProgressBar} shown while the load is in progress. * @@ -385,17 +391,17 @@ public class PreviewImageFragment extends FileFragment { */ private final WeakReference mProgressWheelRef; - + /** - * Error message to show when a load fails + * Error message to show when a load fails */ private int mErrorMessageId; - - + + /** * Constructor. - * - * @param imageView Target {@link ImageView} where the bitmap will be loaded into. + * + * @param imageView Target {@link ImageView} where the bitmap will be loaded into. */ public LoadBitmapTask(ImageViewCustom imageView, TextView messageView, ProgressBar progressWheel) { @@ -403,8 +409,8 @@ public class PreviewImageFragment extends FileFragment { mMessageViewRef = new WeakReference(messageView); mProgressWheelRef = new WeakReference(progressWheel); } - - + + @Override protected Bitmap doInBackground(String... params) { Bitmap result = null; @@ -454,18 +460,18 @@ public class PreviewImageFragment extends FileFragment { } catch (NoSuchFieldError e) { mErrorMessageId = R.string.common_error_unknown; - Log_OC.e(TAG, "Error from access to unexisting field despite protection; file " - + storagePath, e); - + Log_OC.e(TAG, "Error from access to unexisting field despite protection; file " + + storagePath, e); + } catch (Throwable t) { mErrorMessageId = R.string.common_error_unknown; Log_OC.e(TAG, "Unexpected error loading " + getFile().getStoragePath(), t); - + } - + return result; } - + @Override protected void onCancelled(Bitmap result) { if (result != null) { @@ -478,7 +484,8 @@ public class PreviewImageFragment extends FileFragment { hideProgressWheel(); if (result != null) { showLoadedImage(result); - } else { + } + else { showErrorMessage(); } if (result != null && mBitmap != result) { @@ -486,7 +493,7 @@ public class PreviewImageFragment extends FileFragment { result.recycle(); } } - + @SuppressLint("InlinedApi") private void showLoadedImage(Bitmap result) { final ImageViewCustom imageView = mImageViewRef.get(); @@ -503,7 +510,7 @@ public class PreviewImageFragment extends FileFragment { messageView.setVisibility(View.GONE); } // else , silently finish, the fragment was destroyed } - + private void showErrorMessage() { final ImageView imageView = mImageViewRef.get(); if (imageView != null) { @@ -517,14 +524,14 @@ public class PreviewImageFragment extends FileFragment { messageView.setVisibility(View.VISIBLE); } // else , silently finish, the fragment was destroyed } - + private void hideProgressWheel() { final ProgressBar progressWheel = mProgressWheelRef.get(); if (progressWheel != null) { progressWheel.setVisibility(View.GONE); } } - + } /** @@ -538,7 +545,7 @@ public class PreviewImageFragment extends FileFragment { return (file != null && file.isImage()); } - + /** * Finishes the preview */ @@ -546,7 +553,7 @@ public class PreviewImageFragment extends FileFragment { Activity container = getActivity(); container.finish(); } - + public TouchImageViewCustom getImageView() { return mImageView; } diff --git a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java index d87b82cb..02aebd0c 100644 --- a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -64,7 +64,7 @@ import com.owncloud.android.ui.fragment.FileFragment; /** * This fragment shows a preview of a downloaded media file (audio or video). - * + * * Trying to get an instance with NULL {@link OCFile} or ownCloud {@link Account} values will * produce an {@link IllegalStateException}. * @@ -84,46 +84,46 @@ public class PreviewMediaFragment extends FileFragment implements private ImageView mImagePreview; private VideoView mVideoPreview; private int mSavedPlaybackPosition; - + private MediaServiceBinder mMediaServiceBinder = null; private MediaControlView mMediaController = null; private MediaServiceConnection mMediaServiceConnection = null; private VideoHelper mVideoHelper; private boolean mAutoplay; public boolean mPrepared; - + private static final String TAG = PreviewMediaFragment.class.getSimpleName(); - + /** * Creates a fragment to preview a file. - * + *

* When 'fileToDetail' or 'ocAccount' are null - * - * @param fileToDetail An {@link OCFile} to preview in the fragment - * @param ocAccount An ownCloud account; needed to start downloads + * + * @param fileToDetail An {@link OCFile} to preview in the fragment + * @param ocAccount An ownCloud account; needed to start downloads */ public PreviewMediaFragment( - OCFile fileToDetail, - Account ocAccount, - int startPlaybackPosition, + OCFile fileToDetail, + Account ocAccount, + int startPlaybackPosition, boolean autoplay) { - + super(fileToDetail); mAccount = ocAccount; mSavedPlaybackPosition = startPlaybackPosition; mAutoplay = autoplay; } - - + + /** - * Creates an empty fragment for previews. - * - * MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically - * (for instance, when the device is turned a aside). - * - * DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful - * construction + * Creates an empty fragment for previews. + *

+ * MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically + * (for instance, when the device is turned a aside). + *

+ * DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful + * construction */ public PreviewMediaFragment() { super(); @@ -131,8 +131,8 @@ public class PreviewMediaFragment extends FileFragment implements mSavedPlaybackPosition = 0; mAutoplay = true; } - - + + /** * {@inheritDoc} */ @@ -141,29 +141,29 @@ public class PreviewMediaFragment extends FileFragment implements super.onCreate(savedInstanceState); setHasOptionsMenu(true); } - + /** * {@inheritDoc} */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); Log_OC.e(TAG, "onCreateView"); - + mView = inflater.inflate(R.layout.file_preview, container, false); - - mImagePreview = (ImageView)mView.findViewById(R.id.image_preview); - mVideoPreview = (VideoView)mView.findViewById(R.id.video_preview); + + mImagePreview = (ImageView) mView.findViewById(R.id.image_preview); + mVideoPreview = (VideoView) mView.findViewById(R.id.video_preview); mVideoPreview.setOnTouchListener(this); - - mMediaController = (MediaControlView)mView.findViewById(R.id.media_controller); - + + mMediaController = (MediaControlView) mView.findViewById(R.id.media_controller); + return mView; } - + /** * {@inheritDoc} @@ -184,30 +184,32 @@ public class PreviewMediaFragment extends FileFragment implements if (!file.isDown()) { throw new IllegalStateException("There is no local file to preview"); } - - } else { - file = (OCFile)savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE); + + } + else { + file = (OCFile) savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE); setFile(file); mAccount = savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_ACCOUNT); - mSavedPlaybackPosition = + mSavedPlaybackPosition = savedInstanceState.getInt(PreviewMediaFragment.EXTRA_PLAY_POSITION); mAutoplay = savedInstanceState.getBoolean(PreviewMediaFragment.EXTRA_PLAYING); - + } if (file != null && file.isDown()) { if (file.isVideo()) { mVideoPreview.setVisibility(View.VISIBLE); mImagePreview.setVisibility(View.GONE); prepareVideo(); - - } else { + + } + else { mVideoPreview.setVisibility(View.GONE); mImagePreview.setVisibility(View.VISIBLE); } } - + } - + /** * {@inheritDoc} @@ -216,24 +218,25 @@ public class PreviewMediaFragment extends FileFragment implements public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); Log_OC.e(TAG, "onSaveInstanceState"); - + outState.putParcelable(PreviewMediaFragment.EXTRA_FILE, getFile()); outState.putParcelable(PreviewMediaFragment.EXTRA_ACCOUNT, mAccount); - + if (getFile().isVideo()) { mSavedPlaybackPosition = mVideoPreview.getCurrentPosition(); mAutoplay = mVideoPreview.isPlaying(); - outState.putInt(PreviewMediaFragment.EXTRA_PLAY_POSITION , mSavedPlaybackPosition); - outState.putBoolean(PreviewMediaFragment.EXTRA_PLAYING , mAutoplay); - } else { + outState.putInt(PreviewMediaFragment.EXTRA_PLAY_POSITION, mSavedPlaybackPosition); + outState.putBoolean(PreviewMediaFragment.EXTRA_PLAYING, mAutoplay); + } + else { outState.putInt( - PreviewMediaFragment.EXTRA_PLAY_POSITION , + PreviewMediaFragment.EXTRA_PLAY_POSITION, mMediaServiceBinder.getCurrentPosition()); outState.putBoolean( - PreviewMediaFragment.EXTRA_PLAYING , mMediaServiceBinder.isPlaying()); + PreviewMediaFragment.EXTRA_PLAYING, mMediaServiceBinder.isPlaying()); } } - + @Override public void onStart() { @@ -242,17 +245,20 @@ public class PreviewMediaFragment extends FileFragment implements OCFile file = getFile(); if (file != null && file.isDown()) { - if (file.isAudio()) { - bindMediaService(); - - } else if (file.isVideo()) { - stopAudio(); - playVideo(); - } + if (file.isAudio()) { + bindMediaService(); + + } + else { + if (file.isVideo()) { + stopAudio(); + playVideo(); + } + } } } - - + + private void stopAudio() { Intent i = new Intent(getActivity(), MediaService.class); i.setAction(MediaService.ACTION_STOP_ALL); @@ -276,7 +282,7 @@ public class PreviewMediaFragment extends FileFragment implements @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); - + if (mContainerActivity.getStorageManager() != null) { FileMenuFilter mf = new FileMenuFilter( getFile(), @@ -301,9 +307,16 @@ public class PreviewMediaFragment extends FileFragment implements item.setVisible(false); item.setEnabled(false); } + + // additional restriction for this fragment + item = menu.findItem(R.id.action_copy); + if (item != null) { + item.setVisible(false); + item.setEnabled(false); + } } - - + + /** * {@inheritDoc} */ @@ -353,26 +366,26 @@ public class PreviewMediaFragment extends FileFragment implements return false; } } - /** * Update the file of the fragment with file value + * * @param file */ - public void updateFile(OCFile file){ + public void updateFile(OCFile file) { setFile(file); } - + private void sendFile() { stopPreview(false); mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile()); - + } private void seeDetails() { stopPreview(false); - mContainerActivity.showDetails(getFile()); + mContainerActivity.showDetails(getFile()); } @@ -383,77 +396,80 @@ public class PreviewMediaFragment extends FileFragment implements mVideoPreview.setOnCompletionListener(mVideoHelper); mVideoPreview.setOnErrorListener(mVideoHelper); } - + @SuppressWarnings("static-access") private void playVideo() { // create and prepare control panel for the user mMediaController.setMediaPlayer(mVideoPreview); - + // load the video file in the video player ; // when done, VideoHelper#onPrepared() will be called Uri uri = Uri.parse(getFile().getStoragePath()); mVideoPreview.setVideoPath(uri.encode(getFile().getStoragePath())); } - + private class VideoHelper implements OnCompletionListener, OnPreparedListener, OnErrorListener { - - /** + + /** * Called when the file is ready to be played. - * + *

* Just starts the playback. - * + * * @param vp {@link MediaPlayer} instance performing the playback. */ @Override public void onPrepared(MediaPlayer vp) { Log_OC.e(TAG, "onPrepared"); mVideoPreview.seekTo(mSavedPlaybackPosition); - if (mAutoplay) { + if (mAutoplay) { mVideoPreview.start(); } mMediaController.setEnabled(true); mMediaController.updatePausePlay(); mPrepared = true; } - - + + /** * Called when the file is finished playing. - * + *

* Finishes the activity. - * - * @param mp {@link MediaPlayer} instance performing the playback. + * + * @param mp {@link MediaPlayer} instance performing the playback. */ @Override - public void onCompletion(MediaPlayer mp) { + public void onCompletion(MediaPlayer mp) { Log_OC.e(TAG, "completed"); if (mp != null) { mVideoPreview.seekTo(0); // next lines are necessary to work around undesired video loops if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD) { - mVideoPreview.pause(); - - } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1) { - // mVideePreview.pause() is not enough - - mMediaController.setEnabled(false); - mVideoPreview.stopPlayback(); - mAutoplay = false; - mSavedPlaybackPosition = 0; - mVideoPreview.setVideoPath(getFile().getStoragePath()); + mVideoPreview.pause(); + + } + else { + if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1) { + // mVideePreview.pause() is not enough + + mMediaController.setEnabled(false); + mVideoPreview.stopPlayback(); + mAutoplay = false; + mSavedPlaybackPosition = 0; + mVideoPreview.setVideoPath(getFile().getStoragePath()); + } } } // else : called from onError() mMediaController.updatePausePlay(); } - - + + /** * Called when an error in playback occurs. - * - * @param mp {@link MediaPlayer} instance performing the playback. - * @param what Type of error - * @param extra Extra code specific to the error + * + * @param mp {@link MediaPlayer} instance performing the playback. + * @param what Type of error + * @param extra Extra code specific to the error */ @Override public boolean onError(MediaPlayer mp, int what, int extra) { @@ -474,28 +490,28 @@ public class PreviewMediaFragment extends FileFragment implements } return true; } - + } - + @Override public void onPause() { Log_OC.e(TAG, "onPause"); super.onPause(); } - + @Override public void onResume() { super.onResume(); Log_OC.e(TAG, "onResume"); } - + @Override public void onDestroy() { Log_OC.e(TAG, "onDestroy"); super.onDestroy(); } - + @Override public void onStop() { Log_OC.e(TAG, "onStop"); @@ -510,10 +526,10 @@ public class PreviewMediaFragment extends FileFragment implements mMediaServiceConnection = null; mMediaServiceBinder = null; } - + super.onStop(); } - + @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN && v == mVideoPreview) { @@ -526,7 +542,7 @@ public class PreviewMediaFragment extends FileFragment implements return false; } - + private void startFullScreenVideo() { Intent i = new Intent(getActivity(), PreviewVideoActivity.class); i.putExtra(FileActivity.EXTRA_ACCOUNT, mAccount); @@ -538,29 +554,30 @@ public class PreviewMediaFragment extends FileFragment implements } @Override - public void onConfigurationChanged (Configuration newConfig) { + public void onConfigurationChanged(Configuration newConfig) { Log_OC.e(TAG, "onConfigurationChanged " + this); } - + @Override - public void onActivityResult (int requestCode, int resultCode, Intent data) { + public void onActivityResult(int requestCode, int resultCode, Intent data) { Log_OC.e(TAG, "onActivityResult " + this); super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { mSavedPlaybackPosition = data.getExtras().getInt( PreviewVideoActivity.EXTRA_START_POSITION); - mAutoplay = data.getExtras().getBoolean(PreviewVideoActivity.EXTRA_AUTOPLAY); + mAutoplay = data.getExtras().getBoolean(PreviewVideoActivity.EXTRA_AUTOPLAY); } } - + private void playAudio() { OCFile file = getFile(); if (!mMediaServiceBinder.isPlaying(file)) { Log_OC.d(TAG, "starting playback of " + file.getStoragePath()); mMediaServiceBinder.start(mAccount, file, mAutoplay, mSavedPlaybackPosition); - - } else { + + } + else { if (!mMediaServiceBinder.isPlaying() && mAutoplay) { mMediaServiceBinder.start(); mMediaController.updatePausePlay(); @@ -597,7 +614,8 @@ public class PreviewMediaFragment extends FileFragment implements Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready"); - } else { + } + else { Log_OC.e(TAG, "Unexpected response from MediaService while binding"); } } @@ -619,7 +637,8 @@ public class PreviewMediaFragment extends FileFragment implements Log_OC.e(TAG, "Media service suddenly disconnected"); if (mMediaController != null) { mMediaController.setMediaPlayer(null); - } else { + } + else { Toast.makeText( getActivity(), "No media controller to release when disconnected from media service", @@ -629,9 +648,8 @@ public class PreviewMediaFragment extends FileFragment implements mMediaServiceConnection = null; } } - } + } - /** * Opens the previewed file with an external application. @@ -641,31 +659,33 @@ public class PreviewMediaFragment extends FileFragment implements mContainerActivity.getFileOperationsHelper().openFile(getFile()); finish(); } - + /** * Helper method to test if an {@link OCFile} can be passed to a {@link PreviewMediaFragment} - * to be previewed. - * - * @param file File to test if can be previewed. - * @return 'True' if the file can be handled by the fragment. + * to be previewed. + * + * @param file File to test if can be previewed. + * @return 'True' if the file can be handled by the fragment. */ public static boolean canBePreviewed(OCFile file) { return (file != null && (file.isAudio() || file.isVideo())); } - + public void stopPreview(boolean stopAudio) { OCFile file = getFile(); if (file.isAudio() && stopAudio) { mMediaServiceBinder.pause(); - - } else if (file.isVideo()) { - mVideoPreview.stopPlayback(); + + } + else { + if (file.isVideo()) { + mVideoPreview.stopPlayback(); + } } } - /** * Finishes the preview */ @@ -681,12 +701,12 @@ public class PreviewMediaFragment extends FileFragment implements Log_OC.e(TAG, "getting position: " + mSavedPlaybackPosition); return mSavedPlaybackPosition; } - + public boolean isPlaying() { if (mPrepared) { mAutoplay = mVideoPreview.isPlaying(); } return mAutoplay; } - + } diff --git a/src/com/owncloud/android/utils/ErrorMessageAdapter.java b/src/com/owncloud/android/utils/ErrorMessageAdapter.java index c86346b3..b80cc573 100644 --- a/src/com/owncloud/android/utils/ErrorMessageAdapter.java +++ b/src/com/owncloud/android/utils/ErrorMessageAdapter.java @@ -206,9 +206,10 @@ public class ErrorMessageAdapter { } } else if (operation instanceof MoveFileOperation) { - if (result.getCode() == ResultCode.FILE_NOT_FOUND) { + if(isNetworkError(result.getCode())){ + message = getErrorMessage(result, res); + } else if (result.getCode() == ResultCode.FILE_NOT_FOUND) { message = res.getString(R.string.move_file_not_found); - } else if (result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT) { message = res.getString(R.string.move_file_invalid_into_descendent); @@ -242,11 +243,11 @@ public class ErrorMessageAdapter { } } } else if (operation instanceof CopyFileOperation) { - - if (result.getCode() == ResultCode.FILE_NOT_FOUND) { + if(isNetworkError(result.getCode())){ + message = getErrorMessage(result, res); + } else if (result.getCode() == ResultCode.FILE_NOT_FOUND) { message = res.getString(R.string.copy_file_not_found); - - } else if (result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT) { + } else if (result.getCode() == ResultCode.INVALID_COPY_INTO_DESCENDANT) { message = res.getString(R.string.copy_file_invalid_into_descendent); } else if (result.getCode() == ResultCode.INVALID_OVERWRITE) {