- * Launches the account creation activity. To use when no ownCloud account is available
- */
- private void createFirstAccount() {
- Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
- intent.putExtra(android.provider.Settings.EXTRA_AUTHORITIES, new String[] { AccountAuthenticator.AUTHORITY });
- startActivity(intent); // the new activity won't be created until this.onStart() and this.onResume() are finished;
- }
-
-
- /**
- * Load of state dependent of the existence of an ownCloud account
- */
- private void initDataFromCurrentAccount() {
- /// Storage manager initialization - access to local database
- mStorageManager = new FileDataStorageManager(
- AccountUtils.getCurrentOwnCloudAccount(this),
- getContentResolver());
-
- /// Check if mCurrentDir is a directory
- if(mCurrentDir != null && !mCurrentDir.isDirectory()) {
- mCurrentFile = mCurrentDir;
- mCurrentDir = mStorageManager.getFileById(mCurrentDir.getParentId());
- }
-
- /// Check if mCurrentDir and mCurrentFile are in the current account, and update them
- if (mCurrentDir != null) {
- mCurrentDir = mStorageManager.getFileByPath(mCurrentDir.getRemotePath()); // mCurrentDir == null if it is not in the current account
- }
- if (mCurrentFile != null) {
- if (mCurrentFile.fileExists()) {
- mCurrentFile = mStorageManager.getFileByPath(mCurrentFile.getRemotePath()); // mCurrentFile == null if it is not in the current account
- } // else : keep mCurrentFile with the received value; this is currently the case of an upload in progress, when the user presses the status notification in a landscape tablet
- }
-
- /// Default to root if mCurrentDir was not found
- if (mCurrentDir == null) {
- mCurrentDir = mStorageManager.getFileByPath("/"); // will be NULL if the database was never synchronized
- }
- }
-
-
- private void initFileDetailsInDualPane() {
- if (mDualPane && getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG) == null) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- if (mCurrentFile != null) {
- if (PreviewMediaFragment.canBePreviewed(mCurrentFile)) {
- if (mCurrentFile.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(mCurrentFile, AccountUtils.getCurrentOwnCloudAccount(this), startPlaybackPosition, autoplay), FileDetailFragment.FTAG);
- } else {
- transaction.replace(R.id.file_details_container, new FileDetailFragment(mCurrentFile, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG);
- mWaitingToPreview = mCurrentFile;
+ * Called when the ownCloud {@link Account} associated to the Activity was just updated.
+ */
+ @Override
+ protected void onAccountSet(boolean stateWasRecovered) {
+ if (getAccount() != null) {
+ mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
+
+ /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
+ OCFile file = getFile();
+ if (file != null) {
+ if (file.isDown() && file.getLastSyncDateForProperties() == 0) {
+ // upload in progress - right now, files are not inserted in the local cache until the upload is successful
+ if (mStorageManager.getFileById(file.getParentId()) == null) {
+ file = null; // not able to know the directory where the file is uploading