Skip to content

Commit 57c6406

Browse files
Handle switch accounts via ecosystem links
Signed-off-by: tobiasKaminsky <[email protected]>
1 parent 0758e25 commit 57c6406

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

app/src/main/java/com/nextcloud/utils/LinkHelper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ object LinkHelper {
4949
if (intent != null) {
5050
// app installed - open directly
5151
// TODO handle null user?
52-
intent.putExtra(FileDisplayActivity.KEY_ACCOUNT, user.hashCode())
52+
intent.putExtra(FileDisplayActivity.KEY_ACCOUNT, user)
5353
context.startActivity(intent)
5454
} else {
5555
// app not found - open market (Google Play Store, F-Droid, etc.)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ private View findQuotaViewById(int id) {
12341234
/**
12351235
* restart helper method which is called after a changing the current account.
12361236
*/
1237-
private void restart() {
1237+
protected void restart() {
12381238
Intent i = new Intent(this, FileDisplayActivity.class);
12391239
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
12401240
i.setAction(FileDisplayActivity.RESTART);

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,17 @@ class FileDisplayActivity :
600600
OPEN_FILE -> {
601601
onOpenFileIntent(intent)
602602
}
603+
Intent.ACTION_MAIN -> handleSwitchAccount(intent)
603604
}
604605
}
605606

607+
private fun handleSwitchAccount(intent: Intent) {
608+
val accountName = intent.getStringExtra(KEY_ACCOUNT)
609+
val account = accountManager.getAccountByName(accountName)
610+
setAccount(account, false)
611+
restart()
612+
}
613+
606614
@SuppressLint("UnsafeIntentLaunch")
607615
private fun handleRestartIntent(intent: Intent) {
608616
if (intent.action != RESTART) {
@@ -1327,6 +1335,8 @@ class FileDisplayActivity :
13271335
override fun onResume() {
13281336
Log_OC.v(TAG, "onResume() start")
13291337

1338+
handleCommonIntents(intent)
1339+
13301340
super.onResume()
13311341
if (SettingsActivity.isBackPressed) {
13321342
Log_OC.d(TAG, "User returned from settings activity, skipping reset content logic")

0 commit comments

Comments
 (0)