- ((FileList)getSupportFragmentManager().findFragmentById(id.file_list_container)).onBackPressed();\r
- }\r
- \r
- //@Override\r
- /*protected void onActivityResult(int requestCode, int resultCode, Intent data) {\r
- super.onActivityResult(requestCode, resultCode, data);\r
- }\r
- \r
- @Override\r
- protected void onSaveInstanceState(Bundle outState) {\r
- super.onSaveInstanceState(outState);\r
- outState.putSerializable("parentsStack", mParents);\r
- outState.putSerializable("path", mPath);\r
- outState.putBoolean("isDisplayingFile", mIsDisplayingFile);\r
- }*/\r
-}
\ No newline at end of file
+\r
+ private class DirectoryCreator implements Runnable {\r
+ private String mTargetPath;\r
+ private Account mAccount;\r
+ private AccountManager mAm;\r
+\r
+ public DirectoryCreator(String targetPath, Account account) {\r
+ mTargetPath = targetPath;\r
+ mAccount = account;\r
+ mAm = (AccountManager) getSystemService(ACCOUNT_SERVICE);\r
+ }\r
+\r
+ @Override\r
+ public void run() {\r
+ WebdavClient wdc = new WebdavClient(Uri.parse(mAm.getUserData(\r
+ mAccount, AccountAuthenticator.KEY_OC_URL)));\r
+\r
+ String username = mAccount.name.substring(0,\r
+ mAccount.name.lastIndexOf('@'));\r
+ String password = mAm.getPassword(mAccount);\r
+\r
+ wdc.setCredentials(username, password);\r
+ wdc.allowUnsignedCertificates();\r
+ wdc.createDirectory(mTargetPath);\r
+ }\r
+\r
+ }\r
+\r
+ // Custom array adapter to override text colors\r
+ private class CustomArrayAdapter<T> extends ArrayAdapter<T> {\r
+\r
+ public CustomArrayAdapter(FileDisplayActivity ctx, int view) {\r
+ super(ctx, view);\r
+ }\r
+\r
+ public View getView(int position, View convertView, ViewGroup parent) {\r
+ View v = super.getView(position, convertView, parent);\r
+\r
+ ((TextView) v).setTextColor(getResources().getColorStateList(\r
+ android.R.color.white));\r
+ return v;\r
+ }\r
+\r
+ public View getDropDownView(int position, View convertView,\r
+ ViewGroup parent) {\r
+ View v = super.getDropDownView(position, convertView, parent);\r
+\r
+ ((TextView) v).setTextColor(getResources().getColorStateList(\r
+ android.R.color.white));\r
+\r
+ return v;\r
+ }\r
+\r
+ }\r
+\r
+ public void onClick(DialogInterface dialog, int which) {\r
+ // In any case - we won't need it anymore\r
+ dialog.dismiss();\r
+ switch (which) {\r
+ case DialogInterface.BUTTON_POSITIVE:\r
+ Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");\r
+ intent.putExtra("authorities",\r
+ new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });\r
+ startActivity(intent);\r
+ break;\r
+ case DialogInterface.BUTTON_NEGATIVE:\r
+ finish();\r
+ }\r
+\r
+ }\r
+\r
+ /**\r
+ * Checks, whether or not there are any ownCloud accounts setup.\r
+ * \r
+ * @return true, if there is at least one account.\r
+ */\r
+ private boolean accountsAreSetup() {\r
+ AccountManager accMan = AccountManager.get(this);\r
+ Account[] accounts = accMan\r
+ .getAccountsByType(AccountAuthenticator.ACCOUNT_TYPE);\r
+ return accounts.length > 0;\r
+ }\r
+\r
+ private class SyncBroadcastReceiver extends BroadcastReceiver {\r
+ /**\r
+ * {@link BroadcastReceiver} to enable syncing feedback in UI\r
+ */\r
+ @Override\r
+ public void onReceive(Context context, Intent intent) {\r
+ boolean inProgress = intent.getBooleanExtra(\r
+ FileSyncService.IN_PROGRESS, false);\r
+ String account_name = intent\r
+ .getStringExtra(FileSyncService.ACCOUNT_NAME);\r
+ Log.d("FileDisplay", "sync of account " + account_name\r
+ + " is in_progress: " + inProgress);\r
+ setProgressBarIndeterminateVisibility(inProgress);\r
+ if (!inProgress) {\r
+ FileListFragment fileListFramgent = (FileListFragment) getSupportFragmentManager()\r
+ .findFragmentById(R.id.fileList);\r
+ if (fileListFramgent != null)\r
+ fileListFramgent.populateFileList();\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+}\r