and android
This commit is contained in:
parent
e012110b00
commit
6254985c9b
@ -37,7 +37,8 @@
|
||||
<EnableLLVM>false</EnableLLVM>
|
||||
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
|
||||
<BundleAssemblies>false</BundleAssemblies>
|
||||
<AndroidSupportedAbis>x86_64</AndroidSupportedAbis>
|
||||
<AndroidSupportedAbis>x86_64;x86</AndroidSupportedAbis>
|
||||
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
@ -1,9 +1,10 @@
|
||||
namespace Billing.UI;
|
||||
|
||||
public static partial class Definition
|
||||
namespace Billing.UI
|
||||
{
|
||||
public static partial string GetCascadiaRegularFontFamily() => "CascadiaCode-Regular.ttf#CascadiaCode-Regular";
|
||||
public static partial string GetCascadiaBoldFontFamily() => "CascadiaCode-Bold.ttf#CascadiaCode-Bold";
|
||||
public static partial string GetRobotoCondensedRegularFontFamily() => "RobotoCondensed-Regular.ttf#RobotoCondensed-Regular";
|
||||
public static partial string GetRobotoCondensedBoldFontFamily() => "RobotoCondensed-Bold.ttf#RobotoCondensed-Bold";
|
||||
}
|
||||
public static partial class Definition
|
||||
{
|
||||
public static partial string GetCascadiaRegularFontFamily() => "CascadiaCode-Regular.ttf#CascadiaCode-Regular";
|
||||
public static partial string GetCascadiaBoldFontFamily() => "CascadiaCode-Bold.ttf#CascadiaCode-Bold";
|
||||
public static partial string GetRobotoCondensedRegularFontFamily() => "RobotoCondensed-Regular.ttf#RobotoCondensed-Regular";
|
||||
public static partial string GetRobotoCondensedBoldFontFamily() => "RobotoCondensed-Bold.ttf#RobotoCondensed-Bold";
|
||||
}
|
||||
}
|
@ -8,26 +8,27 @@ using Xamarin.Forms.Platform.Android;
|
||||
|
||||
[assembly: ResolutionGroupName("Org.Tsanie")]
|
||||
[assembly: ExportEffect(typeof(ShadowEffectPlatform), nameof(ShadowEffect))]
|
||||
namespace Billing.Droid.Effects;
|
||||
|
||||
public class ShadowEffectPlatform : PlatformEffect
|
||||
namespace Billing.Droid.Effects
|
||||
{
|
||||
protected override void OnAttached()
|
||||
public class ShadowEffectPlatform : PlatformEffect
|
||||
{
|
||||
try
|
||||
protected override void OnAttached()
|
||||
{
|
||||
var effect = (ShadowEffect)Element.Effects.FirstOrDefault(e => e is ShadowEffect);
|
||||
var paint = new Paint(PaintFlags.AntiAlias);
|
||||
paint.SetShadowLayer(effect.Radius, (float)effect.Offect.Width, (float)effect.Offect.Height, effect.Color.ToAndroid());
|
||||
Control.SetLayerPaint(paint);
|
||||
try
|
||||
{
|
||||
var effect = (ShadowEffect)Element.Effects.FirstOrDefault(e => e is ShadowEffect);
|
||||
var paint = new Paint(PaintFlags.AntiAlias);
|
||||
paint.SetShadowLayer(effect.Radius, (float)effect.Offect.Width, (float)effect.Offect.Height, effect.Color.ToAndroid());
|
||||
Control.SetLayerPaint(paint);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Helper.Error("shadow.effect.attached", $"Cannot set property on attached control, error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Helper.Error("shadow.effect.attached", $"Cannot set property on attached control, error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDetached()
|
||||
{
|
||||
protected override void OnDetached()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,29 +3,30 @@ using Android.Content.PM;
|
||||
using Android.Runtime;
|
||||
using Android.OS;
|
||||
|
||||
namespace Billing.Droid;
|
||||
|
||||
[Activity(
|
||||
Label = "Billing",
|
||||
Icon = "@mipmap/icon",
|
||||
RoundIcon = "@mipmap/icon_round",
|
||||
Theme = "@style/MainTheme",
|
||||
MainLauncher = true,
|
||||
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
|
||||
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
||||
namespace Billing.Droid
|
||||
{
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
[Activity(
|
||||
Label = "Billing",
|
||||
Icon = "@mipmap/icon",
|
||||
RoundIcon = "@mipmap/icon_round",
|
||||
Theme = "@style/MainTheme",
|
||||
MainLauncher = true,
|
||||
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)]
|
||||
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
||||
Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||
LoadApplication(new App());
|
||||
}
|
||||
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
|
||||
{
|
||||
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
|
||||
Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||
LoadApplication(new App());
|
||||
}
|
||||
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
|
||||
{
|
||||
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,65 +2,66 @@
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
|
||||
namespace Billing.Languages;
|
||||
|
||||
public partial class PlatformCulture
|
||||
namespace Billing.Languages
|
||||
{
|
||||
public partial string GetNamespace()
|
||||
public partial class PlatformCulture
|
||||
{
|
||||
return typeof(MainActivity).Namespace;
|
||||
}
|
||||
|
||||
public partial void Init()
|
||||
{
|
||||
var locale = Java.Util.Locale.Default;
|
||||
string lang = AndroidToDotnetLanguage($"{locale.Language}-{locale.Country}");
|
||||
|
||||
CultureInfo ci;
|
||||
Init(lang);
|
||||
try
|
||||
public partial string GetNamespace()
|
||||
{
|
||||
ci = new CultureInfo(Language);
|
||||
return typeof(MainActivity).Namespace;
|
||||
}
|
||||
catch (CultureNotFoundException e)
|
||||
|
||||
public partial void Init()
|
||||
{
|
||||
var locale = Java.Util.Locale.Default;
|
||||
string lang = AndroidToDotnetLanguage($"{locale.Language}-{locale.Country}");
|
||||
|
||||
CultureInfo ci;
|
||||
Init(lang);
|
||||
try
|
||||
{
|
||||
var fallback = ToDotnetFallbackLanguage();
|
||||
Helper.Debug($"{lang} failed, trying {fallback} ({e.Message})");
|
||||
ci = new CultureInfo(fallback);
|
||||
ci = new CultureInfo(Language);
|
||||
}
|
||||
catch (CultureNotFoundException e1)
|
||||
catch (CultureNotFoundException e)
|
||||
{
|
||||
Helper.Error("culture.get", $"{lang} couldn't be set, using 'zh-CN' ({e1.Message})");
|
||||
ci = new CultureInfo("zh-CN");
|
||||
try
|
||||
{
|
||||
var fallback = ToDotnetFallbackLanguage();
|
||||
Helper.Debug($"{lang} failed, trying {fallback} ({e.Message})");
|
||||
ci = new CultureInfo(fallback);
|
||||
}
|
||||
catch (CultureNotFoundException e1)
|
||||
{
|
||||
Helper.Error("culture.get", $"{lang} couldn't be set, using 'zh-CN' ({e1.Message})");
|
||||
ci = new CultureInfo("zh-CN");
|
||||
}
|
||||
}
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = ci;
|
||||
Thread.CurrentThread.CurrentUICulture = ci;
|
||||
|
||||
Helper.Debug($"CurrentCulture set: {ci.Name}");
|
||||
}
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = ci;
|
||||
Thread.CurrentThread.CurrentUICulture = ci;
|
||||
|
||||
Helper.Debug($"CurrentCulture set: {ci.Name}");
|
||||
}
|
||||
|
||||
private static string AndroidToDotnetLanguage(string androidLanguage)
|
||||
{
|
||||
//certain languages need to be converted to CultureInfo equivalent
|
||||
string netLanguage = androidLanguage switch
|
||||
private static string AndroidToDotnetLanguage(string androidLanguage)
|
||||
{
|
||||
// Not supported .NET culture
|
||||
"ms-BN" or "ms-MY" or "ms-SG" => "ms", // closest supported
|
||||
// "Indonesian (Indonesia)" has different code in .NET
|
||||
"in-ID" => "id-ID", // correct code for .NET
|
||||
// "Schwiizertüütsch (Swiss German)" not supported .NET culture
|
||||
"gsw-CH" => "de-CH", // closest supported
|
||||
//certain languages need to be converted to CultureInfo equivalent
|
||||
string netLanguage = androidLanguage switch
|
||||
{
|
||||
// Not supported .NET culture
|
||||
"ms-BN" or "ms-MY" or "ms-SG" => "ms", // closest supported
|
||||
// "Indonesian (Indonesia)" has different code in .NET
|
||||
"in-ID" => "id-ID", // correct code for .NET
|
||||
// "Schwiizertüütsch (Swiss German)" not supported .NET culture
|
||||
"gsw-CH" => "de-CH", // closest supported
|
||||
|
||||
// add more application-specific cases here (if required)
|
||||
// ONLY use cultures that have been tested and known to work
|
||||
// add more application-specific cases here (if required)
|
||||
// ONLY use cultures that have been tested and known to work
|
||||
|
||||
_ => androidLanguage,
|
||||
};
|
||||
Helper.Debug($"Android Language: {androidLanguage}, .NET Language/Locale: {netLanguage}");
|
||||
return netLanguage;
|
||||
_ => androidLanguage,
|
||||
};
|
||||
Helper.Debug($"Android Language: {androidLanguage}, .NET Language/Locale: {netLanguage}");
|
||||
return netLanguage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -5,29 +5,30 @@ using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
|
||||
[assembly: ExportRenderer(typeof(LongPressButton), typeof(LongPressButtonRenderer))]
|
||||
namespace Billing.Droid.Renderers;
|
||||
|
||||
public class LongPressButtonRenderer : ButtonRenderer
|
||||
namespace Billing.Droid.Renderers
|
||||
{
|
||||
public LongPressButtonRenderer(Context context) : base(context)
|
||||
public class LongPressButtonRenderer : ButtonRenderer
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
if (Element is LongPressButton && Control != null)
|
||||
public LongPressButtonRenderer(Context context) : base(context)
|
||||
{
|
||||
Control.LongClick += Control_LongClick;
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
if (Element is LongPressButton && Control != null)
|
||||
{
|
||||
Control.LongClick += Control_LongClick;
|
||||
}
|
||||
}
|
||||
|
||||
private void Control_LongClick(object sender, LongClickEventArgs e)
|
||||
{
|
||||
if (Element is LongPressButton button)
|
||||
{
|
||||
button.TriggerLongPress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Control_LongClick(object sender, LongClickEventArgs e)
|
||||
{
|
||||
if (Element is LongPressButton button)
|
||||
{
|
||||
button.TriggerLongPress();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,22 +6,23 @@ using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
|
||||
[assembly: ExportRenderer(typeof(OptionEntry), typeof(OptionEntryRenderer))]
|
||||
namespace Billing.Droid.Renderers;
|
||||
|
||||
public class OptionEntryRenderer : EntryRenderer
|
||||
namespace Billing.Droid.Renderers
|
||||
{
|
||||
public OptionEntryRenderer(Context context) : base(context)
|
||||
public class OptionEntryRenderer : EntryRenderer
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
if (e.NewElement != null)
|
||||
public OptionEntryRenderer(Context context) : base(context)
|
||||
{
|
||||
var drawable = new ColorDrawable(e.NewElement.BackgroundColor.ToAndroid());
|
||||
Control.SetBackground(drawable);
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
if (e.NewElement != null)
|
||||
{
|
||||
var drawable = new ColorDrawable(e.NewElement.BackgroundColor.ToAndroid());
|
||||
Control.SetBackground(drawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,31 +6,32 @@ using Xamarin.Forms;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
|
||||
[assembly: ExportRenderer(typeof(TintImage), typeof(TintImageRenderer))]
|
||||
namespace Billing.Droid.Renderers;
|
||||
|
||||
public class TintImageRenderer : ImageRenderer
|
||||
namespace Billing.Droid.Renderers
|
||||
{
|
||||
public TintImageRenderer(Context context) : base(context)
|
||||
public class TintImageRenderer : ImageRenderer
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnElementPropertyChanged(sender, e);
|
||||
|
||||
if (e.PropertyName == nameof(TintImage.PrimaryColor) && Control?.Drawable != null && Element is TintImage image)
|
||||
public TintImageRenderer(Context context) : base(context)
|
||||
{
|
||||
Control.Drawable.SetTint(image.PrimaryColor?.ToAndroid() ?? 0);
|
||||
}
|
||||
|
||||
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnElementPropertyChanged(sender, e);
|
||||
|
||||
if (e.PropertyName == nameof(TintImage.PrimaryColor) && Control?.Drawable != null && Element is TintImage image)
|
||||
{
|
||||
Control.Drawable.SetTint(image.PrimaryColor?.ToAndroid() ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
if (Control?.Drawable != null && Element is TintImage image)
|
||||
{
|
||||
Control.Drawable.SetTint(image.PrimaryColor?.ToAndroid() ?? 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
|
||||
if (Control?.Drawable != null && Element is TintImage image)
|
||||
{
|
||||
Control.Drawable.SetTint(image.PrimaryColor?.ToAndroid() ?? 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ namespace Billing.Droid
|
||||
{
|
||||
|
||||
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.2.0.155")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
|
||||
public partial class Resource
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user