diff --git a/Samples/Sample.Android/FragmentActivityCustomScanArea.cs b/Samples/Sample.Android/FragmentActivityCustomScanArea.cs new file mode 100644 index 000000000..322c0f4b3 --- /dev/null +++ b/Samples/Sample.Android/FragmentActivityCustomScanArea.cs @@ -0,0 +1,317 @@ +using System; +using System.Collections.Generic; +using ZXing.Mobile; +using Android.OS; + +using Android.App; +using Android.Widget; +using Android.Content.PM; +using Android.Views; +using Xamarin.Essentials; +using Android.Content; +using AndroidX.ConstraintLayout.Widget; + +namespace Sample.Android +{ + [Activity(Label = "ZXing.Net.Mobile", Theme = "@style/Theme.AppCompat.Light", ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.KeyboardHidden)] + public class FragmentActivityCustomScanArea : AndroidX.Fragment.App.FragmentActivity + { + ZXingScannerFragment scanFragment; + Button buttonRectangle; + Button buttonSquare; + Button buttonRandom; + ImageButton buttonIncrease; + ImageButton buttonDecrease; + ToggleButton scanViewPosition; + View scanArea; + bool scanAreaIsRectangle = true; + bool isScanAreaCentered = false; + + protected override void OnCreate (Bundle savedInstanceState) + { + base.OnCreate (savedInstanceState); + + SetContentView (Resource.Layout.FragmentActivity); + + } + + protected override void OnResume () + { + base.OnResume (); + + + if (scanFragment == null) + { + var zxingOverlay = LayoutInflater.FromContext(this).Inflate(Resource.Layout.ZxingOverlayCustomScanArea, null); + scanArea = zxingOverlay.FindViewById(Resource.Id.scanView); + + //Find all the buttons and wire up their events + buttonRectangle = zxingOverlay.FindViewById