Эх сурвалжийг харах

Retrying an upload failed due to wrong credentials checks if stored credentials were already updated before asking to the user

David A. Velasco 9 жил өмнө
parent
commit
e181253410

+ 1 - 0
res/values/strings.xml

@@ -245,6 +245,7 @@
     <string name="filename_forbidden_charaters_from_server">File name contains at least one invalid character</string>
     <string name="filename_empty">File name cannot be empty</string>
     <string name="wait_a_moment">Wait a moment</string>
+    <string name="wait_checking_credentials">Checking stored credentials</string>
     <string name="filedisplay_unexpected_bad_get_content">"Unexpected problem ; please select the file from a different app"</string>
     <string name="filedisplay_no_file_selected">No file was selected</string>
     <string name="activity_chooser_title">Send link to &#8230;</string>

+ 3 - 1
src/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -1500,7 +1500,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         OwnCloudClientManagerFactory.getDefaultSingleton().removeClientFor(ocAccount);
 
         setAccountAuthenticatorResult(response);
-        setResult(RESULT_OK);
+        final Intent intent = new Intent();
+        intent.putExtras(response);
+        setResult(RESULT_OK, intent);
 
     }
 

+ 19 - 4
src/com/owncloud/android/files/FileOperationsHelper.java

@@ -235,7 +235,7 @@ public class FileOperationsHelper {
         if (file != null) {
             // TODO check capability?
             mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
-                    getString(R.string.wait_a_moment));
+                getString(R.string.wait_a_moment));
 
             Intent service = new Intent(mFileActivity, OperationsService.class);
             service.setAction(OperationsService.ACTION_CREATE_SHARE_WITH_SHAREE);
@@ -342,8 +342,8 @@ public class FileOperationsHelper {
         SharePasswordDialogFragment dialog =
                 SharePasswordDialogFragment.newInstance(file, createShare);
         dialog.show(
-                mFileActivity.getSupportFragmentManager(),
-                SharePasswordDialogFragment.PASSWORD_FRAGMENT
+            mFileActivity.getSupportFragmentManager(),
+            SharePasswordDialogFragment.PASSWORD_FRAGMENT
         );
     }
 
@@ -456,7 +456,7 @@ public class FileOperationsHelper {
             intent.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
             mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent);
             mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
-                    getString(R.string.wait_a_moment));
+                getString(R.string.wait_a_moment));
             
         } else {
             Intent intent = new Intent(mFileActivity, OperationsService.class);
@@ -611,4 +611,19 @@ public class FileOperationsHelper {
         return false;
     }
 
+    /**
+     * Starts a check of the currenlty stored credentials for the given account.
+     *
+     * @param account       OC account which credentials will be checked.
+     */
+    public void checkCurrentCredentials(Account account) {
+        Intent service = new Intent(mFileActivity, OperationsService.class);
+        service.setAction(OperationsService.ACTION_CHECK_CURRENT_CREDENTIALS);
+        service.putExtra(OperationsService.EXTRA_ACCOUNT, account);
+        mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
+
+        mFileActivity.showLoadingDialog(
+            mFileActivity.getApplicationContext().getString(R.string.wait_checking_credentials)
+        );
+    }
 }

+ 65 - 0
src/com/owncloud/android/operations/CheckCurrentCredentialsOperation.java

@@ -0,0 +1,65 @@
+/**
+ *   ownCloud Android client application
+ *
+ *   @author David A. Velasco
+ *   Copyright (C) 2016 ownCloud Inc.
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.operations;
+
+import android.accounts.Account;
+
+import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.operations.RemoteOperation;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
+import com.owncloud.android.operations.common.SyncOperation;
+
+import java.util.ArrayList;
+
+/**
+ * Checks validity of currently stored credentials for a given OC account
+ */
+public class CheckCurrentCredentialsOperation extends SyncOperation {
+
+    private Account mAccount = null;
+
+    public CheckCurrentCredentialsOperation(Account account) {
+        if (account == null) {
+            throw new IllegalArgumentException("NULL account");
+        }
+        mAccount = account;
+    }
+
+    @Override
+    protected RemoteOperationResult run(OwnCloudClient client) {
+        RemoteOperationResult result = null;
+        if (!getStorageManager().getAccount().name.equals(mAccount.name)) {
+            result = new RemoteOperationResult(new IllegalStateException(
+                "Account to validate is not the account connected to!")
+            );
+        } else {
+            RemoteOperation check = new ExistenceCheckRemoteOperation(OCFile.ROOT_PATH, false);
+            result = check.execute(client);
+            ArrayList<Object> data = new ArrayList<Object>();
+            data.add(mAccount);
+            result.setData(data);
+        }
+        return result;
+    }
+
+}

+ 6 - 0
src/com/owncloud/android/services/OperationsService.java

@@ -52,6 +52,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.shares.ShareType;
 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;
+import com.owncloud.android.operations.CheckCurrentCredentialsOperation;
 import com.owncloud.android.operations.CopyFileOperation;
 import com.owncloud.android.operations.CreateFolderOperation;
 import com.owncloud.android.operations.CreateShareViaLinkOperation;
@@ -113,6 +114,7 @@ public class OperationsService extends Service {
     public static final String ACTION_SYNC_FOLDER = "SYNC_FOLDER";
     public static final String ACTION_MOVE_FILE = "MOVE_FILE";
     public static final String ACTION_COPY_FILE = "COPY_FILE";
+    public static final String ACTION_CHECK_CURRENT_CREDENTIALS = "CHECK_CURRENT_CREDENTIALS";
 
     public static final String ACTION_OPERATION_ADDED = OperationsService.class.getName() +
             ".OPERATION_ADDED";
@@ -689,6 +691,10 @@ public class OperationsService extends Service {
                     String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                     String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH);
                     operation = new CopyFileOperation(remotePath, newParentPath, account);
+
+                } else if (action.equals(ACTION_CHECK_CURRENT_CREDENTIALS)) {
+                    // Check validity of currently stored credentials for a given account
+                    operation = new CheckCurrentCredentialsOperation(account);
                 }
             }
                 

+ 27 - 7
src/com/owncloud/android/ui/activity/FileActivity.java

@@ -111,6 +111,9 @@ public class FileActivity extends AppCompatActivity
     private static final String DIALOG_SHARE_PASSWORD = "DIALOG_SHARE_PASSWORD";
     private static final String KEY_ACTION_BAR_TITLE = "ACTION_BAR_TITLE";
 
+    public static final int REQUEST_CODE__UPDATE_CREDENTIALS = 0;
+    public static final int REQUEST_CODE__LAST_SHARED = REQUEST_CODE__UPDATE_CREDENTIALS;
+
     protected static final long DELAY_TO_REQUEST_OPERATIONS_LATER = 200;
 
     /** OwnCloud {@link Account} where the main {@link OCFile} handled by the activity is located.*/
@@ -732,7 +735,7 @@ public class FileActivity extends AppCompatActivity
 
     /**
      *
-     * @param operation     Removal operation performed.
+     * @param operation     Operation performed.
      * @param result        Result of the removal.
      */
     @Override
@@ -752,7 +755,6 @@ public class FileActivity extends AppCompatActivity
             requestCredentialsUpdate(this);
 
             if (result.getCode() == ResultCode.UNAUTHORIZED) {
-                dismissLoadingDialog();
                 Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result,
                                 operation, getResources()),
                         Toast.LENGTH_LONG);
@@ -799,16 +801,34 @@ public class FileActivity extends AppCompatActivity
      * Invalidates the credentials stored for the current OC account and requests new credentials to the user,
      * navigating to {@link AuthenticatorActivity}
      *
+     * Equivalent to call requestCredentialsUpdate(context, null);
+     *
      * @param context   Android Context needed to access the {@link AccountManager}. Received as a parameter
      *                  to make the method accessible to {@link android.content.BroadcastReceiver}s.
      */
     protected void requestCredentialsUpdate(Context context) {
+        requestCredentialsUpdate(context, null);
+    }
+
+    /**
+     * Invalidates the credentials stored for the given OC account and requests new credentials to the user,
+     * navigating to {@link AuthenticatorActivity}
+     *
+     * @param context   Android Context needed to access the {@link AccountManager}. Received as a parameter
+     *                  to make the method accessible to {@link android.content.BroadcastReceiver}s.
+     * @param account   Stored OC account to request credentials update for. If null, current account will
+     *                  be used.
+     */
+    protected void requestCredentialsUpdate(Context context, Account account) {
 
         try {
             /// step 1 - invalidate credentials of current account
+            if (account == null) {
+                account = getAccount();
+            }
             OwnCloudClient client;
             OwnCloudAccount ocAccount =
-                    new OwnCloudAccount(getAccount(), context);
+                    new OwnCloudAccount(account, context);
             client = (OwnCloudClientManagerFactory.getDefaultSingleton().
                     removeClientFor(ocAccount));
             if (client != null) {
@@ -817,23 +837,23 @@ public class FileActivity extends AppCompatActivity
                     AccountManager am = AccountManager.get(context);
                     if (cred.authTokenExpires()) {
                         am.invalidateAuthToken(
-                                getAccount().type,
+                                account.type,
                                 cred.getAuthToken()
                         );
                     } else {
-                        am.clearPassword(getAccount());
+                        am.clearPassword(account);
                     }
                 }
             }
 
             /// step 2 - request credentials to user
             Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
-            updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount());
+            updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);
             updateAccountCredentials.putExtra(
                     AuthenticatorActivity.EXTRA_ACTION,
                     AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN);
             updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
-            startActivity(updateAccountCredentials);
+            startActivityForResult(updateAccountCredentials, REQUEST_CODE__UPDATE_CREDENTIALS);
 
         } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
             Toast.makeText(context, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();

+ 8 - 12
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -83,7 +83,6 @@ import com.owncloud.android.operations.UploadFileOperation;
 import com.owncloud.android.services.observer.FileObserverService;
 import com.owncloud.android.syncadapter.FileSyncAdapter;
 import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
-import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
 import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;
 import com.owncloud.android.ui.fragment.FileDetailFragment;
@@ -124,15 +123,12 @@ public class FileDisplayActivity extends HookActivity implements
     private static final String KEY_SYNC_IN_PROGRESS = "SYNC_IN_PROGRESS";
     private static final String KEY_WAITING_TO_SEND = "WAITING_TO_SEND";
 
-    public static final int DIALOG_SHORT_WAIT = 0;
-    private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 1;
-
     public static final String ACTION_DETAILS = "com.owncloud.android.ui.activity.action.DETAILS";
 
-    public static final int ACTION_SELECT_CONTENT_FROM_APPS = 1;
-    public static final int ACTION_SELECT_MULTIPLE_FILES = 2;
-    public static final int ACTION_MOVE_FILES = 3;
-    public static final int ACTION_COPY_FILES = 4;
+    public static final int REQUEST_CODE__SELECT_CONTENT_FROM_APPS = REQUEST_CODE__LAST_SHARED + 1;
+    public static final int REQUEST_CODE__SELECT_MULTIPLE_FILES = REQUEST_CODE__LAST_SHARED + 2;
+    public static final int REQUEST_CODE__MOVE_FILES = REQUEST_CODE__LAST_SHARED + 3;
+    public static final int REQUEST_CODE__COPY_FILES = REQUEST_CODE__LAST_SHARED + 4;
 
     private static final String TAG = FileDisplayActivity.class.getSimpleName();
 
@@ -653,7 +649,7 @@ public class FileDisplayActivity extends HookActivity implements
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
 
-        if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK ||
+        if (requestCode == REQUEST_CODE__SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK ||
                 resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
 
             //getClipData is only supported on api level 16+, Jelly Bean
@@ -670,11 +666,11 @@ public class FileDisplayActivity extends HookActivity implements
             } else {
                 requestSimpleUpload(data, resultCode);
             }
-        } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES && (resultCode == RESULT_OK ||
+        } else if (requestCode == REQUEST_CODE__SELECT_MULTIPLE_FILES && (resultCode == RESULT_OK ||
                 resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
             requestMultipleUpload(data, resultCode);
 
-        } else if (requestCode == ACTION_MOVE_FILES && resultCode == RESULT_OK) {
+        } else if (requestCode == REQUEST_CODE__MOVE_FILES && resultCode == RESULT_OK) {
             final Intent fData = data;
             final int fResultCode = resultCode;
             getHandler().postDelayed(
@@ -687,7 +683,7 @@ public class FileDisplayActivity extends HookActivity implements
                     DELAY_TO_REQUEST_OPERATIONS_LATER
             );
 
-        } else if (requestCode == ACTION_COPY_FILES && resultCode == RESULT_OK) {
+        } else if (requestCode == REQUEST_CODE__COPY_FILES && resultCode == RESULT_OK) {
 
             final Intent fData = data;
             final int fResultCode = resultCode;

+ 44 - 6
src/com/owncloud/android/ui/activity/UploadListActivity.java

@@ -21,6 +21,8 @@
  */
 package com.owncloud.android.ui.activity;
 
+import android.accounts.Account;
+import android.accounts.AccountManager;
 import android.content.ActivityNotFoundException;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
@@ -39,13 +41,17 @@ import android.view.MenuItem;
 import android.widget.Toast;
 
 import com.owncloud.android.R;
+import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.datamodel.UploadsStorageManager;
 import com.owncloud.android.db.OCUpload;
 import com.owncloud.android.db.UploadResult;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
+import com.owncloud.android.lib.common.operations.RemoteOperation;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.operations.CheckCurrentCredentialsOperation;
 import com.owncloud.android.ui.fragment.UploadListFragment;
 import com.owncloud.android.utils.MimetypeIconUtil;
 
@@ -63,8 +69,6 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
 
     private static final String TAG_UPLOAD_LIST_FRAGMENT = "UPLOAD_LIST_FRAGMENT";
 
-    public static final int UPDATE_CREDENTIALS_REQUEST_CODE = 100;
-
     private UploadMessagesReceiver mUploadMessagesReceiver;
 
     @Override
@@ -223,14 +227,48 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
-        Log_OC.e(TAG, "onActivityResult " + resultCode);
-        if (requestCode == UPDATE_CREDENTIALS_REQUEST_CODE && resultCode == RESULT_OK) {
-            // Retry uploads of this account
+        if (requestCode == FileActivity.REQUEST_CODE__UPDATE_CREDENTIALS && resultCode == RESULT_OK) {
+            // Retry uploads of the updated account
+            Account account = AccountUtils.getOwnCloudAccountByName(
+                this,
+                data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME)
+            );
             FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
-            requester.retryFailedUploads(this, getAccount(), UploadResult.CREDENTIAL_ERROR);
+            requester.retryFailedUploads(
+                this,
+                account,
+                UploadResult.CREDENTIAL_ERROR
+            );
+        }
+    }
+
+    /**
+     *
+     * @param operation     Operation performed.
+     * @param result        Result of the removal.
+     */
+    @Override
+    public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
+        if (operation instanceof CheckCurrentCredentialsOperation) {
+            // Do not call super in this case; more refactoring needed around onRemoteOeprationFinish :'(
+            getFileOperationsHelper().setOpIdWaitingFor(Long.MAX_VALUE);
+            dismissLoadingDialog();
+            Account account = (Account) result.getData().get(0);
+            if (!result.isSuccess()) {
+                requestCredentialsUpdate(this, account);
+
+            } else {
+                // already updated -> just retry!
+                FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
+                requester.retryFailedUploads(this, account, UploadResult.CREDENTIAL_ERROR);
+            }
+
+        } else {
+            super.onRemoteOperationFinish(operation, result);
         }
     }
 
+
     @Override
     protected ServiceConnection newTransferenceServiceConnection() {
         return new UploadListServiceConnection();

+ 4 - 4
src/com/owncloud/android/ui/activity/Uploader.java

@@ -121,7 +121,7 @@ public class Uploader extends FileActivity
     private final static int DIALOG_NO_STREAM = 2;
     private final static int DIALOG_MULTIPLE_ACCOUNT = 3;
 
-    private final static int REQUEST_CODE_SETUP_ACCOUNT = 0;
+    private final static int REQUEST_CODE__SETUP_ACCOUNT = REQUEST_CODE__LAST_SHARED + 1;
 
     private final static String KEY_PARENTS = "PARENTS";
     private final static String KEY_FILE = "FILE";
@@ -261,7 +261,7 @@ public class Uploader extends FileActivity
                         // and Settings.EXTRA_AUTHORITIES
                         Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
                         intent.putExtra("authorities", new String[]{MainApp.getAuthTokenType()});
-                        startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT);
+                        startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
                     } else {
                         // since in API7 there is no direct call for
                         // account setup, so we need to
@@ -269,7 +269,7 @@ public class Uploader extends FileActivity
                         // desired results and setup
                         // everything for ourself
                         Intent intent = new Intent(getBaseContext(), AccountAuthenticator.class);
-                        startActivityForResult(intent, REQUEST_CODE_SETUP_ACCOUNT);
+                        startActivityForResult(intent, REQUEST_CODE__SETUP_ACCOUNT);
                     }
                 }
             });
@@ -406,7 +406,7 @@ public class Uploader extends FileActivity
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
         Log_OC.i(TAG, "result received. req: " + requestCode + " res: " + resultCode);
-        if (requestCode == REQUEST_CODE_SETUP_ACCOUNT) {
+        if (requestCode == REQUEST_CODE__SETUP_ACCOUNT) {
             dismissDialog(DIALOG_NO_ACCOUNT);
             if (resultCode == RESULT_CANCELED) {
                 finish();

+ 3 - 13
src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java

@@ -354,19 +354,9 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
                     view.setOnClickListener(new OnClickListener() {
                         @Override
                         public void onClick(View v) {
-                            // let the user update credentials with one click
-                            Intent updateAccountCredentials = new Intent(mParentActivity,
-                                AuthenticatorActivity.class);
-                            updateAccountCredentials.putExtra(
-                                AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount
-                                    (mParentActivity));
-                            updateAccountCredentials.putExtra(
-                                AuthenticatorActivity.EXTRA_ACTION,
-                                AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN);
-                            updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
-                            updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
-                            mParentActivity.startActivityForResult(updateAccountCredentials,
-                                UploadListActivity.UPDATE_CREDENTIALS_REQUEST_CODE);
+                            mParentActivity.getFileOperationsHelper().checkCurrentCredentials(
+                                upload.getAccount(mParentActivity)
+                            );
                         }
                     });
 

+ 3 - 3
src/com/owncloud/android/ui/dialog/UploadSourceDialogFragment.java

@@ -77,12 +77,12 @@ public class UploadSourceDialogFragment extends DialogFragment {
                             UploadFilesActivity.EXTRA_ACCOUNT,
                             ((FileActivity)getActivity()).getAccount()
                     );
-                    //startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES);
+                    //startActivityForResult(action, REQUEST_CODE__SELECT_MULTIPLE_FILES);
                     // this flow seems broken;
                     // Actionbarsherlock, maybe?
                     getActivity().startActivityForResult(
                             action,
-                            FileDisplayActivity.ACTION_SELECT_MULTIPLE_FILES
+                            FileDisplayActivity.REQUEST_CODE__SELECT_MULTIPLE_FILES
                     );
 
                 } else if (item == 1) {
@@ -94,7 +94,7 @@ public class UploadSourceDialogFragment extends DialogFragment {
                     }
                     getActivity().startActivityForResult(
                             Intent.createChooser(action, getString(R.string.upload_chooser_title)),
-                            FileDisplayActivity.ACTION_SELECT_CONTENT_FROM_APPS
+                            FileDisplayActivity.REQUEST_CODE__SELECT_CONTENT_FROM_APPS
                     );
                 }
             }

+ 4 - 4
src/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -229,7 +229,7 @@ public class OCFileListFragment extends ExtendedListFragment
             @Override
             public void onClick(View v) {
                 UploadFilesActivity.startUploadActivityForResult(getActivity(), ((FileActivity)getActivity())
-                        .getAccount(), FileDisplayActivity.ACTION_SELECT_MULTIPLE_FILES);
+                        .getAccount(), FileDisplayActivity.REQUEST_CODE__SELECT_MULTIPLE_FILES);
                 getFabMain().collapse();
                 recordMiniFabClick();
             }
@@ -285,7 +285,7 @@ public class OCFileListFragment extends ExtendedListFragment
                 }
                 getActivity().startActivityForResult(
                         Intent.createChooser(action, getString(R.string.upload_chooser_title)),
-                        FileDisplayActivity.ACTION_SELECT_CONTENT_FROM_APPS
+                        FileDisplayActivity.REQUEST_CODE__SELECT_CONTENT_FROM_APPS
                 );
                 getFabMain().collapse();
                 recordMiniFabClick();
@@ -586,7 +586,7 @@ public class OCFileListFragment extends ExtendedListFragment
 
                 // Pass mTargetFile that contains info of selected file/folder
                 action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
-                getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
+                getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__MOVE_FILES);
                 return true;
             }
             case R.id.action_favorite_file: {
@@ -602,7 +602,7 @@ public class OCFileListFragment extends ExtendedListFragment
 
                 // Pass mTargetFile that contains info of selected file/folder
                 action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
-                getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES);
+                getActivity().startActivityForResult(action, FileDisplayActivity.REQUEST_CODE__COPY_FILES);
                 return true;
             default:
                 return false;

+ 1 - 1
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java

@@ -557,7 +557,7 @@ public class PreviewMediaFragment extends FileFragment implements
         i.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, mVideoPreview.isPlaying());
         mVideoPreview.pause();
         i.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, mVideoPreview.getCurrentPosition());
-        startActivityForResult(i, 0);
+        startActivityForResult(i, FileActivity.REQUEST_CODE__LAST_SHARED + 1);
     }
 
     @Override