+ public void browseToRoot() {
+ OCFileListFragment listOfFiles = getListOfFilesFragment();
+ if (listOfFiles != null) { // should never be null, indeed
+ OCFile root = getStorageManager().getFileByPath(OCFile.ROOT_PATH);
+ listOfFiles.listDirectory(root);
+ setFile(listOfFiles.getCurrentFile());
+ updateNavigationElementsInActionBar();
+ startSyncFolderOperation(root);
+ }
+ }
+
+ @Override
+ public void onBackPressed() {
+ OCFileListFragment listOfFiles = getListOfFilesFragment();
+ if (listOfFiles != null) { // should never be null, indeed
+ int levelsUp = listOfFiles.onBrowseUp();
+ if (levelsUp == 0) {
+ finish();
+ return;
+ }
+ setFile(listOfFiles.getCurrentFile());
+ updateNavigationElementsInActionBar();
+ }
+ }
+
+ private void updateNavigationElementsInActionBar() {
+ ActionBar actionBar = getSupportActionBar();
+ OCFile currentDir = getCurrentFolder();
+ boolean atRoot = (currentDir == null || currentDir.getParentId() == 0);
+ actionBar.setDisplayHomeAsUpEnabled(!atRoot);
+ actionBar.setHomeButtonEnabled(!atRoot);
+ actionBar.setTitle(
+ atRoot
+ ? getString(R.string.default_display_name_for_root_folder)
+ : currentDir.getFileName()
+ );
+ }
+
+ /**
+ * Set per-view controllers
+ */
+ private void initControls(){
+ mCancelBtn = (Button) findViewById(R.id.move_files_btn_cancel);
+ mCancelBtn.setOnClickListener(this);
+ mChooseBtn = (Button) findViewById(R.id.move_files_btn_choose);
+ mChooseBtn.setOnClickListener(this);
+ }
+
+ @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_AND_MOVE, data);
+ finish();
+ }
+ }
+
+
+ @Override
+ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
+ super.onRemoteOperationFinish(operation, result);
+
+ if (operation instanceof CreateFolderOperation) {
+ onCreateFolderOperationFinish((CreateFolderOperation)operation, result);
+
+ }
+ }
+
+
+ /**
+ * Updates the view associated to the activity after the finish of an operation trying
+ * to create a new folder.
+ *
+ * @param operation Creation operation performed.
+ * @param result Result of the creation.
+ */
+ private void onCreateFolderOperationFinish(
+ CreateFolderOperation operation, RemoteOperationResult result
+ ) {
+
+ if (result.isSuccess()) {
+ dismissLoadingDialog();
+ refreshListOfFilesFragment();
+ } else {
+ dismissLoadingDialog();
+ try {
+ Toast msg = Toast.makeText(MoveActivity.this,
+ ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
+ Toast.LENGTH_LONG);
+ msg.show();
+
+ } catch (NotFoundException e) {
+ Log_OC.e(TAG, "Error while trying to show fail message " , e);
+ }
+ }
+ }
+
+
+