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

Ensure that userId is always present (#3909)

Ensure that userId is always present
Tobias Kaminsky 6 жил өмнө
parent
commit
deffbd8b00
28 өөрчлөгдсөн 275 нэмэгдсэн , 330 устгасан
  1. 0 0
      src/androidTest/disabledTests/AuthenticatorActivityTest.java
  2. 84 0
      src/androidTest/java/com/nextcloud/client/account/OwnCloudClientManagerTest.java
  3. 51 0
      src/androidTest/java/com/nextcloud/client/account/UserAccountManagerImplTest.java
  4. 4 4
      src/androidTest/java/com/owncloud/android/AbstractIT.java
  5. 1 1
      src/main/java/com/nextcloud/android/sso/Constants.java
  6. 2 12
      src/main/java/com/nextcloud/client/account/UserAccountManager.java
  7. 25 78
      src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java
  8. 9 0
      src/main/java/com/nextcloud/client/preferences/AppPreferences.java
  9. 11 0
      src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java
  10. 6 6
      src/main/java/com/owncloud/android/MainApp.java
  11. 21 24
      src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java
  12. 2 5
      src/main/java/com/owncloud/android/operations/CommentFileOperation.java
  13. 1 11
      src/main/java/com/owncloud/android/operations/GetUserProfileOperation.java
  14. 2 10
      src/main/java/com/owncloud/android/operations/UploadFileOperation.java
  15. 15 17
      src/main/java/com/owncloud/android/operations/common/SyncOperation.java
  16. 3 14
      src/main/java/com/owncloud/android/services/OperationsService.java
  17. 1 19
      src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java
  18. 0 6
      src/main/java/com/owncloud/android/ui/activity/FileActivity.java
  19. 7 5
      src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java
  20. 1 2
      src/main/java/com/owncloud/android/ui/asynctasks/FetchRemoteFileTask.java
  21. 6 30
      src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java
  22. 6 14
      src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java
  23. 2 12
      src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
  24. 1 4
      src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java
  25. 4 9
      src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java
  26. 10 24
      src/main/java/com/owncloud/android/ui/trashbin/RemoteTrashbinRepository.java
  27. 0 22
      src/main/res/values-large-land/bools.xml
  28. 0 1
      src/main/res/values/setup.xml

+ 0 - 0
src/androidTest/java/com/owncloud/android/authentication/AuthenticatorActivityTest.java → src/androidTest/disabledTests/AuthenticatorActivityTest.java


+ 84 - 0
src/androidTest/java/com/nextcloud/client/account/OwnCloudClientManagerTest.java

@@ -0,0 +1,84 @@
+/* Nextcloud Android Library is available under MIT license
+ *
+ *   @author Tobias Kaminsky
+ *   Copyright (C) 2019 Tobias Kaminsky
+ *   Copyright (C) 2019 Nextcloud GmbH
+ *
+ *   Permission is hereby granted, free of charge, to any person obtaining a copy
+ *   of this software and associated documentation files (the "Software"), to deal
+ *   in the Software without restriction, including without limitation the rights
+ *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ *   copies of the Software, and to permit persons to whom the Software is
+ *   furnished to do so, subject to the following conditions:
+ *
+ *   The above copyright notice and this permission notice shall be included in
+ *   all copies or substantial portions of the Software.
+ *
+ *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ *   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ *   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ *   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ *   THE SOFTWARE.
+ *
+ */
+
+package com.nextcloud.client.account;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
+import android.net.Uri;
+import android.os.Bundle;
+
+import com.owncloud.android.AbstractIT;
+import com.owncloud.android.lib.common.OwnCloudAccount;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientManager;
+import com.owncloud.android.lib.common.accounts.AccountUtils;
+
+import org.junit.Test;
+
+import java.io.IOException;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import static org.junit.Assert.assertEquals;
+
+public class OwnCloudClientManagerTest extends AbstractIT {
+
+    /**
+     * Like on files app we create & store an account in Android's account manager.
+     */
+    @Test
+    public void testUserId() throws OperationCanceledException, AuthenticatorException, IOException,
+        AccountUtils.AccountNotFoundException {
+        Bundle arguments = InstrumentationRegistry.getArguments();
+
+        Uri url = Uri.parse(arguments.getString("TEST_SERVER_URL"));
+        String loginName = arguments.getString("TEST_SERVER_USERNAME");
+        String password = arguments.getString("TEST_SERVER_PASSWORD");
+
+        AccountManager accountManager = AccountManager.get(targetContext);
+        String accountName = AccountUtils.buildAccountName(url, loginName);
+        Account newAccount = new Account(accountName, "nextcloud");
+
+        accountManager.addAccountExplicitly(newAccount, password, null);
+        accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_OC_BASE_URL, url.toString());
+        accountManager.setUserData(newAccount, AccountUtils.Constants.KEY_USER_ID, loginName);
+
+        OwnCloudClientManager manager = new OwnCloudClientManager();
+        OwnCloudAccount account = new OwnCloudAccount(newAccount, targetContext);
+
+        OwnCloudClient client = manager.getClientFor(account, targetContext);
+
+        assertEquals(loginName, client.getUserId());
+
+        accountManager.removeAccountExplicitly(newAccount);
+
+        assertEquals(1, accountManager.getAccounts().length);
+    }
+}

+ 51 - 0
src/androidTest/java/com/nextcloud/client/account/UserAccountManagerImplTest.java

@@ -0,0 +1,51 @@
+package com.nextcloud.client.account;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.os.Bundle;
+
+import com.nextcloud.client.preferences.AppPreferences;
+import com.nextcloud.client.preferences.AppPreferencesImpl;
+import com.owncloud.android.AbstractIT;
+import com.owncloud.android.lib.common.accounts.AccountUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNull;
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertFalse;
+
+public class UserAccountManagerImplTest extends AbstractIT {
+
+    private AccountManager accountManager;
+
+    @Before
+    public void setUp() {
+        accountManager = AccountManager.get(targetContext);
+    }
+
+    @Test
+    public void updateOneAccount() {
+        AppPreferences appPreferences = AppPreferencesImpl.fromContext(targetContext);
+        UserAccountManagerImpl sut = new UserAccountManagerImpl(targetContext, accountManager);
+        assertEquals(1, sut.getAccounts().length);
+        assertFalse(appPreferences.isUserIdMigrated());
+
+        Account account = sut.getAccounts()[0];
+
+        // for testing remove userId
+        accountManager.setUserData(account, AccountUtils.Constants.KEY_USER_ID, null);
+        assertNull(accountManager.getUserData(account, AccountUtils.Constants.KEY_USER_ID));
+
+        sut.migrateUserId();
+
+        Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
+        String userId = arguments.getString("TEST_SERVER_USERNAME");
+
+        // assume that userId == loginname (as we manually set it)
+        assertEquals(userId, accountManager.getUserData(account, AccountUtils.Constants.KEY_USER_ID));
+        assertTrue(appPreferences.isUserIdMigrated());
+    }
+}

+ 4 - 4
src/androidTest/java/com/owncloud/android/AbstractIT.java

@@ -47,10 +47,10 @@ public abstract class AbstractIT {
             Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
             Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
 
 
             Uri baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL"));
             Uri baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL"));
-            String username = arguments.getString("TEST_SERVER_USERNAME");
+            String loginName = arguments.getString("TEST_SERVER_USERNAME");
             String password = arguments.getString("TEST_SERVER_PASSWORD");
             String password = arguments.getString("TEST_SERVER_PASSWORD");
 
 
-            Account temp = new Account(username + "@" + baseUrl, MainApp.getAccountType(targetContext));
+            Account temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext));
 
 
             if (!com.owncloud.android.authentication.AccountUtils.exists(temp, targetContext)) {
             if (!com.owncloud.android.authentication.AccountUtils.exists(temp, targetContext)) {
                 AccountManager accountManager = AccountManager.get(targetContext);
                 AccountManager accountManager = AccountManager.get(targetContext);
@@ -59,11 +59,11 @@ public abstract class AbstractIT {
                         Integer.toString(com.owncloud.android.authentication.AccountUtils.ACCOUNT_VERSION));
                         Integer.toString(com.owncloud.android.authentication.AccountUtils.ACCOUNT_VERSION));
                 accountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
                 accountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
                 accountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
                 accountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
-                accountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, username);
+                accountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
             }
             }
 
 
             account = com.owncloud.android.authentication.AccountUtils.getOwnCloudAccountByName(targetContext,
             account = com.owncloud.android.authentication.AccountUtils.getOwnCloudAccountByName(targetContext,
-                                                                                                username + "@" + baseUrl);
+                                                                                                loginName + "@" + baseUrl);
 
 
             if (account == null) {
             if (account == null) {
                 throw new ActivityNotFoundException();
                 throw new ActivityNotFoundException();

+ 1 - 1
src/main/java/com/nextcloud/android/sso/Constants.java

@@ -26,7 +26,7 @@ package com.nextcloud.android.sso;
 
 
 public final class Constants {
 public final class Constants {
     // Authenticator related constants
     // Authenticator related constants
-    public static final String SSO_USERNAME = "username";
+    public static final String SSO_USER_ID = "user_id";
     public static final String SSO_TOKEN = "token";
     public static final String SSO_TOKEN = "token";
     public static final String SSO_SERVER_URL = "server_url";
     public static final String SSO_SERVER_URL = "server_url";
     public static final String SSO_SHARED_PREFERENCE = "single-sign-on";
     public static final String SSO_SHARED_PREFERENCE = "single-sign-on";

+ 2 - 12
src/main/java/com/nextcloud/client/account/UserAccountManager.java

@@ -25,11 +25,6 @@ import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.Nullable;
 
 
 public interface UserAccountManager extends CurrentAccountProvider {
 public interface UserAccountManager extends CurrentAccountProvider {
-
-    int ACCOUNT_VERSION = 1;
-    int ACCOUNT_VERSION_WITH_PROPER_ID = 2;
-    String ACCOUNT_USES_STANDARD_PASSWORD = "ACCOUNT_USES_STANDARD_PASSWORD";
-
     /**
     /**
      * Get configured NextCloud's user accounts.
      * Get configured NextCloud's user accounts.
      *
      *
@@ -39,14 +34,9 @@ public interface UserAccountManager extends CurrentAccountProvider {
     Account[] getAccounts();
     Account[] getAccounts();
 
 
     /**
     /**
-     * Update the accounts in AccountManager to meet the current
-     * version of accounts expected by the app, if needed.
-     * <p>
-     * Introduced to handle a change in the structure of stored account names
-     * needed to allow different Nextcloud servers in the same domain, but not in
-     * the same path.
+     * Verifies that every account has userId set.
      */
      */
-    void updateAccountVersion();
+    void migrateUserId();
 
 
     @Nullable
     @Nullable
     Account getAccountByName(String name);
     Account getAccountByName(String name);

+ 25 - 78
src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java

@@ -23,8 +23,10 @@ package com.nextcloud.client.account;
 import android.accounts.Account;
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AccountManager;
 import android.content.Context;
 import android.content.Context;
-import android.net.Uri;
+import android.text.TextUtils;
 
 
+import com.nextcloud.client.preferences.AppPreferences;
+import com.nextcloud.client.preferences.AppPreferencesImpl;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.authentication.AccountUtils;
@@ -80,34 +82,28 @@ public class UserAccountManagerImpl implements UserAccountManager {
         return null;
         return null;
     }
     }
 
 
-    public void updateAccountVersion() {
-        Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(context);
+    public void migrateUserId() {
+        AppPreferences appPreferences = AppPreferencesImpl.fromContext(context);
 
 
-        if (currentAccount == null) {
+        if (appPreferences.isUserIdMigrated()) {
+            // migration done
             return;
             return;
         }
         }
 
 
-        final String currentAccountVersion = accountManager.getUserData(currentAccount, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION);
-        final boolean needsUpdate = !String.valueOf(ACCOUNT_VERSION_WITH_PROPER_ID).equalsIgnoreCase(currentAccountVersion);
-        if (!needsUpdate) {
-            return;
-        }
-
-        Log_OC.i(TAG, "Upgrading accounts to account version #" + ACCOUNT_VERSION_WITH_PROPER_ID);
-
+        boolean success = false;
         Account[] ocAccounts = accountManager.getAccountsByType(MainApp.getAccountType(context));
         Account[] ocAccounts = accountManager.getAccountsByType(MainApp.getAccountType(context));
-        String serverUrl;
-        String username;
+        String userId;
         String displayName;
         String displayName;
-        String newAccountName;
-        Account newAccount;
         GetRemoteUserInfoOperation remoteUserNameOperation = new GetRemoteUserInfoOperation();
         GetRemoteUserInfoOperation remoteUserNameOperation = new GetRemoteUserInfoOperation();
 
 
         for (Account account : ocAccounts) {
         for (Account account : ocAccounts) {
-            // build new account name
-            serverUrl = accountManager.getUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_OC_BASE_URL);
+            String storedUserId = accountManager.getUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
 
 
-            // update user name
+            if (!TextUtils.isEmpty(storedUserId)) {
+                continue;
+            }
+
+            // add userId
             try {
             try {
                 OwnCloudAccount ocAccount = new OwnCloudAccount(account, context);
                 OwnCloudAccount ocAccount = new OwnCloudAccount(account, context);
                 OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton()
                 OwnCloudClient client = OwnCloudClientManagerFactory.getDefaultSingleton()
@@ -117,7 +113,7 @@ public class UserAccountManagerImpl implements UserAccountManager {
 
 
                 if (result.isSuccess()) {
                 if (result.isSuccess()) {
                     UserInfo userInfo = (UserInfo) result.getData().get(0);
                     UserInfo userInfo = (UserInfo) result.getData().get(0);
-                    username = userInfo.id;
+                    userId = userInfo.id;
                     displayName = userInfo.displayName;
                     displayName = userInfo.displayName;
                 } else {
                 } else {
                     // skip account, try it next time
                     // skip account, try it next time
@@ -129,68 +125,19 @@ public class UserAccountManagerImpl implements UserAccountManager {
                 continue;
                 continue;
             }
             }
 
 
-            newAccountName = com.owncloud.android.lib.common.accounts.AccountUtils.
-                buildAccountName(Uri.parse(serverUrl), username);
-
-            // migrate to a new account, if needed
-            if (!newAccountName.equals(account.name)) {
-                newAccount = migrateAccount(context, currentAccount, accountManager, serverUrl, newAccountName,
-                                            account);
+            accountManager.setUserData(account,
+                                       com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_DISPLAY_NAME,
+                                       displayName);
+            accountManager.setUserData(account,
+                                       com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID,
+                                       userId);
 
 
-            } else {
-                // servers which base URL is in the root of their domain need no change
-                Log_OC.d(TAG, account.name + " needs no upgrade ");
-                newAccount = account;
-            }
-
-            accountManager.setUserData(newAccount, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_DISPLAY_NAME, displayName);
-            accountManager.setUserData(newAccount, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID, username);
-
-            // at least, upgrade account version
-            Log_OC.d(TAG, "Setting version " + ACCOUNT_VERSION_WITH_PROPER_ID + " to " + newAccountName);
-            accountManager.setUserData(newAccount, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
-                                   Integer.toString(ACCOUNT_VERSION_WITH_PROPER_ID));
+            success = true;
         }
         }
-    }
 
 
-    @NonNull
-    private Account migrateAccount(Context context, Account currentAccount, AccountManager accountMgr,
-                                          String serverUrl, String newAccountName, Account account) {
-
-        Log_OC.d(TAG, "Upgrading " + account.name + " to " + newAccountName);
-
-        // create the new account
-        Account newAccount = new Account(newAccountName, MainApp.getAccountType(context));
-        String password = accountMgr.getPassword(account);
-        accountMgr.addAccountExplicitly(newAccount, (password != null) ? password : "", null);
-
-        // copy base URL
-        accountMgr.setUserData(newAccount, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_OC_BASE_URL, serverUrl);
-
-        // copy server version
-        accountMgr.setUserData(
-            newAccount,
-            com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_OC_VERSION,
-            accountMgr.getUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_OC_VERSION)
-        );
-
-        // copy cookies
-        accountMgr.setUserData(
-            newAccount,
-            com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_COOKIES,
-            accountMgr.getUserData(account, com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_COOKIES)
-        );
-
-        // don't forget the account saved in preferences as the current one
-        if (currentAccount.name.equals(account.name)) {
-            AccountUtils.setCurrentOwnCloudAccount(context, newAccountName);
+        if (success) {
+            appPreferences.setMigratedUserId(true);
         }
         }
-
-        // remove the old account
-        accountMgr.removeAccount(account, null, null);
-
-        // will assume it succeeds, not a big deal otherwise
-        return newAccount;
     }
     }
 
 
     private String getAccountType() {
     private String getAccountType() {

+ 9 - 0
src/main/java/com/nextcloud/client/preferences/AppPreferences.java

@@ -283,4 +283,13 @@ public interface AppPreferences {
 
 
     String getCurrentAccountName();
     String getCurrentAccountName();
     void setCurrentAccountName(String accountName);
     void setCurrentAccountName(String accountName);
+
+    /**
+     * Gets status of migration to user id, default false
+     *
+     * @return true: migration done: every account has userId, false: pending accounts without userId
+     */
+    boolean isUserIdMigrated();
+
+    void setMigratedUserId(boolean value);
 }
 }

+ 11 - 0
src/main/java/com/nextcloud/client/preferences/AppPreferencesImpl.java

@@ -70,6 +70,7 @@ public final class AppPreferencesImpl implements AppPreferences {
     private static final String PREF__SHOW_MEDIA_SCAN_NOTIFICATIONS = "show_media_scan_notifications";
     private static final String PREF__SHOW_MEDIA_SCAN_NOTIFICATIONS = "show_media_scan_notifications";
     private static final String PREF__LOCK = SettingsActivity.PREFERENCE_LOCK;
     private static final String PREF__LOCK = SettingsActivity.PREFERENCE_LOCK;
     private static final String PREF__SELECTED_ACCOUNT_NAME = "select_oc_account";
     private static final String PREF__SELECTED_ACCOUNT_NAME = "select_oc_account";
+    private static final String PREF__MIGRATED_USER_ID = "migrated_user_id";
 
 
     private final Context context;
     private final Context context;
     private final SharedPreferences preferences;
     private final SharedPreferences preferences;
@@ -436,6 +437,16 @@ public final class AppPreferencesImpl implements AppPreferences {
         preferences.edit().putString(PREF__SELECTED_ACCOUNT_NAME, accountName).apply();
         preferences.edit().putString(PREF__SELECTED_ACCOUNT_NAME, accountName).apply();
     }
     }
 
 
+    @Override
+    public boolean isUserIdMigrated() {
+        return preferences.getBoolean(PREF__MIGRATED_USER_ID, false);
+    }
+
+    @Override
+    public void setMigratedUserId(boolean value) {
+        preferences.edit().putBoolean(PREF__MIGRATED_USER_ID, value).apply();
+    }
+
     /**
     /**
      * Get preference value for a folder.
      * Get preference value for a folder.
      * If folder is not set itself, it finds an ancestor that is set.
      * If folder is not set itself, it finds an ancestor that is set.

+ 6 - 6
src/main/java/com/owncloud/android/MainApp.java

@@ -186,6 +186,12 @@ public class MainApp extends MultiDexApplication implements
 
 
         registerActivityLifecycleCallbacks(new ActivityInjector());
         registerActivityLifecycleCallbacks(new ActivityInjector());
 
 
+        Thread t = new Thread(() -> {
+            // best place, before any access to AccountManager or database
+            accountManager.migrateUserId();
+        });
+        t.start();
+
         JobManager.create(this).addJobCreator(
         JobManager.create(this).addJobCreator(
             new NCJobCreator(
             new NCJobCreator(
                 getApplicationContext(),
                 getApplicationContext(),
@@ -204,7 +210,6 @@ public class MainApp extends MultiDexApplication implements
         MainApp.storagePath = preferences.getStoragePath(getApplicationContext().getFilesDir().getAbsolutePath());
         MainApp.storagePath = preferences.getStoragePath(getApplicationContext().getFilesDir().getAbsolutePath());
 
 
         OwnCloudClientManagerFactory.setUserAgent(getUserAgent());
         OwnCloudClientManagerFactory.setUserAgent(getUserAgent());
-        OwnCloudClientManagerFactory.setNextcloudUserAgent(getNextcloudUserAgent());
 
 
         // initialise thumbnails cache on background thread
         // initialise thumbnails cache on background thread
         new ThumbnailsCacheManager.InitDiskCacheTask().execute();
         new ThumbnailsCacheManager.InitDiskCacheTask().execute();
@@ -513,11 +518,6 @@ public class MainApp extends MultiDexApplication implements
     }
     }
 
 
     public static String getUserAgent() {
     public static String getUserAgent() {
-        // Mozilla/5.0 (Android) ownCloud-android/1.7.0
-        return getUserAgent(R.string.user_agent);
-    }
-
-    public static String getNextcloudUserAgent() {
         // Mozilla/5.0 (Android) Nextcloud-android/2.1.0
         // Mozilla/5.0 (Android) Nextcloud-android/2.1.0
         return getUserAgent(R.string.nextcloud_user_agent);
         return getUserAgent(R.string.nextcloud_user_agent);
     }
     }

+ 21 - 24
src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -130,6 +130,7 @@ import java.security.cert.Certificate;
 import java.security.cert.CertificateException;
 import java.security.cert.CertificateException;
 import java.security.cert.CertificateFactory;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
 import java.security.cert.X509Certificate;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Map;
@@ -367,7 +368,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         mLoginWebView.getSettings().setDomStorageEnabled(true);
         mLoginWebView.getSettings().setDomStorageEnabled(true);
 
 
         if (useGenericUserAgent) {
         if (useGenericUserAgent) {
-            mLoginWebView.getSettings().setUserAgentString(MainApp.getNextcloudUserAgent());
+            mLoginWebView.getSettings().setUserAgentString(MainApp.getUserAgent());
         } else {
         } else {
             mLoginWebView.getSettings().setUserAgentString(getWebLoginUserAgent());
             mLoginWebView.getSettings().setUserAgentString(getWebLoginUserAgent());
         }
         }
@@ -1634,7 +1635,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
      */
      */
     @SuppressFBWarnings("DMI")
     @SuppressFBWarnings("DMI")
     @SuppressLint("TrulyRandom")
     @SuppressLint("TrulyRandom")
-    private boolean createAccount(RemoteOperationResult authResult) {
+    protected boolean createAccount(RemoteOperationResult authResult) {
         String accountType = MainApp.getAccountType(this);
         String accountType = MainApp.getAccountType(this);
 
 
         // create and save new ownCloud account
         // create and save new ownCloud account
@@ -1644,14 +1645,16 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
         }
         }
 
 
         Uri uri = Uri.parse(mServerInfo.mBaseUrl);
         Uri uri = Uri.parse(mServerInfo.mBaseUrl);
-        String username;
+        // used for authenticate on every login/network connection, determined by first login (weblogin/old login)
+        // can be anything: email, name, name with whitespaces
+        String loginName;
         if (!webViewLoginMethod) {
         if (!webViewLoginMethod) {
-            username = mUsernameInput.getText().toString().trim();
+            loginName = mUsernameInput.getText().toString().trim();
         } else {
         } else {
-            username = webViewUser;
+            loginName = webViewUser;
         }
         }
 
 
-        String accountName = com.owncloud.android.lib.common.accounts.AccountUtils.buildAccountName(uri, username);
+        String accountName = com.owncloud.android.lib.common.accounts.AccountUtils.buildAccountName(uri, loginName);
         Account newAccount = new Account(accountName, accountType);
         Account newAccount = new Account(accountName, accountType);
         if (AccountUtils.exists(newAccount, getApplicationContext())) {
         if (AccountUtils.exists(newAccount, getApplicationContext())) {
             // fail - not a new account, but an existing one; disallow
             // fail - not a new account, but an existing one; disallow
@@ -1686,32 +1689,26 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             final Intent intent = new Intent();
             final Intent intent = new Intent();
             intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
             intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
             intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);
             intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);
-            intent.putExtra(AccountManager.KEY_USERDATA, username);
+            intent.putExtra(AccountManager.KEY_USERDATA, loginName);
 
 
             /// add user data to the new account; TODO probably can be done in the last parameter
             /// add user data to the new account; TODO probably can be done in the last parameter
             //      addAccountExplicitly, or in KEY_USERDATA
             //      addAccountExplicitly, or in KEY_USERDATA
             mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION, mServerInfo.mVersion.getVersion());
             mAccountMgr.setUserData(mAccount, Constants.KEY_OC_VERSION, mServerInfo.mVersion.getVersion());
             mAccountMgr.setUserData(mAccount, Constants.KEY_OC_BASE_URL, mServerInfo.mBaseUrl);
             mAccountMgr.setUserData(mAccount, Constants.KEY_OC_BASE_URL, mServerInfo.mBaseUrl);
 
 
-            if (authResult.getData() != null) {
-                try {
-                    UserInfo userInfo = (UserInfo) authResult.getData().get(0);
-                    mAccountMgr.setUserData(mAccount, Constants.KEY_DISPLAY_NAME, userInfo.getDisplayName());
-                    mAccountMgr.setUserData(mAccount, Constants.KEY_USER_ID, userInfo.getId());
-                    mAccountMgr.setUserData(mAccount, Constants.KEY_OC_ACCOUNT_VERSION,
-                                            Integer.toString(AccountUtils.ACCOUNT_VERSION_WITH_PROPER_ID));
-
-                } catch (ClassCastException c) {
-                    mAccountMgr.setUserData(mAccount, Constants.KEY_OC_ACCOUNT_VERSION,
-                                            Integer.toString(AccountUtils.ACCOUNT_VERSION));
-                    Log_OC.w(TAG, "Couldn't get display name and user id for " + username);
-                }
-            } else {
-                mAccountMgr.setUserData(mAccount, Constants.KEY_OC_ACCOUNT_VERSION,
-                                        Integer.toString(AccountUtils.ACCOUNT_VERSION));
-                Log_OC.w(TAG, "Couldn't get display name and user id for " + username);
+            ArrayList<Object> authResultData = authResult.getData();
+            if (authResultData == null || authResultData.size() == 0) {
+                Log_OC.e(this, "Could not read user data!");
+                return false;
             }
             }
 
 
+            UserInfo userInfo = (UserInfo) authResultData.get(0);
+            mAccountMgr.setUserData(mAccount, Constants.KEY_DISPLAY_NAME, userInfo.getDisplayName());
+            mAccountMgr.setUserData(mAccount, Constants.KEY_USER_ID, userInfo.getId());
+            mAccountMgr.setUserData(mAccount, Constants.KEY_OC_ACCOUNT_VERSION,
+                                    Integer.toString(AccountUtils.ACCOUNT_VERSION_WITH_PROPER_ID));
+
+
             setAccountAuthenticatorResult(intent.getExtras());
             setAccountAuthenticatorResult(intent.getExtras());
             setResult(RESULT_OK, intent);
             setResult(RESULT_OK, intent);
 
 

+ 2 - 5
src/main/java/com/owncloud/android/operations/CommentFileOperation.java

@@ -35,18 +35,15 @@ public class CommentFileOperation extends SyncOperation {
 
 
     private String message;
     private String message;
     private String fileId;
     private String fileId;
-    private String userId;
 
 
     /**
     /**
      * Constructor
      * Constructor
      *
      *
      * @param message Comment to store
      * @param message Comment to store
-     * @param userId  userId to access correct dav endpoint
      */
      */
-    public CommentFileOperation(String message, String fileId, String userId) {
+    public CommentFileOperation(String message, String fileId) {
         this.message = message;
         this.message = message;
         this.fileId = fileId;
         this.fileId = fileId;
-        this.userId = userId;
     }
     }
 
 
     /**
     /**
@@ -56,7 +53,7 @@ public class CommentFileOperation extends SyncOperation {
      */
      */
     @Override
     @Override
     protected RemoteOperationResult run(OwnCloudClient client) {
     protected RemoteOperationResult run(OwnCloudClient client) {
-        RemoteOperationResult result = new CommentFileRemoteOperation(message, fileId, userId).execute(client);
+        RemoteOperationResult result = new CommentFileRemoteOperation(message, fileId).execute(client);
 
 
         if (!result.isSuccess()) {
         if (!result.isSuccess()) {
             Log_OC.e(this, "File with Id " + fileId + " could not be commented");
             Log_OC.e(this, "File with Id " + fileId + " could not be commented");

+ 1 - 11
src/main/java/com/owncloud/android/operations/GetUserProfileOperation.java

@@ -60,17 +60,7 @@ public class GetUserProfileOperation extends SyncOperation {
             AccountManager accountManager = AccountManager.get(MainApp.getAppContext());
             AccountManager accountManager = AccountManager.get(MainApp.getAppContext());
             UserInfo userInfo = (UserInfo) result.getData().get(0);
             UserInfo userInfo = (UserInfo) result.getData().get(0);
             Account storedAccount = getStorageManager().getAccount();
             Account storedAccount = getStorageManager().getAccount();
-            accountManager.setUserData(
-                storedAccount,
-                AccountUtils.Constants.KEY_DISPLAY_NAME,
-                userInfo.getDisplayName()
-            );
-
-            accountManager.setUserData(
-                    storedAccount,
-                    AccountUtils.Constants.KEY_USER_ID,
-                    userInfo.getId()
-            );
+            accountManager.setUserData(storedAccount, AccountUtils.Constants.KEY_DISPLAY_NAME, userInfo.getDisplayName());
         }
         }
         return result;
         return result;
     }
     }

+ 2 - 10
src/main/java/com/owncloud/android/operations/UploadFileOperation.java

@@ -22,7 +22,6 @@
 package com.owncloud.android.operations;
 package com.owncloud.android.operations;
 
 
 import android.accounts.Account;
 import android.accounts.Account;
-import android.accounts.AccountManager;
 import android.annotation.SuppressLint;
 import android.annotation.SuppressLint;
 import android.content.Context;
 import android.content.Context;
 import android.net.Uri;
 import android.net.Uri;
@@ -43,7 +42,6 @@ import com.owncloud.android.datamodel.UploadsStorageManager;
 import com.owncloud.android.db.OCUpload;
 import com.owncloud.android.db.OCUpload;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.lib.common.OwnCloudClient;
 import com.owncloud.android.lib.common.OwnCloudClient;
-import com.owncloud.android.lib.common.accounts.AccountUtils;
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
 import com.owncloud.android.lib.common.network.ProgressiveDataTransfer;
 import com.owncloud.android.lib.common.network.ProgressiveDataTransfer;
 import com.owncloud.android.lib.common.operations.OperationCancelledException;
 import com.owncloud.android.lib.common.operations.OperationCancelledException;
@@ -582,15 +580,12 @@ public class UploadFileOperation extends SyncOperation {
             /// perform the upload
             /// perform the upload
             if (size > ChunkedFileUploadRemoteOperation.CHUNK_SIZE_MOBILE) {
             if (size > ChunkedFileUploadRemoteOperation.CHUNK_SIZE_MOBILE) {
 
 
-                String userId = AccountManager.get(getContext()).getUserData(getAccount(),
-                                                                             AccountUtils.Constants.KEY_USER_ID);
-
                 boolean onWifiConnection = ConnectivityUtils.isOnlineWithWifi(mContext);
                 boolean onWifiConnection = ConnectivityUtils.isOnlineWithWifi(mContext);
 
 
                 mUploadOperation = new ChunkedFileUploadRemoteOperation(encryptedTempFile.getAbsolutePath(),
                 mUploadOperation = new ChunkedFileUploadRemoteOperation(encryptedTempFile.getAbsolutePath(),
                                                                         mFile.getParentRemotePath() + encryptedFileName,
                                                                         mFile.getParentRemotePath() + encryptedFileName,
                                                                         mFile.getMimeType(), mFile.getEtagInConflict(),
                                                                         mFile.getMimeType(), mFile.getEtagInConflict(),
-                                                                        timeStamp, userId, onWifiConnection);
+                                                                        timeStamp, onWifiConnection);
             } else {
             } else {
                 mUploadOperation = new UploadFileRemoteOperation(encryptedTempFile.getAbsolutePath(),
                 mUploadOperation = new UploadFileRemoteOperation(encryptedTempFile.getAbsolutePath(),
                         mFile.getParentRemotePath() + encryptedFileName, mFile.getMimeType(),
                         mFile.getParentRemotePath() + encryptedFileName, mFile.getMimeType(),
@@ -831,15 +826,12 @@ public class UploadFileOperation extends SyncOperation {
 
 
             // perform the upload
             // perform the upload
             if (size > ChunkedFileUploadRemoteOperation.CHUNK_SIZE_MOBILE) {
             if (size > ChunkedFileUploadRemoteOperation.CHUNK_SIZE_MOBILE) {
-                String userId = AccountManager.get(getContext()).getUserData(getAccount(),
-                                                                             AccountUtils.Constants.KEY_USER_ID);
-
                 boolean onWifiConnection = ConnectivityUtils.isOnlineWithWifi(mContext);
                 boolean onWifiConnection = ConnectivityUtils.isOnlineWithWifi(mContext);
 
 
                 mUploadOperation = new ChunkedFileUploadRemoteOperation(mFile.getStoragePath(),
                 mUploadOperation = new ChunkedFileUploadRemoteOperation(mFile.getStoragePath(),
                                                                         mFile.getRemotePath(), mFile.getMimeType(),
                                                                         mFile.getRemotePath(), mFile.getMimeType(),
                                                                         mFile.getEtagInConflict(),
                                                                         mFile.getEtagInConflict(),
-                                                                        timeStamp, userId, onWifiConnection);
+                                                                        timeStamp, onWifiConnection);
             } else {
             } else {
                 mUploadOperation = new UploadFileRemoteOperation(mFile.getStoragePath(),
                 mUploadOperation = new UploadFileRemoteOperation(mFile.getStoragePath(),
                         mFile.getRemotePath(), mFile.getMimeType(), mFile.getEtagInConflict(), timeStamp);
                         mFile.getRemotePath(), mFile.getMimeType(), mFile.getEtagInConflict(), timeStamp);

+ 15 - 17
src/main/java/com/owncloud/android/operations/common/SyncOperation.java

@@ -35,22 +35,20 @@ import lombok.Getter;
 /**
 /**
  * Operation which execution involves both interactions with an ownCloud server and
  * Operation which execution involves both interactions with an ownCloud server and
  * with local data in the device.
  * with local data in the device.
- * 
+ *
  * Provides methods to execute the operation both synchronously or asynchronously.
  * Provides methods to execute the operation both synchronously or asynchronously.
  */
  */
 public abstract class SyncOperation extends RemoteOperation {
 public abstract class SyncOperation extends RemoteOperation {
-    //private static final String TAG = SyncOperation.class.getSimpleName();
-
     @Getter private FileDataStorageManager storageManager;
     @Getter private FileDataStorageManager storageManager;
 
 
     /**
     /**
      * Synchronously executes the operation on the received ownCloud account.
      * Synchronously executes the operation on the received ownCloud account.
-     * 
+     *
      * Do not call this method from the main thread.
      * Do not call this method from the main thread.
-     * 
+     *
      * This method should be used whenever an ownCloud account is available, instead of
      * This method should be used whenever an ownCloud account is available, instead of
      * {@link #execute(OwnCloudClient, com.owncloud.android.datamodel.FileDataStorageManager)}.
      * {@link #execute(OwnCloudClient, com.owncloud.android.datamodel.FileDataStorageManager)}.
-     * 
+     *
      * @param storageManager
      * @param storageManager
      * @param context   Android context for the component calling the method.
      * @param context   Android context for the component calling the method.
      * @return          Result of the operation.
      * @return          Result of the operation.
@@ -67,13 +65,13 @@ public abstract class SyncOperation extends RemoteOperation {
         this.storageManager = storageManager;
         this.storageManager = storageManager;
         return super.execute(this.storageManager.getAccount(), context);
         return super.execute(this.storageManager.getAccount(), context);
     }
     }
-    
-	
-	/**
+
+
+    /**
 	 * Synchronously executes the remote operation
 	 * Synchronously executes the remote operation
-	 * 
+     *
      * Do not call this method from the main thread.
      * Do not call this method from the main thread.
-     * 
+     *
 	 * @param client	Client object to reach an ownCloud server during the execution of the o
 	 * @param client	Client object to reach an ownCloud server during the execution of the o
      *                  peration.
      *                  peration.
      * @param storageManager
      * @param storageManager
@@ -89,13 +87,13 @@ public abstract class SyncOperation extends RemoteOperation {
 		return super.execute(client);
 		return super.execute(client);
 	}
 	}
 
 
-	
+
     /**
     /**
      * Asynchronously executes the remote operation
      * Asynchronously executes the remote operation
-     * 
+     *
      * This method should be used whenever an ownCloud account is available, instead of
      * This method should be used whenever an ownCloud account is available, instead of
      * {@link #execute(OwnCloudClient)}.
      * {@link #execute(OwnCloudClient)}.
-     * 
+     *
      * @param account           ownCloud account in remote ownCloud server to reach during the
      * @param account           ownCloud account in remote ownCloud server to reach during the
      *                          execution of the operation.
      *                          execution of the operation.
      * @param context           Android context for the component calling the method.
      * @param context           Android context for the component calling the method.
@@ -121,10 +119,10 @@ public abstract class SyncOperation extends RemoteOperation {
     }
     }
     */
     */
 
 
-    
-	/**
+
+    /**
 	 * Asynchronously executes the remote operation
 	 * Asynchronously executes the remote operation
-	 * 
+     *
 	 * @param client			Client object to reach an ownCloud server during the
 	 * @param client			Client object to reach an ownCloud server during the
      *                          execution of the operation.
      *                          execution of the operation.
 	 * @param listener			Listener to be notified about the execution of the operation.
 	 * @param listener			Listener to be notified about the execution of the operation.

+ 3 - 14
src/main/java/com/owncloud/android/services/OperationsService.java

@@ -24,8 +24,6 @@ package com.owncloud.android.services;
 
 
 import android.accounts.Account;
 import android.accounts.Account;
 import android.accounts.AccountsException;
 import android.accounts.AccountsException;
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
 import android.app.Service;
 import android.app.Service;
 import android.content.Intent;
 import android.content.Intent;
 import android.net.Uri;
 import android.net.Uri;
@@ -47,7 +45,6 @@ import com.owncloud.android.lib.common.OwnCloudClient;
 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
 import com.owncloud.android.lib.common.OwnCloudCredentials;
 import com.owncloud.android.lib.common.OwnCloudCredentials;
 import com.owncloud.android.lib.common.OwnCloudCredentialsFactory;
 import com.owncloud.android.lib.common.OwnCloudCredentialsFactory;
-import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException;
 import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
 import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
 import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
@@ -105,7 +102,6 @@ public class OperationsService extends Service {
     public static final String EXTRA_SHARE_HIDE_FILE_DOWNLOAD = "HIDE_FILE_DOWNLOAD";
     public static final String EXTRA_SHARE_HIDE_FILE_DOWNLOAD = "HIDE_FILE_DOWNLOAD";
     public static final String EXTRA_SHARE_ID = "SHARE_ID";
     public static final String EXTRA_SHARE_ID = "SHARE_ID";
     public static final String EXTRA_SHARE_NOTE = "SHARE_NOTE";
     public static final String EXTRA_SHARE_NOTE = "SHARE_NOTE";
-    public static final String EXTRA_USER_ID = "USER_ID";
     public static final String EXTRA_IN_BACKGROUND = "IN_BACKGROUND";
     public static final String EXTRA_IN_BACKGROUND = "IN_BACKGROUND";
 
 
     public static final String EXTRA_COOKIE = "COOKIE";
     public static final String EXTRA_COOKIE = "COOKIE";
@@ -217,14 +213,8 @@ public class OperationsService extends Service {
     public void onDestroy() {
     public void onDestroy() {
         Log_OC.v(TAG, "Destroying service" );
         Log_OC.v(TAG, "Destroying service" );
         // Saving cookies
         // Saving cookies
-        try {
-            OwnCloudClientManagerFactory.getDefaultSingleton().
-                    saveAllClients(this, MainApp.getAccountType(getApplicationContext()));
-
-            // TODO - get rid of these exceptions
-        } catch (AccountNotFoundException | IOException | OperationCanceledException | AuthenticatorException e) {
-            Log_OC.d(TAG, e.getMessage(), e);
-        }
+        OwnCloudClientManagerFactory.getDefaultSingleton()
+            .saveAllClients(this, MainApp.getAccountType(getApplicationContext()));
 
 
         mUndispatchedFinishedOperations.clear();
         mUndispatchedFinishedOperations.clear();
 
 
@@ -701,9 +691,8 @@ public class OperationsService extends Service {
 
 
                     case ACTION_RESTORE_VERSION:
                     case ACTION_RESTORE_VERSION:
                         FileVersion fileVersion = operationIntent.getParcelableExtra(EXTRA_FILE_VERSION);
                         FileVersion fileVersion = operationIntent.getParcelableExtra(EXTRA_FILE_VERSION);
-                        String userId = operationIntent.getStringExtra(EXTRA_USER_ID);
                         operation = new RestoreFileVersionRemoteOperation(fileVersion.getRemoteId(),
                         operation = new RestoreFileVersionRemoteOperation(fileVersion.getRemoteId(),
-                                                                          fileVersion.getFileName(), userId);
+                                                                          fileVersion.getFileName());
                         break;
                         break;
 
 
                     default:
                     default:

+ 1 - 19
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -982,30 +982,12 @@ public abstract class DrawerActivity extends ToolbarActivity
                 }
                 }
 
 
                 final Context context = MainApp.getAppContext();
                 final Context context = MainApp.getAppContext();
-                AccountManager mAccountMgr = AccountManager.get(context);
-                String userId = mAccountMgr.getUserData(currentAccount,
-                        com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
-
-                RemoteOperation getQuotaInfoOperation;
-                if (TextUtils.isEmpty(userId)) {
-                    getQuotaInfoOperation = new GetRemoteUserInfoOperation();
-                } else {
-                    getQuotaInfoOperation = new GetRemoteUserInfoOperation(userId);
-                }
-
-                RemoteOperationResult result = getQuotaInfoOperation.execute(currentAccount, context);
+                RemoteOperationResult result = new GetRemoteUserInfoOperation().execute(currentAccount, context);
 
 
                 if (result.isSuccess() && result.getData() != null) {
                 if (result.isSuccess() && result.getData() != null) {
                     final UserInfo userInfo = (UserInfo) result.getData().get(0);
                     final UserInfo userInfo = (UserInfo) result.getData().get(0);
                     final Quota quota = userInfo.getQuota();
                     final Quota quota = userInfo.getQuota();
 
 
-                    // Since we always call this method, might as well put it here
-                    if (userInfo.getId() != null) {
-                        mAccountMgr.setUserData(currentAccount,
-                                com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID,
-                                userInfo.getId());
-                    }
-
                     if (quota != null) {
                     if (quota != null) {
                         final long used = quota.getUsed();
                         final long used = quota.getUsed();
                         final long total = quota.getTotal();
                         final long total = quota.getTotal();

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

@@ -177,12 +177,6 @@ public abstract class FileActivity extends DrawerActivity
                     false);
                     false);
         }
         }
 
 
-        Thread t = new Thread(() -> {
-            // best place, before any access to AccountManager or database
-            accountManager.updateAccountVersion();
-        });
-        t.start();
-
         setAccount(account, savedInstanceState != null);
         setAccount(account, savedInstanceState != null);
 
 
         mOperationsServiceConnection = new OperationsServiceConnection();
         mOperationsServiceConnection = new OperationsServiceConnection();

+ 7 - 5
src/main/java/com/owncloud/android/ui/activity/SsoGrantPermissionActivity.java

@@ -42,10 +42,7 @@ import android.util.Log;
 import android.widget.Button;
 import android.widget.Button;
 import android.widget.ImageView;
 import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.TextView;
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import butterknife.OnClick;
-import butterknife.Unbinder;
+
 import com.nextcloud.android.sso.Constants;
 import com.nextcloud.android.sso.Constants;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.R;
@@ -57,6 +54,11 @@ import com.owncloud.android.utils.ThemeUtils;
 
 
 import java.util.UUID;
 import java.util.UUID;
 
 
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.Unbinder;
+
 import static com.nextcloud.android.sso.Constants.DELIMITER;
 import static com.nextcloud.android.sso.Constants.DELIMITER;
 import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_ACCESS_DECLINED;
 import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_ACCESS_DECLINED;
 import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_NOT_FOUND;
 import static com.nextcloud.android.sso.Constants.EXCEPTION_ACCOUNT_NOT_FOUND;
@@ -201,7 +203,7 @@ public class SsoGrantPermissionActivity extends BaseActivity {
         result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
         result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
         result.putString(AccountManager.KEY_ACCOUNT_TYPE, MainApp.getAccountType(this));
         result.putString(AccountManager.KEY_ACCOUNT_TYPE, MainApp.getAccountType(this));
         result.putString(AccountManager.KEY_AUTHTOKEN, NEXTCLOUD_SSO);
         result.putString(AccountManager.KEY_AUTHTOKEN, NEXTCLOUD_SSO);
-        result.putString(Constants.SSO_USERNAME, userId);
+        result.putString(Constants.SSO_USER_ID, userId);
         result.putString(Constants.SSO_TOKEN, token);
         result.putString(Constants.SSO_TOKEN, token);
         result.putString(Constants.SSO_SERVER_URL, serverUrl);
         result.putString(Constants.SSO_SERVER_URL, serverUrl);
 
 

+ 1 - 2
src/main/java/com/owncloud/android/ui/asynctasks/FetchRemoteFileTask.java

@@ -66,8 +66,7 @@ public class FetchRemoteFileTask extends AsyncTask<Void, Void, String> {
 
 
         SearchRemoteOperation searchRemoteOperation = new SearchRemoteOperation(fileId,
         SearchRemoteOperation searchRemoteOperation = new SearchRemoteOperation(fileId,
                                                                                 FILE_ID_SEARCH,
                                                                                 FILE_ID_SEARCH,
-                                                                                false,
-                                                                                userId);
+                                                                                false);
         RemoteOperationResult remoteOperationResult = searchRemoteOperation.execute(account, fileDisplayActivity);
         RemoteOperationResult remoteOperationResult = searchRemoteOperation.execute(account, fileDisplayActivity);
 
 
         if (remoteOperationResult.isSuccess() && remoteOperationResult.getData() != null) {
         if (remoteOperationResult.isSuccess() && remoteOperationResult.getData() != null) {

+ 6 - 30
src/main/java/com/owncloud/android/ui/dialog/SetupEncryptionDialogFragment.java

@@ -21,6 +21,7 @@
 package com.owncloud.android.ui.dialog;
 package com.owncloud.android.ui.dialog;
 
 
 import android.accounts.Account;
 import android.accounts.Account;
+import android.accounts.AccountManager;
 import android.app.Dialog;
 import android.app.Dialog;
 import android.content.DialogInterface;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.Intent;
@@ -35,13 +36,12 @@ import android.widget.TextView;
 
 
 import com.owncloud.android.R;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.ArbitraryDataProvider;
 import com.owncloud.android.datamodel.ArbitraryDataProvider;
-import com.owncloud.android.lib.common.UserInfo;
+import com.owncloud.android.lib.common.accounts.AccountUtils;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.users.DeletePublicKeyOperation;
 import com.owncloud.android.lib.resources.users.DeletePublicKeyOperation;
 import com.owncloud.android.lib.resources.users.GetPrivateKeyOperation;
 import com.owncloud.android.lib.resources.users.GetPrivateKeyOperation;
 import com.owncloud.android.lib.resources.users.GetPublicKeyOperation;
 import com.owncloud.android.lib.resources.users.GetPublicKeyOperation;
-import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
 import com.owncloud.android.lib.resources.users.SendCSROperation;
 import com.owncloud.android.lib.resources.users.SendCSROperation;
 import com.owncloud.android.lib.resources.users.StorePrivateKeyOperation;
 import com.owncloud.android.lib.resources.users.StorePrivateKeyOperation;
 import com.owncloud.android.utils.CsrHelper;
 import com.owncloud.android.utils.CsrHelper;
@@ -253,19 +253,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment {
             //  - store public key
             //  - store public key
             //  - decrypt private key, store unencrypted private key in database
             //  - decrypt private key, store unencrypted private key in database
 
 
-            // get user id
-            String userID;
-            GetRemoteUserInfoOperation remoteUserNameOperation = new GetRemoteUserInfoOperation();
-            RemoteOperationResult remoteUserNameOperationResult = remoteUserNameOperation.execute(account, getContext());
-
-            if (remoteUserNameOperationResult.isSuccess() && remoteUserNameOperationResult.getData() != null) {
-                UserInfo userInfo = (UserInfo) remoteUserNameOperationResult.getData().get(0);
-                userID = userInfo.getId();
-            } else {
-                userID = account.name;
-            }
-
-            GetPublicKeyOperation publicKeyOperation = new GetPublicKeyOperation(userID);
+            GetPublicKeyOperation publicKeyOperation = new GetPublicKeyOperation();
             RemoteOperationResult publicKeyResult = publicKeyOperation.execute(account, getContext());
             RemoteOperationResult publicKeyResult = publicKeyOperation.execute(account, getContext());
 
 
             if (publicKeyResult.isSuccess()) {
             if (publicKeyResult.isSuccess()) {
@@ -347,22 +335,10 @@ public class SetupEncryptionDialogFragment extends DialogFragment {
                 // Create public/private key pair
                 // Create public/private key pair
                 KeyPair keyPair = EncryptionUtils.generateKeyPair();
                 KeyPair keyPair = EncryptionUtils.generateKeyPair();
 
 
-                // get user id
-                String userID;
-                GetRemoteUserInfoOperation remoteUserNameOperation = new GetRemoteUserInfoOperation();
-                RemoteOperationResult remoteUserNameOperationResult = remoteUserNameOperation.execute(account,
-                                                                                                      getContext());
-
-                if (remoteUserNameOperationResult.isSuccess() &&
-                        remoteUserNameOperationResult.getData() != null) {
-                    UserInfo userInfo = (UserInfo) remoteUserNameOperationResult.getData().get(0);
-                    userID = userInfo.getId();
-                } else {
-                    userID = account.name;
-                }
-
                 // create CSR
                 // create CSR
-                String urlEncoded = CsrHelper.generateCsrPemEncodedString(keyPair, userID);
+                AccountManager accountManager = AccountManager.get(getContext());
+                String userId = accountManager.getUserData(account, AccountUtils.Constants.KEY_USER_ID);
+                String urlEncoded = CsrHelper.generateCsrPemEncodedString(keyPair, userId);
 
 
                 SendCSROperation operation = new SendCSROperation(urlEncoded);
                 SendCSROperation operation = new SendCSROperation(urlEncoded);
                 RemoteOperationResult result = operation.execute(account, getContext());
                 RemoteOperationResult result = operation.execute(account, getContext());

+ 6 - 14
src/main/java/com/owncloud/android/ui/fragment/FileDetailActivitiesFragment.java

@@ -24,7 +24,6 @@
 package com.owncloud.android.ui.fragment;
 package com.owncloud.android.ui.fragment;
 
 
 import android.accounts.Account;
 import android.accounts.Account;
-import android.accounts.AccountManager;
 import android.accounts.AuthenticatorException;
 import android.accounts.AuthenticatorException;
 import android.accounts.OperationCanceledException;
 import android.accounts.OperationCanceledException;
 import android.content.Context;
 import android.content.Context;
@@ -146,7 +145,6 @@ public class FileDetailActivitiesFragment extends Fragment implements
     public String noResultsMessage;
     public String noResultsMessage;
 
 
     private boolean restoreFileVersionSupported;
     private boolean restoreFileVersionSupported;
-    private String userId;
     private FileOperationsHelper operationsHelper;
     private FileOperationsHelper operationsHelper;
     private VersionListInterface.CommentCallback callback;
     private VersionListInterface.CommentCallback callback;
 
 
@@ -188,10 +186,6 @@ public class FileDetailActivitiesFragment extends Fragment implements
         swipeListRefreshLayout.setOnRefreshListener(() -> onRefreshListLayout(swipeListRefreshLayout));
         swipeListRefreshLayout.setOnRefreshListener(() -> onRefreshListLayout(swipeListRefreshLayout));
         swipeEmptyListRefreshLayout.setOnRefreshListener(() -> onRefreshListLayout(swipeEmptyListRefreshLayout));
         swipeEmptyListRefreshLayout.setOnRefreshListener(() -> onRefreshListLayout(swipeEmptyListRefreshLayout));
 
 
-        AccountManager accountManager = AccountManager.get(getContext());
-        userId = accountManager.getUserData(account,
-                com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
-
         callback = new VersionListInterface.CommentCallback() {
         callback = new VersionListInterface.CommentCallback() {
 
 
             @Override
             @Override
@@ -227,7 +221,7 @@ public class FileDetailActivitiesFragment extends Fragment implements
         String trimmedComment = commentField.toString().trim();
         String trimmedComment = commentField.toString().trim();
 
 
         if (trimmedComment.length() > 0) {
         if (trimmedComment.length() > 0) {
-            new SubmitCommentTask(trimmedComment, userId, file.getLocalId(), callback, ownCloudClient).execute();
+            new SubmitCommentTask(trimmedComment, file.getLocalId(), callback, ownCloudClient).execute();
         }
         }
     }
     }
 
 
@@ -329,7 +323,7 @@ public class FileDetailActivitiesFragment extends Fragment implements
                 ArrayList<Object> versions = null;
                 ArrayList<Object> versions = null;
                 if (restoreFileVersionSupported) {
                 if (restoreFileVersionSupported) {
                     ReadFileVersionsRemoteOperation readFileVersionsOperation = new ReadFileVersionsRemoteOperation(
                     ReadFileVersionsRemoteOperation readFileVersionsOperation = new ReadFileVersionsRemoteOperation(
-                            file.getLocalId(), userId);
+                        file.getLocalId());
 
 
                     RemoteOperationResult result1 = readFileVersionsOperation.execute(ownCloudClient);
                     RemoteOperationResult result1 = readFileVersionsOperation.execute(ownCloudClient);
 
 
@@ -459,21 +453,19 @@ public class FileDetailActivitiesFragment extends Fragment implements
 
 
     @Override
     @Override
     public void onRestoreClicked(FileVersion fileVersion) {
     public void onRestoreClicked(FileVersion fileVersion) {
-        operationsHelper.restoreFileVersion(fileVersion, userId);
+        operationsHelper.restoreFileVersion(fileVersion);
     }
     }
 
 
     private static class SubmitCommentTask extends AsyncTask<Void, Void, Boolean> {
     private static class SubmitCommentTask extends AsyncTask<Void, Void, Boolean> {
 
 
         private String message;
         private String message;
-        private String userId;
         private String fileId;
         private String fileId;
         private VersionListInterface.CommentCallback callback;
         private VersionListInterface.CommentCallback callback;
         private OwnCloudClient client;
         private OwnCloudClient client;
 
 
-        private SubmitCommentTask(String message, String userId, String fileId,
-                                  VersionListInterface.CommentCallback callback, OwnCloudClient client) {
+        private SubmitCommentTask(String message, String fileId, VersionListInterface.CommentCallback callback,
+                                  OwnCloudClient client) {
             this.message = message;
             this.message = message;
-            this.userId = userId;
             this.fileId = fileId;
             this.fileId = fileId;
             this.callback = callback;
             this.callback = callback;
             this.client = client;
             this.client = client;
@@ -481,7 +473,7 @@ public class FileDetailActivitiesFragment extends Fragment implements
 
 
         @Override
         @Override
         protected Boolean doInBackground(Void... voids) {
         protected Boolean doInBackground(Void... voids) {
-            CommentFileOperation commentFileOperation = new CommentFileOperation(message, fileId, userId);
+            CommentFileOperation commentFileOperation = new CommentFileOperation(message, fileId);
 
 
             RemoteOperationResult result = commentFileOperation.execute(client);
             RemoteOperationResult result = commentFileOperation.execute(client);
 
 

+ 2 - 12
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -1454,15 +1454,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
             OwnCloudClient mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
             OwnCloudClient mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
                     getClientFor(ocAccount, MainApp.getAppContext());
                     getClientFor(ocAccount, MainApp.getAppContext());
 
 
-            String userId = mAccountMgr.getUserData(currentAccount,
-                    com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
-
-            if (TextUtils.isEmpty(userId)) {
-                userId = mClient.getCredentials().getUsername();
-            }
-
             ToggleFavoriteRemoteOperation toggleFavoriteOperation = new ToggleFavoriteRemoteOperation(
             ToggleFavoriteRemoteOperation toggleFavoriteOperation = new ToggleFavoriteRemoteOperation(
-                event.shouldFavorite, event.remotePath, userId);
+                event.shouldFavorite, event.remotePath);
             RemoteOperationResult remoteOperationResult = toggleFavoriteOperation.execute(mClient);
             RemoteOperationResult remoteOperationResult = toggleFavoriteOperation.execute(mClient);
 
 
             if (remoteOperationResult.isSuccess()) {
             if (remoteOperationResult.isSuccess()) {
@@ -1532,11 +1525,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
                 searchOnlyFolders = true;
                 searchOnlyFolders = true;
             }
             }
 
 
-            String userId = AccountManager.get(MainApp.getAppContext()).getUserData(currentAccount,
-                    com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
-
             remoteOperation = new SearchRemoteOperation(event.getSearchQuery(), event.getSearchType(),
             remoteOperation = new SearchRemoteOperation(event.getSearchQuery(), event.getSearchType(),
-                searchOnlyFolders, userId);
+                                                        searchOnlyFolders);
         } else {
         } else {
             remoteOperation = new GetRemoteSharesOperation();
             remoteOperation = new GetRemoteSharesOperation();
         }
         }

+ 1 - 4
src/main/java/com/owncloud/android/ui/fragment/ShareFileFragment.java

@@ -379,10 +379,7 @@ public class ShareFileFragment extends Fragment implements ShareUserListAdapter.
         @Override
         @Override
         public void onClick(View expirationView) {
         public void onClick(View expirationView) {
             if (mPublicShare != null && mPublicShare.getExpirationDate() > 0) {
             if (mPublicShare != null && mPublicShare.getExpirationDate() > 0) {
-                long chosenDateInMillis = -1;
-                if (mPublicShare != null) {
-                    chosenDateInMillis = mPublicShare.getExpirationDate();
-                }
+                long chosenDateInMillis = mPublicShare.getExpirationDate();
                 ExpirationDatePickerDialogFragment dialog =
                 ExpirationDatePickerDialogFragment dialog =
                         ExpirationDatePickerDialogFragment.newInstance(mFile, chosenDateInMillis);
                         ExpirationDatePickerDialogFragment.newInstance(mFile, chosenDateInMillis);
                 dialog.show(
                 dialog.show(

+ 4 - 9
src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java

@@ -492,9 +492,8 @@ public class FileOperationsHelper {
      * Helper method to revert to a file version. Starts a request to do it in {@link OperationsService}
      * Helper method to revert to a file version. Starts a request to do it in {@link OperationsService}
      *
      *
      * @param fileVersion The file version to restore
      * @param fileVersion The file version to restore
-     * @param userId      userId of current account
      */
      */
-    public void restoreFileVersion(FileVersion fileVersion, String userId) {
+    public void restoreFileVersion(FileVersion fileVersion) {
         if (fileVersion != null) {
         if (fileVersion != null) {
             mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
             mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
                     getString(R.string.wait_a_moment));
                     getString(R.string.wait_a_moment));
@@ -503,7 +502,6 @@ public class FileOperationsHelper {
             service.setAction(OperationsService.ACTION_RESTORE_VERSION);
             service.setAction(OperationsService.ACTION_RESTORE_VERSION);
             service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
             service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
             service.putExtra(OperationsService.EXTRA_FILE_VERSION, fileVersion);
             service.putExtra(OperationsService.EXTRA_FILE_VERSION, fileVersion);
-            service.putExtra(OperationsService.EXTRA_USER_ID, userId);
             mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
             mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
         } else {
         } else {
             Log_OC.e(TAG, "Trying to restore a NULL FileVersion");
             Log_OC.e(TAG, "Trying to restore a NULL FileVersion");
@@ -720,12 +718,9 @@ public class FileOperationsHelper {
 
 
         OCCapability capability = mFileActivity.getStorageManager().getCapability(mFileActivity.getAccount().name);
         OCCapability capability = mFileActivity.getStorageManager().getCapability(mFileActivity.getAccount().name);
         SendShareDialog mSendShareDialog;
         SendShareDialog mSendShareDialog;
-        if (capability != null) {
-            mSendShareDialog = SendShareDialog.newInstance(file, hideNcSharingOptions,
-                    capability.getFilesSharingPublicPasswordEnforced().isTrue());
-        } else {
-            mSendShareDialog = SendShareDialog.newInstance(file, hideNcSharingOptions, false);
-        }
+
+        mSendShareDialog = SendShareDialog.newInstance(file, hideNcSharingOptions,
+                                                       capability.getFilesSharingPublicPasswordEnforced().isTrue());
         mSendShareDialog.setFileOperationsHelper(this);
         mSendShareDialog.setFileOperationsHelper(this);
         mSendShareDialog.show(ft, "TAG_SEND_SHARE_DIALOG");
         mSendShareDialog.show(ft, "TAG_SEND_SHARE_DIALOG");
     }
     }

+ 10 - 24
src/main/java/com/owncloud/android/ui/trashbin/RemoteTrashbinRepository.java

@@ -48,22 +48,15 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
 
 
     private static final String TAG = RemoteTrashbinRepository.class.getSimpleName();
     private static final String TAG = RemoteTrashbinRepository.class.getSimpleName();
 
 
-    private String userId;
     private OwnCloudClient client;
     private OwnCloudClient client;
 
 
     RemoteTrashbinRepository(final Context context, final Account account) {
     RemoteTrashbinRepository(final Context context, final Account account) {
-        AccountManager platformAccountManager = AccountManager.get(context);
         try {
         try {
             OwnCloudAccount nextcloudAccount = new OwnCloudAccount(account, context);
             OwnCloudAccount nextcloudAccount = new OwnCloudAccount(account, context);
             client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(nextcloudAccount, context);
             client = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(nextcloudAccount, context);
         } catch (Exception e) {
         } catch (Exception e) {
             Log_OC.e(TAG, e.getMessage());
             Log_OC.e(TAG, e.getMessage());
         }
         }
-
-        userId = platformAccountManager.getUserData(
-            account,
-            com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID
-        );
     }
     }
 
 
     public void removeTrashbinFile(TrashbinFile file, OperationCallback callback) {
     public void removeTrashbinFile(TrashbinFile file, OperationCallback callback) {
@@ -99,24 +92,22 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
     }
     }
 
 
     public void emptyTrashbin(OperationCallback callback) {
     public void emptyTrashbin(OperationCallback callback) {
-        new EmptyTrashbinTask(client, userId, callback).execute();
+        new EmptyTrashbinTask(client, callback).execute();
     }
     }
 
 
     private static class EmptyTrashbinTask extends AsyncTask<Void, Void, Boolean> {
     private static class EmptyTrashbinTask extends AsyncTask<Void, Void, Boolean> {
 
 
         private OwnCloudClient client;
         private OwnCloudClient client;
-        private String userId;
         private OperationCallback callback;
         private OperationCallback callback;
 
 
-        private EmptyTrashbinTask(OwnCloudClient client, String userId, OperationCallback callback) {
+        private EmptyTrashbinTask(OwnCloudClient client, OperationCallback callback) {
             this.client = client;
             this.client = client;
-            this.userId = userId;
             this.callback = callback;
             this.callback = callback;
         }
         }
 
 
         @Override
         @Override
         protected Boolean doInBackground(Void... voids) {
         protected Boolean doInBackground(Void... voids) {
-            EmptyTrashbinRemoteOperation emptyTrashbinFileOperation = new EmptyTrashbinRemoteOperation(userId);
+            EmptyTrashbinRemoteOperation emptyTrashbinFileOperation = new EmptyTrashbinRemoteOperation();
             RemoteOperationResult result = emptyTrashbinFileOperation.execute(client);
             RemoteOperationResult result = emptyTrashbinFileOperation.execute(client);
 
 
             return result.isSuccess();
             return result.isSuccess();
@@ -132,28 +123,26 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
 
 
     @Override
     @Override
     public void restoreFile(TrashbinFile file, OperationCallback callback) {
     public void restoreFile(TrashbinFile file, OperationCallback callback) {
-        new RestoreTrashbinFileTask(file, userId, client, callback).execute();
+        new RestoreTrashbinFileTask(file, client, callback).execute();
     }
     }
 
 
     private static class RestoreTrashbinFileTask extends AsyncTask<Void, Void, Boolean> {
     private static class RestoreTrashbinFileTask extends AsyncTask<Void, Void, Boolean> {
 
 
         private TrashbinFile file;
         private TrashbinFile file;
-        private String userId;
         private OwnCloudClient client;
         private OwnCloudClient client;
         private TrashbinRepository.OperationCallback callback;
         private TrashbinRepository.OperationCallback callback;
 
 
-        private RestoreTrashbinFileTask(TrashbinFile file, String userId, OwnCloudClient client,
+        private RestoreTrashbinFileTask(TrashbinFile file, OwnCloudClient client,
                                         TrashbinRepository.OperationCallback callback) {
                                         TrashbinRepository.OperationCallback callback) {
             this.file = file;
             this.file = file;
-            this.userId = userId;
             this.client = client;
             this.client = client;
             this.callback = callback;
             this.callback = callback;
         }
         }
 
 
         @Override
         @Override
         protected Boolean doInBackground(Void... voids) {
         protected Boolean doInBackground(Void... voids) {
-            RemoteOperationResult result = new RestoreTrashbinFileRemoteOperation(
-                file.getFullRemotePath(), file.getFileName(), userId).execute(client);
+            RemoteOperationResult result = new RestoreTrashbinFileRemoteOperation(file.getFullRemotePath(),
+                                                                                  file.getFileName()).execute(client);
 
 
             return result.isSuccess();
             return result.isSuccess();
         }
         }
@@ -168,28 +157,25 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
 
 
     @Override
     @Override
     public void getFolder(String remotePath, @NonNull LoadFolderCallback callback) {
     public void getFolder(String remotePath, @NonNull LoadFolderCallback callback) {
-        new ReadRemoteTrashbinFolderTask(remotePath, userId, client, callback).execute();
+        new ReadRemoteTrashbinFolderTask(remotePath, client, callback).execute();
     }
     }
 
 
     private static class ReadRemoteTrashbinFolderTask extends AsyncTask<Void, Void, Boolean> {
     private static class ReadRemoteTrashbinFolderTask extends AsyncTask<Void, Void, Boolean> {
 
 
         private String remotePath;
         private String remotePath;
-        private String userId;
         private OwnCloudClient client;
         private OwnCloudClient client;
         private List<Object> trashbinFiles;
         private List<Object> trashbinFiles;
         private LoadFolderCallback callback;
         private LoadFolderCallback callback;
 
 
-        private ReadRemoteTrashbinFolderTask(String remotePath, String userId, OwnCloudClient client,
-                                             LoadFolderCallback callback) {
+        private ReadRemoteTrashbinFolderTask(String remotePath, OwnCloudClient client, LoadFolderCallback callback) {
             this.remotePath = remotePath;
             this.remotePath = remotePath;
-            this.userId = userId;
             this.client = client;
             this.client = client;
             this.callback = callback;
             this.callback = callback;
         }
         }
 
 
         @Override
         @Override
         protected Boolean doInBackground(Void... voids) {
         protected Boolean doInBackground(Void... voids) {
-            RemoteOperationResult result = new ReadTrashbinFolderRemoteOperation(remotePath, userId).execute(client);
+            RemoteOperationResult result = new ReadTrashbinFolderRemoteOperation(remotePath).execute(client);
 
 
             if (result.isSuccess()) {
             if (result.isSuccess()) {
                 trashbinFiles = result.getData();
                 trashbinFiles = result.getData();

+ 0 - 22
src/main/res/values-large-land/bools.xml

@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ownCloud Android client application
-
-  Copyright (C) 2015 ownCloud Inc.
-
-  This program is free software: you can redistribute it and/or modify
-  it under the terms of the GNU General Public License version 2,
-  as published by the Free Software Foundation.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program.  If not, see <http://www.gnu.org/licenses/>.
--->
-<!-- Large screen, landscape orientation boolean values -->
-<resources>
-    <bool name="large_land_layout">true</bool>
-</resources>

+ 0 - 1
src/main/res/values/setup.xml

@@ -17,7 +17,6 @@
     <string name="db_name">nextcloud</string>
     <string name="db_name">nextcloud</string>
     <string name="data_folder">nextcloud</string>
     <string name="data_folder">nextcloud</string>
     <string name="default_display_name_for_root_folder">Nextcloud</string>
     <string name="default_display_name_for_root_folder">Nextcloud</string>
-    <string name="user_agent">Mozilla/5.0 (Android) ownCloud-android/%1$s</string>
     <string name="nextcloud_user_agent">Mozilla/5.0 (Android) Nextcloud-android/%1$s</string>
     <string name="nextcloud_user_agent">Mozilla/5.0 (Android) Nextcloud-android/%1$s</string>
 
 
     <!-- URLs and flags related -->
     <!-- URLs and flags related -->