Пример #1
0
        public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == Camera && resultCode == (int)Android.App.Result.Ok)
            {
                if (!imageURL.Equals(""))
                {
                    Bitmap bitmap;

                    //Converstion Image Size
                    int height = Resources.DisplayMetrics.HeightPixels;
                    int width  = Resources.DisplayMetrics.WidthPixels;
                    using (bitmap = fileImagePath.Path.LoadAndResizeBitmap(width / 4, height / 4))
                    {
                    }
                    long   size1   = fileImagePath.Length() / 1024 * 1024;
                    string imgsize = size1.ToString();

                    TaskFileMapping_Model attachmentModel = new TaskFileMapping_Model();
                    attachmentModel.Path     = imageURL;
                    attachmentModel.FileType = "Image";
                    attachmentModel.FileName = imageName;
                    //attachmentModel.localtaskId = licenceidmodel[licenceidmodel.Count - 1].taskid.ToString();
                    // attachmentModel.file_format = Utility.imagetype;
                    attachmentModel.FileSize = imgsize;
                    // attachmentModel.GeoLocation = geolocation;
                    //  attachmentModel.max_numbers = image_max.ToString();
                    listmapping.Add(attachmentModel);

                    //comp_AttachmentModels.Add(attachmentModel);


                    //imagelist.AddRange(comp_AttachmentModels.Where(p => p.Attachment_Type == "Image" ));
                    //image_list = db.GetCreateAttachmentData("Image", licenceidmodel[licenceidmodel.Count - 1].taskid.ToString());
                    //for (int i = 0; i < image_list.Count; i++)
                    //{

                    //}
                    for (int i = 0; i < listmapping.Count; i++)
                    {
                        if (listmapping[i].FileType.Equals("Image"))
                        {
                            image_list.Add(listmapping[i]);
                        }
                    }
                    adapter_1          = new GridImageAdapterCreatetask(Activity, image_list);
                    Gridview_1.Adapter = adapter_1;
                    Gridview_1.setExpanded(true);
                    Gridview_1.ChoiceMode = (ChoiceMode)AbsListViewChoiceMode.MultipleModal;
                    Gridview_1.SetMultiChoiceModeListener(new MultiChoiceModeListener1(Activity));
                    imageCount++;
                }
            }
            if (requestCode == Video)
            {
                if (requestCode == Video && resultCode == (int)Android.App.Result.Ok)
                {
                    long   size2     = fileVideoPath.Length() / 1024;
                    string videosize = size2.ToString();

                    TaskFileMapping_Model attachmentModel = new TaskFileMapping_Model();

                    // attachmentModel.Path = videoURL;
                    attachmentModel.FileType    = "Video";
                    attachmentModel.FileName    = videoName;
                    attachmentModel.localtaskId = task_id_to_send;
                    attachmentModel.localPath   = videoURL;
                    // attachmentModel.file_format = Utility.videotype;
                    attachmentModel.FileSize = videosize;
                    // attachmentModel.GeoLocation = geolocation;
                    // attachmentModel.max_numbers = video_max.ToString();
                    //  db.InsertCreateAttachData(attachmentModel);
                    listmapping.Add(attachmentModel);
                    //comp_AttachmentModels.Add(attachmentModel);
                    for (int i = 0; i < listmapping.Count; i++)
                    {
                        if (listmapping[i].FileType.Equals("Video"))
                        {
                            video_list.Add(listmapping[i]);
                        }
                    }

                    //imagelist.AddRange(comp_AttachmentModels.Where(p => p.Attachment_Type == "Image" ));
                    //video_list = db.GetCreateAttachmentData("Video",licenceidmodel[0].taskid.ToString());

                    adapter_2          = new GridVideoAdapterCreateTask(Activity, video_list);
                    Gridview_2.Adapter = adapter_2;
                    Gridview_2.setExpanded(true);
                    Gridview_2.ChoiceMode = (ChoiceMode)AbsListViewChoiceMode.MultipleModal;
                    Gridview_2.SetMultiChoiceModeListener(new MultiChoiceModeListener2(Activity));

                    videoCount++;
                }
            }
            if (requestCode == fileattachment && resultCode == (int)Android.App.Result.Ok)
            {
                string filepath = data.Data.Path;
                String fileName = filepath.Substring(filepath.LastIndexOf("/") + 1);
                TaskFileMapping_Model attachmentmodel = new TaskFileMapping_Model();
                attachmentmodel.Path     = filepath;
                attachmentmodel.FileType = "Attachment";
                attachmentmodel.FileName = fileName;
                listmapping.Add(attachmentmodel);
                forCreate           = new GridAttachmentForCreate(Activity, listmapping);
                Grid_attach.Adapter = forCreate;
                Grid_attach.setExpanded(true);
            }
            //if (requestCode == Video && resultCode == (int)Android.App.Result.Ok)
            //{
            //    if (!videoURL.Equals(""))
            //    {
            //        long size2 = fileVideoPath.Length() / 1024;
            //        string videosize = size2.ToString();

            //        for (int i = 0; i < listmapping.Count; i++)
            //        {
            //            if (listmapping[i].FileType.Equals("Video"))
            //            {
            //                video_list.Add(listmapping[i]);
            //            }
            //        }
            //        TaskFileMapping_Model attachmentModel = new TaskFileMapping_Model();

            //        attachmentModel.Path = videoURL;
            //        attachmentModel.FileType = "Video";
            //        attachmentModel.FileName = audioname;
            //        attachmentModel.localtaskId = task_id_to_send;
            //        attachmentModel.localPath = videoURL;
            //        // attachmentModel.file_format = Utility.videotype;
            //        attachmentModel.FileSize = videosize;
            //        // attachmentModel.GeoLocation = geolocation;
            //        // attachmentModel.max_numbers = video_max.ToString();
            //        //  db.InsertCreateAttachData(attachmentModel);
            //        listmapping.Add(attachmentModel);
            //        //    //comp_AttachmentModels.Add(attachmentModel);


            //        //comp_AttachmentModels.Add(attachmentModel);


            //        //imagelist.AddRange(comp_AttachmentModels.Where(p => p.Attachment_Type == "Image" ));
            //        adapter_2 = new GridVideoAdapterCreateTask(Activity, video_list);
            //        Gridview_2.Adapter = adapter_2;
            //        Gridview_2.setExpanded(true);
            //        Gridview_2.ChoiceMode = (ChoiceMode)AbsListViewChoiceMode.MultipleModal;
            //        Gridview_2.SetMultiChoiceModeListener(new MultiChoiceModeListener2(Activity));

            //        videoCount++;
            //    }

            //}
        }
Пример #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View view = inflater.Inflate(Resource.Layout.create_ref_layout, null);

            db             = new DbHelper();
            geo            = new Geolocation();
            geolocation    = geo.GetGeoLocation(Activity);
            HasOptionsMenu = true;
            isRecording    = false;
            prefs          = PreferenceManager.GetDefaultSharedPreferences(Activity);
            licenceId      = prefs.GetString("LicenceId", "");
            tempId         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + licenceId;
            camera         = view.FindViewById <ImageButton>(Resource.Id.camera_btn);
            video          = view.FindViewById <ImageButton>(Resource.Id.video_btn);
            microphone     = view.FindViewById <ImageButton>(Resource.Id.micro_btn);
            Gridview_1     = view.FindViewById <ExpandableHeightGridView>(Resource.Id.grid);
            Grid_attach    = view.FindViewById <ExpandableHeightGridView>(Resource.Id.gridattachment);
            Gridview_2     = view.FindViewById <ExpandableHeightGridView>(Resource.Id.gridView2);
            Gridview_3     = view.FindViewById <ExpandableHeightGridView>(Resource.Id.gridView3);
            attachment_btn = view.FindViewById <ImageButton>(Resource.Id.attachment);
            // Gridview_1 = view.FindViewById<ExpandableHeightGridView>(Resource.Id.gridView1);
            //Grid_attach = view.FindViewById<ExpandableHeightGridView>(Resource.Id.gridattachment);
            //Gridview_2 = view.FindViewById<ExpandableHeightGridView>(Resource.Id.gridView2);
            //Gridview_3 = view.FindViewById<ExpandableHeightGridView>(Resource.Id.gridView3);
            //title = view.FindViewById<ImageView>(Resource.Id.imageView1);
            //   listmapping = new List<TaskFileMapping_Model>();
            desc = view.FindViewById <ImageView>(Resource.Id.imageView3);

            if (image_list.Count > 0)
            {
                adapter_1          = new GridImageAdapterCreatetask(Activity, image_list);
                Gridview_1.Adapter = adapter_1;
                Gridview_1.setExpanded(true);
                Gridview_1.ChoiceMode = (ChoiceMode)AbsListViewChoiceMode.MultipleModal;
                Gridview_1.SetMultiChoiceModeListener(new MultiChoiceModeListener1(Activity));
            }
            if (video_list.Count > 0)
            {
                adapter_2          = new GridVideoAdapterCreateTask(Activity, video_list);
                Gridview_2.Adapter = adapter_2;
                Gridview_2.setExpanded(true);
                Gridview_2.ChoiceMode = (ChoiceMode)AbsListViewChoiceMode.MultipleModal;
                Gridview_2.SetMultiChoiceModeListener(new MultiChoiceModeListener2(Activity));
            }
            if (audio_list.Count > 0)
            {
                adapter_3          = new GridAudioCreateTask(Activity, audio_list);
                Gridview_3.Adapter = adapter_3;
                Gridview_3.setExpanded(true);
                Gridview_3.ChoiceMode = (ChoiceMode)AbsListViewChoiceMode.MultipleModal;
                Gridview_3.SetMultiChoiceModeListener(new MultiChoiceModeListener3(Activity));
            }
            if (listmapping.Count > 0)
            {
                forCreate           = new GridAttachmentForCreate(Activity, listmapping);
                Grid_attach.Adapter = forCreate;
                Grid_attach.setExpanded(true);
            }
            attachment_btn.Click += delegate
            {
                attachmentClick();
            };
            camera.Click += delegate
            {
                BtnCamera_Click();
            };

            video.Click += delegate
            {
                VideoClick();
            };
            microphone.Click += delegate
            {
                recording();
            };
            string rec = Android.Content.PM.PackageManager.FeatureMicrophone;

            if (rec != "android.hardware.microphone")
            {
                // no microphone, no recording. Disable the button and output an alert
                var alert = new Android.App.AlertDialog.Builder(title.Context);
                alert.SetTitle("You don't seem to have a microphone to record with");
                alert.SetPositiveButton("OK", (sender, e) =>
                {
                    task_name.Text    = "No microphone present";
                    title.Enabled     = false;
                    task_comment.Text = "No microphone present";
                    desc.Enabled      = false;
                    return;
                });

                alert.Show();
            }
            else
            {
                //title.Click += delegate
                //{
                //    // change the text on the button

                //    isRecording = !isRecording;
                //    if (isRecording)
                //    {
                //        // create the intent and start the activity
                //        var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);

                //        // put a message on the modal dialog
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, Android.App.Application.Context.GetString(Resource.String.messageSpeakNow));

                //        // if there is more then 1.5s of silence, consider the speech over
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);


                //        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
                //        StartActivityForResult(voiceIntent, VOICE);
                //    }
                //  };
                //desc.Click += delegate
                //{
                //    isRecording = !isRecording;
                //    if (isRecording)
                //    {
                //        // create the intent and start the activity
                //        var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);

                //        // put a message on the modal dialog
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, Android.App.Application.Context.GetString(Resource.String.messageSpeakNow));

                //        // if there is more then 1.5s of silence, consider the speech over
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
                //        voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);

                //        // you can specify other languages recognised here, for example
                //        // voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.German);
                //        // if you wish it to recognise the default Locale language and German
                //        // if you do use another locale, regional dialects may not be recognised very well

                //        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
                //        StartActivityForResult(voiceIntent, DESC);
                //    }
                //};
            }
            return(view);
        }