diff options
author | E.Z. Hart <hartez@gmail.com> | 2016-03-24 10:33:32 -0600 |
---|---|---|
committer | E.Z. Hart <hartez@gmail.com> | 2016-03-24 10:48:21 -0600 |
commit | 1dcf5fef35c1c09e64f3c9e9ce6a31d2d0c3cd4a (patch) | |
tree | 2d3ae2fe8ef99ccca22306ecf530053d32d3bab1 | |
parent | a9e90a88ed401a8605b9798d4566d09a7192e280 (diff) | |
download | xamarin-forms-1dcf5fef35c1c09e64f3c9e9ce6a31d2d0c3cd4a.tar.gz xamarin-forms-1dcf5fef35c1c09e64f3c9e9ce6a31d2d0c3cd4a.tar.bz2 xamarin-forms-1dcf5fef35c1c09e64f3c9e9ce6a31d2d0c3cd4a.zip |
Move initialization of configuration files (if needed) to a pre-build task
Remove unneeded init scripts
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Setup.ps1 | 22 | ||||
-rwxr-xr-x | Setup.sh | 26 | ||||
-rw-r--r-- | Xamarin.Forms.ControlGallery.Android/Activity1.cs | 2 | ||||
-rw-r--r-- | Xamarin.Forms.ControlGallery.Android/Properties/MapsKey.cs.blank | 6 | ||||
-rw-r--r-- | Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj | 6 | ||||
-rw-r--r-- | Xamarin.Forms.ControlGallery.WP8/App.xaml.cs | 6 | ||||
-rw-r--r-- | Xamarin.Forms.ControlGallery.Windows/App.xaml.cs | 2 | ||||
-rw-r--r-- | Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml.cs | 2 | ||||
-rw-r--r-- | Xamarin.Forms.ControlGallery.WindowsUniversal/App.xaml.cs | 2 | ||||
-rw-r--r-- | Xamarin.Forms.ControlGallery.iOS/Main.cs | 2 | ||||
-rw-r--r-- | Xamarin.Forms.Controls/App.cs | 34 | ||||
-rw-r--r-- | Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj | 10 | ||||
-rw-r--r-- | Xamarin.Forms.Controls/blank.config | 0 |
14 files changed, 52 insertions, 69 deletions
@@ -43,4 +43,5 @@ Xamarin.Forms.UITest.Validator/UITestCoverage/index.html Xamarin.Forms.ControlGallery.Windows/AppPackages/ Xamarin.Forms.ControlGallery.WindowsPhone/AppPackages/ Xamarin.Forms.Controls/secrets.txt +Xamarin.Forms.Controls/controlgallery.config Xamarin.Forms.ControlGallery.Android/Properties/MapsKey.cs
\ No newline at end of file diff --git a/Setup.ps1 b/Setup.ps1 deleted file mode 100644 index ebe70393..00000000 --- a/Setup.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -$createSecrets = Test-Path .\Xamarin.Forms.Controls\secrets.txt -$createMapKeys = Test-Path .\Xamarin.Forms.ControlGallery.Android\Properties\MapsKey.cs - -if(-not $createSecrets){ - Write-Host "Creating secrets.txt" - New-Item -ItemType File .\Xamarin.Forms.Controls\secrets.txt -} - -if(-not $createMapKeys){ - Write-Host "Creating MapKeys.cs" - - $content = @" -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using Android.App; - -[assembly: Android.App.MetaData("com.google.android.maps.v2.API_KEY", Value = "")] -"@ - - Set-Content .\Xamarin.Forms.ControlGallery.Android\Properties\MapsKey.cs $content -}
\ No newline at end of file diff --git a/Setup.sh b/Setup.sh deleted file mode 100755 index 0e0c10a4..00000000 --- a/Setup.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -secrets="./Xamarin.Forms.Controls/secrets.txt" -mapskey="./Xamarin.Forms.ControlGallery.Android/Properties/MapsKey.cs" - -if [ -f "$secrets" ] -then - echo "$secrets found." -else - echo "$secrets not found." - touch $secrets - echo "$secrets created." -fi - -if [ -f "$mapskey" ] -then - echo "$mapskey found." -else - echo "$mapskey not found." - touch $mapskey - echo "using System.Reflection;" >> $mapskey - echo "using System.Runtime.CompilerServices;" >> $mapskey - echo "using System.Runtime.InteropServices;" >> $mapskey - echo "using Android.App;" >> $mapskey - echo "[assembly: Android.App.MetaData(\"com.google.android.maps.v2.API_KEY\", Value = \"\")]" >> $mapskey - echo "$mapskey created." -fi
\ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.Android/Activity1.cs b/Xamarin.Forms.ControlGallery.Android/Activity1.cs index 9dbd4b63..4a96b800 100644 --- a/Xamarin.Forms.ControlGallery.Android/Activity1.cs +++ b/Xamarin.Forms.ControlGallery.Android/Activity1.cs @@ -312,7 +312,7 @@ namespace Xamarin.Forms.ControlGallery.Android base.OnCreate (bundle); if (!Debugger.IsAttached) - Insights.Initialize (App.Secrets["InsightsApiKey"], ApplicationContext); + Insights.Initialize (App.InsightsApiKey, ApplicationContext); Forms.Init (this, bundle); FormsMaps.Init (this, bundle); diff --git a/Xamarin.Forms.ControlGallery.Android/Properties/MapsKey.cs.blank b/Xamarin.Forms.ControlGallery.Android/Properties/MapsKey.cs.blank new file mode 100644 index 00000000..9cfe62ba --- /dev/null +++ b/Xamarin.Forms.ControlGallery.Android/Properties/MapsKey.cs.blank @@ -0,0 +1,6 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Android.App; + +[assembly: Android.App.MetaData("com.google.android.maps.v2.API_KEY", Value = "")] diff --git a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj index ff23e911..e5628d8b 100644 --- a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj +++ b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj @@ -257,4 +257,10 @@ </PropertyGroup> <Error Condition="!Exists('..\packages\Xamarin.Insights.1.11.4\build\MonoAndroid10\Xamarin.Insights.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Insights.1.11.4\build\MonoAndroid10\Xamarin.Insights.targets'))" /> </Target> + <Target Name="BeforeBuild"> + <CreateItem Include="Properties\MapsKey.cs.blank"> + <Output TaskParameter="Include" ItemName="MapsKey" /> + </CreateItem> + <Copy SourceFiles="@(MapsKey)" DestinationFiles="Properties\MapsKey.cs" Condition="!Exists('Properties\MapsKey.cs')" /> + </Target> </Project>
\ No newline at end of file diff --git a/Xamarin.Forms.ControlGallery.WP8/App.xaml.cs b/Xamarin.Forms.ControlGallery.WP8/App.xaml.cs index 6b43e3b7..513632c9 100644 --- a/Xamarin.Forms.ControlGallery.WP8/App.xaml.cs +++ b/Xamarin.Forms.ControlGallery.WP8/App.xaml.cs @@ -26,9 +26,9 @@ namespace Xamarin.Forms.ControlGallery.WP8 public App() { if (!Debugger.IsAttached) - Insights.Initialize (Controls.App.Secrets["InsightsApiKey"]); - - FormsMaps.Init (Controls.App.Secrets["WP8AppId"], Controls.App.Secrets["WP8AuthToken"]); + Insights.Initialize (Controls.App.InsightsApiKey); + + FormsMaps.Init (Controls.App.Config["WP8AppId"], Controls.App.Config["WP8AuthToken"]); // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; diff --git a/Xamarin.Forms.ControlGallery.Windows/App.xaml.cs b/Xamarin.Forms.ControlGallery.Windows/App.xaml.cs index a20e2ce0..6b7d20f7 100644 --- a/Xamarin.Forms.ControlGallery.Windows/App.xaml.cs +++ b/Xamarin.Forms.ControlGallery.Windows/App.xaml.cs @@ -37,7 +37,7 @@ namespace Xamarin.Forms.ControlGallery.Windows rootFrame.NavigationFailed += OnNavigationFailed; Forms.Init (e); - FormsMaps.Init (Controls.App.Secrets["Win8MapsAuthKey"]); + FormsMaps.Init (Controls.App.Config["Win8MapsAuthKey"]); // Place the frame in the current Window Window.Current.Content = rootFrame; diff --git a/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml.cs b/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml.cs index 1842bb86..db874ef2 100644 --- a/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml.cs +++ b/Xamarin.Forms.ControlGallery.WindowsPhone/App.xaml.cs @@ -65,7 +65,7 @@ namespace Xamarin.Forms.ControlGallery.WindowsPhone rootFrame.CacheSize = 1; Forms.Init (e); - FormsMaps.Init (Controls.App.Secrets["WinPhoneMapsAuthKey"]); + FormsMaps.Init (Controls.App.Config["WinPhoneMapsAuthKey"]); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { diff --git a/Xamarin.Forms.ControlGallery.WindowsUniversal/App.xaml.cs b/Xamarin.Forms.ControlGallery.WindowsUniversal/App.xaml.cs index ff21e8fc..288d008b 100644 --- a/Xamarin.Forms.ControlGallery.WindowsUniversal/App.xaml.cs +++ b/Xamarin.Forms.ControlGallery.WindowsUniversal/App.xaml.cs @@ -63,7 +63,7 @@ namespace Xamarin.Forms.ControlGallery.WindowsUniversal rootFrame.NavigationFailed += OnNavigationFailed; Forms.Init (e); - FormsMaps.Init (Controls.App.Secrets["UWPMapsAuthKey"]); + FormsMaps.Init (Controls.App.Config["UWPMapsAuthKey"]); // Place the frame in the current Window Window.Current.Content = rootFrame; diff --git a/Xamarin.Forms.ControlGallery.iOS/Main.cs b/Xamarin.Forms.ControlGallery.iOS/Main.cs index cf4bfa12..921c475e 100644 --- a/Xamarin.Forms.ControlGallery.iOS/Main.cs +++ b/Xamarin.Forms.ControlGallery.iOS/Main.cs @@ -22,7 +22,7 @@ namespace Xamarin.Forms.ControlGallery.iOS // you can specify it here. #if __UNIFIED__ if (!Debugger.IsAttached) - Insights.Initialize (App.Secrets["InsightsApiKey"]); + Insights.Initialize (App.InsightsApiKey); #endif UIApplication.Main (args, null, "AppDelegate"); } diff --git a/Xamarin.Forms.Controls/App.cs b/Xamarin.Forms.Controls/App.cs index 53424cce..975faf8c 100644 --- a/Xamarin.Forms.Controls/App.cs +++ b/Xamarin.Forms.Controls/App.cs @@ -72,7 +72,21 @@ namespace Xamarin.Forms.Controls public class App : Application { - public string InsightsApiKey = Secrets["InsightsApiKey"]; + static string s_insightsKey; + public static string InsightsApiKey + { + get + { + if (s_insightsKey == null) + { + var key = Config["InsightsApiKey"]; + s_insightsKey = string.IsNullOrEmpty(key) ? Insights.DebugModeKey : key; + } + + return s_insightsKey; + } + } + public const string AppName = "XamarinFormsControls"; public const string AppVersion = "1.4.3"; public static int IOSVersion = -1; @@ -153,11 +167,11 @@ namespace Xamarin.Forms.Controls return text; } - public static void InitSecrets () + public static void LoadConfig () { - secrets = new Dictionary<string, string> (); + s_config = new Dictionary<string, string> (); - string keyData = LoadResource ("secrets.txt").Result; + string keyData = LoadResource ("controlgallery.config").Result; string[] entries = keyData.Split ("\n\r".ToCharArray (), StringSplitOptions.RemoveEmptyEntries); foreach (string entry in entries) { string[] parts = entry.Split (':'); @@ -165,21 +179,21 @@ namespace Xamarin.Forms.Controls continue; } - secrets.Add (parts[0].Trim (), parts[1].Trim ()); + s_config.Add (parts[0].Trim (), parts[1].Trim ()); } } - private static Dictionary<string, string> secrets; + static Dictionary<string, string> s_config; - public static Dictionary<string, string> Secrets + public static Dictionary<string, string> Config { get { - if (secrets == null) { - InitSecrets (); + if (s_config == null) { + LoadConfig (); } - return secrets; + return s_config; } } } diff --git a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj index c56b1436..fbccef9e 100644 --- a/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj +++ b/Xamarin.Forms.Controls/Xamarin.Forms.Controls.csproj @@ -266,6 +266,7 @@ </ItemGroup> <ItemGroup> <None Include="app.config" /> + <EmbeddedResource Include="controlgallery.config" /> <None Include="packages.config" /> </ItemGroup> <ItemGroup> @@ -278,8 +279,11 @@ <SubType>Designer</SubType> </EmbeddedResource> </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="secrets.txt" /> - </ItemGroup> <Import Project="..\packages\Xamarin.Insights.1.11.4\build\portable-win+net45+wp80+windows8+wpa+MonoAndroid10+MonoTouch10\Xamarin.Insights.targets" Condition="Exists('..\packages\Xamarin.Insights.1.11.4\build\portable-win+net45+wp80+windows8+wpa+MonoAndroid10+MonoTouch10\Xamarin.Insights.targets')" /> + <Target Name="BeforeBuild"> + <CreateItem Include="blank.config"> + <Output TaskParameter="Include" ItemName="ConfigFile" /> + </CreateItem> + <Copy SourceFiles="@(ConfigFile)" DestinationFiles="controlgallery.config" Condition="!Exists('controlgallery.config')" /> + </Target> </Project>
\ No newline at end of file diff --git a/Xamarin.Forms.Controls/blank.config b/Xamarin.Forms.Controls/blank.config new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Xamarin.Forms.Controls/blank.config |