示例#1
0
        void FireEventPermissionCompletionHandler(ClusterEventAuthorizationType eventType)
        {
            EKAuthorizationStatus status = EKEventStore.GetAuthorizationStatus(EKEquivalentEventType(eventType));

            if (_eventPermissionCompletionHandler != null)
            {
                ClusterDialogResult userDialogResult   = ClusterDialogResult.Granted;
                ClusterDialogResult systemDialogResult = ClusterDialogResult.Granted;
                if (status == EKAuthorizationStatus.NotDetermined)
                {
                    userDialogResult   = ClusterDialogResult.Denied;
                    systemDialogResult = ClusterDialogResult.NoActionTaken;
                }
                else if (status == EKAuthorizationStatus.Authorized)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Granted;
                }
                else if (status == EKAuthorizationStatus.Denied)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Denied;
                }
                else if (status == EKAuthorizationStatus.Restricted)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.ParentallyRestricted;
                }
                _eventPermissionCompletionHandler((status == EKAuthorizationStatus.Authorized),
                                                  userDialogResult,
                                                  systemDialogResult);
                _eventPermissionCompletionHandler = null;
            }
        }
示例#2
0
        void FirePhotoPermissionCompletionHandler()
        {
            ALAuthorizationStatus status = ALAssetsLibrary.AuthorizationStatus;

            if (_photoPermissionCompletionHandler != null)
            {
                ClusterDialogResult userDialogResult   = ClusterDialogResult.Granted;
                ClusterDialogResult systemDialogResult = ClusterDialogResult.Granted;
                if (status == ALAuthorizationStatus.NotDetermined)
                {
                    userDialogResult   = ClusterDialogResult.Denied;
                    systemDialogResult = ClusterDialogResult.NoActionTaken;
                }
                else if (status == ALAuthorizationStatus.Authorized)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Granted;
                }
                else if (status == ALAuthorizationStatus.Denied)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Denied;
                }
                else if (status == ALAuthorizationStatus.Restricted)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.ParentallyRestricted;
                }
                _photoPermissionCompletionHandler((status == ALAuthorizationStatus.Authorized),
                                                  userDialogResult,
                                                  systemDialogResult);
                _photoPermissionCompletionHandler = null;
            }
        }
示例#3
0
        void FireContactPermissionCompletionHandler()
        {
            ABAuthorizationStatus status = ABAddressBook.GetAuthorizationStatus();

            if (_contactPermissionCompletionHandler != null)
            {
                ClusterDialogResult userDialogResult   = ClusterDialogResult.Granted;
                ClusterDialogResult systemDialogResult = ClusterDialogResult.Granted;
                if (status == ABAuthorizationStatus.NotDetermined)
                {
                    userDialogResult   = ClusterDialogResult.Denied;
                    systemDialogResult = ClusterDialogResult.NoActionTaken;
                }
                else if (status == ABAuthorizationStatus.Authorized)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Granted;
                }
                else if (status == ABAuthorizationStatus.Denied)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Denied;
                }
                else if (status == ABAuthorizationStatus.Restricted)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.ParentallyRestricted;
                }
                _contactPermissionCompletionHandler((status == ABAuthorizationStatus.Authorized),
                                                    userDialogResult,
                                                    systemDialogResult);
                _contactPermissionCompletionHandler = null;
            }
        }
示例#4
0
        void FireAVPermissionCompletionHandlerWithType(ClusterAVAuthorizationType mediaType)
        {
            AVAuthorizationStatus status = AVCaptureDevice.GetAuthorizationStatus(AVEquivalentMediaType(mediaType));

            if (_avPermissionCompletionHandler != null)
            {
                ClusterDialogResult userDialogResult   = ClusterDialogResult.Granted;
                ClusterDialogResult systemDialogResult = ClusterDialogResult.Granted;
                if (status == AVAuthorizationStatus.NotDetermined)
                {
                    userDialogResult   = ClusterDialogResult.Denied;
                    systemDialogResult = ClusterDialogResult.NoActionTaken;
                }
                else if (status == AVAuthorizationStatus.Authorized)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Granted;
                }
                else if (status == AVAuthorizationStatus.Denied)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Denied;
                }
                else if (status == AVAuthorizationStatus.Restricted)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.ParentallyRestricted;
                }
                _avPermissionCompletionHandler((status == AVAuthorizationStatus.Authorized),
                                               userDialogResult,
                                               systemDialogResult);
                _avPermissionCompletionHandler = null;
            }
        }
 string StringFromDialogResult(ClusterDialogResult result)
 {
     switch (result)
     {
         case ClusterDialogResult.NoActionTaken:
             return @"No Action Taken";
         case ClusterDialogResult.Granted:
             return @"Granted";
         case ClusterDialogResult.Denied:
             return @"Denied";
         case ClusterDialogResult.ParentallyRestricted:
             return @"Restricted";
         default:
             return string.Empty;
     }
 }
示例#6
0
        void UpdateResultLabel(UILabel resultLabel, bool hasPermission, ClusterDialogResult userDialogResult, ClusterDialogResult systemDialogResult)
        {
            resultLabel.Text  = @"haha";
            resultLabel.Alpha = 0.0f;

            if (hasPermission)
            {
                resultLabel.TextColor = UIColor.FromRGBA(0.1f, 1.0f, 0.1f, 1.0f);
            }
            else
            {
                resultLabel.TextColor = UIColor.FromRGBA(0.1f, 0.1f, 0.1f, 1.0f);
            }
            string text = null;

            if (userDialogResult == ClusterDialogResult.NoActionTaken &&
                systemDialogResult == ClusterDialogResult.NoActionTaken)
            {
                string prefix = null;
                if (hasPermission)
                {
                    prefix = @"Granted.";
                }
                else if (systemDialogResult == ClusterDialogResult.ParentallyRestricted)
                {
                    prefix = @"Restricted.";
                }
                else
                {
                    prefix = @"Denied.";
                }
                text = string.Format(@"{0} Dialogs not shown, system choice already made.", prefix);
            }
            else
            {
                string userResultString   = StringFromDialogResult(userDialogResult);
                string systemResultString = StringFromDialogResult(systemDialogResult);
                text = string.Format(@"User Action: {0}\nSystem Action: {1}", userResultString, systemResultString);
            }
            resultLabel.Text = text;

            UIView.Animate(0.35, delegate
            {
                resultLabel.Alpha = 1.0f;
            });
        }
        void UpdateResultLabel(UILabel resultLabel, bool hasPermission, ClusterDialogResult userDialogResult, ClusterDialogResult systemDialogResult)
        {
            resultLabel.Text = @"haha";
            resultLabel.Alpha = 0.0f;

            if (hasPermission)
            {
                resultLabel.TextColor = UIColor.FromRGBA (0.1f, 1.0f, 0.1f, 1.0f);
            }
            else
            {
                resultLabel.TextColor = UIColor.FromRGBA (0.1f, 0.1f, 0.1f, 1.0f);
            }
            string text = null;
            if (userDialogResult == ClusterDialogResult.NoActionTaken &&
                systemDialogResult == ClusterDialogResult.NoActionTaken)
            {
                string prefix = null;
                if (hasPermission)
                {
                    prefix = @"Granted.";
                }
                else if (systemDialogResult == ClusterDialogResult.ParentallyRestricted)
                {
                    prefix = @"Restricted.";
                }
                else
                {
                    prefix = @"Denied.";
                }
                text = string.Format (@"{0} Dialogs not shown, system choice already made.", prefix);
            }
            else
            {
                string userResultString = StringFromDialogResult (userDialogResult);
                string systemResultString = StringFromDialogResult (systemDialogResult);
                text = string.Format (@"User Action: {0}\nSystem Action: {1}", userResultString, systemResultString);
            }
            resultLabel.Text = text;

            UIView.Animate (0.35, delegate
            {
                resultLabel.Alpha = 1.0f;
            });
        }
示例#8
0
        string StringFromDialogResult(ClusterDialogResult result)
        {
            switch (result)
            {
            case ClusterDialogResult.NoActionTaken:
                return(@"No Action Taken");

            case ClusterDialogResult.Granted:
                return(@"Granted");

            case ClusterDialogResult.Denied:
                return(@"Denied");

            case ClusterDialogResult.ParentallyRestricted:
                return(@"Restricted");

            default:
                return(string.Empty);
            }
        }
示例#9
0
        void FireLocationPermissionCompletionHandler()
        {
            var status = CLLocationManager.Status;

            if (_locationPermissionCompletionHandler != null)
            {
                ClusterDialogResult userDialogResult   = ClusterDialogResult.Granted;
                ClusterDialogResult systemDialogResult = ClusterDialogResult.Granted;
                if (status == CLAuthorizationStatus.NotDetermined)
                {
                    userDialogResult   = ClusterDialogResult.Denied;
                    systemDialogResult = ClusterDialogResult.NoActionTaken;
                }
                else if (LocationAuthorizationStatusPermitsAccess(status))
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Granted;
                }
                else if (status == CLAuthorizationStatus.Denied)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.Denied;
                }
                else if (status == CLAuthorizationStatus.Restricted)
                {
                    userDialogResult   = ClusterDialogResult.Granted;
                    systemDialogResult = ClusterDialogResult.ParentallyRestricted;
                }
                _locationPermissionCompletionHandler((LocationAuthorizationStatusPermitsAccess(status)),
                                                     userDialogResult,
                                                     systemDialogResult);
                _locationPermissionCompletionHandler = null;
            }
            if (_locationManager != null)
            {
                _locationManager.StopUpdatingLocation();
                _locationManager = null;
            }
        }