+ private static final String KEY_DIR_ARRAY = "DIR_ARRAY";\r
+ private static final String KEY_CURRENT_DIR = "DIR";\r
+ \r
+ private static final int DIALOG_SETUP_ACCOUNT = 0;\r
+ private static final int DIALOG_CREATE_DIR = 1;\r
+ private static final int ACTION_SELECT_FILE = 1;\r
+\r
+ @Override\r
+ public void onCreate(Bundle savedInstanceState) {\r
+ super.onCreate(savedInstanceState);\r
+\r
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\r
+ setProgressBarIndeterminateVisibility(false);\r
+\r
+ Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(getApplicationContext()));\r
+\r
+ if(savedInstanceState != null){\r
+ mCurrentDir = (OCFile) savedInstanceState.getParcelable(KEY_CURRENT_DIR);\r
+ }\r
+ \r
+ if (findViewById(R.id.file_list_view) == null) \r
+ mLayoutView = getLayoutInflater().inflate(R.layout.files, null); // always inflate this at onCreate() ; just once!\r
+ \r
+ //TODO: Dialog useless -> get rid of this\r
+ if (!accountsAreSetup()) {\r
+ setContentView(R.layout.no_account_available);\r
+ setProgressBarIndeterminateVisibility(false);\r
+ getSupportActionBar().setNavigationMode(ActionBar.DISPLAY_SHOW_TITLE);\r
+ findViewById(R.id.setup_account).setOnClickListener(this);\r
+ \r
+ } else if (findViewById(R.id.file_list_view) == null) {\r
+ setContentView(mLayoutView);\r
+ }\r
+ \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
+ public boolean onOptionsItemSelected(MenuItem item) {\r
+ boolean retval = true;\r
+ switch (item.getItemId()) {\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
+ case R.id.action_settings: {\r
+ Intent settingsIntent = new Intent(this, Preferences.class);\r
+ startActivity(settingsIntent);\r
+ }\r
+ case android.R.id.home: {\r
+ if(mCurrentDir != null && mCurrentDir.getParentId() != 0){\r
+ onBackPressed(); \r
+ }\r
+ break;\r
+ }\r
+ default:\r
+ retval = false;\r
+ }\r
+ return retval;\r