package com.owncloud.android.ui.activity;
import android.accounts.Account;
-import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
private FileDataStorageManager mStorageManager;
private DownloadFinishReceiver mDownloadFinishReceiver;
+
+ private Configuration mNewConfigurationChangeToApplyOnStart;
+
+ private boolean mStarted;
+
+ private boolean mDualPane;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
+ mStarted = false;
+
mFile = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);
mAccount = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT);
mStorageManager = new FileDataStorageManager(mAccount, getContentResolver());
- setContentView(R.layout.file_activity_details);
-
- ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
+ // check if configuration is proper for this activity; tablets in landscape should pass the torch to FileDisplayActivity
+ Configuration conf = getResources().getConfiguration();
+ mDualPane = (conf.orientation == Configuration.ORIENTATION_LANDSCAPE &&
+ (conf.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE
+ );
- if (savedInstanceState == null) {
- mWaitingToPreview = false;
- createChildFragment();
+ if (mDualPane) {
+ // only happens when notifications (downloads, uploads) are clicked at the notification bar
+ changeToDualView(false);
+
} else {
- mWaitingToPreview = savedInstanceState.getBoolean(KEY_WAITING_TO_PREVIEW);
- }
+ setContentView(R.layout.file_activity_details);
- mDownloadConnection = new DetailsServiceConnection();
- bindService(new Intent(this, FileDownloader.class), mDownloadConnection, Context.BIND_AUTO_CREATE);
- mUploadConnection = new DetailsServiceConnection();
- bindService(new Intent(this, FileUploader.class), mUploadConnection, Context.BIND_AUTO_CREATE);
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ if (savedInstanceState == null) {
+ mWaitingToPreview = false;
+ createChildFragment();
+ } else {
+ mWaitingToPreview = savedInstanceState.getBoolean(KEY_WAITING_TO_PREVIEW);
+ }
+
+ mDownloadConnection = new DetailsServiceConnection();
+ bindService(new Intent(this, FileDownloader.class), mDownloadConnection, Context.BIND_AUTO_CREATE);
+ mUploadConnection = new DetailsServiceConnection();
+ bindService(new Intent(this, FileUploader.class), mUploadConnection, Context.BIND_AUTO_CREATE);
+ }
}
/**
ft.commit();
}
+ @Override
+ public void onActivityResult (int requestCode, int resultCode, Intent data) {
+ Log_OC.e(TAG, "onActivityResult");
+ super.onActivityResult(requestCode, resultCode, data);
+ }
@Override
public void onConfigurationChanged (Configuration newConfig) {
super.onConfigurationChanged(newConfig);
+ if (mStarted) {
+ checkConfigurationChange(newConfig);
+ } else {
+ mNewConfigurationChangeToApplyOnStart = newConfig;
+ }
+ }
+
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putBoolean(KEY_WAITING_TO_PREVIEW, mWaitingToPreview);
+ }
+
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ Log_OC.e(TAG, "onStart");
+ if (mNewConfigurationChangeToApplyOnStart != null) {
+ checkConfigurationChange(mNewConfigurationChangeToApplyOnStart);
+ mNewConfigurationChangeToApplyOnStart = null;
+ }
+ mStarted = true;
+ }
+
+ private void checkConfigurationChange(Configuration newConfig) {
finish();
Intent intent = null;
if ((newConfig.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE
}
startActivity(intent);
}
-
-
+
@Override
- protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putBoolean(KEY_WAITING_TO_PREVIEW, mWaitingToPreview);
+ public void onStop() {
+ super.onStop();
+ Log_OC.e(TAG, "onStop");
+ mStarted = false;
}
-
-
@Override
public void onPause() {
super.onPause();
+ Log_OC.e(TAG, "onPause");
if (mDownloadFinishReceiver != null) {
unregisterReceiver(mDownloadFinishReceiver);
mDownloadFinishReceiver = null;
@Override
public void onResume() {
super.onResume();
+ Log_OC.e(TAG, "onResume");
// TODO this is probably unnecessary
Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
if (fragment != null && fragment instanceof FileDetailFragment) {
@Override
public void onDestroy() {
super.onDestroy();
+ Log_OC.e(TAG, "onDestroy");
if (mDownloadConnection != null) {
unbindService(mDownloadConnection);
mDownloadConnection = null;
switch(item.getItemId()){
case android.R.id.home:
- //backToDisplayActivity();
- onBackPressed();
+ changeToDualView(true);
returnValue = true;
break;
default:
return returnValue;
}
- //private void backToDisplayActivity() {
@Override
public void onBackPressed() {
+ changeToDualView(true);
+ }
+
+ private void changeToDualView(boolean moveToParent) {
Intent intent = new Intent(this, FileDisplayActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
OCFile targetFile = null;
if (mFile != null) {
- targetFile = mStorageManager.getFileById(mFile.getParentId());
+ targetFile = moveToParent ? mStorageManager.getFileById(mFile.getParentId()) : mFile;;
}
intent.putExtra(FileDetailFragment.EXTRA_FILE, targetFile);
intent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, mAccount);
}
+ @Override
+ protected void onAccountChanged() {
+ // TODO Auto-generated method stub
+
+ }
+
}