Skip to content

Commit 64f6c88

Browse files
fix user account switch, use account name instead of hash
Signed-off-by: tobiasKaminsky <[email protected]>
1 parent 0830e68 commit 64f6c88

File tree

8 files changed

+13
-12
lines changed

8 files changed

+13
-12
lines changed

app/src/main/java/com/nextcloud/client/account/UserAccountManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public interface UserAccountManager extends CurrentAccountProvider {
9595

9696
boolean setCurrentOwnCloudAccount(String accountName);
9797

98-
boolean setCurrentOwnCloudAccount(int hashCode);
98+
boolean setCurrentOwnCloudAccount(User user);
9999

100100
/**
101101
* Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER

app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,11 @@ public boolean setCurrentOwnCloudAccount(String accountName) {
346346
}
347347

348348
@Override
349-
public boolean setCurrentOwnCloudAccount(int hashCode) {
349+
public boolean setCurrentOwnCloudAccount(User chosenUser) {
350350
boolean result = false;
351-
if (hashCode != 0) {
351+
if (chosenUser != null) {
352352
for (final User user : getAllUsers()) {
353-
if (hashCode == user.hashCode()) {
353+
if (chosenUser.nameEquals(user)) {
354354
SharedPreferences.Editor appPrefs = PreferenceManager.getDefaultSharedPreferences(context).edit();
355355
appPrefs.putString(PREF_SELECT_OC_ACCOUNT, user.getAccountName());
356356
appPrefs.apply();

app/src/main/java/com/nextcloud/ui/ChooseAccountDialogFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class ChooseAccountDialogFragment :
231231
}
232232

233233
override fun onAccountClicked(user: User?) {
234-
(activity as DrawerActivity).accountClicked(user.hashCode())
234+
(activity as DrawerActivity).accountClicked(user)
235235
}
236236

237237
override fun onOptionItemClicked(user: User?, view: View?) {

app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,11 @@ private void launchActivityForSearch(SearchEvent searchEvent, int menuItemId) {
734734
* sets the new/current account and restarts. In case the given account equals the actual/current account the call
735735
* will be ignored.
736736
*
737-
* @param hashCode HashCode of account to be set
737+
* @param User user to be set
738738
*/
739-
public void accountClicked(int hashCode) {
739+
public void accountClicked(User user) {
740740
final User currentUser = accountManager.getUser();
741-
if (currentUser.hashCode() != hashCode && accountManager.setCurrentOwnCloudAccount(hashCode)) {
741+
if (!currentUser.nameEquals(user) && accountManager.setCurrentOwnCloudAccount(user)) {
742742
fetchExternalLinks(true);
743743
restart();
744744
}

app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ import com.owncloud.android.utils.ErrorMessageAdapter
153153
import com.owncloud.android.utils.FileSortOrder
154154
import com.owncloud.android.utils.MimeTypeUtil
155155
import com.owncloud.android.utils.PermissionUtil
156-
import com.owncloud.android.utils.PermissionUtil.requestStoragePermissionIfNeeded
157156
import com.owncloud.android.utils.PermissionUtil.requestNotificationPermission
157+
import com.owncloud.android.utils.PermissionUtil.requestStoragePermissionIfNeeded
158158
import com.owncloud.android.utils.PushUtils
159159
import com.owncloud.android.utils.StringUtils
160160
import com.owncloud.android.utils.theme.CapabilityUtils
@@ -2875,7 +2875,7 @@ class FileDisplayActivity :
28752875
} else if (!TextUtils.isEmpty(filePath)) {
28762876
openFileByPath(optionalUser.get(), filePath)
28772877
} else {
2878-
accountClicked(optionalUser.get().hashCode())
2878+
accountClicked(optionalUser.get())
28792879
}
28802880
} else {
28812881
DisplayUtils.showSnackMessage(this, getString(R.string.associated_account_not_found))

app/src/main/java/com/owncloud/android/ui/activity/ManageAccountsActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ class ManageAccountsActivity :
435435
val itemId = item.itemId
436436
when (itemId) {
437437
R.id.action_open_account -> {
438-
accountClicked(user.hashCode())
438+
accountClicked(user)
439439
}
440440
R.id.action_delete_account -> {
441441
openAccountRemovalDialog(user, supportFragmentManager)

app/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
161161
if (itemId == android.R.id.home) {
162162
getOnBackPressedDispatcher().onBackPressed();
163163
} else if (itemId == R.id.action_open_account) {
164-
accountClicked(user.hashCode());
164+
accountClicked(user);
165165
} else if (itemId == R.id.action_delete_account) {
166166
openAccountRemovalDialog(user, getSupportFragmentManager());
167167
} else {

app/src/main/java/com/owncloud/android/utils/PermissionUtil.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ object PermissionUtil {
161161
}
162162

163163
// region Storage permission checks
164+
164165
/**
165166
* Checks if the application has storage/media access permissions.
166167
*

0 commit comments

Comments
 (0)