コード例 #1
0
 public void OnPermissionsDenied(int p0, IList <string> p1)
 {
     if (EasyPermissions.SomePermissionPermanentlyDenied(currentActivity, p1))
     {
         new AppSettingsDialog.Builder(currentActivity).Build().Show();
     }
 }
コード例 #2
0
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
        {
            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);

            var results = grantResults.Select(item => (int)item).ToArray();

            EasyPermissions.OnRequestPermissionsResult(requestCode, permissions, results, this);
        }
コード例 #3
0
            public bool SwitchToMicrophoneMode()
            {
                ScrollToBottom();
                string[] perms = { Android.Manifest.Permission.RecordAudio, Android.Manifest.Permission.WriteExternalStorage };

                if (!EasyPermissions.HasPermissions(currentActivity, perms))
                {
                    EasyPermissions.RequestPermissions(currentActivity, currentActivity.Resources.GetString(Resource.String.rationale_record_voice), RC_RECORD_VOICE, perms);
                }
                return(true);
            }
コード例 #4
0
            public bool SwitchToGalleryMode()
            {
                ScrollToBottom();
                string[] perms = { Android.Manifest.Permission.ReadExternalStorage };

                if (!EasyPermissions.HasPermissions(currentActivity, perms))
                {
                    EasyPermissions.RequestPermissions(currentActivity, currentActivity.Resources.GetString(Resource.String.rationale_photo), RC_PHOTO, perms);
                }
                mChatView.GetChatInputView().SelectPhotoView.UpdateData();
                return(true);
            }
コード例 #5
0
            public void OnStartRecord()
            {
                var perms = new string[] { Android.Manifest.Permission.WriteExternalStorage };

                if (!EasyPermissions.HasPermissions(_currentActivity, perms))
                {
                    EasyPermissions.RequestPermissions(_currentActivity, _currentActivity.Resources.GetString(Resource.String.rationale_camera), 0x0002, perms);
                }
                else
                {
                    string path = Android.OS.Environment.ExternalStorageDirectory.Path + "/voice";

                    var file = new Java.IO.File(path);
                    if (!file.Exists())
                    {
                        file.Mkdir();
                    }
                    mChatView.SetRecordVoiceFile(file.Path, DateTime.Now.ToString("yyyy-MM-dd-hhmmss"));
                }
            }
コード例 #6
0
        private void RequestPermission()
        {
            string[] perms =
            {
                Android.Manifest.Permission.WriteExternalStorage,
                Android.Manifest.Permission.Camera,
                Android.Manifest.Permission.RecordAudio
            };

            // EasyPermissions.RequestPermissions(this, Resources.GetString(Resource.String.camera_and_location_rationale), RC_CAMERA, perms);

            var request = new PermissionRequest.Builder(this, RC_CAMERA, perms)
                          .SetRationale("app need some Permissions")
                          .SetPositiveButtonText("OK")
                          .SetNegativeButtonText("reject")
                          .SetTheme(Resource.Style.AlertDialog_AppCompat_Light)
                          .Build();

            EasyPermissions.RequestPermissions(request);
        }
コード例 #7
0
            public bool SwitchToCameraMode()
            {
                ScrollToBottom();
                string[] perms =
                {
                    Android.Manifest.Permission.WriteExternalStorage,
                    Android.Manifest.Permission.Camera,
                    Android.Manifest.Permission.RecordAudio
                };

                if (!EasyPermissions.HasPermissions(currentActivity, perms))
                {
                    EasyPermissions.RequestPermissions(currentActivity, currentActivity.Resources.GetString(Resource.String.rationale_camera), RC_CAMERA, perms);
                }
                else
                {
                    string fileDir = currentActivity.FilesDir.AbsolutePath + "/photo";

                    mChatView.SetCameraCaptureFile(fileDir, DateTime.Now.ToString("yyyyMMddHHmmss"));
                }

                return(true);
            }
コード例 #8
0
 public void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
 {
     EasyPermissions.OnRequestPermissionsResult(requestCode, permissions, grantResults.Select(item => (int)item).ToArray());
 }