Exemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            RequestWindowFeature(WindowFeatures.NoTitle);

            Window.AddFlags(WindowManagerFlags.Fullscreen);             //to show
            Window.AddFlags(WindowManagerFlags.KeepScreenOn);           //Don't go to sleep while scanning

            if (ScanningOptions.AutoRotate.HasValue && !ScanningOptions.AutoRotate.Value)
            {
                RequestedOrientation = ScreenOrientation.Nosensor;
            }

            SetContentView(Resource.Layout.zxingscanneractivitylayout);

            scannerFragment = new ZXingScannerFragment();
            scannerFragment.CustomOverlayView    = CustomOverlayView;
            scannerFragment.UseCustomOverlayView = UseCustomOverlayView;
            scannerFragment.TopText    = TopText;
            scannerFragment.BottomText = BottomText;

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.contentFrame, scannerFragment, "ZXINGFRAGMENT")
            .Commit();

            CancelRequestedHandler    = CancelScan;
            AutoFocusRequestedHandler = AutoFocus;
            TorchRequestedHandler     = SetTorch;
            PauseAnalysisHandler      = scannerFragment.PauseAnalysis;
            ResumeAnalysisHandler     = scannerFragment.ResumeAnalysis;
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			this.RequestWindowFeature (WindowFeatures.NoTitle);

			this.Window.AddFlags (WindowManagerFlags.Fullscreen); //to show
			this.Window.AddFlags (WindowManagerFlags.KeepScreenOn); //Don't go to sleep while scanning

			if (ScanningOptions.AutoRotate.HasValue && !ScanningOptions.AutoRotate.Value)
				RequestedOrientation = ScreenOrientation.Nosensor;

			SetContentView(Resource.Layout.zxingscanneractivitylayout);

            scannerFragment = new ZXingScannerFragment ();
			scannerFragment.CustomOverlayView = CustomOverlayView;
			scannerFragment.UseCustomOverlayView = UseCustomOverlayView;
			scannerFragment.TopText = TopText;
			scannerFragment.BottomText = BottomText;

			SupportFragmentManager.BeginTransaction()
				.Replace(Resource.Id.contentFrame, scannerFragment, "ZXINGFRAGMENT")
				.Commit();
            
			OnCancelRequested += HandleCancelScan;
			OnAutoFocusRequested += HandleAutoFocus;
			OnTorchRequested += HandleTorchRequested;
		}
Exemplo n.º 3
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			SetContentView (Resource.Layout.FragmentActivity);

			scanFragment = new ZXingScannerFragment (result => {

				// Null result means scanning was cancelled
				if (result == null || string.IsNullOrEmpty (result.Text)) {
					Toast.MakeText (this, "Scanning Cancelled", ToastLength.Long).Show ();
					return;
				}

				// Otherwise, proceed with result


			}, new MobileBarcodeScanningOptions {
				PossibleFormats = new List<ZXing.BarcodeFormat> {
					ZXing.BarcodeFormat.All_1D
				},
				CameraResolutionSelector = availableResolutions => {

					foreach (var ar in availableResolutions) {
						Console.WriteLine ("Resolution: " + ar.Width + "x" + ar.Height);
					}
					return null;
				}
			});

			SupportFragmentManager.BeginTransaction ()
				.Replace (Resource.Id.fragment_container, scanFragment)
				.Commit ();
		}
Exemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            this.RequestWindowFeature(WindowFeatures.NoTitle);

            this.Window.AddFlags(WindowManagerFlags.Fullscreen);              //to show
            this.Window.AddFlags(WindowManagerFlags.KeepScreenOn);            //Don't go to sleep while scanning


            SetContentView(Resource.Layout.zxingscanneractivitylayout);

            scannerFragment = new ZXingScannerFragment(result => {
                var evt = OnScanCompleted;
                if (evt != null)
                {
                    OnScanCompleted(result);
                }

                this.Finish();
            }, ScanningOptions);
            scannerFragment.CustomOverlayView = CustomOverlayView;
            scannerFragment.UseCustomView     = UseCustomView;
            scannerFragment.TopText           = TopText;
            scannerFragment.BottomText        = BottomText;

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.contentFrame, scannerFragment, "ZXINGFRAGMENT")
            .Commit();

            OnCancelRequested    += HandleCancelScan;
            OnAutoFocusRequested += HandleAutoFocus;
            OnTorchRequested     += HandleTorchRequested;
        }
Exemplo n.º 5
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			this.RequestWindowFeature (WindowFeatures.NoTitle);

			this.Window.AddFlags (WindowManagerFlags.Fullscreen); //to show
			this.Window.AddFlags (WindowManagerFlags.KeepScreenOn); //Don't go to sleep while scanning


			SetContentView(Resource.Layout.zxingscanneractivitylayout);

			scannerFragment = new ZXingScannerFragment(result => {
				var evt = OnScanCompleted;
				if (evt != null)
					OnScanCompleted(result);

				this.Finish();

			}, ScanningOptions);
			scannerFragment.CustomOverlayView = CustomOverlayView;
			scannerFragment.UseCustomView = UseCustomView;

			SupportFragmentManager.BeginTransaction()
				.Replace(Resource.Id.contentFrame, scannerFragment, "ZXINGFRAGMENT")
				.Commit();

			OnCancelRequested += HandleCancelScan;
			OnAutoFocusRequested += HandleAutoFocus;
			OnTorchRequested += HandleTorchRequested;

		}
Exemplo n.º 6
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			SetContentView (Resource.Layout.FragmentActivity);

			scanFragment = new ZXingScannerFragment ();

			SupportFragmentManager.BeginTransaction ()
				.Replace (Resource.Id.fragment_container, scanFragment)
				.Commit ();            
		}
Exemplo n.º 7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            this.RequestWindowFeature(WindowFeatures.NoTitle);

            this.Window.AddFlags(WindowManagerFlags.Fullscreen);   //to show
            this.Window.AddFlags(WindowManagerFlags.KeepScreenOn); //Don't go to sleep while scanning

            if (ScanningOptions.AutoRotate.HasValue && !ScanningOptions.AutoRotate.Value)
            {
                RequestedOrientation = ScreenOrientation.Nosensor;
            }

            SetContentView(Resource.Layout.zxingscanneractivitylayout);

            scannerFragment = new ZXingScannerFragment();
            scannerFragment.CustomOverlayView    = CustomOverlayView;
            scannerFragment.UseCustomOverlayView = UseCustomOverlayView;
            scannerFragment.TopText    = TopText;
            scannerFragment.BottomText = BottomText;

            SupportFragmentManager.BeginTransaction()
            .Replace(Resource.Id.contentFrame, scannerFragment, "ZXINGFRAGMENT")
            .Commit();

            CancelRequestedHandler    = CancelScan;
            AutoFocusRequestedHandler = AutoFocus;
            TorchRequestedHandler     = SetTorch;
            PauseAnalysisHandler      = scannerFragment.PauseAnalysis;
            ResumeAnalysisHandler     = scannerFragment.ResumeAnalysis;

            var permissionsToRequest = new List <string> ();

            // Check and request any permissions
            foreach (var permission in RequiredPermissions)
            {
                if (PlatformChecks.IsPermissionInManifest(this, permission))
                {
                    if (!PlatformChecks.IsPermissionGranted(this, permission))
                    {
                        permissionsToRequest.Add(permission);
                    }
                }
            }

            if (permissionsToRequest.Any())
            {
                waitingForPermission = PlatformChecks.RequestPermissions(this, permissionsToRequest.ToArray(), 101);
            }
        }
Exemplo n.º 8
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			this.RequestWindowFeature (WindowFeatures.NoTitle);

			this.Window.AddFlags (WindowManagerFlags.Fullscreen); //to show
			this.Window.AddFlags (WindowManagerFlags.KeepScreenOn); //Don't go to sleep while scanning

			if (ScanningOptions.AutoRotate.HasValue && !ScanningOptions.AutoRotate.Value)
				RequestedOrientation = ScreenOrientation.Nosensor;

			SetContentView(Resource.Layout.zxingscanneractivitylayout);

            scannerFragment = new ZXingScannerFragment ();
			scannerFragment.CustomOverlayView = CustomOverlayView;
			scannerFragment.UseCustomOverlayView = UseCustomOverlayView;
			scannerFragment.TopText = TopText;
			scannerFragment.BottomText = BottomText;

			SupportFragmentManager.BeginTransaction()
				.Replace(Resource.Id.contentFrame, scannerFragment, "ZXINGFRAGMENT")
				.Commit();
            
			OnCancelRequested += HandleCancelScan;
			OnAutoFocusRequested += HandleAutoFocus;
			OnTorchRequested += HandleTorchRequested;

            var permissionsToRequest = new List<string>();

            // Check and request any permissions
            foreach (var permission in RequiredPermissions) {
                if (PlatformChecks.IsPermissionInManifest (this, permission)) {
                    if (!PlatformChecks.IsPermissionGranted(this, permission))
                        permissionsToRequest.Add(permission);                        
                }
            }

            if (permissionsToRequest.Any())
            {
                waitingForPermission = PlatformChecks.RequestPermissions(this, permissionsToRequest.ToArray (), 101);
            }
		}