diff --git a/App/QR2Web/QR2Web.Droid/Properties/AndroidManifest.xml b/App/QR2Web/QR2Web.Droid/Properties/AndroidManifest.xml index 6707360..8ae6bc7 100644 --- a/App/QR2Web/QR2Web.Droid/Properties/AndroidManifest.xml +++ b/App/QR2Web/QR2Web.Droid/Properties/AndroidManifest.xml @@ -1,5 +1,5 @@  - + diff --git a/App/QR2Web/QR2Web.Droid/packages.config b/App/QR2Web/QR2Web.Droid/packages.config index 670a490..efcef92 100644 --- a/App/QR2Web/QR2Web.Droid/packages.config +++ b/App/QR2Web/QR2Web.Droid/packages.config @@ -10,5 +10,5 @@ - + \ No newline at end of file diff --git a/App/QR2Web/QR2Web.UWP/App.xaml.cs b/App/QR2Web/QR2Web.UWP/App.xaml.cs index eee75e8..041d5d5 100644 --- a/App/QR2Web/QR2Web.UWP/App.xaml.cs +++ b/App/QR2Web/QR2Web.UWP/App.xaml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; using System.Runtime.InteropServices.WindowsRuntime; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; @@ -32,6 +33,48 @@ public App() this.Suspending += OnSuspending; } + private void InitXamarin(IActivatedEventArgs e) + { + //// Workaround to show the scanner also on Windows. + List assembliesToInclude = new List(); + + assembliesToInclude.Add(typeof(ZXing.BarcodeReader).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Reader).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.BaseLuminanceSource).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Binarizer).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.BinaryBitmap).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Dimension).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.LuminanceSource).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.MultiFormatReader).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.PlanarYUVLuminanceSource).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Result).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.ResultPoint).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.RGBLuminanceSource).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.SupportClass).GetTypeInfo().Assembly); + + assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingBarcodeImageView).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingScannerPage).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingScannerView).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.ZXingDefaultOverlay).GetTypeInfo().Assembly); + + assembliesToInclude.Add(typeof(ZXing.Net.Mobile.ZXing_Net_Mobile_WindowsUniversal_XamlTypeInfo.XamlMetaDataProvider).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingBarcodeImageViewRenderer).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingScannerViewRenderer).GetTypeInfo().Assembly); + + assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScanner).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScannerBase).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScanningOptions).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Mobile.ScanPage).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Mobile.MobileBarcodeScannerBase).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Mobile.SoftwareBitmapLuminanceSource).GetTypeInfo().Assembly); + assembliesToInclude.Add(typeof(ZXing.Mobile.ZXingScannerControl).GetTypeInfo().Assembly); + + Xamarin.Forms.Forms.Init(e, assembliesToInclude); + //// End workaround, the original init is only 1 line: + + //Xamarin.Forms.Forms.Init(e); + } + /// /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. @@ -58,7 +101,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) rootFrame.NavigationFailed += OnNavigationFailed; - Xamarin.Forms.Forms.Init(e); + InitXamarin(e); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { @@ -86,8 +129,8 @@ protected override void OnActivated(IActivatedEventArgs args) { ProtocolActivatedEventArgs pargs = (ProtocolActivatedEventArgs)args; bool success = false; - - if(pargs.PreviousExecutionState == ApplicationExecutionState.ClosedByUser || + + if (pargs.PreviousExecutionState == ApplicationExecutionState.ClosedByUser || pargs.PreviousExecutionState == ApplicationExecutionState.NotRunning) { Frame rootFrame = Window.Current.Content as Frame; @@ -101,8 +144,8 @@ protected override void OnActivated(IActivatedEventArgs args) rootFrame.NavigationFailed += OnNavigationFailed; - Xamarin.Forms.Forms.Init(args); - + InitXamarin(args); + // Place the frame in the current Window Window.Current.Content = rootFrame; } diff --git a/App/QR2Web/QR2Web.UWP/MainPage.xaml.cs b/App/QR2Web/QR2Web.UWP/MainPage.xaml.cs index 2ef1d40..4e7e300 100644 --- a/App/QR2Web/QR2Web.UWP/MainPage.xaml.cs +++ b/App/QR2Web/QR2Web.UWP/MainPage.xaml.cs @@ -57,6 +57,7 @@ public void LockPortrait(bool tryToLock) public void InitExternalLibraries() { ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingScannerViewRenderer.Init(); + } public void InitOSSettings() diff --git a/App/QR2Web/QR2Web.UWP/Package.appxmanifest b/App/QR2Web/QR2Web.UWP/Package.appxmanifest index c62c21b..bf44ab7 100644 --- a/App/QR2Web/QR2Web.UWP/Package.appxmanifest +++ b/App/QR2Web/QR2Web.UWP/Package.appxmanifest @@ -1,6 +1,6 @@  - + QR2Web Inventory @@ -22,27 +22,27 @@ - + QR.png - QR to Web + Pic2Shop Emulation - + QR.png - QR to Web + Mocha Emulation - + QR.png - Mocha Emulation + QR to Web - + QR.png - Pic2Shop Emulation + QR to Web @@ -52,5 +52,6 @@ + \ No newline at end of file diff --git a/App/QR2Web/QR2Web.UWP/Properties/AssemblyInfo.cs b/App/QR2Web/QR2Web.UWP/Properties/AssemblyInfo.cs index 9e9219c..53bd4bb 100644 --- a/App/QR2Web/QR2Web.UWP/Properties/AssemblyInfo.cs +++ b/App/QR2Web/QR2Web.UWP/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("QR to Web Inventory")] -[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/App/QR2Web/QR2Web.UWP/QR2Web.UWP.csproj b/App/QR2Web/QR2Web.UWP/QR2Web.UWP.csproj index 1145c2e..2f00211 100644 --- a/App/QR2Web/QR2Web.UWP/QR2Web.UWP.csproj +++ b/App/QR2Web/QR2Web.UWP/QR2Web.UWP.csproj @@ -92,6 +92,7 @@ prompt true true + true @@ -144,7 +145,26 @@ - + + False + ..\..\..\..\ZXing.Net.Mobile\Build\Forms\Release\uwp\ZXing.Net.Mobile.Core.dll + + + False + ..\..\..\..\ZXing.Net.Mobile\Build\Forms\Release\uwp\ZXing.Net.Mobile.Forms.dll + + + False + ..\..\..\..\ZXing.Net.Mobile\Build\Forms\Release\uwp\ZXing.Net.Mobile.Forms.WindowsUniversal.dll + + + False + ..\..\..\..\ZXing.Net.Mobile\Build\Forms\Release\uwp\zxing.portable.dll + + + False + ..\..\..\..\ZXing.Net.Mobile\Build\Forms\Release\uwp\ZXingNetMobile.dll + 14.0 diff --git a/App/QR2Web/QR2Web.UWP/project.json b/App/QR2Web/QR2Web.UWP/project.json index 0abadca..9e9183b 100644 --- a/App/QR2Web/QR2Web.UWP/project.json +++ b/App/QR2Web/QR2Web.UWP/project.json @@ -1,8 +1,7 @@ { "dependencies": { "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2", - "Xamarin.Forms": "2.3.3.175", - "ZXing.Net.Mobile.Forms": "2.1.47" + "Xamarin.Forms": "2.3.3.175" }, "frameworks": { "uap10.0": {} diff --git a/App/QR2Web/QR2Web.iOS/Entitlements.plist b/App/QR2Web/QR2Web.iOS/Entitlements.plist deleted file mode 100644 index 0c67376..0000000 --- a/App/QR2Web/QR2Web.iOS/Entitlements.plist +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/App/QR2Web/QR2Web.iOS/Info.plist b/App/QR2Web/QR2Web.iOS/Info.plist index 2e28b4d..745a153 100644 --- a/App/QR2Web/QR2Web.iOS/Info.plist +++ b/App/QR2Web/QR2Web.iOS/Info.plist @@ -21,13 +21,13 @@ UIInterfaceOrientationLandscapeRight MinimumOSVersion - 6.0 + 8.1 CFBundleDisplayName - QR2Web + qr2web Inventory CFBundleIdentifier - ch.petrucci.QR2Web + ch.petrucci.qr2web-Inventory CFBundleVersion - 1.0 + 2 CFBundleIconFiles Icon-60@2x.png @@ -59,6 +59,10 @@ CFBundleShortVersionString - 1.2 + 1.3 + UIMainStoryboardFile + LaunchScreen + UIMainStoryboardFile~ipad + LaunchScreen diff --git a/App/QR2Web/QR2Web.iOS/QR2Web.iOS.csproj b/App/QR2Web/QR2Web.iOS/QR2Web.iOS.csproj index 270124a..8f93c21 100644 --- a/App/QR2Web/QR2Web.iOS/QR2Web.iOS.csproj +++ b/App/QR2Web/QR2Web.iOS/QR2Web.iOS.csproj @@ -10,9 +10,24 @@ Exe QR2Web.iOS Resources - QR2WebiOS + QR2Web + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true true @@ -49,7 +64,8 @@ ARMv7, ARM64 iPhone Developer true - Entitlements.plist + + True False @@ -73,10 +89,9 @@ False ARMv7, ARM64 True - Automatic:AdHoc - iPhone Distribution - Entitlements.plist + iPhone Developer: adosapps@gmail.com (N72LA2ZQZV) False + 7a679996-b650-46a0-9f1b-0539da42258d none @@ -90,16 +105,18 @@ iPhone Distribution Entitlements.plist + + QR2Web.iOS.Application + - + Designer - @@ -189,6 +206,13 @@ + + + False + .NET Framework 3.5 SP1 + true + + diff --git a/App/QR2Web/QR2Web.iOS/iTunesArtwork b/App/QR2Web/QR2Web.iOS/iTunesArtwork index 94c8ebd..89decd2 100644 Binary files a/App/QR2Web/QR2Web.iOS/iTunesArtwork and b/App/QR2Web/QR2Web.iOS/iTunesArtwork differ diff --git a/App/QR2Web/QR2Web.iOS/iTunesArtwork@2x b/App/QR2Web/QR2Web.iOS/iTunesArtwork@2x index fa2ebf7..3a3842f 100644 Binary files a/App/QR2Web/QR2Web.iOS/iTunesArtwork@2x and b/App/QR2Web/QR2Web.iOS/iTunesArtwork@2x differ diff --git a/App/QR2Web/QR2Web/App.cs b/App/QR2Web/QR2Web/App.cs index 7cd88d0..1c5771b 100644 --- a/App/QR2Web/QR2Web/App.cs +++ b/App/QR2Web/QR2Web/App.cs @@ -5,7 +5,7 @@ using System.Text; using Xamarin.Forms; -using ZXing.Net.Mobile.Forms; +//using ZXing.Net.Mobile.Forms; namespace QR2Web { @@ -15,14 +15,17 @@ public class App : Application private Button HistoryButton; private Button MoreButton; private Button HomeButton; + private Button RefreshButton; + private Button SettingsButton; private WebView WebPageWebView; private Scanner QRScanner; private StackLayout TitleStack; + private DateTime lastWindowUpdate; private List> History = new List>(16); public static App Instance { get; set; } = null; // Used to access App from the different OS codes - public static int AppVersion { get; } = 12; // Version of this app for the different OS codes + public static int AppVersion { get; } = 13; // Version of this app for the different OS codes protected override void OnAppLinkRequestReceived(Uri uri) { @@ -42,50 +45,11 @@ public App () if (!Parameters.Options.SaveHistory) History.Clear(); // clear history if no history should be used Language.SetLanguage(Parameters.Options.LanguageIndex); // set language for the app from options - - // create top-bar buttons - ScanButton = new Button - { - Image = new FileImageSource - { - File = "scanb.png", - }, - }; - ScanButton.Clicked += (sender, e) => - { - StartScan(); - }; - - HistoryButton = new Button - { - Image = new FileImageSource - { - File = "scanh.png", - }, - }; - HistoryButton.Clicked += HistoryScan_Clicked; - - HomeButton = new Button - { - Image = new FileImageSource - { - File = "scanp.png", - }, - }; - HomeButton.Clicked += (sender, e) => - { - WebPageWebView.Source = Parameters.Options.HomePage; - }; - MoreButton = new Button - { - Image = new FileImageSource - { - File = "scanm.png", - }, - }; - MoreButton.Clicked += MoreScan_Clicked; + // create top-bar buttons + InitButtons(); + // create webView for the page WebPageWebView = new WebView { @@ -106,17 +70,34 @@ public App () }; WebPageWebView.SizeChanged += (s, e) => { - while (TitleStack.Children.Count > 1) + if(TitleStack.Children.Count == 1) + { + lastWindowUpdate = DateTime.Now; + } + else { - TitleStack.Children.RemoveAt(1); + if((DateTime.Now - lastWindowUpdate).TotalSeconds > 2) + { + while (TitleStack.Children.Count > 1) + { + TitleStack.Children.RemoveAt(1); + } + lastWindowUpdate = DateTime.Now; + } } + if (WebPageWebView.Bounds.Width > 200) TitleStack.Children.Add(ScanButton); if (WebPageWebView.Bounds.Width > 400) TitleStack.Children.Add(HomeButton); + if (WebPageWebView.Bounds.Width > 500) + TitleStack.Children.Add(RefreshButton); if (WebPageWebView.Bounds.Width > 300) TitleStack.Children.Add(HistoryButton); + if (WebPageWebView.Bounds.Width > 600) + TitleStack.Children.Add(SettingsButton); TitleStack.Children.Add(MoreButton); + }; TitleStack = new StackLayout @@ -155,6 +136,78 @@ public App () Padding = new Thickness(0), BackgroundColor = Color.Black, }; + + NavigationPage.SetHasBackButton(MainPage, false); + } + + private void InitButtons() + { + // create top-bar buttons + ScanButton = new Button + { + Image = new FileImageSource + { + File = "scanb.png", + }, + }; + ScanButton.Clicked += (sender, e) => + { + StartScan(); + }; + + HistoryButton = new Button + { + Image = new FileImageSource + { + File = "scanh.png", + }, + }; + HistoryButton.Clicked += HistoryScan_Clicked; + + HomeButton = new Button + { + Image = new FileImageSource + { + File = "scanp.png", + }, + }; + HomeButton.Clicked += (sender, e) => + { + WebPageWebView.Source = Parameters.Options.HomePage; + }; + + RefreshButton = new Button + { + Image = new FileImageSource + { + File = "scanr.png", + }, + }; + RefreshButton.Clicked += (sender, e) => + { + WebPageWebView.Source = (WebPageWebView.Source as UrlWebViewSource).Url; + }; + + SettingsButton = new Button + { + Image = new FileImageSource + { + File = "scanc.png", + }, + }; + SettingsButton.Clicked += async (sender, e) => + { + await App.Current.MainPage.Navigation.PushModalAsync(new OptionsPage()); + }; + + MoreButton = new Button + { + Image = new FileImageSource + { + File = "scanm.png", + }, + }; + MoreButton.Clicked += MoreScan_Clicked; } /// diff --git a/App/QR2Web/QR2Web/OptionsPage.cs b/App/QR2Web/QR2Web/OptionsPage.cs index c0d7b6e..14cfcb6 100644 --- a/App/QR2Web/QR2Web/OptionsPage.cs +++ b/App/QR2Web/QR2Web/OptionsPage.cs @@ -70,11 +70,8 @@ public OptionsPage() languagePicker.SelectedIndex = Parameters.Options.LanguageIndex; languagePicker.SelectedIndexChanged += (s, e) => { saveSettings = true; }; - - Label NeedRestartText = new Label { Text = "--------------------------\n" + Language.GetText("NeedRestart") }; - - + Content = new StackLayout { Padding = new Thickness(10), @@ -149,6 +146,8 @@ public OptionsPage() NeedRestartText }, }; + + NavigationPage.SetHasBackButton(this, true); } /// diff --git a/App/QR2Web/QR2Web/OverlayPage.cs b/App/QR2Web/QR2Web/OverlayPage.cs index 8217599..5c65a03 100644 --- a/App/QR2Web/QR2Web/OverlayPage.cs +++ b/App/QR2Web/QR2Web/OverlayPage.cs @@ -34,21 +34,23 @@ public CustomScanPage() : base() var torch = new Button { Text = "Torch", - HorizontalOptions = LayoutOptions.FillAndExpand + HorizontalOptions = LayoutOptions.FillAndExpand, + TextColor = Color.White }; torch.Clicked += delegate { - zxing.ToggleTorch(); + zxing.ToggleTorch(); }; var abort = new Button { Text = "Abort", - HorizontalOptions = LayoutOptions.FillAndExpand + HorizontalOptions = LayoutOptions.FillAndExpand, + TextColor = Color.White }; abort.Clicked += delegate { zxing.RaiseScanResult(null); }; - + var customOverlayTop = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, @@ -65,13 +67,15 @@ public CustomScanPage() : base() { Text = Language.GetText("AppTitle"), HorizontalTextAlignment = TextAlignment.Center, - HorizontalOptions = LayoutOptions.CenterAndExpand + HorizontalOptions = LayoutOptions.CenterAndExpand, + TextColor = Color.White }, new Label { Text = "Scan QR code...", HorizontalTextAlignment = TextAlignment.Center, - HorizontalOptions = LayoutOptions.CenterAndExpand + HorizontalOptions = LayoutOptions.CenterAndExpand, + TextColor = Color.White } } }; @@ -108,13 +112,11 @@ public CustomScanPage() : base() BackgroundColor = Color.Black, Opacity = 0.7, Padding = new Thickness(0, 10, 0, 10), - Children = - { - abort, - torch, - } }; + customOverlayBottom.Children.Add(abort); + if(zxing.HasTorch) customOverlayBottom.Children.Add(torch); + var customOverlay = new Grid { HorizontalOptions = LayoutOptions.FillAndExpand, @@ -150,12 +152,13 @@ public CustomScanPage() : base() // The root page of your application Content = grid; } - + protected override void OnAppearing() { base.OnAppearing(); zxing.IsScanning = true; + } protected override void OnDisappearing() diff --git a/App/QR2Web/QR2Web/ScanPage.cs b/App/QR2Web/QR2Web/ScanPage.cs index fe607da..377bdd7 100644 --- a/App/QR2Web/QR2Web/ScanPage.cs +++ b/App/QR2Web/QR2Web/ScanPage.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Xamarin.Forms; -using ZXing.Net.Mobile.Forms; +//using ZXing.Net.Mobile.Forms; namespace QR2Web { @@ -109,6 +109,11 @@ public string GenerateJavascriptString(string scanCode) Emulation = Parameters.Options.Emulation; } + if(scanCode.IndexOf("\n") > 0 || scanCode.IndexOf("\r") > 0) + { + scanCode = System.Net.WebUtility.UrlEncode(scanCode); + } + switch (Emulation) { case Parameters.EmulationTypes.MOCHASOFT: // mocha