Merge branch 'master' into text_file_preview_pr_707_with_develop
authormasensio <masensio@solidgear.es>
Fri, 4 Sep 2015 12:31:10 +0000 (14:31 +0200)
committermasensio <masensio@solidgear.es>
Fri, 4 Sep 2015 12:31:10 +0000 (14:31 +0200)
Conflicts:
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java

1  2 
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@@ -77,6 -77,7 +77,7 @@@ import com.owncloud.android.lib.common.
  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.CopyFileOperation;
  import com.owncloud.android.operations.CreateFolderOperation;
  import com.owncloud.android.operations.CreateShareOperation;
  import com.owncloud.android.operations.MoveFileOperation;
@@@ -98,7 -99,6 +99,7 @@@ import com.owncloud.android.ui.fragment
  import com.owncloud.android.ui.preview.PreviewImageActivity;
  import com.owncloud.android.ui.preview.PreviewImageFragment;
  import com.owncloud.android.ui.preview.PreviewMediaFragment;
 +import com.owncloud.android.ui.preview.PreviewTextFragment;
  import com.owncloud.android.ui.preview.PreviewVideoActivity;
  import com.owncloud.android.utils.DisplayUtils;
  import com.owncloud.android.utils.ErrorMessageAdapter;
@@@ -107,6 -107,7 +108,6 @@@ import com.owncloud.android.utils.UriUt
  
  import java.io.File;
  
 -
  /**
   * Displays, what files the user has available in his ownCloud.
   */
@@@ -115,8 -116,6 +116,8 @@@ public class FileDisplayActivity extend
          implements FileFragment.ContainerActivity,
          OnSslUntrustedCertListener, OnEnforceableRefreshListener {
  
 +
 +
      private SyncBroadcastReceiver mSyncBroadcastReceiver;
      private UploadFinishReceiver mUploadFinishReceiver;
      private DownloadFinishReceiver mDownloadFinishReceiver;
      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;
  
      private static final String TAG = FileDisplayActivity.class.getSimpleName();
  
              mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS);
              mWaitingToSend = (OCFile) savedInstanceState.getParcelable(
                      FileDisplayActivity.KEY_WAITING_TO_SEND);
 -           
          } else {
              mWaitingToPreview = null;
              mSyncInProgress = false;
  
          // Inflate and set the layout view
          setContentView(R.layout.files);
-         
          // Navigation Drawer
          initDrawer();
  
  
          mProgressBar.setIndeterminate(mSyncInProgress);
          // always AFTER setContentView(...) ; to work around bug in its implementation
 -        
 +
          setBackgroundText();
  
          Log_OC.v(TAG, "onCreate() end");
          }
      }
  
 -
      private void createMinFragments() {
          OCFileListFragment listOfFiles = new OCFileListFragment();
          FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                  listOfFiles.listDirectory(getCurrentDir());
                  // TODO Enable when "On Device" is recovered
                  // listOfFiles.listDirectory(getCurrentDir(), MainApp.getOnlyOnDevice());
 +
              } else {
                  Log_OC.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
              }
                  setSecondFragment(secondFragment);
                  updateFragmentsVisibility(true);
                  updateActionBarTitleAndHomeButton(file);
 -                
 +
              } else {
                  cleanSecondFragment();
 +                if (file.isDown() && PreviewTextFragment.canBePreviewed(file))
 +                    startTextPreview(file);
              }
  
          } else {
                  secondFragment = new PreviewMediaFragment(file, getAccount(),
                          startPlaybackPosition, autoplay);
  
 +            } else if (file.isDown() && PreviewTextFragment.canBePreviewed(file)) {
 +                secondFragment = null;
              } else {
 -                secondFragment = FileDetailFragment.newInstance(file, getAccount());
 -            }
 +            secondFragment = FileDetailFragment.newInstance(file, getAccount());
 +        }
          }
          return secondFragment;
      }
                          if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
                              startMediaPreview(mWaitingToPreview, 0, true);
                              detailsFragmentChanged = true;
 +                        } else if (PreviewTextFragment.canBePreviewed(mWaitingToPreview)) {
 +                            startTextPreview(mWaitingToPreview);
 +                            detailsFragmentChanged = true;
                          } else {
                              getFileOperationsHelper().openFile(mWaitingToPreview);
                          }
                  dialog.show(getSupportFragmentManager(), DIALOG_CREATE_FOLDER);
                  break;
              }
 +
              case R.id.action_sync_account: {
                  startSynchronization();
                  break;
                  UploadSourceDialogFragment dialog =
                          UploadSourceDialogFragment.newInstance(getAccount());
                  dialog.show(getSupportFragmentManager(), DIALOG_UPLOAD_SOURCE);
 -
                  break;
              }
              case android.R.id.home: {
                  resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
              requestMultipleUpload(data, resultCode);
  
-         } else if (requestCode == ACTION_MOVE_FILES && resultCode == RESULT_OK) {
+         } else if (requestCode == ACTION_MOVE_FILES && resultCode == RESULT_OK){
              final Intent fData = data;
              final int fResultCode = resultCode;
              getHandler().postDelayed(
                      DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS
              );
  
+         } else if (requestCode == ACTION_COPY_FILES && resultCode == RESULT_OK) {
+             final Intent fData = data;
+             final int fResultCode = resultCode;
+             getHandler().postDelayed(
+                     new Runnable() {
+                         @Override
+                         public void run() {
+                             requestCopyOperation(fData, fResultCode);
+                         }
+                     },
+                     DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS
+             );
          } else {
              super.onActivityResult(requestCode, resultCode, data);
          }
          getFileOperationsHelper().moveFile(folderToMoveAt, targetFile);
      }
  
+     /**
+      * Request the operation for copying the file/folder from one path to another
+      *
+      * @param data       Intent received
+      * @param resultCode Result code received
+      */
+     private void requestCopyOperation(Intent data, int resultCode) {
+         OCFile folderToMoveAt = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER);
+         OCFile targetFile = data.getParcelableExtra(FolderPickerActivity.EXTRA_FILE);
+         getFileOperationsHelper().copyFile(folderToMoveAt, targetFile);
+     }
      @Override
      public void onBackPressed() {
          if (!isDrawerOpen()){
      protected void onResume() {
          Log_OC.v(TAG, "onResume() start");
          super.onResume();
 -
          // refresh Navigation Drawer account list
          mNavigationDrawerAdapter.updateAccountList();
  
 -
          // refresh list of files
          refreshListOfFilesFragment();
  
          downloadIntentFilter.addAction(FileDownloader.getDownloadFinishMessage());
          mDownloadFinishReceiver = new DownloadFinishReceiver();
          registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
          Log_OC.v(TAG, "onResume() end");
 +
      }
  
  
                                  FileSyncAdapter.EXTRA_RESULT);
                  boolean sameAccount = (getAccount() != null &&
                          accountName.equals(getAccount().name) && getStorageManager() != null);
 -    
 +
                  if (sameAccount) {
  
                      if (FileSyncAdapter.EVENT_FULL_SYNC_START.equals(event)) {
                                                     synchFolderRemotePath),
                                              Toast.LENGTH_LONG)
                                  .show();
 +
                              browseToRoot();
  
                          } else {
                                          .equals(event));
                                  
                          if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
 -                                    equals(event) &&
 -                                /// TODO refactor and make common
 +                                    equals(event) &&/// TODO refactor and make common
++
                                  synchResult != null && !synchResult.isSuccess() &&
                                  (synchResult.getCode() == ResultCode.UNAUTHORIZED ||
                                          synchResult.isIdPRedirection() ||
                                          new OwnCloudAccount(getAccount(), context);
                                  client = (OwnCloudClientManagerFactory.getDefaultSingleton().
                                          removeClientFor(ocAccount));
 -
                                  if (client != null) {
                                      OwnCloudCredentials cred = client.getCredentials();
                                      if (cred != null) {
                  if (sameAccount && isDescendant) {
                      refreshListOfFilesFragment();
                  }
                  boolean uploadWasFine = intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT,
                          false);
                  boolean renamedInUpload = getFile().getRemotePath().
                          cleanSecondFragment();
                      }
  
 -                    // Force the preview if the file is an image
 -                    if (uploadWasFine && PreviewImageFragment.canBePreviewed(getFile())) {
 -                        startImagePreview(getFile());
 -                    } // TODO what about other kind of previews?
 +                    // Force the preview if the file is an image or text file
 +                    if (uploadWasFine) {
 +                        OCFile ocFile = getFile();
 +                        if (PreviewImageFragment.canBePreviewed(ocFile))
 +                            startImagePreview(getFile());
 +                        else if (PreviewTextFragment.canBePreviewed(ocFile))
 +                            startTextPreview(ocFile);
 +                        // TODO what about other kind of previews?
 +                    }
                  }
  
                  mProgressBar.setIndeterminate(false);
                  if (mWaitingToSend != null) {
                      mWaitingToSend =
                              getStorageManager().getFileByPath(mWaitingToSend.getRemotePath());
 -                    if (mWaitingToSend.isDown()) { 
 +                    if (mWaitingToSend.isDown()) {
                          sendDownloadedFile();
                      }
                  }
              startSyncFolderOperation(root, false);
          }
          cleanSecondFragment();
 -
      }
  
  
              }
              // a new chance to get the mDownloadBinder through
              // getFileDownloadBinder() - THIS IS A MESS
 -            OCFileListFragment listOfFiles = getListOfFilesFragment(); 
 +            OCFileListFragment listOfFiles = getListOfFilesFragment();
              if (listOfFiles != null) {
                  listOfFiles.listDirectory();
                  // TODO Enable when "On Device" is recovered ?
  
          } else if (operation instanceof MoveFileOperation) {
              onMoveFileOperationFinish((MoveFileOperation) operation, result);
+         } else if (operation instanceof CopyFileOperation) {
+             onCopyFileOperationFinish((CopyFileOperation) operation, result);
          }
  
      }
-     
 -
 -
      private void onCreateShareOperationFinish(CreateShareOperation operation,
                                                RemoteOperationResult result) {
          if (result.isSuccess()) {
          }
      }
  
 -
      private void onUnshareLinkOperationFinish(UnshareLinkOperation operation,
                                                RemoteOperationResult result) {
          if (result.isSuccess()) {
                  if (details instanceof PreviewMediaFragment) {
                      // Refresh  OCFile of the fragment
                      ((PreviewMediaFragment) details).updateFile(file);
-                 } else
 +                } else if (details instanceof PreviewTextFragment) {
 +                    // Refresh  OCFile of the fragment
 +                    ((PreviewTextFragment) details).updateFile(file);
+                 } else {
                      showDetails(file);
+                 }
              }
              invalidateOptionsMenu();
          }
      private void onRemoveFileOperationFinish(RemoveFileOperation operation,
                                               RemoteOperationResult result) {
          dismissLoadingDialog();
          Toast msg = Toast.makeText(this,
                  ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
 -                Toast.LENGTH_LONG); 
 +                Toast.LENGTH_LONG);
          msg.show();
  
          if (result.isSuccess()) {
                  setFile(getStorageManager().getFileById(removedFile.getParentId()));
                  cleanSecondFragment();
              }
 -            if (getStorageManager().getFileById(removedFile.getParentId()).equals(getCurrentDir())) {
 +            if (getStorageManager().getFileById(removedFile.getParentId()).equals(getCurrentDir())){
                  refreshListOfFilesFragment();
              }
              invalidateOptionsMenu();
          }
      }
  
+     /**
+      * Updates the view associated to the activity after the finish of an operation trying to copy a
+      * file.
+      *
+      * @param operation Copy operation performed.
+      * @param result    Result of the copy operation.
+      */
+     private void onCopyFileOperationFinish(CopyFileOperation operation, RemoteOperationResult result) {
+         if (result.isSuccess()) {
+             dismissLoadingDialog();
+             refreshListOfFilesFragment();
+         } else {
+             dismissLoadingDialog();
+             try {
+                 Toast msg = Toast.makeText(FileDisplayActivity.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);
+             }
+         }
+     }
  
      /**
       * Updates the view associated to the activity after the finish of an operation trying to rename
                      } else {
                          getFileOperationsHelper().openFile(renamedFile);
                      }
 +                } else if (details instanceof PreviewTextFragment &&
 +                        renamedFile.equals(details.getFile())) {
 +                    ((PreviewTextFragment) details).updateFile(renamedFile);
 +                    if (PreviewTextFragment.canBePreviewed(renamedFile)) {
 +                        startTextPreview(renamedFile);
 +                    } else {
 +                        getFileOperationsHelper().openFile(renamedFile);
 +                    }
                  }
              }
-             
              if (getStorageManager().getFileById(renamedFile.getParentId()).equals(getCurrentDir())){
                  refreshListOfFilesFragment();
              }
          } else {
              Toast msg = Toast.makeText(this,
                      ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
 -                    Toast.LENGTH_LONG); 
 +                    Toast.LENGTH_LONG);
              msg.show();
  
              if (result.isSslRecoverableException()) {
                  getApplicationContext()
          );
          synchFolderOp.execute(getAccount(), MainApp.getAppContext(), this, null, null);
 +
          mProgressBar.setIndeterminate(true);
  
          setBackgroundText();
          showDetailsIntent.putExtra(EXTRA_FILE, file);
          showDetailsIntent.putExtra(EXTRA_ACCOUNT, getAccount());
          startActivity(showDetailsIntent);
 -
      }
  
      /**
       * Stars the preview of an already down media {@link OCFile}.
-      * 
+      *
       * @param file                      Media {@link OCFile} to preview.
       * @param startPlaybackPosition     Media position where the playback will be started,
       *                                  in milliseconds.
      }
  
      /**
 +     * Stars the preview of a text file {@link OCFile}.
 +     *
 +     * @param file Text {@link OCFile} to preview.
 +     */
 +    public void startTextPreview(OCFile file) {
 +        Bundle args = new Bundle();
 +        args.putParcelable(EXTRA_FILE, file);
 +        args.putParcelable(EXTRA_ACCOUNT, getAccount());
 +        Fragment textPreviewFragment = Fragment.instantiate(getApplicationContext(),
 +                PreviewTextFragment.class.getName(), args);
 +        setSecondFragment(textPreviewFragment);
 +        updateFragmentsVisibility(true);
 +        //updateNavigationElementsInActionBar(file);
 +        setFile(file);
 +    }
 +
 +    /**
       * Requests the download of the received {@link OCFile} , updates the UI
       * to monitor the download progress and prepares the activity to preview
       * or open the file when the download finishes.
@@@ -22,8 -22,6 +22,6 @@@
   */
  package com.owncloud.android.ui.fragment;
  
- import java.io.File;
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
@@@ -55,13 -53,14 +53,14 @@@ import com.owncloud.android.ui.dialog.R
  import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
  import com.owncloud.android.ui.preview.PreviewImageFragment;
  import com.owncloud.android.ui.preview.PreviewMediaFragment;
- import com.owncloud.android.utils.DialogMenuItem;
  import com.owncloud.android.utils.FileStorageUtils;
 +import com.owncloud.android.ui.preview.PreviewTextFragment;
  
 -import java.util.Vector;
+ import java.io.File;
  /**
   * A Fragment that lists all files and folders in a given path.
-  * 
+  *
   * TODO refactor to get rid of direct dependency on FileDisplayActivity
   */
  public class OCFileListFragment extends ExtendedListFragment implements FileActionsDialogFragment.FileActionsDialogFragmentListener {
  
      private static final String MY_PACKAGE = OCFileListFragment.class.getPackage() != null ?
              OCFileListFragment.class.getPackage().getName() : "com.owncloud.android.ui.fragment";
-             
      public final static String ARG_JUST_FOLDERS = MY_PACKAGE + ".JUST_FOLDERS";
      public final static String ARG_ALLOW_CONTEXTUAL_ACTIONS = MY_PACKAGE + ".ALLOW_CONTEXTUAL";
-             
      private static final String KEY_FILE = MY_PACKAGE + ".extra.FILE";
  
      private FileFragment.ContainerActivity mContainerActivity;
-    
      private OCFile mFile = null;
      private FileListListAdapter mAdapter;
      private boolean mJustFolders;
          Log_OC.e(TAG, "onAttach");
          try {
              mContainerActivity = (FileFragment.ContainerActivity) activity;
-             
          } catch (ClassCastException e) {
-             throw new ClassCastException(activity.toString() + " must implement " + 
+             throw new ClassCastException(activity.toString() + " must implement " +
                      FileFragment.ContainerActivity.class.getSimpleName());
          }
          try {
              setOnRefreshListener((OnEnforceableRefreshListener) activity);
              
          } catch (ClassCastException e) {
-             throw new ClassCastException(activity.toString() + " must implement " + 
+             throw new ClassCastException(activity.toString() + " must implement " +
                      SwipeRefreshLayout.OnRefreshListener.class.getSimpleName());
          }
      }
  
-     
      @Override
      public void onDetach() {
          setOnRefreshListener(null);
                  mJustFolders,
                  getActivity(),
                  mContainerActivity
-                 );
+         );
          setListAdapter(mAdapter);
  
          registerLongClickListener();
       * Saves the current listed folder.
       */
      @Override
-     public void onSaveInstanceState (Bundle outState) {
+     public void onSaveInstanceState(Bundle outState) {
          super.onSaveInstanceState(outState);
          outState.putParcelable(KEY_FILE, mFile);
      }
-     
      /**
       * Call this, when the user presses the up button.
-      * 
+      *
       * Tries to move up the current folder one level. If the parent folder was removed from the
       * database, it continues browsing up until finding an existing folders.
-      * 
+      * <p/>
       * return       Count of folder levels browsed up.
       */
      public int onBrowseUp() {
          OCFile parentDir = null;
          int moveCount = 0;
-         
-         if(mFile != null){
+         if (mFile != null) {
              FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
-             
              String parentPath = null;
              if (mFile.getParentId() != FileDataStorageManager.ROOT_PARENT_ID) {
                  parentPath = new File(mFile.getRemotePath()).getParent();
-                 parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : 
-                       parentPath + OCFile.PATH_SEPARATOR;
+                 parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath :
+                         parentPath + OCFile.PATH_SEPARATOR;
                  parentDir = storageManager.getFileByPath(parentPath);
                  moveCount++;
              } else {
              }
              while (parentDir == null) {
                  parentPath = new File(parentPath).getParent();
-                 parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : 
-                       parentPath + OCFile.PATH_SEPARATOR;
+                 parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath :
+                         parentPath + OCFile.PATH_SEPARATOR;
                  parentDir = storageManager.getFileByPath(parentPath);
                  moveCount++;
              }   // exit is granted because storageManager.getFileByPath("/") never returns null
              listDirectory(mFile /*, MainApp.getOnlyOnDevice()*/);
  
              onRefresh(false);
-             
              // restore index and top position
              restoreIndexAndTopPosition();
-             
          }   // else - should never happen now
-    
          return moveCount;
      }
-     
      @Override
      public void onItemClick(AdapterView<?> l, View v, int position, long id) {
          OCFile file = (OCFile) mAdapter.getItem(position);
          if (file != null) {
-             if (file.isFolder()) { 
+             if (file.isFolder()) {
                  // update state and view of this fragment
                  // TODO Enable when "On Device" is recovered ?
                  listDirectory(file/*, MainApp.getOnlyOnDevice()*/);
                  mContainerActivity.onBrowsedDownTo(file);
                  // save index and top position
                  saveIndexAndTopPosition(position);
-                 
              } else { /// Click on a file
                  if (PreviewImageFragment.canBePreviewed(file)) {
                      // preview image - it handles the download, if needed
 -                    ((FileDisplayActivity) mContainerActivity).startImagePreview(file);
 -
 +                    ((FileDisplayActivity)mContainerActivity).startImagePreview(file);
 +                } else if (PreviewTextFragment.canBePreviewed(file)){
 +                    ((FileDisplayActivity)mContainerActivity).startTextPreview(file);
                  } else if (file.isDown()) {
                      if (PreviewMediaFragment.canBePreviewed(file)) {
                          // media preview
-                         ((FileDisplayActivity)mContainerActivity).startMediaPreview(file, 0, true);
+                         ((FileDisplayActivity) mContainerActivity).startMediaPreview(file, 0, true);
                      } else {
                          mContainerActivity.getFileOperationsHelper().openFile(file);
                      }
-                     
                  } else {
                      // automatic download, preview on finish
-                     ((FileDisplayActivity)mContainerActivity).startDownloadForPreview(file);
+                     ((FileDisplayActivity) mContainerActivity).startDownloadForPreview(file);
                  }
-                     
              }
-             
          } else {
              Log_OC.d(TAG, "Null object in ListAdapter!!");
          }
-         
      }
-     
      /**
       * {@inheritDoc}
       */
      @Override
-     public void onCreateContextMenu (
+     public void onCreateContextMenu(
              ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
          Bundle args = getArguments();
-         boolean allowContextualActions = 
-                 (args == null) ? true : args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, true); 
+         boolean allowContextualActions =
+                 (args == null) ? true : args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, true);
          if (allowContextualActions) {
              MenuInflater inflater = getActivity().getMenuInflater();
              inflater.inflate(R.menu.file_actions_menu, menu);
              AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
              OCFile targetFile = (OCFile) mAdapter.getItem(info.position);
-             
              if (mContainerActivity.getStorageManager() != null) {
                  FileMenuFilter mf = new FileMenuFilter(
                      targetFile,
                  mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, false);
                  return true;
              }
+             case R.id.action_copy:
+                 Intent action = new Intent(getActivity(), FolderPickerActivity.class);
+                 // Pass mTargetFile that contains info of selected file/folder
+                 action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
+                 getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES);
+                 return true;
              default:
                  return false;
          }
      /**
       * Use this to query the {@link OCFile} that is currently
       * being displayed by this fragment
+      *
       * @return The currently viewed OCFile
       */
-     public OCFile getCurrentFile(){
+     public OCFile getCurrentFile() {
          return mFile;
      }
-     
      /**
       * Calls {@link OCFileListFragment#listDirectory(OCFile)} with a null parameter
       */
          // TODO Enable when "On Device" is recovered ?
          listDirectory(getCurrentFile()/*, MainApp.getOnlyOnDevice()*/);
      }
-     
      /**
       * Lists the given directory on the view. When the input parameter is null,
       * it will either refresh the last known directory. list the root
       * if there never was a directory.
-      * 
+      *
       * @param directory File to be listed
       */
      public void listDirectory(OCFile directory/*, boolean onlyOnDevice*/) {
          if (storageManager != null) {
  
              // Check input parameters for null
-             if(directory == null){
-                 if(mFile != null){
+             if (directory == null) {
+                 if (mFile != null) {
                      directory = mFile;
                  } else {
                      directory = storageManager.getFileByPath("/");
                      if (directory == null) return; // no files, wait for sync
                  }
              }
-         
-         
              // If that's not a directory -> List its parent
-             if(!directory.isFolder()){
+             if (!directory.isFolder()) {
                  Log_OC.w(TAG, "You see, that is not a directory -> " + directory.toString());
                  directory = storageManager.getFileById(directory.getParentId());
              }