- //NOW WE HAVE OUR WANTED STRING\r
- if(selectedImagePath!=null)\r
- System.out.println("selectedImagePath is the right one for you!");\r
- else\r
- System.out.println("filemanagerstring is the right one for you!");\r
- }\r
- }\r
- }\r
- \r
- public String getPath(Uri uri) {\r
- String[] projection = { MediaStore.Images.Media.DATA };\r
- Cursor cursor = managedQuery(uri, projection, null, null, null);\r
- if(cursor!=null)\r
- {\r
- //HERE YOU WILL GET A NULLPOINTER IF CURSOR IS NULL\r
- //THIS CAN BE, IF YOU USED OI FILE MANAGER FOR PICKING THE MEDIA\r
- int column_index = cursor\r
- .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);\r
- cursor.moveToFirst();\r
- return cursor.getString(column_index);\r
- }\r
- else return null;\r
- }\r
- \r
- @Override\r
- protected void onPause() {\r
- super.onPause();\r
- if (b != null) {\r
- unregisterReceiver(b);\r
- b = null;\r
- }\r
- \r
- }\r
- \r
- @Override\r
- public boolean onNavigationItemSelected(int itemPosition, long itemId) {\r
- int i = itemPosition;\r
- while (i-- != 0) {\r
- onBackPressed();\r
- }\r
- return true;\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
+ if(mCurrentDir != null && mCurrentDir.getParentId() != 0){\r
+ action_bar.setDisplayHomeAsUpEnabled(true);\r
+ } else {\r
+ action_bar.setDisplayHomeAsUpEnabled(false);\r
+ }\r
+ \r
+ // List dir here\r
+ mFileList.listDirectory(mCurrentDir);\r
+ }\r