+ @Override\r
+ protected void onResume() {\r
+ super.onResume();\r
+ \r
+ //TODO: Dialog useless -> get rid of this\r
+ if (!accountsAreSetup()) {\r
+ showDialog(DIALOG_SETUP_ACCOUNT);\r
+ return;\r
+ }\r
+\r
+ // Listen for sync messages\r
+ IntentFilter syncIntentFilter = new IntentFilter(FileSyncService.SYNC_MESSAGE);\r
+ syncBroadcastRevceiver = new SyncBroadcastReceiver();\r
+ registerReceiver(syncBroadcastRevceiver, syncIntentFilter);\r
+ \r
+ // Storage manager initialization\r
+ mStorageManager = new FileDataStorageManager(\r
+ AccountUtils.getCurrentOwnCloudAccount(this),\r
+ getContentResolver());\r
+ \r
+ // File list\r
+ mFileList = (FileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);\r
+ \r
+ // Figure out what directory to list. \r
+ // Priority: Intent (here), savedInstanceState (onCreate), root dir (dir is null)\r
+ if(getIntent().hasExtra(FileDetailFragment.EXTRA_FILE)){\r
+ mCurrentDir = (OCFile) getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);\r
+ if(!mCurrentDir.isDirectory()){\r
+ mCurrentDir = mStorageManager.getFileById(mCurrentDir.getParentId());\r
+ }\r
+ \r
+ // Clear intent extra, so rotating the screen will not return us to this directory\r
+ getIntent().removeExtra(FileDetailFragment.EXTRA_FILE);\r
+ } \r
+ \r
+ // Drop-Down navigation and file list restore\r
+ mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);\r
+ \r
+ \r
+ // Given the case we have a file to display:\r
+ if(mCurrentDir != null){\r
+ ArrayList<OCFile> files = new ArrayList<OCFile>();\r
+ OCFile currFile = mCurrentDir;\r
+ while(currFile != null){\r
+ files.add(currFile);\r
+ currFile = mStorageManager.getFileById(currFile.getParentId());\r
+ }\r
+ \r
+ // Insert in mDirs\r
+ mDirs = new String[files.size()];\r
+ for(int i = files.size() - 1; i >= 0; i--){\r
+ mDirs[i] = files.get(i).getFileName();\r
+ }\r
+ }\r
+ \r
+ if (mDirs != null) {\r
+ for (String s : mDirs)\r
+ mDirectories.add(s);\r
+ } else {\r
+ mDirectories.add("/");\r
+ }\r
+ \r
+ // Actionbar setup\r
+ ActionBar action_bar = getSupportActionBar();\r
+ action_bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);\r
+ action_bar.setDisplayShowTitleEnabled(false);\r
+ action_bar.setListNavigationCallbacks(mDirectories, this);\r
+ action_bar.setDisplayHomeAsUpEnabled(true);\r
+ \r
+ // List dir here\r
+ mFileList.listDirectory(mCurrentDir);\r