private OCFileListFragment mFileList;
private boolean mDualPane;
- private boolean mBackFromCreatingFirstAccount;
public static final int DIALOG_SHORT_WAIT = 0;
private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 1;
private boolean mStarted;
@Override
- public void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(Bundle savedInstanceState) {
Log_OC.d(TAG, "onCreate() start");
super.onCreate(savedInstanceState);
actionBar.setListNavigationCallbacks(mDirectories, this);
setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to workaround bug in its implementation
- mBackFromCreatingFirstAccount = false;
-
Log_OC.d(TAG, "onCreate() end");
}
if (mDualPane && getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG) == null) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
if (mChosenFile != null) {
- if (PreviewMediaFragment.canBePreviewed(mChosenFile)) {
- if (mChosenFile.isDown()) {
- int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
- boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
- transaction.replace(R.id.file_details_container, new PreviewMediaFragment(mChosenFile, getAccount(), startPlaybackPosition, autoplay), FileDetailFragment.FTAG);
- } else {
- transaction.replace(R.id.file_details_container, new FileDetailFragment(mChosenFile, getAccount()), FileDetailFragment.FTAG);
+ if (!mChosenFile.isDown()) {
+ transaction.replace(R.id.file_details_container, new FileDetailFragment(mChosenFile, getAccount()), FileDetailFragment.FTAG);
+ if (getIntent().getBooleanExtra(EXTRA_WAITING_TO_PREVIEW, false)) {
mWaitingToPreview = mChosenFile;
}
- } else {
- transaction.replace(R.id.file_details_container, new FileDetailFragment(mChosenFile, getAccount()), FileDetailFragment.FTAG);
+ } else if (PreviewMediaFragment.canBePreviewed(mChosenFile)) {
+ int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
+ boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
+ transaction.replace(R.id.file_details_container, new PreviewMediaFragment(mChosenFile, getAccount(), startPlaybackPosition, autoplay), FileDetailFragment.FTAG);
}
mChosenFile = null;
@Override
- public void onStart() {
+ protected void onStart() {
super.onStart();
if (mNewConfigurationChangeToApplyOnStart != null) {
checkConfigurationChange(mNewConfigurationChangeToApplyOnStart);
}
@Override
- public void onStop() {
+ protected void onStop() {
super.onStop();
mStarted = false;
}
} else {
finish();
Intent intent = new Intent(this, FileDisplayActivity.class);
- intent.putExtra(FileDetailFragment.EXTRA_FILE, getFile());
- intent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, getAccount());
+ intent.putExtra(EXTRA_FILE, getFile());
+ intent.putExtra(EXTRA_ACCOUNT, getAccount());
startActivity(intent);
}
}
@Override
- public void onDestroy() {
+ protected void onDestroy() {
super.onDestroy();
if (mDownloadConnection != null)
unbindService(mDownloadConnection);
/**
* Called, when the user selected something for uploading
*/
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
if (fragment != null) {
OCFile file = fragment.getFile();
if (file != null) {
- outState.putParcelable(FileActivity.EXTRA_FILE, file);
+ outState.putParcelable(EXTRA_FILE, file);
}
}
}
setFile(currentDir);
setSupportProgressBarIndeterminateVisibility(inProgress);
- if (mBackFromCreatingFirstAccount) {
- // awful patch to fix problem with visibility of progress circle with the first refresh of the first account
- // TODO - kill this Activity when the first account has to be created instead of stack the account creation on it
- getSupportActionBar().hide();
- getSupportActionBar().show();
- mBackFromCreatingFirstAccount = false;
- }
removeStickyBroadcast(intent);
}
// update the right panel
if (success && waitedPreview) {
mWaitingToPreview = mStorageManager.getFileById(mWaitingToPreview.getFileId()); // update the file from database, for the local storage path
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.replace(R.id.file_details_container, new PreviewMediaFragment(mWaitingToPreview, getAccount(), 0, true), FileDetailFragment.FTAG);
- transaction.commit();
+ if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.replace(R.id.file_details_container, new PreviewMediaFragment(mWaitingToPreview, getAccount(), 0, true), FileDetailFragment.FTAG);
+ transaction.commit();
+ } else {
+ detailsFragment.updateFileDetails(false, (success));
+ openFile(mWaitingToPreview);
+
+ }
mWaitingToPreview = null;
} else {
*/
@Override
public void onFileClick(OCFile file, boolean onOrientationChange) {
- if (file != null && PreviewImageFragment.canBePreviewed(file)) {
- // preview image - it handles the download, if needed
- startPreviewImage(file);
-
- } else if (file != null && PreviewMediaFragment.canBePreviewed(file)) {
- if (file.isDown()) {
- // general preview
- if (!onOrientationChange) {
- startMediaPreview(file, 0, true, onOrientationChange);
- } else {
- int startPlaybackPosition = 0;
- boolean autoplay = true;
- Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
- if (fragment != null && file.isVideo()) {
- PreviewMediaFragment videoFragment = (PreviewMediaFragment)fragment;
- startPlaybackPosition = videoFragment.getPosition();
- autoplay = videoFragment.isPlaying();
+ if (file != null) {
+ if (PreviewImageFragment.canBePreviewed(file)) {
+ // preview image - it handles the download, if needed
+ startPreviewImage(file);
+
+ } else if (PreviewMediaFragment.canBePreviewed(file)) {
+ if (file.isDown()) {
+ // general preview
+ if (!onOrientationChange) {
+ startMediaPreview(file, 0, true, onOrientationChange);
+ } else {
+ int startPlaybackPosition = 0;
+ boolean autoplay = true;
+ Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
+ if (fragment != null && file.isVideo()) {
+ PreviewMediaFragment videoFragment = (PreviewMediaFragment)fragment;
+ startPlaybackPosition = videoFragment.getPosition();
+ autoplay = videoFragment.isPlaying();
+ }
+ startMediaPreview(file, startPlaybackPosition, autoplay, onOrientationChange);
}
- startMediaPreview(file, startPlaybackPosition, autoplay, onOrientationChange);
+
+ } else {
+ // automatic download, preview on finish
+ startDownloadForPreview(file, onOrientationChange);
+
}
+ } else if (file.isDown()) {
+ // details view
+ startDetails(file, onOrientationChange);
} else {
- // automatic download, preview on finish
startDownloadForPreview(file, onOrientationChange);
-
}
- } else {
- // details view
- startDetails(file, onOrientationChange);
}
}
private void startPreviewImage(OCFile file) {
Intent showDetailsIntent = new Intent(this, PreviewImageActivity.class);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, getAccount());
+ showDetailsIntent.putExtra(EXTRA_FILE, file);
+ showDetailsIntent.putExtra(EXTRA_ACCOUNT, getAccount());
startActivity(showDetailsIntent);
}
} else {
Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, getAccount());
+ showDetailsIntent.putExtra(EXTRA_FILE, file);
+ showDetailsIntent.putExtra(EXTRA_ACCOUNT, getAccount());
showDetailsIntent.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, startPlaybackPosition);
showDetailsIntent.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, autoplay);
startActivity(showDetailsIntent);
} else {
Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, getAccount());
+ showDetailsIntent.putExtra(EXTRA_FILE, file);
+ showDetailsIntent.putExtra(EXTRA_ACCOUNT, getAccount());
startActivity(showDetailsIntent);
}
}
transaction.commit();
} else {
Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, getAccount());
+ showDetailsIntent.putExtra(EXTRA_FILE, file);
+ showDetailsIntent.putExtra(EXTRA_ACCOUNT, getAccount());
startActivity(showDetailsIntent);
}
}
} else {
Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, getAccount());
+ showDetailsIntent.putExtra(EXTRA_FILE, file);
+ showDetailsIntent.putExtra(EXTRA_ACCOUNT, getAccount());
showDetailsIntent.putExtra(FileDetailActivity.EXTRA_MODE, FileDetailActivity.MODE_DETAILS);
startActivity(showDetailsIntent);
}