void SetupUserInterface()
        {
            activity = this.Context as Activity;
            view     = activity.LayoutInflater.Inflate(Resource.Layout.ViewerLayout, this, false);

            mPdfViewCtrl = view.FindViewById <pdftron.PDF.PDFViewCtrl>(Resource.Id.pdfviewctrl);
            AppUtils.SetupPDFViewCtrl(mPdfViewCtrl, PDFViewCtrlConfig.GetDefaultConfig(this.Context));

            var file = Utils.CopyResourceToLocal(this.Context, Resource.Raw.sample, "sample", ".pdf");

            mPdfDoc = mPdfViewCtrl.OpenPDFUri(Android.Net.Uri.FromFile(file), "");

            FragmentActivity fragmentActivity = null;

            if (activity is FragmentActivity)
            {
                fragmentActivity = activity as FragmentActivity;
            }
            mToolManager = ToolManagerBuilder.From().Build(fragmentActivity, mPdfViewCtrl);
            mToolManager.SetCanOpenEditToolbarFromPan(true);
            mToolManager.OpenEditToolbar += (sender, e) =>
            {
                mAnnotationToolbar.Show(AnnotationToolbar.StartModeEditToolbar, null, 0, e.Mode, !mAnnotationToolbar.IsShowing);
            };

            mAnnotationToolbar = view.FindViewById <AnnotationToolbar>(Resource.Id.annotationtoolbar);
            mAnnotationToolbar.Setup(mToolManager);
            mAnnotationToolbar.SetButtonStayDown(true);
            mAnnotationToolbar.HideButton(AnnotationToolbarButtonId.Close);
            mAnnotationToolbar.Show();

            mSeekBar = view.FindViewById <ThumbnailSlider>(Resource.Id.thumbseekbar);
        }
Example #2
0
		protected override void OnElementChanged (ElementChangedEventArgs<Page> e)
		{
			base.OnElementChanged (e);

			if (e.OldElement != null || Element == null)
				return;

			try {
				activity = this.Context as Activity;
				view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
				cameraType = CameraFacing.Back;

				textureView = view.FindViewById<TextureView> (Resource.Id.textureView);
				textureView.SurfaceTextureListener = this;

				takePhotoButton = view.FindViewById<global::Android.Widget.Button> (Resource.Id.takePhotoButton);
				takePhotoButton.Click += TakePhotoButtonTapped;

				switchCameraButton = view.FindViewById<global::Android.Widget.Button> (Resource.Id.switchCameraButton);
				switchCameraButton.Click += SwitchCameraButtonTapped;

				toggleFlashButton = view.FindViewById<global::Android.Widget.Button> (Resource.Id.toggleFlashButton);
				toggleFlashButton.Click += ToggleFlashButtonTapped;

				AddView (view);
			} catch (Exception ex) {
				//Xamarin.Insights.Report (ex);
			}
		}
        void SetupUserInterface()
        {
            var activity = this.Context as Activity;

            view = activity.LayoutInflater.Inflate(Resource.Layout.ViewerLayout, this, false);

            // init UI
            mPdfViewCtrl      = view.FindViewById <pdftron.PDF.PDFViewCtrl>(Resource.Id.pdfviewctrl);
            mToolbarContainer = view.FindViewById <FrameLayout>(Resource.Id.annotation_toolbar_container);
            mPresetContainer  = view.FindViewById <FrameLayout>(Resource.Id.preset_container);

            // setup PDFViewCtrl and ToolManager
            AppUtils.SetupPDFViewCtrl(mPdfViewCtrl, PDFViewCtrlConfig.GetDefaultConfig(this.Context));

            if (activity is FragmentActivity)
            {
                mFragmentActivity = activity as FragmentActivity;
            }
            mToolManager = ToolManagerBuilder.From().Build(mFragmentActivity, mPdfViewCtrl);

            // setup toolbars
            SetupAnnotationToolbar();

            var file = Utils.CopyResourceToLocal(this.Context, Resource.Raw.sample, "sample", ".pdf");

            mPdfDoc = mPdfViewCtrl.OpenPDFUri(Android.Net.Uri.FromFile(file), "");
        }
Example #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            try {
                activity   = this.Context as Activity;
                view       = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
                cameraType = CameraFacing.Back;

                textureView = view.FindViewById <TextureView> (Resource.Id.textureView);
                textureView.SurfaceTextureListener = this;

                takePhotoButton        = view.FindViewById <global::Android.Widget.Button> (Resource.Id.takePhotoButton);
                takePhotoButton.Click += TakePhotoButtonTapped;

                switchCameraButton        = view.FindViewById <global::Android.Widget.Button> (Resource.Id.switchCameraButton);
                switchCameraButton.Click += SwitchCameraButtonTapped;

                toggleFlashButton        = view.FindViewById <global::Android.Widget.Button> (Resource.Id.toggleFlashButton);
                toggleFlashButton.Click += ToggleFlashButtonTapped;

                AddView(view);
            } catch (Exception ex) {
                //Xamarin.Insights.Report (ex);
            }
        }
Example #5
0
 public SectionViewHolder(global::Android.Views.View itemView) : base(itemView)
 {
     //    this.image = itemView.FindViewById<ImageView>(Resource.Id.image);
     this.layout      = itemView.FindViewById <LinearLayout>(Resource.Id.headerbg);
     this.description = itemView.FindViewById <TextView>(Resource.Id.description);
     this.header      = itemView.FindViewById <TextView>(Resource.Id.header);
 }
Example #6
0
        void SetupEventHandlers()
        {
            takePhotoButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.takePhotoButton);
            takePhotoButton.Click += TakePhotoButtonTapped;

            switchCameraButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.switchCameraButton);
            switchCameraButton.Click += SwitchCameraButtonTapped;
        }
Example #7
0
        private void SetupEventHandlers()
        {
            takePhotoButton        = view.FindViewById <global::Android.Widget.Button>(CorePluginMobile.Droid.Resource.Id.takePhotoButton);
            takePhotoButton.Click += TakePhotoButtonTapped;

            switchCameraButton        = view.FindViewById <global::Android.Widget.Button>(CorePluginMobile.Droid.Resource.Id.switchCameraButton);
            switchCameraButton.Click += SwitchCameraButtonTapped;

            toggleFlashButton        = view.FindViewById <global::Android.Widget.Button>(CorePluginMobile.Droid.Resource.Id.toggleFlashButton);
            toggleFlashButton.Click += ToggleFlashButtonTapped;
        }
Example #8
0
        void SetupEventHandlers()
        {
            //takePhotoButton = view.FindViewById<global::Android.Widget.Button>(ObjectDetectionApp.Droid.Resource.Id.takePhotoButton);
            //takePhotoButton.Click += TakePhotoButtonTapped;

            switchCameraButton        = view.FindViewById <global::Android.Widget.Button>(ObjectDetectionApp.Droid.Resource.Id.switchCameraButton);
            switchCameraButton.Click += SwitchCameraButtonTapped;

            toggleFlashButton        = view.FindViewById <global::Android.Widget.Button>(ObjectDetectionApp.Droid.Resource.Id.toggleFlashButton);
            toggleFlashButton.Click += ToggleFlashButtonTapped;
        }
Example #9
0
        void SetupUserInterface()
        {
            activity = this.Context as Activity;
            view     = activity.LayoutInflater.Inflate(Resource.Layout.activity_keyboard, this, false);

            mKeyboard   = new Android.InputMethodServices.Keyboard(Context, Resource.Xml.keyboard);
            mTargetView = view.FindViewById <EditText>(Resource.Id.target);

            mKeyboardView          = view.FindViewById <CustomKeyboardView>(Resource.Id.keyboard_view);
            mKeyboardView.Keyboard = mKeyboard;
        }
Example #10
0
        void SetupEventHandlers()
        {
            pager     = view.FindViewById <global::Android.Support.V4.View.ViewPager>(Resource.Id.pager);
            tabLayout = view.FindViewById <global::Android.Support.Design.Widget.TabLayout>(Resource.Id.sliding_tabs);
            adapter   = new MainPagerAdapter(view.Context, activity.SupportFragmentManager);

            pager.Adapter = adapter;

            /*pager.PageSelected += (object sender, PageSelectedEventArgs e) =>
             *  {
             *      if( e.Position==1)
             *      {
             *          Handler h = new Handler();
             *          Action myAction = () =>
             *          {
             *              // your code that you want to delay here
             *              pager.Adapter.NotifyDataSetChanged();
             *              for (int i = 0; i < tabLayout.TabCount; i++)
             *              {
             *                  Android.Support.Design.Widget.TabLayout.Tab tab = tabLayout.GetTabAt(i);
             *                  tab.SetIcon(tabIcons[i]);
             *              }
             *          };
             *          h.PostDelayed(myAction, 500);
             *      }
             *  };*/
            tabLayout.SetupWithViewPager(pager);

            for (int i = 0; i < tabLayout.TabCount; i++)
            {
                Android.Support.Design.Widget.TabLayout.Tab tab = tabLayout.GetTabAt(i);
                tab.SetIcon(tabIcons[i]);
            }

            Android.Widget.Button ScanButton = view.FindViewById <global::Android.Widget.Button>(Resource.Id.ScanButton);
            ScanButton.Click += (sender, e) =>
            {
                //DependencyService.Get<IActiveScan>().Scan();
                DependencyService.Get <IActiveScan>().Scan();
            };

            search           = view.FindViewById <Android.Support.V7.Widget.SearchView>(Resource.Id.searchview);
            search.QueryHint = "Truy vấn mã sản phẩm";
            search.InputType = 2;
            search.SetIconifiedByDefault(false);
            search.QueryTextSubmit += (sender, e) =>
            {
                //Android.Widget.Toast.MakeText(view.Context, "You searched: " + e.Query, Android.Widget.ToastLength.Short).Show();
                search.SetQuery("", false);
                search.ClearFocus();
                var newResultPage = new ResultPage(e.Query);
                App.Current.MainPage.Navigation.PushAsync(newResultPage);
            };
        }
Example #11
0
        void SetupUserInterface()
        {
            activity        = this.Context as Activity;
            view            = activity.LayoutInflater.Inflate(ObjectDetectionApp.Droid.Resource.Layout.CameraLayout, this, false);
            transparentView = view.FindViewById <SurfaceView>(ObjectDetectionApp.Droid.Resource.Id.transparentView);
            transparentView.SetZOrderOnTop(true);
            holderTransparent = transparentView.Holder;
            holderTransparent.SetFormat(Format.Transparent);

            textureView = view.FindViewById <TextureView>(ObjectDetectionApp.Droid.Resource.Id.textureView);
            textureView.SurfaceTextureListener = this;
        }
Example #12
0
        public CameraPage()
        {
            activity = this.Context as MainActivity;

            view       = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayoutOld, this, false);
            cameraType = CameraFacing.Back;

            textureView = view.FindViewById <TextureView>(Resource.Id.textureView);
            textureView.SurfaceTextureListener = this;

            previousPhoto = view.FindViewById <ImageView>(Resource.Id.previousPhoto);
        }
        void SetupEventHandlers()
        {
            takePhotoButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.takePhotoButton);
            result                 = view.FindViewById <global::Android.Widget.TextView>(Resource.Id.textView1);
            takePhotoButton.Click += TakePhotoButtonTapped;

            switchCameraButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.switchCameraButton);
            switchCameraButton.Click += SwitchCameraButtonTapped;

            toggleFlashButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.toggleFlashButton);
            toggleFlashButton.Click += ToggleFlashButtonTapped;
        }
Example #14
0
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            global::Android.Views.View v = inflater.Inflate(Resource.Layout.HenspeRow, container, false);

            TextView tv = (TextView)v.FindViewById(Resource.Id.description);

            tv.Text = "Adresse";

            ImageView image = (ImageView)v.FindViewById(Resource.Id.image);

            image.SetImageResource(Resource.Drawable.ic_adresse);

            return(v);
        }
Example #15
0
        void SetupUserInterface()
        {
            activity = this.Context as Activity;
            view     = activity.LayoutInflater.Inflate(Resource.Layout.AdvancedViewerLayout, this, false);

            mDocumentView = view.FindViewById <DocumentView>(Resource.Id.document_view);

            var             context      = this.Context;
            FragmentManager childManager = null;

            if (context is FragmentActivity)
            {
                var activity = context as FragmentActivity;
                var manager  = activity.SupportFragmentManager;

                var fragments = manager.Fragments;
                if (fragments.Count > 0)
                {
                    childManager = fragments[0].ChildFragmentManager;
                }
                if (childManager != null)
                {
                    mDocumentView.OpenDocument(GetFile(), "", GetConfig(), childManager);
                }
            }
        }
        /// <summary>
        /// NOT WORKING JUST FOR TEST PURPOSE
        /// </summary>
        private global::Android.Views.View FindScrollingTabContainer()
        {
            global::Android.Views.View decor = activity.Window.DecorView;

            int containerId = activity.Resources.GetIdentifier("action_bar_container", "id", "android");

            // check if appcompat library is used
            if (containerId == 0)
            {
                return(null);
            }

            FrameLayout container = (FrameLayout)decor.FindViewById(containerId);

            for (int i = 0; i < container.ChildCount; i++)
            {
                global::Android.Views.View scrolling = container.GetChildAt(i);

                if (scrolling.Class.SimpleName == "ActionBarContextView")
                {
                    return(scrolling);
                }
            }

            return(null);
        }
Example #17
0
        void SetupEventHandlers()
        {
            takePhotoButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.takePhotoButton);
            takePhotoButton.Click += TakePhotoButtonTapped;

            switchCameraButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.switchCameraButton);
            switchCameraButton.Click += SwitchCameraButtonTapped;

            toggleFlashButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.toggleFlashButton);
            toggleFlashButton.Click += ToggleFlashButtonTapped;

            galleryButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.galleryButton);
            galleryButton.Click += GalleryButtonTapped;

            //backButton = view.FindViewById<global::Android.Widget.Button>(Resource.Id.backButton);
            //backButton.Click += BackButtonTapped;
        }
Example #18
0
        void SetupUserInterface()
        {
            _activity = this.Context as Activity;
            if (_activity != null)
            {
                _activity.Window.DecorView.SystemUiVisibility = (StatusBarVisibility)WindowFlags;
                _activity.Window.AddFlags(WindowManagerFlags.KeepScreenOn);
                _view = _activity.LayoutInflater.Inflate(Resource.Layout.GamestreamLayout, this, false);
            }

            _textureView = _view.FindViewById <TextureView>(Resource.Id.textureView);
            _textureView.SurfaceTextureListener = this;

            _recordButton = _view.FindViewById <global::Android.Widget.Button>(Resource.Id.recordButton);
            _exitButton   = _view.FindViewById <global::Android.Widget.Button>(Resource.Id.exitButton);

            HideButtons();
        }
		void SetupUserInterface ()
		{
			activity = this.Context as Activity;
			view = activity.LayoutInflater.Inflate (Resource.Layout.CameraLayout, this, false);
			cameraType = CameraFacing.Back;

			textureView = view.FindViewById<TextureView> (Resource.Id.textureView);
			textureView.SurfaceTextureListener = this;
		}
Example #20
0
        void SetupUserInterface()
        {
            activity   = this.Context as Activity;
            view       = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
            cameraType = CameraFacing.Back;

            textureView = view.FindViewById <TextureView>(Resource.Id.textureView);
            textureView.SurfaceTextureListener = this;
        }
Example #21
0
            public override global::Android.Views.View GetView(int position, global::Android.Views.View convertView
                                                               , ViewGroup parent)
            {
                if (convertView == null)
                {
                    LayoutInflater inflater = (LayoutInflater)parent.GetContext().GetSystemService(Context
                                                                                                   .LayoutInflaterService);
                    convertView = inflater.Inflate(R.Layout.view_user, null);
                }
                Couchbase.Lite.Document task = (Couchbase.Lite.Document) this.GetItem(position);
                TextView text = (TextView)convertView.FindViewById(R.ID.text);

                text.SetText((string)task.GetProperty("name"));
                Couchbase.Lite.Document user = (Couchbase.Lite.Document) this.GetItem(position);
                CheckBox checkBox            = (CheckBox)convertView.FindViewById(R.ID.@checked);
                bool     @checked            = this.IsMemberOfTheCurrentList(user);

                checkBox.SetChecked(@checked);
                checkBox.SetOnClickListener(new _OnClickListener_118(this, checkBox, user));
                return(convertView);
            }
Example #22
0
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);
            if (e.OldElement != null || Element == null)
            {
                return;
            }

            if (e.NewElement != null)
            {
                activity = this.Context as Activity;
                view     = activity.LayoutInflater.Inflate(Resource.Layout.main_layout, this, false);

                activity.SetContentView(view);
                material_card = (MaterialCardView)view.FindViewById(Resource.Id.material_card);
                localButton   = (Android.Widget.Button)view.FindViewById(Resource.Id.button);

                localButton?.SetOnClickListener(this);
                textview         = (TextView)view.FindViewById(Resource.Id.textview);
                linearLayoutCard = (LinearLayout)view.FindViewById(Resource.Id.linearLayoutCard);
            }
        }
Example #23
0
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            try
            {
                if (App.SelectedCondition.Photos != null && App.SelectedCondition.Photos.Count > 0)
                {
                    ShowHidePreviousPhoto(App.SelectedCondition.Photos[App.SelectedCondition.Photos.Count - 1].Url);
                }

                takePhotoButton         = view.FindViewById <global::Android.Widget.Button>(Resource.Id.takePhotoButton);
                takePhotoButton.Click  += TakePhotoButtonTapped;
                takePhotoButton.Enabled = false;

                switchCameraButton         = view.FindViewById <global::Android.Widget.Button>(Resource.Id.switchCameraButton);
                switchCameraButton.Click  += SwitchCameraButtonTapped;
                switchCameraButton.Enabled = false;

                toggleOverlayButton            = view.FindViewById <Android.Widget.Button>(Resource.Id.toggleOverlayButton);
                toggleOverlayButton.Click     += ToggleOverlayButton_Click;
                toggleOverlayButton.Enabled    = App.SelectedCondition.Photos.Count > 0;
                toggleOverlayButton.Visibility = (App.SelectedCondition.Photos.Count > 0)? ViewStates.Visible : ViewStates.Gone;

                AddView(view);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);//Xamarin.Insights.Report(ex);
            }
        }
Example #24
0
        void SetupUserInterface()
        {
            var metrics = Resources.DisplayMetrics;

            view = CurrentContext.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);

            videoView  = view.FindViewById <VideoView>(Resource.Id.textureView);
            timer      = view.FindViewById <Chronometer>(Resource.Id.timerId);
            mainLayout = new Android.Widget.RelativeLayout(Context);


            Android.Widget.RelativeLayout.LayoutParams liveViewParams = new Android.Widget.RelativeLayout.LayoutParams(
                Android.Widget.RelativeLayout.LayoutParams.FillParent,
                Android.Widget.RelativeLayout.LayoutParams.FillParent);

            liveViewParams.Width  = metrics.WidthPixels; // 80%
            liveViewParams.Height = (metrics.HeightPixels / 5) * 4;

            captureButton = view.FindViewById <Android.Widget.Button>(Resource.Id.takePhotoButton);

            buttonHolder = new Android.Widget.RelativeLayout(Context);

            captureButtonParams = new Android.Widget.RelativeLayout.LayoutParams(
                Android.Widget.RelativeLayout.LayoutParams.FillParent,
                Android.Widget.RelativeLayout.LayoutParams.FillParent);
            captureButtonParams.Width  = metrics.WidthPixels;
            captureButtonParams.Height = (metrics.HeightPixels / 5) * 1;
            captureButtonParams.AddRule(LayoutRules.AlignParentBottom);
            buttonHolder.LayoutParameters = captureButtonParams;

            timer.Visibility = ViewStates.Invisible;

            Holder = videoView.Holder;
            Holder.AddCallback(this);
            Holder.SetType(SurfaceType.PushBuffers);
        }
Example #25
0
        protected override async void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            // exception handling for the camera permission
            try
            {
                activity   = this.Context as Activity;
                view       = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
                cameraType = CameraFacing.Back;

                textureView = view.FindViewById <TextureView>(Resource.Id.textureView);
                textureView.SurfaceTextureListener = this;
                textureView.Click += FocusOnTouch;

                takePhotoButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.takePhotoButton);
                takePhotoButton.Click += TakePhotoButtonTapped;

                cameraRectangle        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.cameraRectangle);
                cameraRectangle.Click += FocusOnTouch;

                toggleFlashButton        = view.FindViewById <global::Android.Widget.Button>(Resource.Id.toggleFlashButton);
                toggleFlashButton.Click += ToggleFlashButtonTapped;

                AddView(view);
            }
            catch (Exception)
            {
                await App.Current.MainPage.DisplayAlert("Error", "Camera Permission Not Granted", "OK");
            }
        }
Example #26
0
        protected override void OnElementChanged(ElementChangedEventArgs <Shared.LeftTabbedPage> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                var inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
                view = inflater.Inflate(Resource.Layout.activity_main_android, null, false);
                view.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                AddView(view);

                // lefttabbed_recycler
                _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.lefttabbed_recycler);

                // var adapter = new RecyclerViewAdapter(me)
                SetMenuItems();
            }
        }
Example #27
0
        void SetupUserInterface()
        {
            activity   = this.Context as Activity;
            view       = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
            cameraType = CameraFacing.Back;

            textureView = view.FindViewById <TextureView>(Resource.Id.textureView);
            textureView.SurfaceTextureListener = this;

            OCR_textView     = view.FindViewById <TextView>(Resource.Id.myOCR_TextView);
            OCR_Rectangle    = view.FindViewById <ImageView>(Resource.Id.btn_capture_photo);
            OCR_Top_Left     = view.FindViewById <ImageView>(Resource.Id.Top_Left_photo);
            OCR_Top_Right    = view.FindViewById <ImageView>(Resource.Id.Top_Right_photo);
            OCR_Bottom_Left  = view.FindViewById <ImageView>(Resource.Id.Bottom_Left_photo);
            OCR_Bottom_Right = view.FindViewById <ImageView>(Resource.Id.Bottom_Right_photo);

            Canvas canvas = textureView.LockCanvas();
            Paint  paint;

            paint       = new Paint();
            paint.Color = Android.Graphics.Color.Red;
            paint.SetStyle(Paint.Style.Stroke);
            paint.StrokeWidth = 2f;
            Rect r = new Rect((int)100, (int)100, (int)200, (int)200);
            // canvas.DrawRect(r, paint);



            var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath;

            if (!Directory.Exists(absolutePath + "/tessdata"))
            {
                Directory.CreateDirectory(absolutePath + "/tessdata");
            }
            if (!File.Exists(absolutePath + "/tessdata/eng.traineddata"))
            {
                string destPath = absolutePath + "/tessdata/eng.traineddata";
                using (var source = activity.Assets.Open("eng.traineddata"))
                    using (var dest = File.OpenWrite(destPath))
                        source.CopyTo(dest);
            }
        }
Example #28
0
 void SetupUserInterface()
 {
     activity = this.Context as Activity;
     view     = activity.LayoutInflater.Inflate(Resource.Layout.EntryLayout, this, false);
     editText = view.FindViewById <EditText>(Resource.Id.editText1);
 }
Example #29
0
        public Camera2Page()
        {
            Activity         = this.Context as MainActivity;
            Activity.CamPage = this;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                view = Activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
            }
            else
            {
                view = Activity.LayoutInflater.Inflate(Resource.Layout.CameraLayoutOld, this, false);
            }

            previousPhoto = view.FindViewById <ImageViewAsync>(Resource.Id.previousPhoto);

            OverlaySeekbar = view.FindViewById <SeekBar>(Resource.Id.overlaySeekbar);

            OverlaySeekbar.SetOnSeekBarChangeListener(this);

            if (App.SelectedCondition.Photos != null && App.SelectedCondition.Photos.Count > 0)
            {
                ShowHidePreviousPhoto(App.SelectedCondition.Photos[App.SelectedCondition.Photos.Count - 1]);
            }
            OverlaySeekbar.Visibility = (App.SelectedCondition.Photos.Count > 0) ? ViewStates.Visible : ViewStates.Gone;

            takePhotoButton         = view.FindViewById <global::Android.Widget.Button>(Resource.Id.takePhotoButton);
            takePhotoButton.Click  += TakePictureTapped;
            takePhotoButton.Enabled = false;

            switchCameraButton            = view.FindViewById <global::Android.Widget.Button>(Resource.Id.switchCameraButton);
            switchCameraButton.Click     += SwitchCameraButton_Click;
            switchCameraButton.Enabled    = false;
            switchCameraButton.Visibility = ViewStates.Gone;

            spinner = view.FindViewById <Android.Widget.ProgressBar>(Resource.Id.progressBar1);
            spinner.Indeterminate = true;
            spinner.Visibility    = ViewStates.Gone;

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                mStateListener = new CameraStateListener()
                {
                    Page = this
                };
                mSurfaceTextureListener = new CameraSurfaceTextureListener(this);
                ORIENTATIONS.Append((int)SurfaceOrientation.Rotation0, 90);
                ORIENTATIONS.Append((int)SurfaceOrientation.Rotation90, 0);
                ORIENTATIONS.Append((int)SurfaceOrientation.Rotation180, 270);
                ORIENTATIONS.Append((int)SurfaceOrientation.Rotation270, 180);

                textureView = view.FindViewById <AutoFitTextureView>(Resource.Id.textureView);
                textureView.SurfaceTextureListener = mSurfaceTextureListener;

                string[] camPermissions = { Android.Manifest.Permission.Camera };

                // Make sure we can use the camera
                if ((int)Android.OS.Build.VERSION.SdkInt >= 23 && Activity.CheckSelfPermission(camPermissions[0]) != (Permission.Granted))
                {
                    Toast.MakeText(Activity, AppResources.Camera_permissionNeeded, ToastLength.Long).Show();
                    Activity.RequestPermissions(camPermissions, CamPermReqId);
                }
                else
                {
                    OpenCamera();
                }
            }
            else
            {
                cameraType = CameraFacing.Back;

                textureView1 = view.FindViewById <TextureView>(Resource.Id.textureView);
                textureView1.SurfaceTextureListener = this;
            }

            AddView(view);
        }
Example #30
0
                public override global::Android.Views.View GetView(int position, global::Android.Views.View convertView
                                                                   , ViewGroup parent)
                {
                    if (convertView == null)
                    {
                        LayoutInflater inflater = (LayoutInflater)parent.GetContext().GetSystemService(Context
                                                                                                       .LayoutInflaterService);
                        convertView = inflater.Inflate(Resource.Layout.view_task, null);
                    }
                    Couchbase.Lite.Document task   = (Couchbase.Lite.Document) this.GetItem(position);
                    Bitmap             image       = null;
                    Bitmap             thumbnail   = null;
                    IList <Attachment> attachments = task.GetCurrentRevision().GetAttachments();

                    if (attachments != null && attachments.Count > 0)
                    {
                        Attachment attachment = attachments[0];
                        try
                        {
                            image     = BitmapFactory.DecodeStream(attachment.GetContent());
                            thumbnail = ThumbnailUtils.ExtractThumbnail(image, MainActivity.TasksFragment.ThumbnailSizePx
                                                                        , MainActivity.TasksFragment.ThumbnailSizePx);
                        }
                        catch (Exception e)
                        {
                            Log.E(Application.Tag, "Cannot decode the attached image", e);
                        }
                    }
                    Bitmap    displayImage = image;
                    ImageView imageView    = (ImageView)convertView.FindViewById(Resource.Id.image);

                    if (thumbnail != null)
                    {
                        imageView.SetImageBitmap(thumbnail);
                    }
                    else
                    {
                        imageView.SetImageDrawable(this._enclosing.GetResources().GetDrawable(Resource.Drawable.
                                                                                              ic_camera_light));
                    }
                    imageView.Click += async(sender, e) => {
                        if (displayImage != null)
                        {
                            DispatchImageViewIntent(displayImage);
                        }
                        else
                        {
                            AttachImage(task);
                        }
                    };
                    TextView text = (TextView)convertView.FindViewById(Resource.Id.text);

                    text.SetText((string)task.GetProperty("title"));
                    CheckBox checkBox        = (CheckBox)convertView.FindViewById(Resource.Id.@checked);
                    bool     checkedProperty = (bool)task.GetProperty("checked");
                    bool     @checked        = checkedProperty != null ? checkedProperty : false;

                    checkBox.SetChecked(@checked);
                    checkBox.Click += async(sender, e) => {
                        try
                        {
                            Task.UpdateCheckedStatus(task, checkBox.IsChecked());
                        }
                        catch (CouchbaseLiteException ex)
                        {
                            Log.E(((CouchbaseSample.Android.Application)Application).Tag, "Cannot update checked status", e);
                        }
                    };
                    return(convertView);
                }
Example #31
0
        protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
                return;

            try
            {
                var activity = this.Context as Activity;
                activity.RequestedOrientation = ScreenOrientation.Landscape;
                view = activity.LayoutInflater.Inflate(Resource.Layout.CameraLayout, this, false);
                _textureView = view.FindViewById<TextureView>(Resource.Id.textureView);
                _textureView.SurfaceTextureListener = this;
                cameraType = CameraFacing.Back;
                AddView(view);
            }
            catch (Exception ex)
            {

                Console.WriteLine("Roland error...." + ex.Message);
            }
        }