Browse Source

moved account handling to base activity since this is not file specific and thus should be available on (new) base level

Andy Scherzinger 9 years ago
parent
commit
3fef018452

+ 26 - 0
src/com/owncloud/android/ui/activity/BaseActivity.java

@@ -5,6 +5,7 @@ import android.accounts.AccountManager;
 import android.accounts.AccountManagerCallback;
 import android.accounts.AccountManagerFuture;
 import android.accounts.OperationCanceledException;
+import android.content.Intent;
 import android.os.Bundle;
 import android.os.Handler;
 import android.support.v7.app.AppCompatActivity;
@@ -52,6 +53,31 @@ public abstract class BaseActivity extends AppCompatActivity {
      */
     private FileDataStorageManager mStorageManager = null;
 
+    @Override
+    protected void onNewIntent (Intent intent) {
+        Log_OC.v(TAG, "onNewIntent() start");
+        Account current = AccountUtils.getCurrentOwnCloudAccount(this);
+        if (current != null && mCurrentAccount != null && !mCurrentAccount.name.equals(current.name)) {
+            mCurrentAccount = current;
+        }
+        Log_OC.v(TAG, "onNewIntent() stop");
+    }
+
+    /**
+     *  Since ownCloud {@link Account}s can be managed from the system setting menu, the existence of the {@link
+     *  Account} associated to the instance must be checked every time it is restarted.
+     */
+    @Override
+    protected void onRestart() {
+        Log_OC.v(TAG, "onRestart() start");
+        super.onRestart();
+        boolean validAccount = (mCurrentAccount != null && AccountUtils.exists(mCurrentAccount, this));
+        if (!validAccount) {
+            swapToDefaultAccount();
+        }
+        Log_OC.v(TAG, "onRestart() end");
+    }
+
     /**
      * Sets and validates the ownCloud {@link Account} associated to the Activity.
      * <p/>

+ 0 - 30
src/com/owncloud/android/ui/activity/FileActivity.java

@@ -97,9 +97,6 @@ public class FileActivity extends DrawerActivity
     private static final String DIALOG_UNTRUSTED_CERT = "DIALOG_UNTRUSTED_CERT";
     private static final String DIALOG_CERT_NOT_SAVED = "DIALOG_CERT_NOT_SAVED";
 
-    /** OwnCloud {@link Account} where the main {@link OCFile} handled by the activity is located.*/
-    private Account mAccount;
-
      /** Main {@link OCFile} handled by the activity.*/
     private OCFile mFile;
 
@@ -172,33 +169,6 @@ public class FileActivity extends DrawerActivity
 
     }
 
-    @Override
-    protected void onNewIntent (Intent intent) {
-        Log_OC.v(TAG, "onNewIntent() start");
-        Account current = AccountUtils.getCurrentOwnCloudAccount(this);
-        if (current != null && mAccount != null && !mAccount.name.equals(current.name)) {
-            mAccount = current;
-        }
-        Log_OC.v(TAG, "onNewIntent() stop");
-    }
-
-    /**
-     *  Since ownCloud {@link Account}s can be managed from the system setting menu,
-     *  the existence of the {@link Account} associated to the instance must be checked
-     *  every time it is restarted.
-     */
-    @Override
-    protected void onRestart() {
-        Log_OC.v(TAG, "onRestart() start");
-        super.onRestart();
-        boolean validAccount = (mAccount != null && AccountUtils.exists(mAccount, this));
-        if (!validAccount) {
-            swapToDefaultAccount();
-        }
-        Log_OC.v(TAG, "onRestart() end");
-    }
-
-
     @Override
     protected void onStart() {
         super.onStart();