|
@@ -29,6 +29,7 @@ import android.content.Intent;
|
|
|
import android.content.IntentFilter;
|
|
|
import android.content.res.Resources.NotFoundException;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Parcelable;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.support.v4.app.FragmentTransaction;
|
|
|
import android.util.Log;
|
|
@@ -52,6 +53,7 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundExce
|
|
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
|
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
|
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
|
|
+import com.owncloud.android.lib.common.utils.Log_OC;
|
|
|
import com.owncloud.android.operations.CreateFolderOperation;
|
|
|
import com.owncloud.android.operations.SynchronizeFolderOperation;
|
|
|
import com.owncloud.android.syncadapter.FileSyncAdapter;
|
|
@@ -60,26 +62,26 @@ import com.owncloud.android.ui.fragment.FileFragment;
|
|
|
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
|
|
import com.owncloud.android.utils.DisplayUtils;
|
|
|
import com.owncloud.android.utils.ErrorMessageAdapter;
|
|
|
-import com.owncloud.android.lib.common.utils.Log_OC;
|
|
|
|
|
|
-public class MoveActivity extends HookActivity implements FileFragment.ContainerActivity,
|
|
|
+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
|
|
|
|
|
|
- public static final int RESULT_OK_AND_MOVE = 1;
|
|
|
-
|
|
|
private SyncBroadcastReceiver mSyncBroadcastReceiver;
|
|
|
|
|
|
- private static final String TAG = MoveActivity.class.getSimpleName();
|
|
|
+ private static final String TAG = FolderPickerActivity.class.getSimpleName();
|
|
|
|
|
|
private static final String TAG_LIST_OF_FOLDERS = "LIST_OF_FOLDERS";
|
|
|
|
|
|
private boolean mSyncInProgress = false;
|
|
|
|
|
|
- private Button mCancelBtn;
|
|
|
- private Button mChooseBtn;
|
|
|
+ protected Button mCancelBtn;
|
|
|
+ protected Button mChooseBtn;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -89,7 +91,7 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
- setContentView(R.layout.files_move);
|
|
|
+ setContentView(R.layout.files_folder_picker);
|
|
|
|
|
|
if (savedInstanceState == null) {
|
|
|
createFragments();
|
|
@@ -118,11 +120,6 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
getSupportActionBar().setIcon(DisplayUtils.getSeasonalIconId());
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- protected void onDestroy() {
|
|
|
- super.onDestroy();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Called when the ownCloud {@link Account} associated to the Activity was just updated.
|
|
|
*/
|
|
@@ -180,8 +177,8 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private OCFileListFragment getListOfFilesFragment() {
|
|
|
- Fragment listOfFiles = getSupportFragmentManager().findFragmentByTag(MoveActivity.TAG_LIST_OF_FOLDERS);
|
|
|
+ protected OCFileListFragment getListOfFilesFragment() {
|
|
|
+ Fragment listOfFiles = getSupportFragmentManager().findFragmentByTag(FolderPickerActivity.TAG_LIST_OF_FOLDERS);
|
|
|
if (listOfFiles != null) {
|
|
|
return (OCFileListFragment)listOfFiles;
|
|
|
}
|
|
@@ -267,6 +264,8 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
menu.findItem(R.id.action_upload).setVisible(false);
|
|
|
menu.findItem(R.id.action_settings).setVisible(false);
|
|
|
menu.findItem(R.id.action_sync_account).setVisible(false);
|
|
|
+ menu.findItem(R.id.action_logger).setVisible(false);
|
|
|
+ menu.findItem(R.id.action_sort).setVisible(false);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -296,7 +295,7 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
- private OCFile getCurrentFolder() {
|
|
|
+ protected OCFile getCurrentFolder() {
|
|
|
OCFile file = getFile();
|
|
|
if (file != null) {
|
|
|
if (file.isFolder()) {
|
|
@@ -341,7 +340,7 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void updateNavigationElementsInActionBar() {
|
|
|
+ protected void updateNavigationElementsInActionBar() {
|
|
|
ActionBar actionBar = getSupportActionBar();
|
|
|
OCFile currentDir = getCurrentFolder();
|
|
|
boolean atRoot = (currentDir == null || currentDir.getParentId() == 0);
|
|
@@ -358,9 +357,9 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
* Set per-view controllers
|
|
|
*/
|
|
|
private void initControls(){
|
|
|
- mCancelBtn = (Button) findViewById(R.id.move_files_btn_cancel);
|
|
|
+ mCancelBtn = (Button) findViewById(R.id.folder_picker_btn_cancel);
|
|
|
mCancelBtn.setOnClickListener(this);
|
|
|
- mChooseBtn = (Button) findViewById(R.id.move_files_btn_choose);
|
|
|
+ mChooseBtn = (Button) findViewById(R.id.folder_picker_btn_choose);
|
|
|
mChooseBtn.setOnClickListener(this);
|
|
|
}
|
|
|
|
|
@@ -370,12 +369,14 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
finish();
|
|
|
} else if (v == mChooseBtn) {
|
|
|
Intent i = getIntent();
|
|
|
- OCFile targetFile = (OCFile) i.getParcelableExtra(MoveActivity.EXTRA_TARGET_FILE);
|
|
|
+ Parcelable targetFile = i.getParcelableExtra(FolderPickerActivity.EXTRA_FILE);
|
|
|
|
|
|
Intent data = new Intent();
|
|
|
- data.putExtra(EXTRA_CURRENT_FOLDER, getCurrentFolder());
|
|
|
- data.putExtra(EXTRA_TARGET_FILE, targetFile);
|
|
|
- setResult(RESULT_OK_AND_MOVE, data);
|
|
|
+ data.putExtra(EXTRA_FOLDER, getCurrentFolder());
|
|
|
+ if (targetFile != null) {
|
|
|
+ data.putExtra(EXTRA_FILE, targetFile);
|
|
|
+ }
|
|
|
+ setResult(RESULT_OK, data);
|
|
|
finish();
|
|
|
}
|
|
|
}
|
|
@@ -409,7 +410,7 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
} else {
|
|
|
dismissLoadingDialog();
|
|
|
try {
|
|
|
- Toast msg = Toast.makeText(MoveActivity.this,
|
|
|
+ Toast msg = Toast.makeText(FolderPickerActivity.this,
|
|
|
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
|
|
|
Toast.LENGTH_LONG);
|
|
|
msg.show();
|
|
@@ -434,8 +435,10 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
Log_OC.d(TAG, "Received broadcast " + event);
|
|
|
String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME);
|
|
|
String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH);
|
|
|
- RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncAdapter.EXTRA_RESULT);
|
|
|
- boolean sameAccount = (getAccount() != null && accountName.equals(getAccount().name) && getStorageManager() != null);
|
|
|
+ RemoteOperationResult synchResult = (RemoteOperationResult)intent.
|
|
|
+ getSerializableExtra(FileSyncAdapter.EXTRA_RESULT);
|
|
|
+ boolean sameAccount = (getAccount() != null &&
|
|
|
+ accountName.equals(getAccount().name) && getStorageManager() != null);
|
|
|
|
|
|
if (sameAccount) {
|
|
|
|
|
@@ -443,13 +446,17 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
mSyncInProgress = true;
|
|
|
|
|
|
} else {
|
|
|
- OCFile currentFile = (getFile() == null) ? null : getStorageManager().getFileByPath(getFile().getRemotePath());
|
|
|
- OCFile currentDir = (getCurrentFolder() == null) ? null : getStorageManager().getFileByPath(getCurrentFolder().getRemotePath());
|
|
|
+ OCFile currentFile = (getFile() == null) ? null :
|
|
|
+ getStorageManager().getFileByPath(getFile().getRemotePath());
|
|
|
+ OCFile currentDir = (getCurrentFolder() == null) ? null :
|
|
|
+ getStorageManager().getFileByPath(getCurrentFolder().getRemotePath());
|
|
|
|
|
|
if (currentDir == null) {
|
|
|
// current folder was removed from the server
|
|
|
- Toast.makeText( MoveActivity.this,
|
|
|
- String.format(getString(R.string.sync_current_folder_was_removed), getCurrentFolder().getFileName()),
|
|
|
+ Toast.makeText( FolderPickerActivity.this,
|
|
|
+ String.format(
|
|
|
+ getString(R.string.sync_current_folder_was_removed),
|
|
|
+ getCurrentFolder().getFileName()),
|
|
|
Toast.LENGTH_LONG)
|
|
|
.show();
|
|
|
browseToRoot();
|
|
@@ -460,7 +467,8 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
currentFile = currentDir;
|
|
|
}
|
|
|
|
|
|
- if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) {
|
|
|
+ if (synchFolderRemotePath != null && currentDir.getRemotePath().
|
|
|
+ equals(synchFolderRemotePath)) {
|
|
|
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
|
|
if (fileListFragment != null) {
|
|
|
fileListFragment.listDirectory(currentDir);
|
|
@@ -469,7 +477,8 @@ public class MoveActivity extends HookActivity implements FileFragment.Container
|
|
|
setFile(currentFile);
|
|
|
}
|
|
|
|
|
|
- mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) && !SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event));
|
|
|
+ mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) &&
|
|
|
+ !SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event));
|
|
|
|
|
|
if (SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
|
|
|
equals(event) &&
|