Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[WEEX-435][android] modify playground app camera runtime permission request behavior #1221

Conversation

shawnlinboy
Copy link
Contributor

For ActivityCompat.shouldShowRequestPermissionRationale(), it means your app should display a dialog or something else to explain why you are going to request this permission, and try again to request the permission, see https://developer.android.com/training/permissions/requesting and https://github.com/googlesamples/android-RuntimePermissionsBasic/blob/master/Application/src/main/java/com/example/android/basicpermissions/MainActivity.java#L124

For the original code, if the permission was NOT granted, the ContextCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED will always returns true and ActivityCompat.shouldShowRequestPermissionRationale((Activity) mWXSDKInstance.getContext(), Manifest.permission.CAMERA) did the same thing, which means If a user tap 扫描二维码, the Weex playground need the camera permission to scan QR code toast will always show up without prompting a permission request dialog, users have to navigate to system app management and grant permission manually. If one user was not familiar with this mechanism,the Playground app will always be not able to scan code.

This patch fix can show a dialog to tell user that Weex playground need the camera permission to scan QR code and then request this code immediately, it will make the a system permission dialog alert and the user can now grant permission directly.

@weex-bot
Copy link

weex-bot commented May 29, 2018

Messages
📖 has no android file changed.
📖 android test finished.

Generated by 🚫 dangerJS

@shawnlinboy
Copy link
Contributor Author

@misakuo PTAL :)

@xuyouyang
Copy link
Contributor

@shawnlinboy Thank you for your contribution!!As the development process shows, we need create a jira issue in apache, and format your pull request title and commit log. :)

@shawnlinboy shawnlinboy changed the title [android] modify playground app camera runtime permission request behavior [WEEX-435][android] modify playground app camera runtime permission request behavior Jun 4, 2018
@shawnlinboy
Copy link
Contributor Author

@xuyouyang Thanks for reviewing, already created one.
https://issues.apache.org/jira/browse/WEEX-435

@gubaojian
Copy link
Member

in your onRequestPermissionsResult you don't handle WRITE_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE and give an tips. please add this case.

@shawnlinboy
Copy link
Contributor Author

@gubaojian They didn't handle that so I'd like not to add extra code to that.

Copy link
Contributor

@YorkShen YorkShen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@YorkShen YorkShen merged commit b874c1f into apache:master Jan 8, 2019
gubaojian pushed a commit to gubaojian/incubator-weex that referenced this pull request Jan 30, 2019
* origin/master:
  [android] modify playground app camera runtime permission request behavior (apache#1221)
  [WEEX][Android] Support  Downgrade To Full Page Root Instance (apache#1952)
  [WEEX][Android] Weex Bugfix For Scroller Remove Failed Because Of Edit Of Scroller Touch Event (apache#2005)
  [WEEX][Android] When View Not InstanceOf WXGestureObservable, mGestureType is Null, remove event has none affect, (apache#1968)
  [iOS] fix customEnvironment crash
  * [iOS] Add support for custom event with stoppropagation
katherine95s pushed a commit to katherine95s/incubator-weex that referenced this pull request Jul 4, 2019
katherine95s pushed a commit to katherine95s/incubator-weex that referenced this pull request Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants