diff --git a/Rouble/Droid/MainActivity.cs b/Rouble/Droid/MainActivity.cs new file mode 100644 index 0000000..8afde42 --- /dev/null +++ b/Rouble/Droid/MainActivity.cs @@ -0,0 +1,23 @@ +using System; +using Android.App; +using Android.Content; +using Android.Runtime; +using Android.Views; +using Android.Widget; +using Android.OS; + +namespace Rouble +{ + [Activity(Label = "Rouble Demo", MainLauncher = true)] + public class MainActivity : Activity + { + protected override void OnCreate(Bundle bundle) + { + base.OnCreate(bundle); + SetContentView(Resource.Layout.Main); + + FindViewById(Resource.Id.textView1).SetTextWithRouble("Обычная цена: 100.50 ", RoubleType.Regular); + FindViewById(Resource.Id.textView2).SetTextWithRouble("Жирная цена: 10 000 ", RoubleType.Bold); + } + } +} diff --git a/Rouble/Droid/Properties/AndroidManifest.xml b/Rouble/Droid/Properties/AndroidManifest.xml new file mode 100644 index 0000000..3e552e5 --- /dev/null +++ b/Rouble/Droid/Properties/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Rouble/Droid/Properties/AssemblyInfo.cs b/Rouble/Droid/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e2d6df5 --- /dev/null +++ b/Rouble/Droid/Properties/AssemblyInfo.cs @@ -0,0 +1,23 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using Android.App; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. +[assembly: AssemblyTitle("Droid")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Touch Instinct")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("Touch Instinct")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. +[assembly: AssemblyVersion("1.0.0")] +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/Rouble/Droid/Resources/Resource.designer.cs b/Rouble/Droid/Resources/Resource.designer.cs new file mode 100644 index 0000000..6ad83d4 --- /dev/null +++ b/Rouble/Droid/Resources/Resource.designer.cs @@ -0,0 +1,115 @@ +#pragma warning disable 1591 +// ------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Mono Runtime Version: 4.0.30319.17020 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ + +[assembly: Android.Runtime.ResourceDesignerAttribute("Rouble.Resource", IsApplication=true)] + +namespace Rouble +{ + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")] + public partial class Resource + { + + static Resource() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + public static void UpdateIdValues() + { + } + + public partial class Attribute + { + + static Attribute() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Attribute() + { + } + } + + public partial class Drawable + { + + // aapt resource value: 0x7f020000 + public const int Icon = 2130837504; + + static Drawable() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Drawable() + { + } + } + + public partial class Id + { + + // aapt resource value: 0x7f050000 + public const int textView1 = 2131034112; + + // aapt resource value: 0x7f050001 + public const int textView2 = 2131034113; + + static Id() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Id() + { + } + } + + public partial class Layout + { + + // aapt resource value: 0x7f030000 + public const int Main = 2130903040; + + static Layout() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Layout() + { + } + } + + public partial class String + { + + // aapt resource value: 0x7f040001 + public const int app_name = 2130968577; + + // aapt resource value: 0x7f040000 + public const int hello = 2130968576; + + static String() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private String() + { + } + } + } +} +#pragma warning restore 1591 diff --git a/Rouble/Droid/Resources/drawable/Icon.png b/Rouble/Droid/Resources/drawable/Icon.png new file mode 100644 index 0000000..a07c69f Binary files /dev/null and b/Rouble/Droid/Resources/drawable/Icon.png differ diff --git a/Rouble/Droid/Resources/layout/Main.axml b/Rouble/Droid/Resources/layout/Main.axml new file mode 100644 index 0000000..a5d13da --- /dev/null +++ b/Rouble/Droid/Resources/layout/Main.axml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/Rouble/Droid/Resources/values/Strings.xml b/Rouble/Droid/Resources/values/Strings.xml new file mode 100644 index 0000000..81861a8 --- /dev/null +++ b/Rouble/Droid/Resources/values/Strings.xml @@ -0,0 +1,5 @@ + + + Hello World, Click Me! + Droid + diff --git a/Rouble/Droid/Rouble.Droid.csproj b/Rouble/Droid/Rouble.Droid.csproj new file mode 100644 index 0000000..dd4ecac --- /dev/null +++ b/Rouble/Droid/Rouble.Droid.csproj @@ -0,0 +1,77 @@ + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {D119DAC0-88F6-45FB-84E6-9535831B5036} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Rouble + True + Resources\Resource.designer.cs + Resource + Resources + Assets + True + Droid + v4.3 + Properties\AndroidManifest.xml + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + None + false + + + full + true + bin\Release + prompt + 4 + false + false + + + + + + + + + + + + + Rouble.cs + + + RoubleType.cs + + + + + + + + + + + + + + + + + + Assets\Rouble.ttf + + + \ No newline at end of file diff --git a/Rouble/Droid/TextViewExt.cs b/Rouble/Droid/TextViewExt.cs new file mode 100644 index 0000000..08707ac --- /dev/null +++ b/Rouble/Droid/TextViewExt.cs @@ -0,0 +1,54 @@ +using System; +using Android.App; +using Android.Graphics; +using Android.Text.Style; +using Android.Widget; +using Android.Text; + +namespace Rouble +{ + public static class TextViewExt + { + private static CharacterStyle RoubleSpan { get; set; } + private static Typeface Rouble { get; set; } + + static TextViewExt() + { + Rouble = Typeface.CreateFromAsset(Application.Context.Assets, "Rouble.ttf"); + RoubleSpan = new CustomTypefaceSpan(Rouble); + } + + public static void SetTextWithRouble(this TextView label, string text, RoubleType roubleType) + { + var textFormatted = new SpannableString(text + Roubles.GetRoubleSymbFor(roubleType)); + textFormatted.SetSpan(RoubleSpan, textFormatted.Length() - 1, textFormatted.Length(), SpanTypes.ExclusiveExclusive); + label.TextFormatted = textFormatted; + } + + private class CustomTypefaceSpan: MetricAffectingSpan + { + private Typeface _typeface; + + public CustomTypefaceSpan(Typeface typeface) + { + _typeface = typeface; + } + + public override void UpdateDrawState(TextPaint drawState) + { + Apply(drawState); + } + + public override void UpdateMeasureState(TextPaint paint) + { + Apply(paint); + } + + private void Apply(Paint paint) + { + paint.SetTypeface(_typeface); + } + } + } +} + diff --git a/Rouble/Rouble.sln b/Rouble/Rouble.sln index fe74d49..403629f 100644 --- a/Rouble/Rouble.sln +++ b/Rouble/Rouble.sln @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rouble", "IOs\Rouble.csproj", "{0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rouble.Droid", "Droid\Rouble.Droid.csproj", "{D119DAC0-88F6-45FB-84E6-9535831B5036}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|iPhoneSimulator = Debug|iPhoneSimulator @@ -11,20 +13,34 @@ Global Release|iPhone = Release|iPhone Ad-Hoc|iPhone = Ad-Hoc|iPhone AppStore|iPhone = AppStore|iPhone + Debug|Android = Debug|Android + Release|Android = Release|Android EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.AppStore|iPhone.ActiveCfg = AppStore|iPhone {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.AppStore|iPhone.Build.0 = AppStore|iPhone + {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Debug|Android.ActiveCfg = Debug|iPhoneSimulator {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Debug|iPhone.ActiveCfg = Debug|iPhone {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Debug|iPhone.Build.0 = Debug|iPhone {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Release|Android.ActiveCfg = Debug|iPhoneSimulator {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Release|iPhone.ActiveCfg = Release|iPhone {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Release|iPhone.Build.0 = Release|iPhone {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator {0F5F2F1C-52CD-4DF6-84F7-223D5CCEAAE9}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator + {D119DAC0-88F6-45FB-84E6-9535831B5036}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU + {D119DAC0-88F6-45FB-84E6-9535831B5036}.AppStore|iPhone.ActiveCfg = Release|Any CPU + {D119DAC0-88F6-45FB-84E6-9535831B5036}.Debug|Android.ActiveCfg = Debug|Any CPU + {D119DAC0-88F6-45FB-84E6-9535831B5036}.Debug|Android.Build.0 = Debug|Any CPU + {D119DAC0-88F6-45FB-84E6-9535831B5036}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {D119DAC0-88F6-45FB-84E6-9535831B5036}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {D119DAC0-88F6-45FB-84E6-9535831B5036}.Release|Android.ActiveCfg = Debug|Any CPU + {D119DAC0-88F6-45FB-84E6-9535831B5036}.Release|Android.Build.0 = Debug|Any CPU + {D119DAC0-88F6-45FB-84E6-9535831B5036}.Release|iPhone.ActiveCfg = Release|Any CPU + {D119DAC0-88F6-45FB-84E6-9535831B5036}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = IOs\Rouble.csproj