Skip to content

Commit

Permalink
Version 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
adriano committed Dec 22, 2021
1 parent 8953f0a commit 86cee53
Show file tree
Hide file tree
Showing 25 changed files with 3,423 additions and 504 deletions.
14 changes: 13 additions & 1 deletion App/QR2Web/QR2Web.Droid/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Plugin.CurrentActivity;
using Android.Content;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using Xamarin.Essentials;

namespace QR2Web.Droid
{
Expand Down Expand Up @@ -145,18 +146,29 @@ public void InitExternalLibraries()
{
Xamarin.Essentials.Platform.Init(Application);
ZXing.Net.Mobile.Forms.Android.Platform.Init();
Rg.Plugins.Popup.Popup.Init(this);
}

public void InitOSSettings(Bundle bundle)
{

}

public override void OnBackPressed()
{
Rg.Plugins.Popup.Popup.SendBackPressed(base.OnBackPressed);
}

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
Plugin.Permissions.PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
public async void EnablePermissionLocation()
{
await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
}

public bool OpenExternalUrl(string url)
{
Expand Down
2 changes: 1 addition & 1 deletion App/QR2Web/QR2Web.Droid/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionName="2.1" android:versionCode="26" package="ch.petrucci.qr2web_2">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionName="2.2" android:versionCode="27" package="ch.petrucci.qr2web_2">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
Expand Down
14 changes: 14 additions & 0 deletions App/QR2Web/QR2Web.Droid/QR2Web.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<AndroidSigningKeyPass>store123</AndroidSigningKeyPass>
<AndroidLinkTool>r8</AndroidLinkTool>
<MandroidI18n />
<AndroidSupportedAbis />
</PropertyGroup>
<ItemGroup>
<Compile Include="Helpers\Settings.cs" />
Expand Down Expand Up @@ -118,6 +119,9 @@
<PackageReference Include="Plugin.CurrentActivity">
<Version>2.1.0.4</Version>
</PackageReference>
<PackageReference Include="Rg.Plugins.Popup">
<Version>2.0.0.13</Version>
</PackageReference>
<PackageReference Include="System.CodeDom">
<Version>6.0.0</Version>
</PackageReference>
Expand Down Expand Up @@ -196,6 +200,16 @@
<ItemGroup>
<AndroidResource Include="Resources\Drawable\numeric.png" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\Drawable\about.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\Drawable\help.png">
<Generator>MSBuild:UpdateGeneratedFiles</Generator>
</AndroidResource>
</ItemGroup>
<Import Project="..\QR2Web\QR2Web.projitems" Label="Shared" Condition="Exists('..\QR2Web\QR2Web.projitems')" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
2,765 changes: 2,688 additions & 77 deletions App/QR2Web/QR2Web.Droid/Resources/Resource.Designer.cs

Large diffs are not rendered by default.

Binary file added App/QR2Web/QR2Web.Droid/Resources/drawable/about.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added App/QR2Web/QR2Web.Droid/Resources/drawable/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions App/QR2Web/QR2Web.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ private void InitXamarin(IActivatedEventArgs e)
assembliesToInclude.Add(typeof(ZXing.Mobile.SoftwareBitmapLuminanceSource).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(ZXing.Mobile.ZXingScannerControl).GetTypeInfo().Assembly);

Rg.Plugins.Popup.Popup.Init();
assembliesToInclude.AddRange(Rg.Plugins.Popup.Popup.GetExtraAssemblies());

Xamarin.Forms.Forms.Init(e, assembliesToInclude);
//// End workaround, the original init is only 1 line:

Expand Down
7 changes: 6 additions & 1 deletion App/QR2Web/QR2Web.UWP/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public void LockPortrait(bool tryToLock)
public void InitExternalLibraries()
{
ZXing.Net.Mobile.Forms.WindowsUniversal.ZXingScannerViewRenderer.Init();

}

public void InitOSSettings()
Expand All @@ -85,5 +84,11 @@ public bool OpenExternalUrl(string url)
}
return success;
}

public void EnablePermissionLocation() //try to enable location over app
{

}

}
}
7 changes: 6 additions & 1 deletion App/QR2Web/QR2Web.UWP/QR2Web.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<EnableDotNetNativeCompatibleProfile>false</EnableDotNetNativeCompatibleProfile>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -114,6 +114,8 @@
<None Include="QR2Web.UWP_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<Content Include="about.png" />
<Content Include="help.png" />
<Content Include="torch.png" />
<None Include="Package.StoreAssociation.xml" />
<Content Include="numeric.png" />
Expand Down Expand Up @@ -146,6 +148,9 @@
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Rg.Plugins.Popup">
<Version>2.0.0.13</Version>
</PackageReference>
<PackageReference Include="Xam.Plugin.Geolocator">
<Version>4.5.0.6</Version>
</PackageReference>
Expand Down
Binary file added App/QR2Web/QR2Web.UWP/about.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added App/QR2Web/QR2Web.UWP/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 7 additions & 38 deletions App/QR2Web/QR2Web/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public class App : Application
private Scanner QRScanner = null;
private QRMainPage QRPage = null;

public static List<KeyValuePair<DateTime, string>> History = new List<KeyValuePair<DateTime, string>>(16);
public History ScanHistory = null;

public static App Instance { get; set; } = null; // Used to access App from the different OS codes
public static int AppVersion { get; } = 21; // Version of this app for the different OS codes
public static int AppVersion { get; } = 22; // Version of this app for the different OS codes

public static bool HasBackButton { get; private set; }
public static OSInterface IOS { get; private set; }
Expand Down Expand Up @@ -48,14 +48,11 @@ public void LoadMainPage(bool baseInit = true)
else
{
QRScanner = new Scanner(); // initialize scanner class (ZXing scanner)

Parameters.LoadHistory(ref History); // load scan results history
ScanHistory = new History();

if (Parameters.Options.UseLocation)
QRLocation.InitLocation();

if (!Parameters.Options.SaveHistory) History.Clear(); // clear history if no history should be used

QRPage.Initialize();
}

Expand Down Expand Up @@ -105,8 +102,8 @@ public void StartScan()

if (result != null)
{
AddHistory(result.Text);
OpenJSFunctionQRCode(result.Text);
ScanHistory.Add(result.Text);
InjectJSQRCode(result.Text);
if (Parameters.Options.UseLocation)
{
OpenJSFunctionLocation();
Expand All @@ -129,9 +126,9 @@ public void StartScan()
/// Execute the callback function in the webpage, passing the parsed QR code.
/// </summary>
/// <param name="scanCode">Code or text parsed from barcode</param>
public void OpenJSFunctionQRCode(string scanCode)
public void InjectJSQRCode(string scanCode)
{
string jsString = QRScanner.GenerateJavascriptString(scanCode);
string jsString = QRScanner.InjectJavascriptScanCode(scanCode);

QRPage.InjectJS(jsString);
}
Expand All @@ -146,34 +143,6 @@ public void OpenJSFunctionLocation()
QRPage.InjectJS(jsString);
}

/// <summary>
/// Add the QR-code to history. So it can be used later.
/// </summary>
/// <param name="value">The QR code or the parsed value (can be text)</param>
public void AddHistory(string value)
{
for (int i = 0; i < History.Count; i++)
{
if (History[i].Value == value)
{
History.RemoveAt(i);
}
}
if (Parameters.Options.SaveHistory)
{
History.Insert(
0,
new KeyValuePair<DateTime, string>
(
DateTime.Now,
value
)
);

Parameters.SaveHistory(ref History);
}
}

protected override void OnStart()
{
// Handle when your app starts
Expand Down
141 changes: 141 additions & 0 deletions App/QR2Web/QR2Web/History.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
using System;
using System.Collections.Generic;
using System.Text;
using Rg.Plugins.Popup.Extensions;
using Xamarin.Forms;

namespace QR2Web
{
public class History
{
private List<KeyValuePair<DateTime, string>> ScanData = new List<KeyValuePair<DateTime, string>>(16);

public History()
{
Parameters.LoadHistory(ref ScanData); // load scan results history

if (!Parameters.Options.SaveHistory) ScanData.Clear(); // clear history if no history should be used
}

/// <summary>
/// Add the QR-code to history. So it can be used later.
/// </summary>
/// <param name="value">The QR code or the parsed value (can be text)</param>
public void Add(string value)
{
for (int i = 0; i < ScanData.Count; i++)
{
if (ScanData[i].Value == value)
{
if (i == 0) return;
ScanData.RemoveAt(i);
}
}
if (Parameters.Options.SaveHistory)
{
ScanData.Insert(
0,
new KeyValuePair<DateTime, string>
(
DateTime.Now,
value
)
);

Parameters.SaveHistory(ref ScanData);
}
}

public async void ShowDialog(QRMainPage BasePage)
{
var historyPage = new HistoryPage(ScanData);
await BasePage.Navigation.PushPopupAsync(historyPage);
}
}

class HistoryPage : Rg.Plugins.Popup.Pages.PopupPage
{
public HistoryPage(List<KeyValuePair<DateTime, string>> ScanData)
{
Title = "History";

var content = new StackLayout
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Orientation = StackOrientation.Vertical,
Children = {
}
};

if (ScanData.Count == 0)
{
content.Children.Add(new Label { Text = "[empty]", HorizontalTextAlignment = TextAlignment.Center });
}

for (int i = 0; i < ScanData.Count; i++)
{
Label b = new Label { Text = ScanData[i].Value, HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Start, BackgroundColor = Color.Transparent, TextColor = Color.SkyBlue, Padding = new Thickness(10, 2, 10, 0) };
if (ScanData[i].Value.Length < 20) b.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
else if (ScanData[i].Value.Length < 20) b.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
Label l = null;
if (ScanData[i].Key.Day == DateTime.Now.Day)
{
l = new Label { Text = ScanData[i].Key.ToString("H:mm:ss"), HorizontalOptions = LayoutOptions.EndAndExpand, TextColor = Color.SlateGray, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) };
}
else if (ScanData[i].Key.Day == DateTime.Now.AddDays(-1).Day)
{
l = new Label { Text = ScanData[i].Key.ToString("d.MMM H:mm"), HorizontalOptions = LayoutOptions.EndAndExpand, TextColor = Color.SlateGray, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) };
}
else
{
l = new Label { Text = ScanData[i].Key.ToString("d.MMMM.yyyy"), HorizontalOptions = LayoutOptions.EndAndExpand, TextColor = Color.SlateGray, FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label)) };
}

var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (s, e) => {
var t = (s as Label).Text;
App.Instance.InjectJSQRCode(t);
Navigation.PopPopupAsync();
};
b.GestureRecognizers.Add(tapGestureRecognizer);

content.Children.Add(b);
content.Children.Add(l);
}

Content = new ScrollView
{
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
WidthRequest = 300,
HeightRequest = 500,
Padding = new Thickness(10, 5, 10, 5),
BackgroundColor = Color.Black,
Content = content
};
}

protected override void OnAppearing()
{
base.OnAppearing();
}

protected override void OnDisappearing()
{
base.OnDisappearing();
}

protected override bool OnBackButtonPressed()
{
return false;
}

// Invoked when background is clicked
protected override bool OnBackgroundClicked()
{
// Return false if you don't want to close this popup page when a background of the popup page is clicked
return base.OnBackgroundClicked();
}
}
}
7 changes: 5 additions & 2 deletions App/QR2Web/QR2Web/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ static public String GetText(string TextKey)
/// </summary>
static private void FillDictionary()
{
AddText("AppTitle", new string[] { "QR to Web Inventory", "QR to Web Inventory", "QR to Web Inventory" });
AddText("AppTitleShort", new string[] { "QR2Web", "QR2Web", "QR2Web" });
AddText("AppTitle", new string[] { "QR to Web", "QR to Web", "QR to Web" });
AddText("AppTitleShort", new string[] { "QR 2 Web", "QR 2 Web", "QR 2 Web" });
AddText("Settings", new string[] { "Settings", "Einstellungen", "Impostazioni" });
AddText("Help", new string[] { "Help", "Hilfe", "Aiuto" });
AddText("About", new string[] { "About", "Über", "Info" });
Expand All @@ -126,11 +126,14 @@ static private void FillDictionary()
AddText("Yes", new string[] { "Yes", "Ja", "Sì" });
AddText("No", new string[] { "No", "Nein", "No" });
AddText("Torch", new string[] { "Torch", "Lampe", "Torcia" });
AddText("Scan", new string[] { "Scan", "Einscannen", "Scansiona" });
AddText("ScannerText1", new string[] { "Scan with a distance of 20-30cm", "Abstand von 20-30cm halten", "Leggere da una distanza di 20-30cm" });
AddText("ScannerText2", new string[] { "Light On/Off", "Licht Ein/Aus", "Luce On/Off" });
AddText("NeedRestart", new string[] { "(* App must be restarted)", "(* App muss neu gestartet werden)", "(* necessita un riavvio dell'app)" });
AddText("RefreshPage", new string[] { "Refresh page", "Seite aktualisieren", "Aggiorna pagina" });
AddText("Refresh", new string[] { "Refresh", "Aktualisieren", "Aggiorna" });
AddText("HomePage", new string[] { "Return to home page", "Zurück zur home page", "Torna alla pagina principale" });
AddText("Home", new string[] { "Home page", "Start Seite", "Pagina principale" });
AddText("TimeToScan", new string[] { "(XX seconds to scan..)", "(XX Sekunden um zu scannen...)", "(XX secondi per scannerizzare...)" });

AddText("Option1_1", new string[] { "Home Page", "Home Page", "Home Page" });
Expand Down
Loading

0 comments on commit 86cee53

Please sign in to comment.