public override bool OnShowFileChooser(WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            if (_activity.mUploadMessage != null)
            {
                _activity.mUploadMessage.OnReceiveValue(null);
            }

            _activity.mUploadMessage = filePathCallback;

            try
            {
                File file = createImageFile();
                imageUri = Uri.FromFile(file);

                _activity.mCameraPhotoPath = imageUri;

                Intent captureIntent = new Intent(MediaStore.ActionImageCapture);
                captureIntent.PutExtra(MediaStore.ExtraOutput, imageUri);

                Intent i = new Intent(Intent.ActionGetContent);
                i.AddCategory(Intent.CategoryOpenable);
                i.SetType("image/*");

                Intent chooserIntent = Intent.CreateChooser(i, "이미지 선택기");
                chooserIntent.PutExtra(Intent.ExtraInitialIntents, new IParcelable[] { captureIntent });

                _activity.StartActivityForResult(chooserIntent, MainActivity.FILECHOOSER_RESULTCODE);
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e.Message);
            }

            return(true);
        }
Beispiel #2
0
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
        {
            switch (requestCode)
            {
            case CodeRequestDocPermissionsCamera:
                if (grantResults != null && grantResults.Length > 0 && grantResults[0] == Permission.Granted)
                {
                    // Check whether the permission is obtained. If the permission is obtained, the external storage is open and a toast message is displayed
                    string sdCard = Android.OS.Environment.ExternalStorageState;
                    if (Android.OS.Environment.MediaMounted.Equals(sdCard) && mActivity != null)
                    {
                        DoTakePhoto(mActivity);
                    }
                    else
                    {
                        Logger.Warn(Tag, "onRequestPermissionsResult: SD card is not mounted normally.");
                    }
                }
                else
                {
                    if (uriCallbacks != null)
                    {
                        uriCallbacks.OnReceiveValue(null);
                        uriCallbacks = null;
                    }
                    Logger.Warn(Tag, "onRequestPermissionsResult: no camera permission.");
                }
                break;

            default:
                break;
            }
        }
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);
        // Get our button from the layout resource,
        // and attach an event to it
        Button button = FindViewById <Button> (Resource.Id.myButton);

        button.Click += delegate {
            button.Text = string.Format("{0} clicks!", count++);
        };
        var chrome = new FileChooserWebChromeClient((uploadMsg, acceptType, capture) => {
            mUploadMessage = uploadMsg;
            var i          = new Intent(Intent.ActionGetContent);
            i.AddCategory(Intent.CategoryOpenable);
            i.SetType("image/*");
            StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
        });
        var webview = this.FindViewById <WebView> (Resource.Id.webView1);

        webview.SetWebViewClient(new WebViewClient());
        webview.SetWebChromeClient(chrome);
        webview.Settings.JavaScriptEnabled = true;
        webview.LoadUrl("http://www.script-tutorials.com/demos/199/index.html");
    }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                if (requestCode != FILECHOOSER_RESULTCODE && mUploadMessage == null)
                {
                    base.OnActivityResult(requestCode, resultCode, data);
                    return;
                }

                Uri[] results = null;

                if (resultCode == Result.Ok)
                {
                    results = data == null || resultCode != Result.Ok ? null : new Android.Net.Uri[] { data.Data };

                    if (data == null)
                    {
                        if (mCameraPhotoPath != null)
                        {
                            results = new Uri[] { Uri.Parse(mCameraPhotoPath) };
                        }
                    }
                }

                mUploadMessage.OnReceiveValue(results);
                mUploadMessage = null;
            }
        }
Beispiel #5
0
 public void openFileChooser(IValueCallback uploadMsg, Java.Lang.String acceptType, Java.Lang.String capture)
 {
     if (callback != null)
     {
         callback(uploadMsg, acceptType, capture);
     }
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            ActivityCompat.RequestPermissions(this,
                                              new String[] { Manifest.Permission.ReadExternalStorage, Manifest.Permission.WriteExternalStorage },
                                              REQUEST_WRITE_EXTERNAL_STORAGE);

            var chrome = new FileChooserWebChromeClient((uploadMsg, acceptType, capture) =>
            {
                _mUploadMessage = uploadMsg;
                var i           = new Intent(Intent.ActionGetContent);
                i.AddCategory(Intent.CategoryOpenable);
                i.SetType("image/*");
                StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), FILE_CHOOSER_RESULT_CODE);
            }, this);

            var wv = this.FindViewById <WebView>(Resource.Id.wv);

            wv.SetWebViewClient(new WebViewClient());
            wv.SetWebChromeClient(chrome);
            wv.Settings.JavaScriptEnabled = true;
            wv.LoadUrl("http://963c5cbc.ngrok.io/upload.html");
        }
Beispiel #7
0
        public Task InitializeAsync(ILogger logger, IValueCallback valueCallback, string configFilePath)
        {
            _logger        = logger;
            _valueCallback = valueCallback;

            return(Task.CompletedTask);
        }
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == FILECHOOSER_RESULTCODE)
            {
                if (null == this.mUploadMessage)
                {
                    return;
                }

                Android.Net.Uri[] result = null;

                try
                {
                    if (resultCode != Result.Ok)
                    {
                        result = null;
                    }
                    else
                    {
                        //Retrieve from the private variable if the intent is null
                        result = data == null ? new Android.Net.Uri[] { mCameraPhotoPath } : new Android.Net.Uri[] { data.Data };
                    }
                }
                catch (System.Exception e)
                {
                    Toast.MakeText(ApplicationContext, "activity :" + e, ToastLength.Long).Show();
                }

                mUploadMessage.OnReceiveValue(result);
                mUploadMessage = null;
            }
        }
Beispiel #9
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            WebView = FindViewById <WebView> (Resource.Id.webView);
            var wvc    = new CCWebViewClient(this);
            var chrome = new CCWebChromeClient((uploadMsg, acceptType, capture) => {
                mUploadMessage = uploadMsg;
                var i          = new Intent(Intent.ActionGetContent);
                i.AddCategory(Intent.CategoryOpenable);
                i.SetType("video/*;image/*");
                StartActivityForResult(Intent.CreateChooser(i, "文件选择"), FILECHOOSER_RESULTCODE);
            });

            WebView.Settings.JavaScriptEnabled  = true;
            WebView.Settings.CacheMode          = CacheModes.Normal;
            WebView.Settings.AllowContentAccess = true;
            WebView.Settings.AllowFileAccess    = true;
            WebView.Settings.AllowUniversalAccessFromFileURLs      = true;
            WebView.Settings.AllowFileAccessFromFileURLs           = true;
            WebView.Settings.JavaScriptCanOpenWindowsAutomatically = true;
            WebView.Settings.LoadWithOverviewMode = true;

            WebView.SetWebViewClient(wvc);
            WebView.SetWebChromeClient(chrome);
            WebView.LoadUrl("http://221.208.208.32:7532/Mobile");
        }
 public void openFileChooser(IValueCallback filePathCallback, string acceptType, string capture)
 {
     Intent chooserIntent = new Intent(Intent.ActionGetContent);
     chooserIntent.AddCategory(Intent.CategoryOpenable);
     chooserIntent.SetType("*/*");
     RegisterCustomFileUploadActivity(filePathCallback, chooserIntent);
 }
Beispiel #11
0
        protected bool ChooseFile(IValueCallback filePathCallback, Intent intent, string title)
        {
            if (_activity == null)
            {
                return(false);
            }

            Action <Result, Intent> callback = (resultCode, intentData) =>
            {
                if (filePathCallback == null)
                {
                    return;
                }

                Java.Lang.Object result = ParseResult(resultCode, intentData);
                filePathCallback.OnReceiveValue(result);
            };

            _requestCodes = _requestCodes ?? new List <int>();

            int newRequestCode = ActivityResultCallbackRegistry.RegisterActivityResultCallback(callback);

            _requestCodes.Add(newRequestCode);

            _activity.StartActivityForResult(Intent.CreateChooser(intent, title), newRequestCode);

            return(true);
        }
Beispiel #12
0
        public async void ChooseFile(IValueCallback filePathCallback, Intent intent)
        {
            GetReadPermission();
            while (ReadExternalStorageAccess == null)
            {
                await Task.Delay(100);
            }
            if (ReadExternalStorageAccess == false)
            {
                return;
            }

            // make sure there is no existing message
            if (UploadMessage != null)
            {
                UploadMessage.OnReceiveValue(null);
                UploadMessage = null;
            }

            UploadMessage = filePathCallback;

            try
            {
                StartActivityForResult(intent, FileChooserCode);
            }
            catch (ActivityNotFoundException e)
            {
                UploadMessage = null;
                Toast.MakeText(this, "Cannot open file chooser", ToastLength.Long).Show();
            }
        }
Beispiel #13
0
        protected bool ChooseFile(IValueCallback filePathCallback, Intent intent, string title)
        {
            if (_activity == null)
            {
                return(false);
            }

            void callback(Result resultCode, Intent intentData)
            {
                if (filePathCallback == null)
                {
                    return;
                }

                var result = ParseResult(resultCode, intentData);

                filePathCallback.OnReceiveValue(result);
            }

            _requestCodes ??= new List <int>();

            var newRequestCode = ActivityResultCallbackRegistryHelper.RegisterActivityResultCallback(callback);

            _requestCodes.Add(newRequestCode);

#pragma warning disable CA2000 // Dispose objects before losing scope
            _activity.StartActivityForResult(Intent.CreateChooser(intent, title), newRequestCode);
#pragma warning restore CA2000 // Dispose objects before losing scope

            return(true);
        }
Beispiel #14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            // Get our button from the layout resource,
            // and attach an event to it



            var chrome = new FileChooserWebChromeClient((uploadMsg, acceptType, capture) => {
                mUploadMessage = uploadMsg;
                var i          = new Intent(Intent.ActionGetContent);
                i.AddCategory(Intent.CategoryOpenable);
                i.SetType("image/*");
                StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
            });

            var    webview = this.FindViewById <WebView> (Resource.Id.webView1);
            string fileUrl = "file:///android_asset/HTML5_Demo.html";

            webview.Settings.JavaScriptEnabled = true;
            webview.AddJavascriptInterface(new MyJSInterface(this), "wx");
            webview.SetWebViewClient(new WebViewClient());
            webview.SetWebChromeClient(chrome);
            webview.Settings.JavaScriptEnabled = true;
            webview.LoadUrl("https://hostcs.kku.ac.th/2561/583021143-5/esaan/index.php");
        }
        private void RegisterCustomFileUploadActivity(IValueCallback filePathCallback, Intent chooserIntent, string title = "File upload")
        {
            if (Forms.Context is IFormsWebViewMainActivity)
            {
                var appActivity = Forms.Context as IFormsWebViewMainActivity;

                Action <Result, Intent> callback = (resultCode, intentData) =>
                {
                    Console.WriteLine("RegisterCustomFileUploadActivity: Entrato in callback");
                    if (filePathCallback == null)
                    {
                        return;
                    }

                    var result = FileChooserParams.ParseResult((int)resultCode, intentData);
                    filePathCallback.OnReceiveValue(result);
                    Console.WriteLine("RegisterCustomFileUploadActivity: Processato evento callback");
                    appActivity.UnregisterActivityResultCallback(FILECHOOSER_RESULTCODE);
                };

                appActivity.RegisterActivityResultCallback(FILECHOOSER_RESULTCODE, callback);

                ((FormsAppCompatActivity)Forms.Context).StartActivityForResult(Intent.CreateChooser(chooserIntent, title), FILECHOOSER_RESULTCODE);
                Console.WriteLine("RegisterCustomFileUploadActivity: REGISTRATO");
            }
            else
            {
                Console.WriteLine("RegisterCustomFileUploadActivity: Non registrato");
            }
        }
        public async Task InitializeAsync(ILogger logger, IValueCallback valueCallback, string configFilePath)
        {
            _logger        = logger;
            _valueCallback = valueCallback;

            var configuration = GetConfiguration(configFilePath);
            var serverAddress = configuration["MqttServerAddress"] ?? "localhost";
            var clientId      = configuration["ClientId"] ?? "myLocalClientId";

            // Create TCP based options using the builder.
            var options = new MqttClientOptionsBuilder()
                          .WithClientId(clientId)
                          .WithTcpServer(serverAddress)
                          //   .WithCredentials("bud", "%spencer%")
                          //     .WithTls()
                          .WithCleanSession()
                          .Build();


            await _mqttClient.ConnectAsync(options, CancellationToken.None);

            _mqttClient.UseDisconnectedHandler(async e =>
            {
                if (!_mqttClient.IsConnected)
                {
                    foreach (var subscription in _subscriptions)
                    {
                        _valueCallback.SetValue(subscription, StatusBits.Invalid);
                    }
                }

                logger.Warn("### DISCONNECTED FROM SERVER ###");

                await Task.Delay(TimeSpan.FromSeconds(5));

                try
                {
                    await _mqttClient.ReconnectAsync();

                    foreach (var symbolicAddress in _subscriptions)
                    {
                        await _mqttClient.SubscribeAsync(
                            new TopicFilterBuilder().WithTopic(symbolicAddress).Build());
                    }
                }
                catch
                {
                    logger.Error("### RECONNECTING FAILED ###");
                }
            });

            _mqttClient.UseApplicationMessageReceivedHandler(args =>
            {
                var payload = Encoding.UTF8.GetString(args.ApplicationMessage.Payload);
                var t       = JsonConvert.DeserializeObject <SensorPayload>(payload);

                _valueCallback.SetValue(args.ApplicationMessage.Topic, t.Value, t.LastChangeDateTime);
            });
        }
        /// <summary>
        /// Is called when the driver is initialized.
        /// </summary>
        public Task InitializeAsync(ILogger logger, IValueCallback valueCallback, string configFilePath)
        {
            _logger        = logger;
            _valueCallback = valueCallback;

            _logger.Info("WeatherForecast driver extension started.");

            return(Task.CompletedTask);
        }
        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);
        }
Beispiel #19
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);
            }
Beispiel #21
0
 // For Android > 5.0
 public override Boolean OnShowFileChooser(Android.Webkit.WebView webView, IValueCallback uploadMsg, WebChromeClient.FileChooserParams fileChooserParams)
 {
     try
     {
         callback(uploadMsg, null, null);
     }
     catch (Exception)
     {
     }
     return(true);
 }
            public override bool OnShowFileChooser(WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
            {
                mainActivity.mUploadMessage = filePathCallback;
                Intent i = new Intent(Intent.ActionGetContent);

                i.AddCategory(Intent.CategoryOpenable);
                i.SetType("*/*");
                mainActivity.StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), MainActivity.FILECHOOSER_RESULTCODE);

                return(true);
            }
        public override bool OnShowFileChooser(Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            ((IWebViewChromeClientActivity)_activity).UploadMessage = filePathCallback;
            Intent i = new Intent(Intent.ActionGetContent);

            i.AddCategory(Intent.CategoryOpenable);
            i.SetType("image/*");
            _activity.StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);

            return(true);
        }
        //File chooser Android 5.0 >
        public override bool OnShowFileChooser(Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            WebViewActivity = Xamarin.Forms.Forms.Context as MainActivity;
            WebViewActivity.mUploadMessage = filePathCallback;

            Intent takePictureIntent = new Intent(MediaStore.ActionImageCapture);

            //add temp file path later
            if (WebViewActivity.IsThereAnAppToTakePictures())
            {
                File photoFile = null;
                try
                {
                    photoFile = createImageFile();
                    takePictureIntent.PutExtra("PhotoPath", WebViewActivity.mCameraPhotoPath);
                }

                catch (Exception e)
                { System.Diagnostics.Debug.WriteLine("Unable to create Image File! " + e); }

                if (photoFile != null)
                {
                    WebViewActivity.mCameraPhotoPath = "file:" + photoFile.AbsolutePath;
                    takePictureIntent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(photoFile));
                }
                else
                {
                    takePictureIntent = null;
                }
            }

            //gallery intent
            Intent galleryIntent = new Intent(Intent.ActionPick, MediaStore.Images.Media.ExternalContentUri);

            Intent[] intentArray;
            if (takePictureIntent != null)
            {
                intentArray = new Intent[] { takePictureIntent };
            }
            else
            {
                intentArray = new Intent[0];
            }

            Intent i = new Intent(Intent.ActionChooser);

            i.PutExtra(Intent.ExtraIntent, galleryIntent);
            i.PutExtra(Intent.ExtraTitle, "Choose Image");
            i.PutExtra(Intent.ExtraInitialIntents, intentArray);

            WebViewActivity.StartActivityForResult(Intent.CreateChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);

            return(true);
        }
Beispiel #25
0
 public override void EvaluateJavascript(string script, IValueCallback resultCallback)
 {
     if ((int)Android.OS.Build.VERSION.SdkInt >= 19)
     {
         base.EvaluateJavascript(script, resultCallback);
     }
     else
     {
         this.LoadUrl("javascript:" + script);
     }
 }
        public override bool OnShowFileChooser(Android.Webkit.WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
        {
            Intent intent = new Intent(Intent.ActionOpenDocument);

            intent.AddCategory(Intent.CategoryOpenable);
            intent.SetType("*/*");
            intent.PutExtra(Intent.ExtraMimeTypes, fileChooserParams.GetAcceptTypes());
            mainActivity.intentCallback = filePathCallback;
            mainActivity.StartActivityForResult(intent, REQUEST_IMAGE_CODE);

            return(true);
        }
Beispiel #27
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);

                if ((int)Build.VERSION.SdkInt >= 21)
                {
                    Android.Net.Uri[] results = null;
                    //Check if response is positive
                    if (resultCode == Result.Ok)
                    {
                        if (requestCode == Fcr)
                        {
                            if (MUma == null)
                            {
                                return;
                            }

                            var dataString = data?.Data?.ToString();
                            if (dataString != null)
                            {
                                results = new[]
                                {
                                    Android.Net.Uri.Parse(dataString)
                                };
                            }
                        }
                    }
                    MUma.OnReceiveValue(results);
                    MUma = null;
                }
                else
                {
                    if (requestCode == Fcr)
                    {
                        if (null == MUm)
                        {
                            return;
                        }

                        Android.Net.Uri result = data == null || resultCode != Result.Ok ? null : data.Data;
                        MUm.OnReceiveValue(result);
                        MUm = null;
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        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);
        }
Beispiel #29
0
            public override bool OnShowFileChooser(WebView webView, IValueCallback filePathCallback, FileChooserParams fileChooserParams)
            {
                Logger.Debug(Tag, "onShowFileChooser");
                mActivity.uriCallbacks = filePathCallback;
                Activity activity = mActivity;

                if (activity == null)
                {
                    return(false);
                }
                mActivity.ShowChooseDialog(activity);
                return(true);
            }
Beispiel #30
0
 protected override void OnActivityResult(int requestCode, Result resultCode, Intent intent)
 {
     if (requestCode == FILECHOOSER_RESULTCODE)
     {
         if (null == mUploadMessage)
         {
             return;
         }
         Java.Lang.Object result = intent == null || resultCode != Result.Ok
                                 ? null
                                 : intent.Data;
         mUploadMessage.OnReceiveValue(result);
         mUploadMessage = null;
     }
 }
		protected bool ChooseFile(IValueCallback filePathCallback, Intent intent, string title)
		{
			Action<Result, Intent> callback = (resultCode, intentData) =>
			{
				if (filePathCallback == null)
					return;

				Object result = ParseResult(resultCode, intentData);
				filePathCallback.OnReceiveValue(result);
			};

			_requestCodes = _requestCodes ?? new List<int>();

			int newRequestCode = _context.RegisterActivityResultCallback(callback);

			_requestCodes.Add(newRequestCode);

			_context.StartActivityForResult(Intent.CreateChooser(intent, title), newRequestCode);

			return true;
		}
		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);
		}
Beispiel #33
0
		public void openFileChooser (IValueCallback uploadMsg, Java.Lang.String acceptType, Java.Lang.String capture)
		{
			callback (uploadMsg, acceptType, capture);
		}
Beispiel #34
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView (Resource.Layout.registry_webview_layout);

			llProgress = FindViewById<LinearLayout> (Resource.Id.llProgressBar);

			isRegistry = false;
			if (this.Intent.Extras != null) {
				if (this.Intent.Extras.ContainsKey (constants.pIsRegistry)) {
					isRegistry = this.Intent.Extras.GetBoolean (constants.pIsRegistry);
				}
			} else {
				Finish ();
			}

			ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
			if (isRegistry) {
				ActionBar.SetTitle (Resource.String.registry_title);
				setHeadingTitle (Resource.String.registry_title);
			} else {
				ActionBar.Title = "Profile management";
				setHeadingTitle ("Profile management");
			}
			ActionBar.SetDisplayShowTitleEnabled (false);
			ActionBar.SetDisplayHomeAsUpEnabled(true);
			ActionBar.SetDisplayShowHomeEnabled (true);

			WebView webView = FindViewById<WebView>(Resource.Id.LocalWebView);
			webView.Settings.JavaScriptEnabled = true;

			// allow zooming/panning            
			webView.Settings.BuiltInZoomControls = true;
			webView.Settings.SetSupportZoom(true);        
			webView.Settings.DisplayZoomControls = false;
			webView.Settings.UseWideViewPort = true;

			webView.Settings.AllowFileAccess = true;
			webView.Settings.AllowContentAccess = true;
			webView.Settings.SetPluginState (WebSettings.PluginState.On);
			webView.Settings.JavaScriptCanOpenWindowsAutomatically = true;
			webView.Settings.PluginsEnabled = true;
			webView.Settings.LoadWithOverviewMode = true;

			var chrome = new MyWCC ((uploadMsg, acceptType, capture) => {
				mUploadMessage = uploadMsg;
				selectActionUpload();
			});
				
			webView.SetWebChromeClient (chrome);

			webView.SetWebViewClient (new MyWebClient (this,llProgress, isRegistry));

			if (isRegistry) {
				constants.currentActivityNotLogIn = this;
				webView.LoadUrl(HttpConstants.BASE_URL + string.Format("Account/Register?role=Customer&accessToken={0}", Guid.Empty));
			} else {
				string pathUpdate = string.Format ("My/Profile/Index?accessToken={0}", Utils.getAccessToken());
				webView.LoadUrl(HttpConstants.BASE_URL+ pathUpdate);
				constants.currentActivity = this;
			}
		}
Beispiel #35
0
		protected override void OnActivityResult (int requestCode, Result resultCode, Intent intent)
		{
			if (requestCode == FILECHOOSER_RESULTCODE) {
				if (null == mUploadMessage)
					return;
				Uri result=null;
				if (resultCode == Result.Ok) {
					result = intent == null ? mCapturedImageURI : intent.Data;
				}
				mUploadMessage.OnReceiveValue (result);
				mUploadMessage = null;
			}
		}
Beispiel #36
0
		public OnCancelDialogWebView(Activity _activity, IValueCallback mUploadMessage)
		{
			this._activity = _activity;
			this._mUploadMessage = mUploadMessage;
		}
Beispiel #37
0
		public void OnCancel(IDialogInterface dialog)
		{
			dialog.Dismiss ();
			this._mUploadMessage.OnReceiveValue (null);
			this._mUploadMessage = null;
		}