If I has two method need same permission,How to distinguish it's for OnShowRationale
@a1018875550 If you declare same permission on different Activities or Fragments it will be handled as different thing. Isn't it enough?
I have some defferent require in an Activity,but they need the permission of "Camera" too;So how to distinguish of them
Can you try like the following? If that doesn't work well, it seems currently we have no way to do that. So improvement is needed.
// use them
private static final String[] PERMISSION_SHOWCAMERA1 = new String[] {"android.permission.CAMERA"};
private static final String[] PERMISSION_SHOWCAMERA2 = new String[] {"android.permission.CAMERA"};
@a1018875550 Did it work well?
No it's dosen't work;
I have two method for OnPermissionDenied the value is
1.PERMISSION_SHOWCAMERA
2.PERMISSION_SHOWCAMERA2
but the Android Studio note
Error:Execution failed for task ':mazi:compileDebugJavaWithJavac'.> permissions.dispatcher.processor.exception.DuplicatedValueException: [android.permission.CAMERA] is duplicated in 'showRationaleForCamera()' annotated with '@OnShowRationale'
so this way can' t distinguish them
@a1018875550 Sorry to hear that.
Currently we don't provide the way to handle same permissions in the same Activity/Fragment.
So my current best advise is creating different Activity/Fragment and put the other permission to it...Is it possible?
;It's like possible for now If put other permission to one of it; But It's not a permanent solutionï¼›
You can add a int value to @NeedsPermission and others to distinguish them,this is my suggest hope you find a better solution; Thank you very much!
You can add a int value to @NeedsPermission and others to distinguish them
Yep we actually thought that feature before but we dropped it because it complicates the library itself. But I think it might be better to reconsider...What do you think @aurae @shiraji ?
In case the permission signature is identical for both permission-protected methods, do you even need to have different rationales? I'd argue that they would report pretty much the same thing to the user, so a single rationale method usually suffices for most use cases.
However, I'd be okay with adding tags to annotated methods, if we can ensure that it doesn't require changes for all current users of the library.
thaks
@aurae Thx for your comment, I didn't realised that but that's the good point.
I still don't see the point of requiring the same permissions in one Activity/Fragment. Other than that, I have pretty much the same opinion with @aurae
So, let's think about how the tag works.
@NeedsPermission, he/she must provides permissions and the tag to all @OnShowRationale, @OnPermissionDenied, @OnNeverAskAgain.showRationaleForCamera will be ignored. (Need more lint check!) @NeedsPermission(Manifest.permission.CAMERA, tag = "FOO") // I set String but tag type can be integer, Object or anything.
void showCamera() {
// do something
}
@OnShowRationale(Manifest.permission.CAMERA)
void showRationaleForCamera(PermissionRequest request) {
// do something
}
Is this all functionalities for tag?
Sample
// this method's OnShowRationale will be showRationaleForCamera
@NeedsPermission(Manifest.permission.CAMERA, tag = "FOO")
void showCamera() {
// do something
}
// this method's OnShowRationale will be showRationaleForCamera2
@NeedsPermission(Manifest.permission.CAMERA)
void showCamera2() {
// do something
}
@OnShowRationale(Manifest.permission.CAMERA, tag = "FOO")
void showRationaleForCamera(PermissionRequest request) {
// do something
}
@OnShowRationale(Manifest.permission.CAMERA)
void showRationaleForCamera2(PermissionRequest request) {
// do something
}
@shiraji Thx, actually @aurae proposed almost the same idea before at https://github.com/hotchemi/PermissionsDispatcher/issues/18#issuecomment-136099353 but at that time I wanted to keep this library simple so didn't implement.
@shiraji Are you working on this issue?
Not yet. You can take it.
2016年8月8日(月) 13:13 Shintaro Katafuchi [email protected]:
@shiraji https://github.com/shiraji Are you working on this issue?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hotchemi/PermissionsDispatcher/issues/177#issuecomment-238138354,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADgVQuYAi8I4TFBg3f23tERVxOtrXIBUks5qdqzRgaJpZM4JTysq
.
@shiraji Okay.
In my think this improvement is not mandatory so I'd like to close it unless someone is eager to implement that.
try it:
it can work.
We can add a int value(eg:Manifest.permission.INTERNET) to @NeedsPermission to distinguish them.
Sample:
@NeedsPermission(Manifest.permission.CAMERA)
@OnPermissionDenied(Manifest.permission.CAMERA)
@OnNeverAskAgain(Manifest.permission.CAMERA)
@NeedsPermission({Manifest.permission.CAMERA,Manifest.permission.INTERNET})
@OnPermissionDenied({Manifest.permission.CAMERA,Manifest.permission.INTERNET})
@OnNeverAskAgain({Manifest.permission.CAMERA,Manifest.permission.INTERNET})
Most helpful comment
@shiraji Okay.
In my think this improvement is not mandatory so I'd like to close it unless someone is eager to implement that.