mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 12:06:29 +02:00
Version 3.0.255
This commit is contained in:
parent
db9c288584
commit
5a26bf273b
1495 changed files with 159465 additions and 5060 deletions
45
Meinkonrad/TINK.Android/Model/Device/AppInfo.cs
Normal file
45
Meinkonrad/TINK.Android/Model/Device/AppInfo.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using TINK.Droid.Model.Device;
|
||||
using TINK.Model.Device;
|
||||
using Xamarin.Forms;
|
||||
|
||||
[assembly: Dependency(typeof(AppInfo))]
|
||||
namespace TINK.Droid.Model.Device
|
||||
{
|
||||
/// <summary> Holds information about the TINK- app. </summary>
|
||||
public class AppInfo : IAppInfo
|
||||
{
|
||||
/// <summary> Holds the the version of the app.</summary>
|
||||
private static Version m_oVersion = null;
|
||||
|
||||
/// <summary> Constructs a app info object. </summary>
|
||||
public AppInfo()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> Constructs a app info object for initialization. </summary>
|
||||
/// <param name="p_strVersionText"> Version to initializ object with.</param>
|
||||
internal AppInfo(string p_strVersionText)
|
||||
{
|
||||
if (m_oVersion != null)
|
||||
{
|
||||
// Set version only once.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Version.TryParse(p_strVersionText, out Version l_oVersion))
|
||||
{
|
||||
m_oVersion = new Version(0, 8);
|
||||
}
|
||||
|
||||
m_oVersion = l_oVersion;
|
||||
}
|
||||
|
||||
/// <summary> Get the version of the app. </summary>
|
||||
public Version Version => m_oVersion ?? new Version(0, 9);
|
||||
|
||||
/// <summary> Gets the URL to the app store. </summary>
|
||||
/// <value>The store URL.</value>
|
||||
public string StoreUrl => $"https://play.google.com/store/apps/details?id={Android.App.Application.Context.PackageName}";
|
||||
}
|
||||
}
|
23
Meinkonrad/TINK.Android/Model/Device/Device.cs
Normal file
23
Meinkonrad/TINK.Android/Model/Device/Device.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using TINK.Model.Device;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
[assembly: Dependency(typeof(TINK.Droid.Model.Device.Device))]
|
||||
namespace TINK.Droid.Model.Device
|
||||
{
|
||||
public class Device : ISmartDevice
|
||||
{
|
||||
public string Manufacturer => DeviceInfo.Manufacturer;
|
||||
|
||||
public string Model => DeviceInfo.Model;
|
||||
|
||||
public string PlatformText => DeviceInfo.Platform.ToString();
|
||||
|
||||
public string VersionText => DeviceInfo.VersionString;
|
||||
|
||||
/// <summary> Gets unitque device identifier. </summary>
|
||||
/// <returns>Gets the identifies specifying device.</returns>
|
||||
public string Identifier
|
||||
=> Android.Provider.Settings.Secure.GetString(Android.App.Application.Context.ContentResolver, Android.Provider.Settings.Secure.AndroidId);
|
||||
}
|
||||
}
|
70
Meinkonrad/TINK.Android/Model/Device/DroidCipher.cs
Normal file
70
Meinkonrad/TINK.Android/Model/Device/DroidCipher.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Javax.Crypto;
|
||||
using Javax.Crypto.Spec;
|
||||
using TINK.Droid.Model.Device;
|
||||
using TINK.Model.Device;
|
||||
using Xamarin.Forms;
|
||||
|
||||
[assembly: Dependency(typeof(TINK.Droid.Model.Device.DroidCipher))]
|
||||
namespace TINK.Droid.Model.Device
|
||||
{
|
||||
public class DroidCipher : ICipher
|
||||
{
|
||||
/// <summary> Encrypt data.</summary>
|
||||
/// <param name="key">Key to encrypt data.</param>
|
||||
/// <param name="clear">Data to entrycpt.</param>
|
||||
/// <returns></returns>
|
||||
public byte[] Encrypt(byte[] key, byte[] clear)
|
||||
{
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key, 0, 24, "AES");
|
||||
Cipher cipher = Cipher.GetInstance("AES/ECB/NoPadding");
|
||||
cipher.Init(CipherMode.EncryptMode, skeySpec);
|
||||
return cipher.DoFinal(clear);
|
||||
}
|
||||
|
||||
/// <summary> Decrypt data. </summary>
|
||||
/// <param name="key">Key to decrypt data with.</param>
|
||||
/// <param name="encrypted">Encrpyted data to decrypt.</param>
|
||||
/// <returns>Decrypted data.</returns>
|
||||
public byte[] Decrypt(byte[] key, byte[] encrypted)
|
||||
{
|
||||
TestDecrypt();
|
||||
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key, 0, 24, "AES");
|
||||
Cipher cipher = Cipher.GetInstance("AES/ECB/NoPadding");
|
||||
cipher.Init(CipherMode.DecryptMode, skeySpec);
|
||||
return cipher.DoFinal(encrypted);
|
||||
}
|
||||
|
||||
public void TestDecrypt()
|
||||
{
|
||||
byte[] decyptedText;
|
||||
|
||||
var encryptedText = (new sbyte[] { 50, 51, -40, 64, 42, 82, 97, -24, 20, -39, -15, 126, 119, -110, 47, -18 }).Select(x => (byte)x).ToArray();
|
||||
|
||||
var key = (new sbyte[] { -6, 53, 29, -112, 7, -83, -41, -7, 30, 45, -13, -2, -108, -29, -90, 71, 15, -74, -76, 32, 0, 0, 0, 0 }).Select(x => (byte)x).ToArray();
|
||||
|
||||
var expecedResult = (new sbyte[] { 19, -66, 55, 18, -106, -92, 70, -40, 117, -87, -19, 124, 19, 54, -18, -82 }).Select(x => (byte)x).ToArray();
|
||||
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key, 0, 24, "AES");
|
||||
Cipher cipher = Cipher.GetInstance("AES/ECB/NoPadding");
|
||||
cipher.Init(CipherMode.DecryptMode, skeySpec);
|
||||
decyptedText = cipher.DoFinal(encryptedText);
|
||||
|
||||
if (!expecedResult.SequenceEqual(decyptedText))
|
||||
{
|
||||
throw new System.Exception("Decrypted text does not match expectation.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using TINK.Model.Device;
|
||||
using TINK.Droid.Model.Device;
|
||||
using Android.Content;
|
||||
using Xamarin.Forms;
|
||||
|
||||
[assembly: Dependency(typeof(ExternalBrowseService))]
|
||||
namespace TINK.Droid.Model.Device
|
||||
{
|
||||
public class ExternalBrowseService : IExternalBrowserService
|
||||
{
|
||||
/// <summary> Opens an external browser. </summary>
|
||||
/// <param name="p_strUrl">Url to open.</param>
|
||||
public void OpenUrl(string p_strUrl)
|
||||
{
|
||||
var uri = Android.Net.Uri.Parse(p_strUrl);
|
||||
var intent = new Intent(Intent.ActionView, uri);
|
||||
|
||||
intent.AddFlags(ActivityFlags.NewTask);
|
||||
|
||||
Android.App.Application.Context.StartActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
30
Meinkonrad/TINK.Android/Model/Device/Gps.cs
Normal file
30
Meinkonrad/TINK.Android/Model/Device/Gps.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.Locations;
|
||||
using Android.OS;
|
||||
using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using TINK.Model.Device;
|
||||
using Xamarin.Forms;
|
||||
|
||||
[assembly: Dependency(typeof(TINK.Droid.Model.Device.Gps))]
|
||||
namespace TINK.Droid.Model.Device
|
||||
{
|
||||
public class Gps : IGeolodationDependent
|
||||
{
|
||||
public bool IsGeolcationEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
LocationManager locationManager = (LocationManager)Android.App.Application.Context.GetSystemService(Context.LocationService);
|
||||
return locationManager.IsProviderEnabled(LocationManager.GpsProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
49
Meinkonrad/TINK.Android/Model/Device/SpecialFolder.cs
Normal file
49
Meinkonrad/TINK.Android/Model/Device/SpecialFolder.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using Serilog;
|
||||
using System;
|
||||
using TINK.Model.Device;
|
||||
using Xamarin.Forms;
|
||||
|
||||
[assembly: Dependency(typeof(TINK.Droid.Model.Device.SpecialFolder))]
|
||||
namespace TINK.Droid.Model.Device
|
||||
{
|
||||
public class SpecialFolder : ISpecialFolder
|
||||
{
|
||||
/// <summary> Get the folder name of external folder to write to. </summary>
|
||||
/// <returns> Name of the external folder. </returns>
|
||||
public string GetExternalFilesDir()
|
||||
{
|
||||
string baseFolderPath = string.Empty;
|
||||
try
|
||||
{
|
||||
var context = Android.App.Application.Context;
|
||||
Java.IO.File[] dirs = context.GetExternalFilesDirs(null);
|
||||
|
||||
foreach (Java.IO.File folder in dirs)
|
||||
{
|
||||
bool IsRemovable = Android.OS.Environment.InvokeIsExternalStorageRemovable(folder);
|
||||
bool IsEmulated = Android.OS.Environment.InvokeIsExternalStorageEmulated(folder);
|
||||
|
||||
if (IsRemovable
|
||||
&& !IsEmulated)
|
||||
{
|
||||
baseFolderPath = folder.Path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception l_oException)
|
||||
{
|
||||
Log.Error("Getting external files directory failed. {@l_oException}", l_oException);
|
||||
}
|
||||
|
||||
return baseFolderPath;
|
||||
}
|
||||
|
||||
/// <summary> Gets the folder name of the personal data folder dir on internal storage. </summary>
|
||||
/// <returns>Directory name.</returns>
|
||||
public string GetInternalPersonalDir()
|
||||
{
|
||||
return Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||
}
|
||||
}
|
||||
}
|
16
Meinkonrad/TINK.Android/Model/Device/WebView.cs
Normal file
16
Meinkonrad/TINK.Android/Model/Device/WebView.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using Android.Webkit;
|
||||
using TINK.Model.Device;
|
||||
|
||||
[assembly: Xamarin.Forms.Dependency(typeof(TINK.Droid.Model.Device.WebView))]
|
||||
namespace TINK.Droid.Model.Device
|
||||
{
|
||||
public class WebView : IWebView
|
||||
{
|
||||
/// <summary> Clears the cookie cache for all web views. </summary>
|
||||
public void ClearCookies()
|
||||
{
|
||||
var cookieManager = CookieManager.Instance;
|
||||
cookieManager.RemoveAllCookie();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue