Эх сурвалжийг харах

Added account existance validation to FileDetailsActivity

David A. Velasco 12 жил өмнө
parent
commit
bc1fcf8493

+ 5 - 5
src/com/owncloud/android/files/services/FileDownloader.java

@@ -37,8 +37,8 @@ import com.owncloud.android.network.OwnCloudClientUtils;
 import com.owncloud.android.operations.DownloadFileOperation;
 import com.owncloud.android.operations.RemoteOperationResult;
 import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDetailActivity;
-import com.owncloud.android.ui.fragment.FileDetailFragment;
 import com.owncloud.android.ui.preview.PreviewImageActivity;
 import com.owncloud.android.ui.preview.PreviewImageFragment;
 
@@ -416,8 +416,8 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         } else {
             showDetailsIntent = new Intent(this, FileDetailActivity.class);
         }
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, download.getFile());
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, download.getAccount());
+        showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, download.getFile());
+        showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, download.getAccount());
         showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), showDetailsIntent, 0);
         
@@ -487,8 +487,8 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                     } else {
                         showDetailsIntent = new Intent(this, FileDetailActivity.class);
                     }
-                    showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, download.getFile());
-                    showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, download.getAccount());
+                    showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, download.getFile());
+                    showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, download.getAccount());
                     showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                     
                 } else {

+ 5 - 5
src/com/owncloud/android/files/services/FileUploader.java

@@ -43,7 +43,6 @@ import com.owncloud.android.operations.RemoteOperationResult;
 import com.owncloud.android.operations.UploadFileOperation;
 import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.ui.activity.FileDetailActivity;
-import com.owncloud.android.ui.fragment.FileDetailFragment;
 import com.owncloud.android.utils.OwnCloudVersion;
 
 import eu.alefzero.webdav.OnDatatransferProgressListener;
@@ -74,6 +73,7 @@ import com.owncloud.android.Log_OC;
 import com.owncloud.android.R;
 import com.owncloud.android.db.DbHandler;
 import com.owncloud.android.ui.activity.FailedUploadActivity;
+import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.InstantUploadActivity;
 import com.owncloud.android.ui.preview.PreviewImageActivity;
 import com.owncloud.android.ui.preview.PreviewImageFragment;
@@ -706,8 +706,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
             showDetailsIntent = new Intent(this, FileDetailActivity.class);
             showDetailsIntent.putExtra(FileDetailActivity.EXTRA_MODE, FileDetailActivity.MODE_DETAILS);
         }
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, upload.getFile());
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, upload.getAccount());
+        showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
+        showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
         showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(),
                 (int) System.currentTimeMillis(), showDetailsIntent, 0);
@@ -769,8 +769,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
                 showDetailsIntent = new Intent(this, FileDetailActivity.class); 
                 showDetailsIntent.putExtra(FileDetailActivity.EXTRA_MODE, FileDetailActivity.MODE_DETAILS);
             }
-            showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, upload.getFile());
-            showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, upload.getAccount());
+            showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
+            showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
             showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
             mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(),
                     (int) System.currentTimeMillis(), showDetailsIntent, 0);

+ 5 - 5
src/com/owncloud/android/media/MediaService.java

@@ -40,8 +40,8 @@ import java.io.IOException;
 import com.owncloud.android.Log_OC;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDetailActivity;
-import com.owncloud.android.ui.fragment.FileDetailFragment;
 
 /**
  * Service that handles media playback, both audio and video. 
@@ -533,8 +533,8 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
     private void updateNotification(String content) {
         // TODO check if updating the Intent is really necessary
         Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, mFile);
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, mAccount);
+        showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, mFile);
+        showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, mAccount);
         showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 
                                                                 (int)System.currentTimeMillis(), 
@@ -570,8 +570,8 @@ public class MediaService extends Service implements OnCompletionListener, OnPre
         
         /// includes a pending intent in the notification showing the details view of the file
         Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, mFile);
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, mAccount);
+        showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, mFile);
+        showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, mAccount);
         showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 
                                                                 (int)System.currentTimeMillis(), 

+ 42 - 37
src/com/owncloud/android/ui/activity/FileDetailActivity.java

@@ -33,7 +33,6 @@ import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentTransaction;
 
 import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
 import com.actionbarsherlock.view.MenuItem;
 import com.owncloud.android.AccountUtils;
 import com.owncloud.android.Log_OC;
@@ -56,7 +55,7 @@ import com.owncloud.android.ui.preview.PreviewVideoActivity;
  * @author Bartek Przybylski
  * @author David A. Velasco
  */
-public class FileDetailActivity extends SherlockFragmentActivity implements FileFragment.ContainerActivity {
+public class FileDetailActivity extends FileActivity implements FileFragment.ContainerActivity {
     
     public static final int DIALOG_SHORT_WAIT = 0;
 
@@ -73,9 +72,6 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
     private FileUploaderBinder mUploaderBinder = null;
     private boolean mWaitingToPreview;
     
-    private OCFile mFile;
-    private Account mAccount;
-
     private FileDataStorageManager mStorageManager;
     private DownloadFinishReceiver mDownloadFinishReceiver;
 
@@ -91,10 +87,6 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
         super.onCreate(savedInstanceState);
         mStarted = false;
         
-        mFile = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);
-        mAccount = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT);
-        mStorageManager = new FileDataStorageManager(mAccount, getContentResolver());
-        
         // 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 && 
@@ -103,7 +95,7 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
 
         if (mDualPane) {
             // only happens when notifications (downloads, uploads) are clicked at the notification bar
-            changeToDualView(false);
+            backToDisplayActivity(false);
             
         } else {
             setContentView(R.layout.file_activity_details);
@@ -133,19 +125,21 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
         int mode = getIntent().getIntExtra(EXTRA_MODE, MODE_PREVIEW); 
         
         Fragment newFragment = null;
-        if (PreviewMediaFragment.canBePreviewed(mFile) && mode == MODE_PREVIEW) {
-            if (mFile.isDown()) {
+        OCFile file = getFile();
+        Account account = getAccount();
+        if (PreviewMediaFragment.canBePreviewed(file) && mode == MODE_PREVIEW) {
+            if (file.isDown()) {
                 int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
                 boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
-                newFragment = new PreviewMediaFragment(mFile, mAccount, startPlaybackPosition, autoplay);
+                newFragment = new PreviewMediaFragment(file, account, startPlaybackPosition, autoplay);
             
             } else {
-                newFragment = new FileDetailFragment(mFile, mAccount);
+                newFragment = new FileDetailFragment(file, account);
                 mWaitingToPreview = true;
             }
             
         } else {
-            newFragment = new FileDetailFragment(mFile, mAccount);
+            newFragment = new FileDetailFragment(file, account);
         }
         FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
         ft.replace(R.id.fragment, newFragment, FileDetailFragment.FTAG);
@@ -180,7 +174,7 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
     public void onStart() {
         super.onStart();
         Log_OC.e(TAG, "onStart");
-        if (mNewConfigurationChangeToApplyOnStart != null) {
+        if (mNewConfigurationChangeToApplyOnStart != null && !isRedirectingToSetupAccount()) {
             checkConfigurationChange(mNewConfigurationChangeToApplyOnStart);
             mNewConfigurationChangeToApplyOnStart = null;
         }
@@ -190,16 +184,18 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
     private void checkConfigurationChange(Configuration newConfig) {
         finish();
         Intent intent = null;
+        OCFile file = getFile();
+        Account account = getAccount();
         if ((newConfig.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE
                 && newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
             
             intent = new Intent(this, FileDisplayActivity.class);
-            intent .putExtra(FileDetailFragment.EXTRA_FILE, mFile);
-            intent .putExtra(FileDetailFragment.EXTRA_ACCOUNT, mAccount);
+            intent.putExtra(EXTRA_FILE, file);
+            intent.putExtra(EXTRA_ACCOUNT, account);
             intent.putExtra(EXTRA_MODE, getIntent().getIntExtra(EXTRA_MODE, MODE_PREVIEW));
             intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
             Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
-            if (fragment != null && mFile != null && fragment instanceof PreviewMediaFragment && mFile.isVideo()) {
+            if (fragment != null && file != null && fragment instanceof PreviewMediaFragment && file.isVideo()) {
                 PreviewMediaFragment videoFragment = (PreviewMediaFragment)fragment;
                 intent.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, videoFragment.getPosition());
                 intent.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, videoFragment.isPlaying());
@@ -207,11 +203,11 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
         
         } else {
             intent = new Intent(this, FileDetailActivity.class);
-            intent .putExtra(FileDetailFragment.EXTRA_FILE, mFile);
-            intent .putExtra(FileDetailFragment.EXTRA_ACCOUNT, mAccount);
+            intent .putExtra(EXTRA_FILE, file);
+            intent .putExtra(EXTRA_ACCOUNT, account);
             intent.putExtra(EXTRA_MODE, getIntent().getIntExtra(EXTRA_MODE, MODE_PREVIEW));
             Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
-            if (fragment != null && mFile != null && fragment instanceof PreviewMediaFragment && mFile.isVideo()) {
+            if (fragment != null && file != null && fragment instanceof PreviewMediaFragment && file.isVideo()) {
                 PreviewMediaFragment videoFragment = (PreviewMediaFragment)fragment;
                 intent.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, videoFragment.getPosition());
                 intent.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, videoFragment.isPlaying());
@@ -318,7 +314,7 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
         
         switch(item.getItemId()){
         case android.R.id.home:
-            changeToDualView(true);
+            backToDisplayActivity(true);
             returnValue = true;
             break;
         default:
@@ -330,18 +326,19 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
 
     @Override
     public void onBackPressed() {
-        changeToDualView(true);
+        backToDisplayActivity(true);
     }
     
-    private void changeToDualView(boolean moveToParent) {
+    private void backToDisplayActivity(boolean moveToParent) {
         Intent intent = new Intent(this, FileDisplayActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         OCFile targetFile = null;
-        if (mFile != null) {
-            targetFile = moveToParent ? mStorageManager.getFileById(mFile.getParentId()) : mFile;;
+        OCFile file = getFile();
+        if (file != null) {
+            targetFile = moveToParent ? mStorageManager.getFileById(file.getParentId()) : file;
         }
-        intent.putExtra(FileDetailFragment.EXTRA_FILE, targetFile);
-        intent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, mAccount);
+        intent.putExtra(EXTRA_FILE, targetFile);
+        intent.putExtra(EXTRA_ACCOUNT, getAccount());
         startActivity(intent);
         finish();
     }
@@ -393,16 +390,16 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
     @Override
     public void showFragmentWithDetails(OCFile file) {
         FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-        transaction.replace(R.id.fragment, new FileDetailFragment(file, mAccount), FileDetailFragment.FTAG); 
+        transaction.replace(R.id.fragment, new FileDetailFragment(file, getAccount()), FileDetailFragment.FTAG); 
         transaction.commit();
     }
 
     
     private void requestForDownload() {
-        if (!mDownloaderBinder.isDownloading(mAccount, mFile)) {
+        if (!mDownloaderBinder.isDownloading(getAccount(), getFile())) {
             Intent i = new Intent(this, FileDownloader.class);
-            i.putExtra(FileDownloader.EXTRA_ACCOUNT, mAccount);
-            i.putExtra(FileDownloader.EXTRA_FILE, mFile);
+            i.putExtra(FileDownloader.EXTRA_ACCOUNT, getAccount());
+            i.putExtra(FileDownloader.EXTRA_FILE, getFile());
             startService(i);
         }
     }
@@ -419,7 +416,7 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
         public void onReceive(Context context, Intent intent) {
             boolean sameAccount = isSameAccount(context, intent);
             String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
-            boolean samePath = (mFile != null && mFile.getRemotePath().equals(downloadedRemotePath));
+            boolean samePath = (getFile() != null && getFile().getRemotePath().equals(downloadedRemotePath));
             
             if (sameAccount && samePath) {
                 updateChildFragment(intent.getAction(), downloadedRemotePath, intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false));
@@ -452,9 +449,9 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
             } else if (downloadEvent.equals(FileDownloader.DOWNLOAD_FINISH_MESSAGE)) {
                 //  refresh the details fragment 
                 if (success && mWaitingToPreview) {
-                    mFile = mStorageManager.getFileById(mFile.getFileId());   // update the file from database, for the local storage path
+                    setFile(mStorageManager.getFileById(getFile().getFileId()));   // update the file from database, for the local storage path
                     FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-                    transaction.replace(R.id.fragment, new PreviewMediaFragment(mFile, mAccount, 0, true), FileDetailFragment.FTAG);
+                    transaction.replace(R.id.fragment, new PreviewMediaFragment(getFile(), getAccount(), 0, true), FileDetailFragment.FTAG);
                     transaction.commit();
                     mWaitingToPreview = false;
                     
@@ -467,10 +464,18 @@ public class FileDetailActivity extends SherlockFragmentActivity implements File
         
     }
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     protected void onAccountChanged() {
-        // TODO Auto-generated method stub
+        mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
         
+        FileFragment fragment = (FileFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
+        if (fragment != null && mStorageManager.getFileById(fragment.getFile().getFileId()) == null) {
+            /// the account was forced to be changed; probably was deleted from system settings
+            backToDisplayActivity(false);
+        }
     }
 
 }

+ 13 - 13
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -270,8 +270,8 @@ public class FileDisplayActivity extends FileActivity implements
         } 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);
         }
     }
@@ -482,7 +482,7 @@ public class FileDisplayActivity extends FileActivity implements
             if (fragment != null) {
                 OCFile file = fragment.getFile();
                 if (file != null) {
-                    outState.putParcelable(FileActivity.EXTRA_FILE, file);
+                    outState.putParcelable(EXTRA_FILE, file);
                 }
             }
         }
@@ -920,8 +920,8 @@ public class FileDisplayActivity extends FileActivity implements
 
     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);
     }
     
@@ -933,8 +933,8 @@ public class FileDisplayActivity extends FileActivity implements
             
         } 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);
@@ -951,8 +951,8 @@ public class FileDisplayActivity extends FileActivity implements
             
         } 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);
         }
     }
@@ -965,8 +965,8 @@ public class FileDisplayActivity extends FileActivity implements
             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);
         }
     }
@@ -1263,8 +1263,8 @@ public class FileDisplayActivity extends FileActivity implements
             
         } 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);
         }

+ 5 - 10
src/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import android.accounts.Account;
-import android.accounts.AccountManager;
 import android.app.Activity;
 import android.content.ActivityNotFoundException;
 import android.content.BroadcastReceiver;
@@ -57,7 +56,6 @@ import com.owncloud.android.files.services.FileObserverService;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
 import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
-import com.owncloud.android.network.OwnCloudClientUtils;
 import com.owncloud.android.operations.OnRemoteOperationListener;
 import com.owncloud.android.operations.RemoteOperation;
 import com.owncloud.android.operations.RemoteOperationResult;
@@ -66,6 +64,7 @@ import com.owncloud.android.operations.RemoveFileOperation;
 import com.owncloud.android.operations.RenameFileOperation;
 import com.owncloud.android.operations.SynchronizeFileOperation;
 import com.owncloud.android.ui.activity.ConflictsResolveActivity;
+import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDetailActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.dialog.EditNameDialog;
@@ -74,7 +73,6 @@ import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener;
 import com.owncloud.android.R;
 
 import eu.alefzero.webdav.OnDatatransferProgressListener;
-import eu.alefzero.webdav.WebdavClient;
 import eu.alefzero.webdav.WebdavUtils;
 
 /**
@@ -88,9 +86,6 @@ public class FileDetailFragment extends SherlockFragment implements
         ConfirmationDialogFragment.ConfirmationDialogFragmentListener, OnRemoteOperationListener, EditNameDialogListener,
         FileFragment {
 
-    public static final String EXTRA_FILE = "FILE";
-    public static final String EXTRA_ACCOUNT = "ACCOUNT";
-
     private FileFragment.ContainerActivity mContainerActivity;
     
     private int mLayout;
@@ -154,8 +149,8 @@ public class FileDetailFragment extends SherlockFragment implements
         super.onCreateView(inflater, container, savedInstanceState);
         
         if (savedInstanceState != null) {
-            mFile = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE);
-            mAccount = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_ACCOUNT);
+            mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE);
+            mAccount = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
         }
         
         if(mFile != null && mAccount != null) {
@@ -207,8 +202,8 @@ public class FileDetailFragment extends SherlockFragment implements
     @Override
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
-        outState.putParcelable(FileDetailFragment.EXTRA_FILE, mFile);
-        outState.putParcelable(FileDetailFragment.EXTRA_ACCOUNT, mAccount);
+        outState.putParcelable(FileActivity.EXTRA_FILE, mFile);
+        outState.putParcelable(FileActivity.EXTRA_ACCOUNT, mAccount);
     }
 
     @Override

+ 5 - 5
src/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -43,8 +43,8 @@ import com.owncloud.android.files.services.FileDownloader;
 import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
+import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDetailActivity;
-import com.owncloud.android.ui.fragment.FileDetailFragment;
 import com.owncloud.android.ui.fragment.FileFragment;
 
 import com.owncloud.android.AccountUtils;
@@ -88,8 +88,8 @@ public class PreviewImageActivity extends SherlockFragmentActivity implements Fi
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        mFile = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE);
-        mAccount = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT);
+        mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE);
+        mAccount = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT);
         if (mFile == null) {
             throw new IllegalStateException("Instanced with a NULL OCFile");
         }
@@ -313,8 +313,8 @@ public class PreviewImageActivity extends SherlockFragmentActivity implements Fi
     @Override
     public void showFragmentWithDetails(OCFile file) {
         Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file);
-        showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
+        showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, file);
+        showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
         showDetailsIntent.putExtra(FileDetailActivity.EXTRA_MODE, FileDetailActivity.MODE_DETAILS);
         startActivity(showDetailsIntent);
         int pos = mPreviewImagePagerAdapter.getFilePosition(file);