From: masensio Date: Mon, 15 Jun 2015 11:56:41 +0000 (+0200) Subject: Merge pull request #1013 from owncloud/keep_permanent_redirections X-Git-Tag: oc-android-1.7.2~1^2~24 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/0b567b9713475d19fe586799a2e068f072c25da0?hp=42da742d5e96072a03f4a34314c50c7bc9193b03 Merge pull request #1013 from owncloud/keep_permanent_redirections Keep permanent redirections --- diff --git a/.travis.yml b/.travis.yml index d7e46cbc..2f5f171f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: android android: components: - - platform-tools - - tools - build-tools-20.0.0 - android-19 before_install: diff --git a/owncloud-android-library b/owncloud-android-library index e48aa9c3..639cb7ea 160000 --- a/owncloud-android-library +++ b/owncloud-android-library @@ -1 +1 @@ -Subproject commit e48aa9c30447d67b0f8ee2054e1fc826108fc5ec +Subproject commit 639cb7eacdae0b4b6dddbd8f446d8d42eb2617b5 diff --git a/src/com/owncloud/android/authentication/AccountUtils.java b/src/com/owncloud/android/authentication/AccountUtils.java index 1e67aa67..9afa819c 100644 --- a/src/com/owncloud/android/authentication/AccountUtils.java +++ b/src/com/owncloud/android/authentication/AccountUtils.java @@ -250,4 +250,21 @@ public class AccountUtils { } + public static String trimWebdavSuffix(String url) { + while(url.endsWith("/")) { + url = url.substring(0, url.length() - 1); + } + int pos = url.lastIndexOf(WEBDAV_PATH_4_0_AND_LATER); + if (pos >= 0) { + url = url.substring(0, pos); + + } else { + pos = url.lastIndexOf(ODAV_PATH); + if (pos >= 0) { + url = url.substring(0, pos); + } + } + return url; + } + } diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 713851ba..bf1010bc 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -785,8 +785,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity Intent getServerInfoIntent = new Intent(); getServerInfoIntent.setAction(OperationsService.ACTION_GET_SERVER_INFO); getServerInfoIntent.putExtra( - OperationsService.EXTRA_SERVER_URL, - normalizeUrlSuffix(uri) + OperationsService.EXTRA_SERVER_URL, + normalizeUrlSuffix(uri) ); if (mOperationsServiceBinder != null) { mWaitingForOpId = mOperationsServiceBinder.queueNewOperation(getServerInfoIntent); @@ -999,7 +999,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity if ( mAction == ACTION_CREATE) { mUsernameInput.setText(username); - success = createAccount(); + success = createAccount(result); } else { if (!mUsernameInput.getText().toString().equals(username)) { @@ -1351,8 +1351,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity Log_OC.d(TAG, "Successful access - time to save the account"); boolean success = false; + if (mAction == ACTION_CREATE) { - success = createAccount(); + success = createAccount(result); } else { try { @@ -1449,13 +1450,18 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity * * TODO Decide how to name the OAuth accounts */ - private boolean createAccount() { + private boolean createAccount(RemoteOperationResult authResult) { /// create and save new ownCloud account boolean isOAuth = AccountTypeUtils. getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType); boolean isSaml = AccountTypeUtils. getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType); + String lastPermanentLocation = authResult.getLastPermanentLocation(); + if (lastPermanentLocation != null) { + mServerInfo.mBaseUrl = AccountUtils.trimWebdavSuffix(lastPermanentLocation); + } + Uri uri = Uri.parse(mServerInfo.mBaseUrl); String username = mUsernameInput.getText().toString().trim(); if (isOAuth) { @@ -1513,7 +1519,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /// add user data to the new account; TODO probably can be done in the last parameter // addAccountExplicitly, or in KEY_USERDATA mAccountMgr.setUserData( - mAccount, Constants.KEY_OC_VERSION, mServerInfo.mVersion.getVersion() + mAccount, Constants.KEY_OC_VERSION, mServerInfo.mVersion.getVersion() ); mAccountMgr.setUserData( mAccount, Constants.KEY_OC_BASE_URL, mServerInfo.mBaseUrl diff --git a/src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java b/src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java index 4b2aed50..a25ade8b 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java +++ b/src/com/owncloud/android/authentication/AuthenticatorAsyncTask.java @@ -24,10 +24,10 @@ import android.content.Context; import android.net.Uri; import android.os.AsyncTask; -import com.owncloud.android.MainApp; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientFactory; import com.owncloud.android.lib.common.OwnCloudCredentials; +import com.owncloud.android.lib.common.network.RedirectionPath; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation; @@ -62,7 +62,6 @@ public class AuthenticatorAsyncTask extends AsyncTask