Skip to content

Commit

Permalink
Merge pull request #588 from Microsoft/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
guperrot authored Jan 29, 2018
2 parents 8e378aa + 33951b5 commit d87a62e
Show file tree
Hide file tree
Showing 111 changed files with 1,200 additions and 899 deletions.
2 changes: 1 addition & 1 deletion Apps/Contoso.Android.Puppet/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.microsoft.appcenter.xamarin.puppet" android:versionCode="45" android:versionName="1.2.0-SNAPSHOT" android:installLocation="auto">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.microsoft.appcenter.xamarin.puppet" android:versionCode="46" android:versionName="1.3.0-SNAPSHOT" android:installLocation="auto">
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
<application android:label="SXPuppet" android:icon="@drawable/Icon" android:theme="@style/PuppetTheme">
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
Expand Down
4 changes: 2 additions & 2 deletions Apps/Contoso.Android.Puppet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0-SNAPSHOT")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0-SNAPSHOT")]
11 changes: 5 additions & 6 deletions Apps/Contoso.Forms.Demo/Contoso.Forms.Demo.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System;
using System.Diagnostics;
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Push;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Globalization;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Push;

namespace Contoso.Forms.Demo.UWP
{
Expand All @@ -28,7 +26,8 @@ public App()
// Note that the country code provided does not reflect the physical device location, but rather the
// country that corresponds to the culture it uses. You may wish to retrieve the country code using
// a different means, such as device location.
AppCenter.SetCountryCode(RegionInfo.CurrentRegion.TwoLetterISORegionName);
var geographicRegion = new GeographicRegion();
AppCenter.SetCountryCode(geographicRegion.CodeTwoLetter);
InitializeComponent();
Suspending += OnSuspending;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="46" android:versionName="1.2.0-SNAPSHOT" package="com.microsoft.appcenter.xamarin.forms.puppet">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="47" android:versionName="1.3.0-SNAPSHOT" package="com.microsoft.appcenter.xamarin.forms.puppet">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="26" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<permission android:name="${applicationId}.permission.C2D_MESSAGE" android:protectionLevel="signature" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0-SNAPSHOT")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0-SNAPSHOT")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using System.Diagnostics;
using System.Globalization;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Push;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Globalization;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using Microsoft.AppCenter.Push;

namespace Contoso.Forms.Puppet.UWP
{
Expand All @@ -26,7 +26,9 @@ public App()
// Note that the country code provided does not reflect the physical device location, but rather the
// country that corresponds to the culture it uses. You may wish to retrieve the country code using
// a different means, such as device location.
AppCenter.SetCountryCode(RegionInfo.CurrentRegion.TwoLetterISORegionName);
var geographicRegion = new GeographicRegion();
AppCenter.SetCountryCode(geographicRegion.CodeTwoLetter);
EventFilterHolder.Implementation = new EventFilterWrapper();
InitializeComponent();
Suspending += OnSuspending;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="EventFilterWrapper.cs" />
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="EventFilter.cs" />
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
Expand Down
128 changes: 128 additions & 0 deletions Apps/Contoso.Forms.Puppet/Contoso.Forms.Puppet.UWP/EventFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics.Ingestion.Models;
using Microsoft.AppCenter.Channel;
using System;
using System.Threading.Tasks;

namespace Contoso.Forms.Puppet.UWP
{
public class EventFilter : AppCenterService
{
#region static

private static readonly object EventFilterLock = new object();

private static EventFilter _instanceField;

public static EventFilter Instance
{
get
{
lock (EventFilterLock)
{
return _instanceField ?? (_instanceField = new EventFilter());
}
}
set
{
lock (EventFilterLock)
{
_instanceField = value; //for testing
}
}
}

/// <summary>
/// Check whether the EventFilter service is enabled or not.
/// </summary>
/// <returns>A task with result being true if enabled, false if disabled.</returns>
public static Task<bool> IsEnabledAsync()
{
lock (EventFilterLock)
{
return Task.FromResult(Instance.InstanceEnabled);
}
}

/// <summary>
/// Enable or disable the EventFilter service.
/// </summary>
/// <returns>A task to monitor the operation.</returns>
public static Task SetEnabledAsync(bool enabled)
{
lock (EventFilterLock)
{
Instance.InstanceEnabled = enabled;
return Task.FromResult(default(object));
}
}

#endregion

#region instance

public override bool InstanceEnabled
{
get
{
return base.InstanceEnabled;
}

set
{
lock (_serviceLock)
{
var prevValue = InstanceEnabled;
base.InstanceEnabled = value;
if (value != prevValue)
{
ApplyEnabledState(value);
}
}
}
}

protected override string ChannelName => "event_filter";

public override string ServiceName => "EventFilter";

public Type BindingType { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

public override void OnChannelGroupReady(IChannelGroup channelGroup, string appSecret)
{
lock (_serviceLock)
{
base.OnChannelGroupReady(channelGroup, appSecret);
ApplyEnabledState(InstanceEnabled);
}
}

private void ApplyEnabledState(bool enabled)
{
lock (_serviceLock)
{
if (ChannelGroup != null)
{
if (enabled)
{
ChannelGroup.FilteringLog += FilterLog;
}
else
{
ChannelGroup.FilteringLog -= FilterLog;
}
}
}
}

private void FilterLog(object sender, FilteringLogEventArgs e)
{
if (e.Log is EventLog)
{
e.FilterRequested = true;
}
}

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Threading.Tasks;

namespace Contoso.Forms.Puppet.UWP
{
internal class EventFilterWrapper : EventFilterHolder.IImplementation
{
public Type BindingType => typeof(EventFilter);

public Task<bool> IsEnabledAsync() => EventFilter.IsEnabledAsync();

public Task SetEnabledAsync(bool enabled) => EventFilter.SetEnabledAsync(enabled);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="10805zumoTestUser.AppCenter-Contoso.Forms.Puppet.U" Publisher="CN=B2D1C358-6AF8-4416-BF73-129CC1F3C152" Version="1.2.0.0" />
<Identity Name="10805zumoTestUser.AppCenter-Contoso.Forms.Puppet.U" Publisher="CN=B2D1C358-6AF8-4416-BF73-129CC1F3C152" Version="1.3.0.0" />
<mp:PhoneIdentity PhoneProductId="55497ed8-b2ac-4485-ba79-e2b65bb720ed" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>AppCenter-Contoso.Forms.Puppet.UWP</DisplayName>
Expand All @@ -24,5 +24,6 @@
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer" />
</Capabilities>
</Package>
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: ComVisible(false)]
4 changes: 2 additions & 2 deletions Apps/Contoso.Forms.Puppet/Contoso.Forms.Puppet.iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<key>CFBundleIdentifier</key>
<string>com.microsoft.appcenter.xamarin.forms.puppet</string>
<key>CFBundleShortVersionString</key>
<string>1.2.0</string>
<string>1.3.0</string>
<key>CFBundleVersion</key>
<string>1.2.0</string>
<string>1.3.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
Expand Down
18 changes: 7 additions & 11 deletions Apps/Contoso.Forms.Puppet/Contoso.Forms.Puppet/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AppCenter;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
using Microsoft.AppCenter.Distribute;
using Microsoft.AppCenter.Push;
using Microsoft.AppCenter.Rum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace Contoso.Forms.Puppet
Expand Down Expand Up @@ -53,10 +51,8 @@ protected override void OnStart()
AppCenterLog.Assert(LogTag, "AppCenter.Configured=" + AppCenter.Configured);
AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es");
Distribute.SetInstallUrl("http://install.appcenter-int.trafficmanager.net");
Distribute.SetApiUrl("https://appcenter-int.trafficmanager.net/api/v0.1");
RealUserMeasurements.SetRumKey("b1919553367d44d8b0ae72594c74e0ff");
AppCenter.Start($"uwp={UwpKey};android={AndroidKey};ios={IosKey}",
typeof(Analytics), typeof(Crashes), typeof(Distribute), typeof(Push), typeof(RealUserMeasurements));
Distribute.SetApiUrl("https://appcenter-int.trafficmanager.net/api/v0.1");
AppCenter.Start($"uwp={UwpKey};android={AndroidKey};ios={IosKey}", typeof(Analytics), typeof(Crashes), typeof(Distribute), typeof(Push));
AppCenter.IsEnabledAsync().ContinueWith(enabled =>
{
AppCenterLog.Info(LogTag, "AppCenter.Enabled=" + enabled.Result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="EventFilterHolder.cs" />
<Compile Include="IFilePicker.cs" />
<Compile Include="MainPuppetPage.cs">
<DependentUpon>MainPuppetPage.xaml</DependentUpon>
Expand Down Expand Up @@ -107,6 +108,7 @@
<Compile Include="Views\TextAttachmentView.xaml.cs">
<DependentUpon>TextAttachmentView.xaml</DependentUpon>
</Compile>
<Compile Include="Property.cs" />
</ItemGroup>
<ItemGroup>
<None Include="project.json" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Threading.Tasks;

namespace Contoso.Forms.Puppet
{
public static class EventFilterHolder
{
public interface IImplementation
{
Type BindingType { get; }

Task<bool> IsEnabledAsync();

Task SetEnabledAsync(bool enabled);
}

public static IImplementation Implementation { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@

namespace Contoso.Forms.Puppet
{
public class Property
{
public string Name { get; private set; }
public string Value { get; private set; }

public Property(string propertyName, string propertyValue)
{
Name = propertyName;
Value = propertyValue;
}
}

[Android.Runtime.Preserve(AllMembers = true)]
public partial class AnalyticsContentPage : ContentPage
{
Expand Down
Loading

0 comments on commit d87a62e

Please sign in to comment.