public override bool OnShowFileChooser(WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            this.message = filePathCallback;
            Intent chooserIntent = fileChooserParams.CreateIntent();

            chooserIntent.AddCategory(Intent.CategoryOpenable);
            this.activity.StartActivity(Intent.CreateChooser(chooserIntent, "File Chooser"), filechooser, this.OnActivityResult);
            return(true);
        }
        public override bool OnShowFileChooser(global::Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            base.OnShowFileChooser(webView, filePathCallback, fileChooserParams);

            var chooserIntent = fileChooserParams.CreateIntent();
            RegisterCustomFileUploadActivity(filePathCallback, chooserIntent, fileChooserParams.Title);

            return true;
        }
예제 #3
0
        public override bool OnShowFileChooser(global::Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            if (fileChooserParams is null)
            {
                throw new ArgumentNullException(nameof(fileChooserParams));
            }

            base.OnShowFileChooser(webView, filePathCallback, fileChooserParams);
            return(ChooseFile(filePathCallback, fileChooserParams.CreateIntent(), fileChooserParams.Title));
        }
예제 #4
0
            private async Task StartFileChooser(CancellationToken ct, FileChooserParams fileChooserParams)
            {
                var intent = fileChooserParams.CreateIntent();
                //Get an invisible (Transparent) Activity to handle the Intent
                var delegateActivity = await StartActivity <DelegateActivity>(ct);

                var result = await delegateActivity.GetActivityResult(ct, intent);

                _filePathCallback.OnReceiveValue(FileChooserParams.ParseResult((int)result.ResultCode, result.Intent));
            }
예제 #5
0
        public override bool OnShowFileChooser(Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            var appActivity = _context as MainActivity;

            mUploadMessage = filePathCallback;
            Intent chooserIntent = fileChooserParams.CreateIntent();

            appActivity.StartActivity(chooserIntent, FILECHOOSER_RESULTCODE, OnActivityResult);
            //return base.OnShowFileChooser (webView, filePathCallback, fileChooserParams);
            return(true);
        }
            public override bool OnShowFileChooser(WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
            {
                if (MainActivity.Instance == null)
                {
                    return(false);
                }
                Intent intent = fileChooserParams.CreateIntent();

                MainActivity.Instance.ChooseFile(filePathCallback, intent);
                return(true);
            }
        public override bool OnShowFileChooser(Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            List <string> items = new List <string>()
            {
                AppResources.CameraFileChooser,
                AppResources.GaleriePhotoFileChooser,
                AppResources.DocumentFileChooser
            };
            string selectedItem = items[0];
            int    resultCode   = 0;
            var    appActivity  = context as MainActivity;

            new AlertDialog.Builder(appActivity)
            .SetSingleChoiceItems(items.ToArray(), 0, (sender, e) =>
            {
                selectedItem = items[e.Which];
                System.Diagnostics.Debug.WriteLine(selectedItem);
            })
            .SetPositiveButton("OK", (sender, e) =>
            {
                Intent intent = null;

                if (selectedItem == AppResources.CameraFileChooser)
                {
                    intent = new Intent(MediaStore.ActionImageCapture);
                    CreateDirectoryForPictures();
                    _file = new File(_dir, String.Format("Pic_{0}.png", NoSeqGenerator.Generate()));
                    intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(_file));

                    resultCode = CAMERA_RESULTCODE;
                }

                else if (selectedItem == AppResources.GaleriePhotoFileChooser)
                {
                    intent = new Intent(Intent.ActionGetContent);
                    intent.SetType("image/*");
                    resultCode = IMAGE_CHOOSER_RESULTCODE;
                }
                else if (selectedItem == AppResources.DocumentFileChooser)
                {
                    intent     = fileChooserParams.CreateIntent();
                    resultCode = FILECHOOSER_RESULTCODE;
                }
                if (intent != null)
                {
                    intent.PutExtra("PheidiParams", JsonConvert.SerializeObject(FileChooserPheidiParams));
                    mUploadMessage = filePathCallback;
                    appActivity.StartActivity(intent, resultCode, OnActivityResult);
                }
            }).Show();
            return(true);
        }
예제 #8
0
 public override bool OnShowFileChooser(Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
 {
     try
     {
         var appActivity = Xamarin.Forms.Forms.Context as MainActivity;
         mUploadMessage = filePathCallback;
         Intent chooserIntent = fileChooserParams.CreateIntent();
         appActivity.StartActivity(chooserIntent);
         //return base.OnShowFileChooser (webView, filePathCallback, fileChooserParams);
         return(true);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("4 " + ex.Message);
         return(true);
     }
 }
예제 #9
0
 public override bool OnShowFileChooser(global::Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
 {
     base.OnShowFileChooser(webView, filePathCallback, fileChooserParams);
     return(ChooseFile(filePathCallback, fileChooserParams.CreateIntent(), fileChooserParams.Title));
 }
예제 #10
0
		public override bool OnShowFileChooser(global::Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
		{
			base.OnShowFileChooser(webView, filePathCallback, fileChooserParams);
			return ChooseFile(filePathCallback, fileChooserParams.CreateIntent(), fileChooserParams.Title);
		}