浏览代码

Removed unused and commented code

jabarros 9 年之前
父节点
当前提交
49bcfd04a3

+ 0 - 145
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -728,14 +728,10 @@ public class FileDisplayActivity extends HookActivity
 
 
     private void requestSimpleUpload(final Intent data, int resultCode) {
-       /* String filePath = null;
-        String mimeType = null;*/
-
 
         int behaviour = (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) ? FileUploader.LOCAL_BEHAVIOUR_MOVE :
                 FileUploader.LOCAL_BEHAVIOUR_COPY;
 
-
         ArrayList<Parcelable> mStreamsToUpload = new ArrayList<Parcelable>() {{
             add(data.getData());
         }};
@@ -752,147 +748,6 @@ public class FileDisplayActivity extends HookActivity
 
         uploader.uploadUris();
 
-
-        /*Uri selectedFileUri = data.getData();
-
-        try {
-            mimeType = getContentResolver().getType(selectedFileUri);
-
-            String fileManagerString = selectedFileUri.getPath();
-            String selectedFilePath = UriUtils.getLocalPath(selectedFileUri, this);
-
-            if (selectedFilePath != null)
-                filePath = selectedFilePath;
-            else
-                filePath = fileManagerString;
-
-        } catch (Exception e) {
-            Log_OC.e(TAG, "Unexpected exception when trying to read the result of " +
-                    "Intent.ACTION_GET_CONTENT", e);
-
-        } finally {
-            if (filePath == null) {
-                Log_OC.e(TAG, "Couldn't resolve path to file");
-                Toast t = Toast.makeText(
-                        this, getString(R.string.filedisplay_unexpected_bad_get_content),
-                        Toast.LENGTH_LONG
-                );
-                t.show();
-                return;
-            }
-        }*/
-
-
-
-       /* Uri selectedFileUri = data.getData();
-
-        try {
-            mimeType = getContentResolver().getType(selectedFileUri);
-
-            String fileManagerString = selectedFileUri.getPath();
-            String selectedFilePath = UriUtils.getLocalPath(selectedFileUri, this);
-
-            if (selectedFilePath != null)
-                filePath = selectedFilePath;
-            else
-                filePath = fileManagerString;
-
-        } catch (Exception e) {
-            Log_OC.e(TAG, "Unexpected exception when trying to read the result of " +
-                    "Intent.ACTION_GET_CONTENT", e);
-
-        } finally {
-            if (filePath == null) {
-                Log_OC.e(TAG, "Couldn't resolve path to file");
-                Toast t = Toast.makeText(
-                        this, getString(R.string.filedisplay_unexpected_bad_get_content),
-                        Toast.LENGTH_LONG
-                );
-                t.show();
-                return;
-            }
-        }
-
-        Intent i = new Intent(this, FileUploader.class);
-        i.putExtra(FileUploader.KEY_ACCOUNT,
-                getAccount());
-        OCFile currentDir = getCurrentDir();
-        String remotePath = (currentDir != null) ? currentDir.getRemotePath() : OCFile.ROOT_PATH;
-
-        if (selectedFileUri.toString().startsWith(UriUtils.URI_CONTENT_SCHEME)) {
-            Cursor cursor = getContentResolver().query(selectedFileUri, null, null, null, null);
-            try {
-                if (cursor != null && cursor.moveToFirst()) {
-                    String displayName = cursor.getString(cursor.getColumnIndex(
-                            OpenableColumns.DISPLAY_NAME));
-                    Log_OC.v(TAG, "Display Name: " + displayName);
-
-                    displayName = displayName.replace(File.separatorChar, '_');
-
-                    remotePath += displayName;
-
-                    // Check if extension is not included in file display name and add file extension
-                    int pos = displayName.lastIndexOf('.');
-                    if (pos < 0) {
-                        remotePath += DisplayUtils.getFileExtension(filePath);
-                    }
-
-                    // URi and remote path parameters
-                    Uri[] uris = new Uri[]{selectedFileUri};
-                    String[] remotePaths = new String[]{remotePath};;
-
-                    // Call to copy and then upload the selected file
-                    copyThenUpload(uris, remotePaths);
-
-                    cursor.close();
-                    return;
-
-                } else {
-                    Toast.makeText(this, R.string.uploader_error_message_no_file_to_upload,
-                            Toast.LENGTH_SHORT).show();
-                }
-                // and what happens in case of error?; wrong target name for the upload
-            } catch (Exception e) {
-                Log_OC.e(TAG, "Error while trying to copy and upload a schema type content file ", e);
-                Toast.makeText(this, R.string.common_error_unknown, Toast.LENGTH_SHORT).show();
-            }
-        } else {
-            remotePath += new File(filePath).getName();
-        }
-
-        int behaviour = (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE) ? FileUploader.LOCAL_BEHAVIOUR_MOVE :
-                FileUploader.LOCAL_BEHAVIOUR_COPY;
-        FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
-        requester.uploadNewFile(
-                this,
-                getAccount(),
-                filePath,
-                remotePath,
-                behaviour,
-                mimeType,
-                false,          // do not create parent folder if not existent
-                UploadFileOperation.CREATED_BY_USER
-        );*/
-
-    }
-
-    /**
-     * Call asyncTask to copy passed files from uris in temporal files
-     *
-     * @param sourceUris        Array of content:// URIs to the files to upload
-     * @param remotePaths       Array of absolute paths to set to the uploaded files
-     */
-    private void copyThenUpload(Uri[] sourceUris, String[] remotePaths) {
-
-        CopyAndUploadContentUrisTask copyTask = new CopyAndUploadContentUrisTask(this, getApplicationContext());
-        copyTask.execute(
-                CopyAndUploadContentUrisTask.makeParamsToExecute(
-                        getAccount(),
-                        sourceUris,
-                        remotePaths,
-                        getContentResolver()
-                )
-        );
     }
 
     /**

+ 1 - 145
src/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

@@ -505,126 +505,8 @@ public class ReceiveExternalFilesActivity extends FileActivity
                     messageResTitle
             );
         }
-
-
-        /*try {
-
-            List<Uri> contentUris = new ArrayList<>();
-            List<String> contentRemotePaths = new ArrayList<>();
-
-            int schemeFileCounter = 0;
-
-            for (Parcelable sourceStream : mStreamsToUpload) {
-                Uri sourceUri = (Uri) sourceStream;
-                if (sourceUri != null) {
-                    String displayName = UriUtils.getDisplayNameForUri(sourceUri, this);
-                    if (displayName == null) {
-                        displayName = generateDiplayName();
-                    }
-                    String remotePath = mUploadPath + displayName;
-
-                    if (ContentResolver.SCHEME_CONTENT.equals(sourceUri.getScheme())) {
-                        contentUris.add(sourceUri);
-                        contentRemotePaths.add(remotePath);
-
-                    } else if (ContentResolver.SCHEME_FILE.equals(sourceUri.getScheme())) {
-                        /// file: uris should point to a local file, should be safe let FileUploader handle them
-                        requestUpload(sourceUri.getPath(), remotePath);
-                        schemeFileCounter++;
-                    }
-                }
-            }
-
-            if (!contentUris.isEmpty()) {
-                /// content: uris will be copied to temporary files before calling {@link FileUploader}
-                copyThenUpload(contentUris.toArray(new Uri[contentUris.size()]),
-                    contentRemotePaths.toArray(new String[contentRemotePaths.size()]));
-
-            } else if (schemeFileCounter == 0) {
-                showErrorDialog(
-                    R.string.uploader_error_message_no_file_to_upload,
-                    R.string.uploader_error_title_no_file_to_upload
-                );
-
-            } else {
-                finish();
-            }
-
-        } catch (SecurityException e) {
-            Log_OC.e(TAG, "Permissions fail", e);
-            showErrorDialog(
-                R.string.uploader_error_message_read_permission_not_granted,
-                R.string.uploader_error_title_file_cannot_be_uploaded
-            );
-
-        } catch (Exception e) {
-            Log_OC.e(TAG, "Unexpted error", e);
-            showErrorDialog(
-                R.string.common_error_unknown,
-                R.string.uploader_error_title_file_cannot_be_uploaded
-            );
-
-        } finally {
-            // Save the path to shared preferences; even if upload is not possible, user chose the folder
-            PreferenceManager.setLastUploadPath(mUploadPath, this);
-        }*/
-    }
-
-
-    private String generateDiplayName() {
-        return getString(R.string.common_unknown) +
-            "-" + DisplayUtils.unixTimeToHumanReadable(System.currentTimeMillis());
     }
 
-    /**
-     *
-     * @param sourceUris        Array of content:// URIs to the files to upload
-     * @param remotePaths       Array of absolute paths to set to the uploaded files
-     */
-    private void copyThenUpload(Uri[] sourceUris, String[] remotePaths) {
-        showWaitingCopyDialog();
-
-        CopyAndUploadContentUrisTask copyTask = new CopyAndUploadContentUrisTask(this, this);
-        FragmentManager fm = getSupportFragmentManager();
-        TaskRetainerFragment taskRetainerFragment =
-            (TaskRetainerFragment) fm.findFragmentByTag(FTAG_TASK_RETAINER_FRAGMENT);
-        taskRetainerFragment.setTask(copyTask);
-        copyTask.execute(
-            CopyAndUploadContentUrisTask.makeParamsToExecute(
-                getAccount(),
-                sourceUris,
-                remotePaths,
-                getContentResolver()
-            )
-        );
-    }
-
-    /**
-     * Requests the upload of a file in the local file system to {@link FileUploader} service.
-     *
-     * The original file will be left in its original location, and will not be duplicated.
-     * As a side effect, the user will see the file as not uploaded when accesses to the OC app.
-     * This is considered as acceptable, since when a file is shared from another app to OC,
-     * the usual workflow will go back to the original app.
-     *
-     * @param localPath     Absolute path in the local file system to the file to upload.
-     * @param remotePath    Absolute path in the current OC account to set to the uploaded file.
-     */
-    private void requestUpload(String localPath, String remotePath) {
-        FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
-        requester.uploadNewFile(
-            this,
-            getAccount(),
-            localPath,
-            remotePath,
-            FileUploader.LOCAL_BEHAVIOUR_FORGET,
-            null,       // MIME type will be detected from file name
-            false,      // do not create parent folder if not existent
-            UploadFileOperation.CREATED_BY_USER
-        );
-    }
-
-
     @Override
     public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
         super.onRemoteOperationFinish(operation, result);
@@ -831,32 +713,6 @@ public class ReceiveExternalFilesActivity extends FileActivity
         finish();
     }
 
-    /**
-     * Show waiting for copy dialog
-     */
-    public void showWaitingCopyDialog() {
-        // Construct dialog
-        LoadingDialog loading = new LoadingDialog(
-                getResources().getString(R.string.wait_for_tmp_copy_from_private_storage));
-        FragmentManager fm = getSupportFragmentManager();
-        FragmentTransaction ft = fm.beginTransaction();
-        loading.show(ft, DIALOG_WAIT_COPY_FILE);
-
-    }
-
-
-    /**
-     * Dismiss waiting for copy dialog
-     */
-    public void dismissWaitingCopyDialog() {
-        Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_COPY_FILE);
-        if (frag != null) {
-            LoadingDialog loading = (LoadingDialog) frag;
-            loading.dismiss();
-        }
-    }
-
-
     /**
      * Show an error dialog, forcing the user to click a single button to exit the activity
      *
@@ -864,7 +720,7 @@ public class ReceiveExternalFilesActivity extends FileActivity
      * @param messageResTitle   Resource id of the title to show in the dialog. 0 to show default alert message.
      *                          -1 to show no title.
      */
-    public void showErrorDialog(int messageResId, int messageResTitle) {
+    private void showErrorDialog(int messageResId, int messageResTitle) {
 
         ConfirmationDialogFragment errorDialog = ConfirmationDialogFragment.newInstance(
             messageResId,