Beispiel #1
0
        public PermissionError CheckForListOfPermissions(List <string> friendlyNamesList, int accessCode,
                                                         ShowReasonCallback showReasonCallback)
        {
            if ((_hostActivity == null) || (friendlyNamesList == null) || (friendlyNamesList.Count == 0))
            {
                return(PermissionError.eFatalError);
            }

            if ((_requestedPermissionsDictionary == null) || (_requestedPermissionsDictionary.Count == 0))
            {
                return(PermissionError.eFatalError);
            }

            var permissionInfoList = PreparePermissionInfo(friendlyNamesList);

            if ((permissionInfoList == null) || (permissionInfoList.Count == 0))
            {
                return(PermissionError.eFatalError);
            }

            var shouldShowReason = (permissionInfoList.Find((CMPPermissionInfo permissionInfo) =>
            {
                return(permissionInfo.ShouldShowReason == true);
            }) != null);

            ShowPermissions(permissionInfoList, shouldShowReason, accessCode, showReasonCallback);
            return(PermissionError.eAllOK);
        }
Beispiel #2
0
        private void ShowPermissions(List <CMPPermissionInfo> permissionInfoList, bool shouldShowReason, int accessCode,
                                     ShowReasonCallback showReasonCallback)
        {
            if (shouldShowReason == true)
            {
                showReasonCallback.Invoke(permissionInfoList, (List <string> permissionsList) =>
                {
                    String[] permissionsArray = null;
                    if (permissionsList == null)
                    {
                        permissionsArray = CMPPermissionsProxy.ExtractPermissions(permissionInfoList);
                    }
                    else
                    {
                        permissionsArray = permissionsList.ToArray();
                    }

                    if ((permissionsArray != null) && (permissionsArray.Length > 0))
                    {
                        _hostActivity.RequestPermissions(permissionsArray, accessCode);
                    }
                });
            }
            else
            {
                String[] permissionsArray = CMPPermissionsProxy.ExtractPermissions(permissionInfoList);
                if ((permissionsArray != null) && (permissionsArray.Length > 0))
                {
                    _hostActivity.RequestPermissions(permissionsArray, accessCode);
                }
            }
        }
        public PermissionError CheckForListOfPermissions(List <string> friendlyNamesList, int accessCode,
                                                         ShowReasonCallback showReasonCallback)
        {
            if (_permissions == null)
            {
                return(PermissionError.eFatalError);
            }

            var response = _permissions.CheckForListOfPermissions(friendlyNamesList, accessCode, showReasonCallback);

            return(response);
        }
        public PermissionError CheckForPermission(string friendlyNameString, int accessCode,
                                                  ShowReasonCallback showReasonCallback)
        {
            if (_permissions == null)
            {
                return(PermissionError.eFatalError);
            }

            var response = _permissions.CheckForPermission(friendlyNameString, accessCode, showReasonCallback);

            return(response);
        }
Beispiel #5
0
        public PermissionError CheckForPermission(string friendlyNameString, int accessCode,
                                                  ShowReasonCallback showReasonCallback)
        {
            var friendlyNamesList = new List <string>();

            friendlyNamesList.Add(friendlyNameString);

            var permissionInfoList = PreparePermissionInfo(friendlyNamesList);
            var permissionInfo     = permissionInfoList[0];

            if (permissionInfo.ShouldShowReason == true)
            {
                ShowPermissions(permissionInfoList, permissionInfo.ShouldShowReason, accessCode, showReasonCallback);
            }
            else
            {
                _hostActivity?.RequestPermissions(new string[] { permissionInfo.RequestedPermissionString },
                                                  accessCode);
            }

            return(PermissionError.eAllOK);
        }