From 6a07bac0eb290ca8b448b22891f507f40ea37377 Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Mon, 10 Jul 2023 11:13:44 +0200 Subject: [PATCH] Switch accounts on intent Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- .../com/owncloud/android/ui/activity/DrawerActivity.java | 2 +- .../owncloud/android/ui/activity/FileDisplayActivity.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 64310307b0..e8de36b982 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -371,7 +371,7 @@ public abstract class DrawerActivity extends ToolbarActivity Intent intent = getPackageManager().getLaunchIntentForPackage(packageName); if (intent != null) { // app installed - open directly - intent.putExtra(FileDisplayActivity.KEY_ACTIVE_USER, getUser().get().hashCode()); + intent.putExtra(FileDisplayActivity.KEY_ACCOUNT, getUser().get().hashCode()); startActivity(intent); } else { // app not found - open market (Google Play Store, F-Droid, etc.) diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 2118e50449..effeefba5d 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -191,7 +191,6 @@ public class FileDisplayActivity extends FileActivity public static final String KEY_FILE_ID = "KEY_FILE_ID"; public static final String KEY_FILE_PATH = "KEY_FILE_PATH"; public static final String KEY_ACCOUNT = "KEY_ACCOUNT"; - public static final String KEY_ACTIVE_USER = "KEY_ACTIVE_USER"; private static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW"; @@ -392,6 +391,10 @@ public class FileDisplayActivity extends FileActivity if (OPEN_FILE.equals(getIntent().getAction())) { getSupportFragmentManager().executePendingTransactions(); onOpenFileIntent(getIntent()); + } else if (RESTART.equals(getIntent().getAction())) { + // most likely switched to different account + DisplayUtils.showSnackMessage(this, String.format(getString(R.string.logged_in_as), + accountManager.getUser().getAccountName())); } upgradeNotificationForInstantUpload(); @@ -2505,8 +2508,6 @@ public class FileDisplayActivity extends FileActivity } else { dismissLoadingDialog(); accountClicked(optionalUser.get().hashCode()); - DisplayUtils.showSnackMessage(this, String.format(getString(R.string.logged_in_as), - optionalUser.get().getAccountName())); } } else { dismissLoadingDialog();