jabarros 10 жил өмнө
parent
commit
48b3852f7b

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

@@ -743,8 +743,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
      * @param resultCode        Result code received
      */
     private void requestMoveOperation(Intent data, int resultCode) {
-        OCFile folderToMoveAt = (OCFile) data.getParcelableExtra(FolderPickerActivity.EXTRA_CURRENT_FOLDER);
-        OCFile targetFile = (OCFile) data.getParcelableExtra(FolderPickerActivity.EXTRA_TARGET_FILE);
+        OCFile folderToMoveAt = (OCFile) data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
+        OCFile targetFile = (OCFile) data.getParcelableExtra(FolderPickerActivity.EXTRA_FILE);
         getFileOperationsHelper().moveFile(folderToMoveAt, targetFile);
     }
 

+ 10 - 7
src/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -65,10 +65,11 @@ import com.owncloud.android.lib.common.utils.Log_OC;
 public class FolderPickerActivity extends FileActivity implements FileFragment.ContainerActivity, 
     OnClickListener, OnEnforceableRefreshListener {
 
-    public static final String EXTRA_CURRENT_FOLDER = UploadFilesActivity.class.getCanonicalName()
-                                                            + ".EXTRA_CURRENT_FOLDER";
-    public static final String EXTRA_TARGET_FILE = UploadFilesActivity.class.getCanonicalName()
-                                                            + "EXTRA_TARGET_FILE";
+    public static final String EXTRA_FOLDER = UploadFilesActivity.class.getCanonicalName()
+                                                            + ".EXTRA_FOLDER";
+    public static final String EXTRA_FILE = UploadFilesActivity.class.getCanonicalName()
+                                                            + ".EXTRA_FILE";
+    //TODO: Think something better
 
     private SyncBroadcastReceiver mSyncBroadcastReceiver;
 
@@ -367,11 +368,13 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
             finish();
         } else if (v == mChooseBtn) {
             Intent i = getIntent();
-            OCFile targetFile = (OCFile) i.getParcelableExtra(FolderPickerActivity.EXTRA_TARGET_FILE);
+            OCFile targetFile = i.getParcelableExtra(FolderPickerActivity.EXTRA_FILE);
 
             Intent data = new Intent();
-            data.putExtra(EXTRA_CURRENT_FOLDER, getCurrentFolder());
-            data.putExtra(EXTRA_TARGET_FILE, targetFile);
+            data.putExtra(EXTRA_FOLDER, getCurrentFolder());
+            if (targetFile != null) {
+                data.putExtra(EXTRA_FILE, targetFile);
+            }
             setResult(RESULT_OK, data);
             finish();
         }

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

@@ -404,10 +404,9 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         super.onActivityResult(requestCode, resultCode, data);
 
-        if (requestCode == ACTION_SELECT_UPLOAD_PATH && (resultCode == RESULT_OK || 
-                resultCode == UploadPathActivity.RESULT_OK_SET_UPLOAD_PATH)){
+        if (requestCode == ACTION_SELECT_UPLOAD_PATH && resultCode == RESULT_OK){
 
-            OCFile folderToUpload = (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_CURRENT_FOLDER);
+            OCFile folderToUpload = (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER);
 
             mUploadPath = folderToUpload.getRemotePath();
 
@@ -418,10 +417,9 @@ public class Preferences extends SherlockPreferenceActivity implements AccountMa
 
             saveInstantUploadPathOnPreferences();
 
-        } else if (requestCode == ACTION_SELECT_UPLOAD_VIDEO_PATH && (resultCode == RESULT_OK || 
-                resultCode == UploadPathActivity.RESULT_OK_SET_UPLOAD_PATH)){
+        } else if (requestCode == ACTION_SELECT_UPLOAD_VIDEO_PATH && resultCode == RESULT_OK){
 
-            OCFile folderToUploadVideo = (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_CURRENT_FOLDER);
+            OCFile folderToUploadVideo = (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER);
 
             mUploadVideoPath = folderToUploadVideo.getRemotePath();
 

+ 1 - 15
src/com/owncloud/android/ui/activity/UploadPathActivity.java

@@ -18,10 +18,8 @@
 package com.owncloud.android.ui.activity;
 
 import android.accounts.Account;
-import android.content.Intent;
 
 import android.os.Bundle;
-import android.view.View;
 import android.view.View.OnClickListener;
 
 import com.owncloud.android.datamodel.OCFile;
@@ -33,7 +31,6 @@ public class UploadPathActivity extends FolderPickerActivity implements FileFrag
 
     public static final String KEY_INSTANT_UPLOAD_PATH = "INSTANT_UPLOAD_PATH";
 
-    public static final int RESULT_OK_SET_UPLOAD_PATH = 1;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -41,6 +38,7 @@ public class UploadPathActivity extends FolderPickerActivity implements FileFrag
 
         String instantUploadPath = getIntent().getStringExtra(KEY_INSTANT_UPLOAD_PATH);
 
+        // The caller activity (Preferences) is not a FileActivity, so it has no OCFile, only a path.
         OCFile folder = new OCFile(instantUploadPath);
 
         setFile(folder);
@@ -76,16 +74,4 @@ public class UploadPathActivity extends FolderPickerActivity implements FileFrag
             updateNavigationElementsInActionBar();
         }
     }
-
-    @Override
-    public void onClick(View v) {
-        if (v == mCancelBtn) {
-            finish();
-        } else if (v == mChooseBtn) {
-            Intent data = new Intent();
-            data.putExtra(EXTRA_CURRENT_FOLDER, getCurrentFolder());
-            setResult(RESULT_OK_SET_UPLOAD_PATH, data);
-            finish();
-        }
-    }
 }

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

@@ -325,7 +325,7 @@ public class OCFileListFragment extends ExtendedListFragment {
                 Intent action = new Intent(getActivity(), FolderPickerActivity.class);
 
                 // Pass mTargetFile that contains info of selected file/folder
-                action.putExtra(FolderPickerActivity.EXTRA_TARGET_FILE, mTargetFile);
+                action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
                 getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
                 return true;
             }