+\r
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
+ setProgressBarIndeterminateVisibility(false);\r
+ // if (getSupportFragmentManager().findFragmentById(R.id.fileList) ==\r
+ // null)\r
+ setContentView(R.layout.files);\r
+\r
+ }\r
+\r
+ @Override\r
+ public boolean onOptionsItemSelected(MenuItem item) {\r
+ boolean retval = true;\r
+ switch (item.getItemId()) {\r
+ case R.id.settingsItem: {\r
+ Intent i = new Intent(this, Preferences.class);\r
+ startActivity(i);\r
+ break;\r
+ }\r
+ case R.id.createDirectoryItem: {\r
+ showDialog(DIALOG_CREATE_DIR);\r
+ break;\r
+ }\r
+ case R.id.startSync: {\r
+ Bundle bundle = new Bundle();\r
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);\r
+ ContentResolver.requestSync(\r
+ AccountUtils.getCurrentOwnCloudAccount(this),\r
+ "org.owncloud", bundle);\r
+ break;\r
+ }\r
+ case R.id.action_upload: {\r
+ Intent action = new Intent(Intent.ACTION_GET_CONTENT);\r
+ action = action.setType("*/*")\r
+ .addCategory(Intent.CATEGORY_OPENABLE);\r
+ startActivityForResult(\r
+ Intent.createChooser(action, "Upload file from..."),\r
+ ACTION_SELECT_FILE);\r
+ break;\r
+ }\r
+\r
+ case android.R.id.home: {\r
+ Intent i = new Intent(this, AccountSelectActivity.class);\r
+ startActivity(i);\r
+ finish();\r
+ break;\r
+ }\r
+ default:\r
+ retval = false;\r
+ }\r
+ return retval;\r
+ }\r
+\r
+ @Override\r
+ public void onBackPressed() {\r
+ if (mDirectories.getCount() == 1) {\r
+ finish();\r
+ return;\r
+ }\r
+ popPath();\r
+ ((FileListFragment) getSupportFragmentManager().findFragmentById(\r
+ R.id.fileList)).onNavigateUp();\r
+ }\r
+\r
+ @Override\r
+ public boolean onCreateOptionsMenu(Menu menu) {\r
+ MenuInflater inflater = getSherlock().getMenuInflater();\r
+ inflater.inflate(R.menu.menu, menu);\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {\r
+ super.onRestoreInstanceState(savedInstanceState);\r
+ // Check, if there are ownCloud accounts\r
+ if (!accountsAreSetup()) {\r
+ showDialog(DIALOG_SETUP_ACCOUNT);\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
+ R.layout.sherlock_spinner_dropdown_item);\r
+ mDirectories.add("/");\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 += "/" + 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