tbruyelle / RxPermissions

Android runtime permissions powered by RxJava2
Apache License 2.0
10.48k stars 1.31k forks source link

Request: for all requesting of permissions, use StringDef, so that auto-complete will work nicely #178

Open AndroidDeveloperLB opened 7 years ago

AndroidDeveloperLB commented 7 years ago

Currently, when you start typing this:

    rxPermissions
            .request(

And you start auto-completion, it doesn't offer logical things to put.

What I suggest is that you use StringDef, to help developers enter correct parameters, easily:

    @StringDef({permission.READ_CALENDAR, permission.WRITE_CALENDAR, permission.CAMERA, permission.READ_CONTACTS, permission.WRITE_CONTACTS, permission.GET_ACCOUNTS
            , permission.ACCESS_COARSE_LOCATION, permission.ACCESS_FINE_LOCATION, permission.RECORD_AUDIO,
            permission.READ_PHONE_STATE, permission.CALL_PHONE, permission.READ_CALL_LOG, permission.WRITE_CALL_LOG, permission.ADD_VOICEMAIL, permission.USE_SIP, permission.PROCESS_OUTGOING_CALLS,
            permission.BODY_SENSORS, permission.SEND_SMS, permission.RECEIVE_SMS, permission.READ_SMS, permission.RECEIVE_WAP_PUSH, permission.RECEIVE_MMS,
            permission.READ_EXTERNAL_STORAGE, permission.WRITE_EXTERNAL_STORAGE})
    @Retention(RetentionPolicy.SOURCE)
    public @interface Permission {
    }
tbruyelle commented 7 years ago

That would be nice, but this requires to maintain the list carefully, for instance when a new permission is added to the framework ?

AndroidDeveloperLB commented 7 years ago

It's only for auto-completion. This means that using a newly created permission will still work. Just not auto-completed.

tbruyelle commented 7 years ago

OK fine.

@StringDef is an android feature, why didn't they add this on their own permission definition, that's a shame.

AndroidDeveloperLB commented 7 years ago

No idea. I've requested it here: https://issuetracker.google.com/issues/67883533

and maybe in the past. I don't remember. Please consider starring it.