Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public interface UserAccountManager extends CurrentAccountProvider {

boolean setCurrentOwnCloudAccount(String accountName);

boolean setCurrentOwnCloudAccount(int hashCode);
boolean setCurrentOwnCloudAccount(User user);

/**
* Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ public boolean setCurrentOwnCloudAccount(String accountName) {
}

@Override
public boolean setCurrentOwnCloudAccount(int hashCode) {
public boolean setCurrentOwnCloudAccount(User chosenUser) {
boolean result = false;
if (hashCode != 0) {
if (chosenUser != null) {
for (final User user : getAllUsers()) {
if (hashCode == user.hashCode()) {
if (chosenUser.nameEquals(user)) {
SharedPreferences.Editor appPrefs = PreferenceManager.getDefaultSharedPreferences(context).edit();
appPrefs.putString(PREF_SELECT_OC_ACCOUNT, user.getAccountName());
appPrefs.apply();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class ChooseAccountDialogFragment :
}

override fun onAccountClicked(user: User?) {
(activity as DrawerActivity).accountClicked(user.hashCode())
(activity as DrawerActivity).accountClicked(user)
}

override fun onOptionItemClicked(user: User?, view: View?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,11 +734,11 @@ private void launchActivityForSearch(SearchEvent searchEvent, int menuItemId) {
* sets the new/current account and restarts. In case the given account equals the actual/current account the call
* will be ignored.
*
* @param hashCode HashCode of account to be set
* @param User user to be set
*/
public void accountClicked(int hashCode) {
public void accountClicked(User user) {
final User currentUser = accountManager.getUser();
if (currentUser.hashCode() != hashCode && accountManager.setCurrentOwnCloudAccount(hashCode)) {
if (!currentUser.nameEquals(user) && accountManager.setCurrentOwnCloudAccount(user)) {
fetchExternalLinks(true);
restart();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ import com.owncloud.android.utils.ErrorMessageAdapter
import com.owncloud.android.utils.FileSortOrder
import com.owncloud.android.utils.MimeTypeUtil
import com.owncloud.android.utils.PermissionUtil
import com.owncloud.android.utils.PermissionUtil.requestStoragePermissionIfNeeded
import com.owncloud.android.utils.PermissionUtil.requestNotificationPermission
import com.owncloud.android.utils.PermissionUtil.requestStoragePermissionIfNeeded
import com.owncloud.android.utils.PushUtils
import com.owncloud.android.utils.StringUtils
import com.owncloud.android.utils.theme.CapabilityUtils
Expand Down Expand Up @@ -2875,7 +2875,7 @@ class FileDisplayActivity :
} else if (!TextUtils.isEmpty(filePath)) {
openFileByPath(optionalUser.get(), filePath)
} else {
accountClicked(optionalUser.get().hashCode())
accountClicked(optionalUser.get())
}
} else {
DisplayUtils.showSnackMessage(this, getString(R.string.associated_account_not_found))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class ManageAccountsActivity :
val itemId = item.itemId
when (itemId) {
R.id.action_open_account -> {
accountClicked(user.hashCode())
accountClicked(user)
}
R.id.action_delete_account -> {
openAccountRemovalDialog(user, supportFragmentManager)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
if (itemId == android.R.id.home) {
getOnBackPressedDispatcher().onBackPressed();
} else if (itemId == R.id.action_open_account) {
accountClicked(user.hashCode());
accountClicked(user);
} else if (itemId == R.id.action_delete_account) {
openAccountRemovalDialog(user, getSupportFragmentManager());
} else {
Expand Down
Loading