+ @Override\r
+ protected void onSaveInstanceState(Bundle outState) {\r
+ super.onSaveInstanceState(outState);\r
+ if(mDirectories != null){\r
+ mDirs = new String[mDirectories.getCount()-1];\r
+ for (int j = mDirectories.getCount() - 2, i = 0; j >= 0; --j, ++i) {\r
+ mDirs[i] = mDirectories.getItem(j);\r
+ }\r
+ }\r
+ }\r
+\r
+ @Override\r
+ protected void onResume() {\r
+ super.onResume();\r
+ if (!accountsAreSetup()) {\r
+ showDialog(DIALOG_SETUP_ACCOUNT);\r
+ return;\r
+ }\r
+\r
+ IntentFilter f = new IntentFilter(FileSyncService.SYNC_MESSAGE);\r
+ syncBroadcastRevceiver = new SyncBroadcastReceiver();\r
+ registerReceiver(syncBroadcastRevceiver, f);\r
+\r
+ mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);\r
+ mDirectories.add("/");\r
+ if (mDirs != null) {\r
+ for (String s : mDirs)\r
+ mDirectories.insert(s, 0);\r
+ FileListFragment fileListFramgent = (FileListFragment) getSupportFragmentManager()\r
+ .findFragmentById(R.id.fileList);\r
+ if (fileListFramgent != null) fileListFramgent.listDirectory();\r
+ }\r
+\r
+ mStorageManager = new FileDataStorageManager(\r
+ AccountUtils.getCurrentOwnCloudAccount(this),\r
+ getContentResolver());\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
+\r
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {\r
+ Log.e("ASD", requestCode + " " + resultCode);\r
+ if (resultCode == RESULT_OK) {\r
+ if (requestCode == ACTION_SELECT_FILE) {\r
+ Uri selectedImageUri = data.getData();\r
+\r
+ String filemanagerstring = selectedImageUri.getPath();\r
+ String selectedImagePath = getPath(selectedImageUri);\r
+ String filepath;\r
+\r
+ if (selectedImagePath != null)\r
+ filepath = selectedImagePath;\r
+ else\r
+ filepath = filemanagerstring;\r
+\r
+ if (filepath == null) {\r
+ Log.e("FileDisplay", "Couldnt resolve path to file");\r
+ return;\r
+ }\r
+\r
+ Intent i = new Intent(this, FileUploader.class);\r
+ i.putExtra(FileUploader.KEY_ACCOUNT,\r
+ AccountUtils.getCurrentOwnCloudAccount(this));\r
+ String remotepath = new String();\r
+ for (int j = mDirectories.getCount() - 2; j >= 0; --j) {\r
+ remotepath += "/" + URLDecoder.decode(mDirectories.getItem(j));\r
+ }\r
+ if (!remotepath.endsWith("/"))\r
+ remotepath += "/";\r
+ remotepath += new File(filepath).getName();\r
+ Log.e("ASD", remotepath + "");\r
+\r
+ i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);\r
+ i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);\r
+ i.putExtra(FileUploader.KEY_UPLOAD_TYPE,\r
+ FileUploader.UPLOAD_SINGLE_FILE);\r
+ startService(i);\r
+ }\r