From 9ea45c74a70862a98599c05d75d6bbdfa0cbd954 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Tue, 28 Mar 2017 12:29:59 +0200 Subject: [PATCH] Basics of push --- .../authentication/AccountAuthenticator.java | 34 ++++++++++++++++--- .../files/services/FileDownloader.java | 10 +++++- .../android/files/services/FileUploader.java | 9 ++++- .../android/syncadapter/FileSyncAdapter.java | 10 +++++- .../android/ui/activity/FileActivity.java | 9 ++++- .../android/ui/activity/UserInfoActivity.java | 10 +++++- src/main/res/values/setup.xml | 2 ++ src/modified/res/values/setup.xml | 1 + 8 files changed, 76 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/owncloud/android/authentication/AccountAuthenticator.java b/src/main/java/com/owncloud/android/authentication/AccountAuthenticator.java index 8bcee0be43..d6f0d1b084 100644 --- a/src/main/java/com/owncloud/android/authentication/AccountAuthenticator.java +++ b/src/main/java/com/owncloud/android/authentication/AccountAuthenticator.java @@ -94,7 +94,14 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator { return e.getFailureBundle(); } - Intent intent = new Intent(mContext, AuthenticatorActivity.class); + Intent intent; + if (!mContext.getResources().getBoolean(R.bool.push_enabled) && + !mContext.getResources().getBoolean(R.bool.analytics_enabled)) { + intent = new Intent(mContext, AuthenticatorActivity.class); + } else { + intent = new Intent(mContext, ModifiedAuthenticatorActivity.class); + } + intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType); intent.putExtra(KEY_REQUIRED_FEATURES, requiredFeatures); @@ -138,7 +145,14 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator { return e.getFailureBundle(); } - Intent intent = new Intent(mContext, AuthenticatorActivity.class); + Intent intent; + if (!mContext.getResources().getBoolean(R.bool.push_enabled) + && !mContext.getResources().getBoolean(R.bool.analytics_enabled)) { + intent = new Intent(mContext, AuthenticatorActivity.class); + } else { + intent = new Intent(mContext, ModifiedAuthenticatorActivity.class); + } + intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); intent.putExtra(KEY_ACCOUNT, account); @@ -189,7 +203,13 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator { } /// if not stored, return Intent to access the AuthenticatorActivity and UPDATE the token for the account - Intent intent = new Intent(mContext, AuthenticatorActivity.class); + Intent intent; + if (!mContext.getResources().getBoolean(R.bool.push_enabled) + && !mContext.getResources().getBoolean(R.bool.analytics_enabled)) { + intent = new Intent(mContext, AuthenticatorActivity.class); + } else { + intent = new Intent(mContext, ModifiedAuthenticatorActivity.class); + } intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType); intent.putExtra(KEY_LOGIN_OPTIONS, options); @@ -220,7 +240,13 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator { Account account, String authTokenType, Bundle options) throws NetworkErrorException { - Intent intent = new Intent(mContext, AuthenticatorActivity.class); + Intent intent; + if (!mContext.getResources().getBoolean(R.bool.push_enabled) && + !mContext.getResources().getBoolean(R.bool.analytics_enabled)) { + intent = new Intent(mContext, AuthenticatorActivity.class); + } else { + intent = new Intent(mContext, ModifiedAuthenticatorActivity.class); + } intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); intent.putExtra(KEY_ACCOUNT, account); intent.putExtra(KEY_AUTH_TOKEN_TYPE, authTokenType); diff --git a/src/main/java/com/owncloud/android/files/services/FileDownloader.java b/src/main/java/com/owncloud/android/files/services/FileDownloader.java index eb1065a677..8ee6c468ec 100644 --- a/src/main/java/com/owncloud/android/files/services/FileDownloader.java +++ b/src/main/java/com/owncloud/android/files/services/FileDownloader.java @@ -41,6 +41,7 @@ import android.util.Pair; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; +import com.owncloud.android.authentication.ModifiedAuthenticatorActivity; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.OwnCloudAccount; @@ -579,7 +580,14 @@ public class FileDownloader extends Service if (needsToUpdateCredentials) { // let the user update credentials with one click - Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); + Intent updateAccountCredentials; + if (!getResources().getBoolean(R.bool.push_enabled) + && !getResources().getBoolean(R.bool.analytics_enabled)) { + updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); + } else { + updateAccountCredentials = new Intent(this, ModifiedAuthenticatorActivity.class); + } + updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, download.getAccount()); updateAccountCredentials.putExtra( diff --git a/src/main/java/com/owncloud/android/files/services/FileUploader.java b/src/main/java/com/owncloud/android/files/services/FileUploader.java index f4a98663c5..8b2b647c61 100644 --- a/src/main/java/com/owncloud/android/files/services/FileUploader.java +++ b/src/main/java/com/owncloud/android/files/services/FileUploader.java @@ -48,6 +48,7 @@ import android.util.Pair; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; +import com.owncloud.android.authentication.ModifiedAuthenticatorActivity; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.ThumbnailsCacheManager; @@ -1081,7 +1082,13 @@ public class FileUploader extends Service if (needsToUpdateCredentials) { // let the user update credentials with one click // let the user update credentials with one click - Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); + Intent updateAccountCredentials; + if (!getResources().getBoolean(R.bool.push_enabled) + && !getResources().getBoolean(R.bool.analytics_enabled)) { + updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); + } else { + updateAccountCredentials = new Intent(this, ModifiedAuthenticatorActivity.class); + } updateAccountCredentials.putExtra( AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount() ); diff --git a/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java index d34c979e09..36160edafa 100644 --- a/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java +++ b/src/main/java/com/owncloud/android/syncadapter/FileSyncAdapter.java @@ -37,6 +37,7 @@ import android.support.v4.app.NotificationCompat; import com.owncloud.android.R; import com.owncloud.android.authentication.AuthenticatorActivity; +import com.owncloud.android.authentication.ModifiedAuthenticatorActivity; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.operations.RemoteOperationResult; @@ -400,7 +401,14 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { if (needsToUpdateCredentials) { // let the user update credentials with one click // let the user update credentials with one click - Intent updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class); + Intent updateAccountCredentials; + if (!getContext().getResources().getBoolean(R.bool.push_enabled) + && !getContext().getResources().getBoolean(R.bool.analytics_enabled)) { + updateAccountCredentials = new Intent(getContext(), AuthenticatorActivity.class); + } else { + updateAccountCredentials = new Intent(getContext(), ModifiedAuthenticatorActivity.class); + } + updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount()); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN); diff --git a/src/main/java/com/owncloud/android/ui/activity/FileActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileActivity.java index a6b61ae320..1a7e9b0c02 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileActivity.java @@ -40,6 +40,7 @@ import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; +import com.owncloud.android.authentication.ModifiedAuthenticatorActivity; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.ui.helpers.FileOperationsHelper; import com.owncloud.android.files.services.FileDownloader; @@ -396,7 +397,13 @@ public abstract class FileActivity extends DrawerActivity } /// step 2 - request credentials to user - Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); + Intent updateAccountCredentials; + if (!getResources().getBoolean(R.bool.push_enabled) && + !getResources().getBoolean(R.bool.analytics_enabled)) { + updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); + } else { + updateAccountCredentials = new Intent(this, ModifiedAuthenticatorActivity.class); + } updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account); updateAccountCredentials.putExtra( AuthenticatorActivity.EXTRA_ACTION, diff --git a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java index d6fe3dc334..0317d3aaf2 100644 --- a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java @@ -48,6 +48,7 @@ import android.widget.TextView; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AuthenticatorActivity; +import com.owncloud.android.authentication.ModifiedAuthenticatorActivity; import com.owncloud.android.lib.common.UserInfo; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; @@ -285,7 +286,14 @@ public class UserInfoActivity extends FileActivity { private void changeAccountPassword(Account account) { // let the user update credentials with one click - Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); + Intent updateAccountCredentials; + if (!getResources().getBoolean(R.bool.push_enabled) && + !getResources().getBoolean(R.bool.analytics_enabled)) { + updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); + } else { + updateAccountCredentials = new Intent(this, ModifiedAuthenticatorActivity.class); + } + updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_TOKEN); diff --git a/src/main/res/values/setup.xml b/src/main/res/values/setup.xml index d1da3caa49..92444bdd48 100644 --- a/src/main/res/values/setup.xml +++ b/src/main/res/values/setup.xml @@ -118,6 +118,8 @@ false + false + false diff --git a/src/modified/res/values/setup.xml b/src/modified/res/values/setup.xml index cabd9cbdb0..015e777ed2 100644 --- a/src/modified/res/values/setup.xml +++ b/src/modified/res/values/setup.xml @@ -112,6 +112,7 @@ false + true true