Skip to content
This repository has been archived by the owner on Feb 4, 2024. It is now read-only.

Dialog is not shown again after flow is interrupted/canceled #264

Open
consp1racy opened this issue Nov 5, 2018 · 1 comment
Open

Dialog is not shown again after flow is interrupted/canceled #264

consp1racy opened this issue Nov 5, 2018 · 1 comment

Comments

@consp1racy
Copy link

Javadoc on Fragment#onRequestPermissionsResult:

Note: It is possible that the permissions request interaction with the user is interrupted. In this case you will receive empty permissions and results arrays which should be treated as a cancellation.

Current handling in RxPermissionFragment#onRequestPermissionsResult:

void onRequestPermissionsResult(String permissions[], int[] grantResults, boolean[] shouldShowRequestPermissionRationale) {
    for (int i = 0, size = permissions.length; i < size; i++) {
        //...
        mSubjects.remove(permissions[i]);
        //...
    }
}

Problem:

Requested permission list is not cleared when permission flow is interrupted.

Solution:

If permissions[] is empty, then mSubjects should be completed unsuccessfully and cleared.

Related:

#218 tries to retry immediately in this case. This is wrong because the interruption happens after onStop.

@consp1racy
Copy link
Author

And, as always, it's not that simple.

When one permission dialog is showing and another request is issued the second request is automatically canceled.

Since everything is currently handled by one fragment we would end up in this state:

  • first permission dialog still showing
  • second request cancellation would cause permission subjects completed and cleared for both requests

At first glance there should be a separate permission fragment or a separate map per different request codes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant