Search in sources :

Example 16 with Permission

use of io.envoyproxy.envoy.config.rbac.v3.Permission in project DevRing by LJYcoder.

the class PermissionManager method requestEach.

// 请求单个权限建议用这个
public void requestEach(FragmentActivity activity, final PermissionListener listener, String... permissions) {
    if (activity != null) {
        RxPermissions rxPermissions = new RxPermissions(activity);
        rxPermissions.requestEach(permissions).subscribe(new Consumer<Permission>() {

            @Override
            public void accept(Permission permission) throws Exception {
                if (permission.granted) {
                    // `permission.name` is granted !
                    if (listener != null) {
                        listener.onGranted(permission.name);
                    }
                } else if (permission.shouldShowRequestPermissionRationale) {
                    // Denied permission without ask never again
                    if (listener != null) {
                        listener.onDenied(permission.name);
                    }
                } else {
                    // Need to go to the settings
                    if (listener != null) {
                        listener.onDeniedWithNeverAsk(permission.name);
                    }
                }
            }
        });
    }
}
Also used : RxPermissions(com.tbruyelle.rxpermissions2.RxPermissions) Permission(com.tbruyelle.rxpermissions2.Permission)

Aggregations

Permission (io.envoyproxy.envoy.config.rbac.v3.Permission)9 Principal (io.envoyproxy.envoy.config.rbac.v3.Principal)9 Test (org.junit.Test)9 GrpcAuthorizationEngine (io.grpc.xds.internal.rbac.engine.GrpcAuthorizationEngine)6 AuthDecision (io.grpc.xds.internal.rbac.engine.GrpcAuthorizationEngine.AuthDecision)6 Permission (com.tbruyelle.rxpermissions2.Permission)5 RxPermissions (com.tbruyelle.rxpermissions2.RxPermissions)5 Metadata (io.grpc.Metadata)5 Attributes (io.grpc.Attributes)3 Permission (com.tbruyelle.rxpermissions3.Permission)2 HeaderMatcher (io.envoyproxy.envoy.config.route.v3.HeaderMatcher)2 PathMatcher (io.envoyproxy.envoy.type.matcher.v3.PathMatcher)2 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 TargetApi (android.annotation.TargetApi)1 Message (com.google.protobuf.Message)1 RxPermissions (com.tbruyelle.rxpermissions3.RxPermissions)1 CidrRange (io.envoyproxy.envoy.config.core.v3.CidrRange)1 Policy (io.envoyproxy.envoy.config.rbac.v3.Policy)1 MetadataMatcher (io.envoyproxy.envoy.type.matcher.v3.MetadataMatcher)1