Skip to content

Commit

Permalink
Windows Phone 8.1 sample app.
Browse files Browse the repository at this point in the history
  • Loading branch information
damieng committed Jan 13, 2015
1 parent 1eaaf47 commit 05db256
Show file tree
Hide file tree
Showing 34 changed files with 2,683 additions and 14 deletions.
37 changes: 35 additions & 2 deletions Source/CSharpAnalytics.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.22231.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpAnalytics.Windows8", "CSharpAnalytics\CSharpAnalytics.Windows8.csproj", "{31872BEA-1F8A-4FF0-B796-7768A0CDF256}"
EndProject
Expand Down Expand Up @@ -50,6 +50,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Windows Phone 8.1", "Window
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpAnalytics.WindowsPhone81", "CSharpAnalytics\CSharpAnalytics.WindowsPhone81.csproj", "{64EB7726-8FD2-4764-94E7-347977E1FEEE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpAnalytics.Sample.WindowsPhone81", "Samples\CSharpAnalytics.Sample.WindowsPhone81\CSharpAnalytics.Sample.WindowsPhone81.csproj", "{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -366,6 +368,36 @@ Global
{64EB7726-8FD2-4764-94E7-347977E1FEEE}.Release|x64.ActiveCfg = Release|Any CPU
{64EB7726-8FD2-4764-94E7-347977E1FEEE}.Release|x86.ActiveCfg = Release|x86
{64EB7726-8FD2-4764-94E7-347977E1FEEE}.Release|x86.Build.0 = Release|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|ARM.ActiveCfg = Debug|ARM
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|ARM.Build.0 = Debug|ARM
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|ARM.Deploy.0 = Debug|ARM
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|Mixed Platforms.Build.0 = Debug|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|Mixed Platforms.Deploy.0 = Debug|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|x64.ActiveCfg = Debug|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|x64.Build.0 = Debug|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|x64.Deploy.0 = Debug|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|x86.ActiveCfg = Debug|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|x86.Build.0 = Debug|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Debug|x86.Deploy.0 = Debug|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|Any CPU.Build.0 = Release|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|Any CPU.Deploy.0 = Release|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|ARM.ActiveCfg = Release|ARM
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|ARM.Build.0 = Release|ARM
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|ARM.Deploy.0 = Release|ARM
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|Mixed Platforms.ActiveCfg = Release|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|Mixed Platforms.Build.0 = Release|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|Mixed Platforms.Deploy.0 = Release|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|x64.ActiveCfg = Release|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|x64.Build.0 = Release|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|x64.Deploy.0 = Release|Any CPU
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|x86.ActiveCfg = Release|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|x86.Build.0 = Release|x86
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -386,5 +418,6 @@ Global
{1A9591AF-E5CD-42DE-80A4-B17B227DD45B} = {6145367D-3F9E-440B-AAE5-2FDF6864C111}
{A599EEEA-FC89-47FB-B8A9-DFD16FC3201D} = {3F625E98-D620-4CF3-BD83-5C97B7360496}
{64EB7726-8FD2-4764-94E7-347977E1FEEE} = {8A95E16A-D32C-407B-B130-D0D56482A6DF}
{522CC2A8-71BD-4DA6-B10D-E214B0873B4D} = {8A95E16A-D32C-407B-B130-D0D56482A6DF}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected override void UnhookEvents()
/// <returns>Task that completes when the requester is ready to use.</returns>
protected override Task SetupRequesterAsync()
{
var webRequester = new HttpWebRequester(ClientUserAgent + " " + WindowsPhoneSystemInfo.GetSystemUserAgent());
var webRequester = new HttpWebRequester(ClientUserAgent + " " + WindowsPhone81SystemInfo.GetSystemUserAgent());
Requester = webRequester.Request;

return Task.FromResult(true);
Expand Down Expand Up @@ -171,7 +171,7 @@ private async void ApplicationOnSuspending(object sender, SuspendingEventArgs su
}

/// <summary>
/// AutoMeasurement static wrapper to make it easier to use across a Windows Phone "Silverlight" application.
/// AutoMeasurement static wrapper to make it easier to use across a Windows Phone 8.1 application.
/// </summary>
public static class AutoMeasurement
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,16 @@ public MeasurementConfiguration(string accountId)
{
}
#endif

#if WINDOWS_PHONE_APP
/// <summary>
/// Create a new cofiguration for analytics.
/// </summary>
/// <param name="accountId">Google Analytics provided property id in the format UA-XXXX-Y.</param>
public MeasurementConfiguration(string accountId)
: this(accountId, SystemInfo.WindowsPhone81SystemInfo.ApplicationName, SystemInfo.WindowsPhone81SystemInfo.ApplicationVersion)
{
}
#endif
}
}
15 changes: 5 additions & 10 deletions Source/CSharpAnalytics/SystemInfo/WindowsPhone81SystemInfo.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
// Copyright (c) Attack Pattern LLC. All rights reserved.
// Copyright (c) Attack Pattern LLC. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

using System;
using System.Linq;
using System.Xml.Linq;
using Windows.Networking;
using Windows.Devices;
using Windows.Security.ExchangeActiveSyncProvisioning;
using Windows.UI.Xaml;
using Windows.ApplicationModel;
using Windows.Security.ExchangeActiveSyncProvisioning;

namespace CSharpAnalytics.SystemInfo
namespace CSharpAnalytics.SystemInfo
{
public static class WindowsPhoneSystemInfo
public static class WindowsPhone81SystemInfo
{
private static readonly string applicationName;
private static readonly string applicationVersion;

static WindowsPhoneSystemInfo()
static WindowsPhone81SystemInfo()
{
/// @todo not wild about the name here; not sure what the better option is
applicationName = Package.Current.Id.Name;
applicationVersion = String.Format("{0}.{1}", Package.Current.Id.Version.Major, Package.Current.Id.Version.Minor);
}
Expand Down
20 changes: 20 additions & 0 deletions Source/Samples/CSharpAnalytics.Sample.WindowsPhone81/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Application
x:Class="CSharpAnalytics.Sample.WindowsPhone81.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:CSharpAnalytics.Sample.WindowsPhone81">

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<ImageBrush x:Key="HubBackgroundImageBrush" ImageSource="Assets/HubBackground.png"/>
</ResourceDictionary>
<ResourceDictionary x:Key="HighContrast">
<ImageBrush x:Key="HubBackgroundImageBrush" ImageSource="{x:Null}"/>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

</ResourceDictionary>
</Application.Resources>
</Application>
137 changes: 137 additions & 0 deletions Source/Samples/CSharpAnalytics.Sample.WindowsPhone81/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
using CSharpAnalytics.Sample.WindowsPhone81.Common;
using System;
using System.Diagnostics;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Animation;
using Windows.UI.Xaml.Navigation;

namespace CSharpAnalytics.Sample.WindowsPhone81
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public sealed partial class App : Application
{
private TransitionCollection transitions;

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
this.Suspending += this.OnSuspending;
}

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used when the application is launched to open a specific file, to display
/// search results, and so forth.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif

Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active.
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page.
rootFrame = new Frame();

// Associate the frame with a SuspensionManager key.
SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

// TODO: Change this value to a cache size that is appropriate for your application.
rootFrame.CacheSize = 1;

// Set the default language
rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// Restore the saved session state only when appropriate.
try
{
await SuspensionManager.RestoreAsync();
}
catch (SuspensionManagerException)
{
// Something went wrong restoring state.
// Assume there is no state and continue.
}
}

// Place the frame in the current Window.
Window.Current.Content = rootFrame;
}

if (rootFrame.Content == null)
{
// Removes the turnstile navigation for startup.
if (rootFrame.ContentTransitions != null)
{
this.transitions = new TransitionCollection();
foreach (var c in rootFrame.ContentTransitions)
{
this.transitions.Add(c);
}
}

rootFrame.ContentTransitions = null;
rootFrame.Navigated += this.RootFrame_FirstNavigated;

// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter.
if (!rootFrame.Navigate(typeof(HubPage), e.Arguments))
{
throw new Exception("Failed to create initial page");
}

AutoMeasurement.DebugWriter = d => Debug.WriteLine(d);
AutoMeasurement.Start(new MeasurementConfiguration("UA-319000-8"), e);
AutoMeasurement.Attach(rootFrame);
}

// Ensure the current window is active.
Window.Current.Activate();
}

/// <summary>
/// Restores the content transitions after the app has launched.
/// </summary>
private void RootFrame_FirstNavigated(object sender, NavigationEventArgs e)
{
var rootFrame = sender as Frame;
rootFrame.ContentTransitions = this.transitions ?? new TransitionCollection() { new NavigationThemeTransition() };
rootFrame.Navigated -= this.RootFrame_FirstNavigated;
}

/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
await SuspensionManager.SaveAsync();
deferral.Complete();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 05db256

Please sign in to comment.