From e528ac10a4d7ad50e57730c29b47756a8b4a51cf Mon Sep 17 00:00:00 2001 From: Alexey Skoryatin Date: Thu, 13 Feb 2014 13:44:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=20=D1=81=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D0=BC=D0=B5=D1=80=D0=BE=D0=BC=20=D0=B8=D1=81=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=80?= =?UTF-8?q?=D1=83=D0=B1=D0=BB=D1=8F=20=D0=BB=D0=B5=D0=B1=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=B2=D0=B0=20=D0=B2=20=D0=B0=D0=BD=D0=B4=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=B4=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rouble/Droid/MainActivity.cs | 23 ++++ Rouble/Droid/Properties/AndroidManifest.xml | 6 + Rouble/Droid/Properties/AssemblyInfo.cs | 23 ++++ Rouble/Droid/Resources/Resource.designer.cs | 115 ++++++++++++++++++++ Rouble/Droid/Resources/drawable/Icon.png | Bin 0 -> 2574 bytes Rouble/Droid/Resources/layout/Main.axml | 19 ++++ Rouble/Droid/Resources/values/Strings.xml | 5 + Rouble/Droid/Rouble.Droid.csproj | 77 +++++++++++++ Rouble/Droid/TextViewExt.cs | 54 +++++++++ Rouble/Rouble.sln | 16 +++ 10 files changed, 338 insertions(+) create mode 100644 Rouble/Droid/MainActivity.cs create mode 100644 Rouble/Droid/Properties/AndroidManifest.xml create mode 100644 Rouble/Droid/Properties/AssemblyInfo.cs create mode 100644 Rouble/Droid/Resources/Resource.designer.cs create mode 100644 Rouble/Droid/Resources/drawable/Icon.png create mode 100644 Rouble/Droid/Resources/layout/Main.axml create mode 100644 Rouble/Droid/Resources/values/Strings.xml create mode 100644 Rouble/Droid/Rouble.Droid.csproj create mode 100644 Rouble/Droid/TextViewExt.cs 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 0000000000000000000000000000000000000000..a07c69fa5a0f4da5d5efe96eea12a543154dbab6 GIT binary patch literal 2574 zcmV+p3i0)cP)Q`Og{P|8RRXpj5bgrSmEzSMfBn+{{vpNxw?;5UX;iv9sYxy_`IQHs$i<61a_iv^L>h8s-`D(`e@|IgS*Fj zNGM876Gf;3D8*1UX9a%v>yJKD*QkCwW2AirU(L{qNA)JghmGItc;(H<$!ABY&gBy1vJIEUj-b8%el*o|VkG)LqNx#TG>Jvj^jIte!!+RY z)T4j$7+PoF1AkRBf}R#^T=-q|PaK1$c<4UH)Hpq3$4WA|xtr!ZQLC=*vNE>O6E9kp+5X0eKB$6>C(lPwI@3#oY zhS_%x7e|j!$yG?ECXmh~EH~^OeuK}+sWoJse3Z3?ha3n`MM9KvA?uqpEnBg4Q46)7 zM$p%a$@l;+O}vfvx%XjH`}a{(-HHth9!JaUwV0*VqGR48^gWNYN<&~7x)y$e!X>e` zZ5!6KZoxbKuV9XUDI%#M1~IVh?pNSdeb~6@$y`v|yk=XK+fHxnDqnUK4&=QRNyIVf zYbDM*cI>~qIy*a7=z7uqkw@agd(<=y-Q7L!ty_23SGdXmahO<;N=wB+j;lNm%=OHC zy zU|>La6h%92y4IPufI$9>Xu!@y`TaNgtg&41@PwMwBdmSm7)xAWDLoqjZ==P2#*k7! z3o1)cVSI3KP_!?d8G^Lg0FtLXC~JYdxi|c%h~lXEixY=%VSFF@!*3&&9>(Rb|iK54Cx5;s~PY5iaV1het%w`dgQFBAJ;aFK zImQC}(|QaCFYUm1JVfzSc)ebv=)ObI)0jwJb``}Zj9J0n0Xgn*Zc(rFM9$xh_makZbm-at_v5^SW zM1y1SW@%+FuIy*WR)i3A2N_q;(YO`O!A|Ts^%z}9ZepCj3ytlw#x%N_fNrKKtPh`< z|1{UqF`4LxHaCQ79+E=uUXCOZ35jAMRz%R%0(P!0FMv=sk>Nr8%+OzY^c-M9@+fz=G`qa@v4sF5u-2289-#$**LWnyNNDwDf1( zkUiMnw|y$tn>pQP=Vn!#|17L^5AGrjtBkN$D@v)Z7LXc5EFhLB4<;7Wehh)CMqX|W zqsiZaO^benJ_hwa&V0ub$-_HUk**?g6fm9|!@kguU6*zhK)$qn-<3*kFrYPIaqR=V zUaUvk>@F_89b@tHs8R!*QKY;INJ<2_U+K6Ca3e9Gsl2{qY0%a7J?uICWgHuLfj+MB z=GkAN1&ifT#2u}B+2S#~$5jA(Qn^;H%CCmIae4AE-Dsng|Hl*Ov!z72k3ZnJs{pp| z+pW`DDueC#mEWOf=ucJ!dTL}hzOeiS-i?m2E;`EKz4<&Lu~NnW?peqVU^@<+T3KKu z{yrI%Qy-Z%HEvLUz}n^~m?7x`xuCtNR#L2En!T>dQtIKdS#V-Hzt3RtwTeYtmQ&dR z6qXZvac*oc@BUYEH%@Ylv_1&tSjkbzzU6*h1(3^C`;1z;g_SmOtclS?KWk2VYE zM*oS<=C483XckW?GN|1jfh3Ro(h + + + + \ 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