Skip to content

Commit

Permalink
Controlled navigation when deleting a file locally via a deep link
Browse files Browse the repository at this point in the history
  • Loading branch information
fesave committed Apr 5, 2022
1 parent d94a039 commit 67fb69e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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
*/
Expand Down Expand Up @@ -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)
);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -1683,6 +1683,8 @@ class FileDisplayActivity : FileActivity(), FileFragment.ContainerActivity, OnEn
} else {
initFragmentsWithFile()
}

isAlreadyHandledDeepLink = true
}

companion object {
Expand Down

0 comments on commit 67fb69e

Please sign in to comment.