From b4fb9f6a625e3b6cc39b9dabc07722e83a110126 Mon Sep 17 00:00:00 2001 From: Fernando Sanz Date: Tue, 5 Apr 2022 11:36:36 +0200 Subject: [PATCH] Controlled navigation when deleting a file locally via a deep link --- .../owncloud/android/ui/activity/FileActivity.java | 14 ++++++++++++++ .../android/ui/activity/FileDisplayActivity.kt | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileActivity.java b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileActivity.java index bccba2ebc95..b6eb34c9594 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileActivity.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileActivity.java @@ -73,6 +73,8 @@ public class FileActivity extends DrawerActivity public static final String EXTRA_ACCOUNT = "com.owncloud.android.ui.activity.ACCOUNT"; public static final String EXTRA_FROM_NOTIFICATION = "com.owncloud.android.ui.activity.FROM_NOTIFICATION"; + public static final String ALREADY_HANDLED_DEEP_LINK = + "com.owncloud.android.ui.activity.ALREADY_HANDLED_DEEP_LINK"; public static final String EXTRA_FILE_LIST_OPTION = "EXTRA_FILE_LIST_OPTION"; private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID"; @@ -98,6 +100,8 @@ public class FileActivity extends DrawerActivity */ private boolean mFromNotification; + private boolean mAlreadyHandledDeepLink = false; + /** * Messages handler associated to the main thread and the life cycle of the activity */ @@ -131,6 +135,7 @@ protected void onCreate(Bundle savedInstanceState) { if (savedInstanceState != null) { mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE); mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION); + mAlreadyHandledDeepLink = savedInstanceState.getBoolean(FileActivity.ALREADY_HANDLED_DEEP_LINK); mFileOperationsHelper.setOpIdWaitingFor( savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE) ); @@ -214,6 +219,7 @@ protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(FileActivity.EXTRA_FILE, mFile); outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification); + outState.putBoolean(FileActivity.ALREADY_HANDLED_DEEP_LINK, mAlreadyHandledDeepLink); outState.putLong(KEY_WAITING_FOR_OP_ID, mFileOperationsHelper.getOpIdWaitingFor()); if (getSupportActionBar() != null && getSupportActionBar().getTitle() != null) { // Null check in case the actionbar is used in ActionBar.NAVIGATION_MODE_LIST @@ -247,6 +253,14 @@ public boolean fromNotification() { return mFromNotification; } + public void setAlreadyHandledDeepLink(boolean alreadyHandledDeepLink) { + mAlreadyHandledDeepLink = alreadyHandledDeepLink; + } + + public boolean isAlreadyHandledDeepLink() { + return mAlreadyHandledDeepLink; + } + public OperationsServiceBinder getOperationsServiceBinder() { return mOperationsServiceBinder; } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt index a2b7cb522d2..9f451d3280d 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt @@ -420,7 +420,7 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn fun refreshListOfFilesFragment(reloadData: Boolean) { val fileListFragment = listOfFilesFragment - if (intent.data == null) { + if (intent.data == null || isAlreadyHandledDeepLink) { fileListFragment?.listDirectory(reloadData) } else { fileListFragment?.listDirectory(isFileDiscovered(intent.data)) @@ -1683,6 +1683,8 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn } else { initFragmentsWithFile() } + + isAlreadyHandledDeepLink = true } companion object {