X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/a6a56bae2acae4f69c421fa5b8166a3cd5ebaf9f..576de8a8bcd3991cc3f701c1c353630ddbafc8e5:/src/com/owncloud/android/ui/activity/FileActivity.java diff --git a/src/com/owncloud/android/ui/activity/FileActivity.java b/src/com/owncloud/android/ui/activity/FileActivity.java index 2e47ce0b..31e3e862 100644 --- a/src/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/com/owncloud/android/ui/activity/FileActivity.java @@ -29,13 +29,14 @@ import android.os.Bundle; import android.webkit.MimeTypeMap; import com.actionbarsherlock.app.SherlockFragmentActivity; -import com.owncloud.android.Log_OC; +import com.owncloud.android.MainApp; import com.owncloud.android.R; -import com.owncloud.android.authentication.AccountAuthenticator; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.oc_framework.accounts.OwnCloudAccount; +import com.owncloud.android.oc_framework.network.webdav.WebdavUtils; +import com.owncloud.android.utils.Log_OC; -import eu.alefzero.webdav.WebdavUtils; /** * Activity with common behaviour for activities handling {@link OCFile}s in ownCloud {@link Account}s . @@ -47,6 +48,7 @@ public abstract class FileActivity extends SherlockFragmentActivity { public static final String EXTRA_FILE = "com.owncloud.android.ui.activity.FILE"; public static final String EXTRA_ACCOUNT = "com.owncloud.android.ui.activity.ACCOUNT"; public static final String EXTRA_WAITING_TO_PREVIEW = "com.owncloud.android.ui.activity.WAITING_TO_PREVIEW"; + public static final String EXTRA_FROM_NOTIFICATION= "com.owncloud.android.ui.activity.FROM_NOTIFICATION"; public static final String TAG = FileActivity.class.getSimpleName(); @@ -65,6 +67,14 @@ public abstract class FileActivity extends SherlockFragmentActivity { /** Flag to signal when the value of mAccount was restored from a saved state */ private boolean mAccountWasRestored; + + /** Flag to signal if the activity is launched by a notification */ + private boolean mFromNotification; + + /** Flag to signal if the server supports the Share API */ + private boolean mIsSharedSupported; + + /** @@ -82,9 +92,11 @@ public abstract class FileActivity extends SherlockFragmentActivity { if(savedInstanceState != null) { account = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT); mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE); + mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION); } else { account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT); mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE); + mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false); } setAccount(account, savedInstanceState != null); @@ -152,6 +164,7 @@ public abstract class FileActivity extends SherlockFragmentActivity { */ private void swapToDefaultAccount() { // default to the most recently used account + AccountManager accountManager = AccountManager.get(this); Account newAccount = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()); if (newAccount == null) { /// no account available: force account creation @@ -165,6 +178,7 @@ public abstract class FileActivity extends SherlockFragmentActivity { mAccountWasRestored = (newAccount.equals(mAccount)); mAccount = newAccount; } + setIsSharedSupported( Boolean.getBoolean(accountManager.getUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_SHARE_API))); } @@ -173,7 +187,7 @@ public abstract class FileActivity extends SherlockFragmentActivity { */ private void createFirstAccount() { AccountManager am = AccountManager.get(getApplicationContext()); - am.addAccount(AccountAuthenticator.ACCOUNT_TYPE, + am.addAccount(MainApp.getAccountType(), null, null, null, @@ -191,6 +205,7 @@ public abstract class FileActivity extends SherlockFragmentActivity { super.onSaveInstanceState(outState); outState.putParcelable(FileActivity.EXTRA_FILE, mFile); outState.putParcelable(FileActivity.EXTRA_ACCOUNT, mAccount); + outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification); } @@ -223,6 +238,12 @@ public abstract class FileActivity extends SherlockFragmentActivity { return mAccount; } + /** + * @return Value of mFromNotification: True if the Activity is launched by a notification + */ + public boolean fromNotification() { + return mFromNotification; + } /** * @return 'True' when the Activity is finishing to enforce the setup of a new account. @@ -233,6 +254,18 @@ public abstract class FileActivity extends SherlockFragmentActivity { /** + * @return 'True' if the server supports the Share API + */ + public boolean isSharedSupported() { + return mIsSharedSupported; + } + + + public void setIsSharedSupported(boolean mIsSharedSupported) { + this.mIsSharedSupported = mIsSharedSupported; + } + + /** * Helper class handling a callback from the {@link AccountManager} after the creation of * a new ownCloud {@link Account} finished, successfully or not. *