Updated to use latest Lumia SensorCore SDK 1.1 Preview

This commit is contained in:
Satyam Bandarapu 2015-03-03 16:37:08 +02:00
Родитель 09f1d327a7
Коммит f8c28c1966
25 изменённых файлов: 636 добавлений и 66 удалений

Просмотреть файл

@ -0,0 +1,55 @@
<Page
x:Class="ActivitiesExample.ActivateSensorCore.ActivateSensorCore"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ActivitiesExample.ActivateSensorCore"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="#FF1bA1E2">
<Grid x:Name="LayoutRoot">
<Grid.ChildrenTransitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</Grid.ChildrenTransitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,17,0,28" >
<TextBlock x:Uid="ApplicationSuite" Text="_SensorCore Example" Style="{ThemeResource TitleTextBlockStyle}" Typography.Capitals="SmallCaps" Foreground="White"/>
<TextBlock x:Uid="ApplicationName" Text="_activities" Style="{ThemeResource HeaderTextBlockStyle}" Foreground="White"/>
</StackPanel>
<Grid x:Name="MotionDataActivationBox" Grid.Row="1" Visibility="Collapsed" Background="#33000000" Margin="0,0,0,28" VerticalAlignment="Top">
<Grid Margin="10,10,10,10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Uid="/ActivateSensorCore/MotionDataActivationTitle" Grid.Row="0" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="36" />
<TextBlock x:Uid="/ActivateSensorCore/MotionDataActivationExplanation" Grid.Row="1" TextWrapping="Wrap" FontSize="20"/>
<Button x:Uid="/ActivateSensorCore/MotionDataActivationButton" Grid.Row="2" VerticalAlignment="Top" Click="MotionDataActivationButton_Click" HorizontalAlignment="Stretch"/>
<Button x:Uid="/ActivateSensorCore/LaterButton" Grid.Row="3" VerticalAlignment="Top" Click="LaterButton_Click" HorizontalAlignment="Stretch"/>
</Grid>
</Grid>
<Grid x:Name="LocationActivationBox" Grid.Row="1" Visibility="Collapsed" Background="#33000000" Margin="0,0,0,28" VerticalAlignment="Top">
<Grid Margin="10,10,10,10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock x:Uid="/ActivateSensorCore/LocationActivationTitle" Grid.Row="0" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="36" />
<TextBlock x:Uid="/ActivateSensorCore/LocationActivationExplanation" Grid.Row="1" TextWrapping="Wrap" FontSize="20"/>
<Button x:Uid="/ActivateSensorCore/LocationActivationButton" Grid.Row="2" VerticalAlignment="Top" HorizontalAlignment="Stretch" Click="LocationActivationButton_Click"/>
<Button x:Uid="/ActivateSensorCore/LaterButton" Grid.Row="3" Content="Activate" VerticalAlignment="Top" HorizontalAlignment="Stretch" Click="LaterButton_Click"/>
</Grid>
</Grid>
</Grid>
</Page>

Просмотреть файл

@ -0,0 +1,197 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using Lumia.Sense;
using System;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
/// <summary>
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556
/// </summary>
namespace ActivitiesExample.ActivateSensorCore
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ActivateSensorCore : Page
{
#region Private members
/// <summary>
/// SensorCore status
/// </summary>
private ActivateSensorCoreStatus _sensorCoreActivationStatus;
/// <summary>
/// Display/Hide Dialog for MotionData
/// </summary>
private bool _updatingDialog = false;
#endregion
/// <summary>
/// Constructor
/// </summary>
public ActivateSensorCore()
{
this.InitializeComponent();
var app = Application.Current as ActivitiesExample.App;
_sensorCoreActivationStatus = app.SensorCoreActivationStatus;
}
/// <summary>
/// Check if motion data is enabled
/// </summary>
async Task UpdateDialog()
{
if (_updatingDialog || (_sensorCoreActivationStatus.activationRequestResult != ActivationRequestResults.NotAvailableYet))
{
return;
}
_updatingDialog = true;
MotionDataActivationBox.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
LocationActivationBox.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
Exception failure = null;
try
{
// GetDefaultAsync will throw if MotionData is disabled
ActivityMonitor monitor = await ActivityMonitor.GetDefaultAsync();
// But confirm that MotionData is really enabled by calling ActivateAsync,
// to cover the case where the MotionData has been disabled after the app has been launched.
await monitor.ActivateAsync();
}
catch (Exception exception)
{
switch (SenseHelper.GetSenseError(exception.HResult))
{
case SenseError.LocationDisabled:
LocationActivationBox.Visibility = Windows.UI.Xaml.Visibility.Visible;
break;
case SenseError.SenseDisabled:
MotionDataActivationBox.Visibility = Windows.UI.Xaml.Visibility.Visible;
break;
default:
// Do something clever here
break;
}
failure = exception;
}
if (failure == null)
{
// All is good now, dismiss the dialog.
_sensorCoreActivationStatus.activationRequestResult = ActivationRequestResults.AllEnabled;
this.Frame.GoBack();
}
_updatingDialog = false;
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached.
/// This parameter is typically used to configure the page.</param>
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.NavigationMode == NavigationMode.New)
{
Window.Current.VisibilityChanged += Current_VisibilityChanged;
_sensorCoreActivationStatus.onGoing = true;
_sensorCoreActivationStatus.activationRequestResult = ActivationRequestResults.NotAvailableYet;
}
await UpdateDialog();
}
/// <summary>
/// Called when navigating from this page
/// </summary>
/// <param name="e">Event argument.</param>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
if (e.NavigationMode == NavigationMode.Back)
{
Window.Current.VisibilityChanged -= Current_VisibilityChanged;
}
}
/// <summary>
/// Called when the page is visible or not
/// </summary>
/// <param name="sender">The sender of the event</param>
/// <param name="e">Event arguments. Contains the arguments returned by the event fired when a CoreWindow instance's visibility changes.</param>
async void Current_VisibilityChanged(object sender, Windows.UI.Core.VisibilityChangedEventArgs e)
{
if (e.Visible)
{
await UpdateDialog();
}
}
/// <summary>
/// Called when later button is clicked
/// </summary>
/// <param name="sender">The sender of the event</param>
/// <param name="e">Event arguments</param>
private void LaterButton_Click(object sender, RoutedEventArgs e)
{
_sensorCoreActivationStatus.activationRequestResult = ActivationRequestResults.AskMeLater;
Application.Current.Exit();
}
/// <summary>
/// Called when never button is clicked
/// </summary>
/// <param name="sender">The sender of the event</param>
/// <param name="e">Event arguments</param>
private void NeverButton_Click(object sender, RoutedEventArgs e)
{
_sensorCoreActivationStatus.activationRequestResult = ActivationRequestResults.NoAndDontAskAgain;
this.Frame.GoBack();
}
/// <summary>
/// Called when motion data is activated
/// </summary>
/// <param name="sender">The sender of the event</param>
/// <param name="e">Event arguments</param>
private async void MotionDataActivationButton_Click(object sender, RoutedEventArgs e)
{
await SenseHelper.LaunchSenseSettingsAsync();
// Although asynchronous, this completes before the user has actually done anything.
// The application will loose control, the system settings will be displayed.
// We will get the control back to our application via a visibilityChanged event.
}
/// <summary>
/// Called when location is activated
/// </summary>
/// <param name="sender">The sender of the event</param>
/// <param name="e">Event arguments</param>
private async void LocationActivationButton_Click(object sender, RoutedEventArgs e)
{
await SenseHelper.LaunchLocationSettingsAsync();
// Although asynchronous, this completes before the user has actually done anything.
// The application will loose control, the system settings will be displayed.
// We will get the control back to our application via a visibilityChanged event.
}
}
}

Просмотреть файл

@ -0,0 +1,54 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ActivitiesExample.ActivateSensorCore
{
/// <summary>
/// Enum to declare the motion data settings status
/// </summary>
public enum ActivationRequestResults
{
AllEnabled,
AskMeLater,
NoAndDontAskAgain,
NotAvailableYet
};
public class ActivateSensorCoreStatus
{
/// <summary>
/// ActivationRequestResults instance
/// </summary>
public ActivationRequestResults activationRequestResult;
/// <summary>
/// Check if the motion data dialog is initialized
/// </summary>
public bool onGoing = false;
}
}

Просмотреть файл

@ -1,4 +1,5 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -26,6 +27,7 @@ using Windows.Phone.UI.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using ActivitiesExample.ActivateSensorCore;
/// <summary>
/// The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556
@ -37,6 +39,28 @@ namespace ActivitiesExample
/// </summary>
sealed partial class App : Application
{
#region Private members
/// <summary>
/// Status of SensorCore
/// </summary>
private ActivateSensorCoreStatus _sensorCoreActivationStatus = new ActivateSensorCoreStatus();
#endregion
/// <summary>
/// Gets or sets the status of SensorCore
/// </summary>
public ActivateSensorCoreStatus SensorCoreActivationStatus
{
get
{
return _sensorCoreActivationStatus;
}
private set
{
_sensorCoreActivationStatus = value;
}
}
/// <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().

Двоичные данные
Activities/Assets/Activities/biking.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.5 KiB

Двоичные данные
Activities/Assets/Activities/movinginvehicle.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.0 KiB

Двоичные данные
Activities/Assets/Activities/running.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 6.0 KiB

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичные данные
Activities/Assets/Activities/walking.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 6.0 KiB

После

Ширина:  |  Высота:  |  Размер: 1.3 KiB

Просмотреть файл

@ -1,4 +1,5 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -18,7 +19,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
*/
using Lumia.Sense;
using System;
using System.Collections.Generic;
@ -70,6 +71,15 @@ namespace ActivitiesExample.Converters
case "running":
hint = this._resourceLoader.GetString("Hint/Running");
break;
case "biking":
hint = this._resourceLoader.GetString("Hint/Biking");
break;
case "moving in vehicle":
hint = this._resourceLoader.GetString("Hint/MovingInVehicle");
break;
case "unknown":
hint = this._resourceLoader.GetString("Hint/Unknown");
break;
default: break;
}
return hint;

Просмотреть файл

@ -1,4 +1,5 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy

Просмотреть файл

@ -1,4 +1,5 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy

Просмотреть файл

@ -1,4 +1,5 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy

Просмотреть файл

@ -1,4 +1,5 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy

Просмотреть файл

@ -1,4 +1,5 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy

Просмотреть файл

@ -1,4 +1,5 @@
/*
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -285,7 +286,8 @@ namespace ActivitiesExample.Data
/// </summary>
public MyQuantifiedData(string s, TimeSpan i)
{
ActivityName = s;
//Split activity string by capital letter
ActivityName = System.Text.RegularExpressions.Regex.Replace(s, @"([A-Z])(?<=[a-z]\1|[A-Za-z]\1(?=[a-z]))", " $1");
ActivityTime = i;
}

Просмотреть файл

@ -1,4 +1,5 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -80,6 +81,9 @@ namespace ActivitiesExample.Data
_listData.Add(new MyQuantifiedData("Stationary", new TimeSpan(1, 0, 0)));
_listData.Add(new MyQuantifiedData("Walking", new TimeSpan(2, 0, 0)));
_listData.Add(new MyQuantifiedData("Running", new TimeSpan(3, 0, 0)));
_listData.Add(new MyQuantifiedData("Biking", new TimeSpan(5, 0, 0)));
_listData.Add(new MyQuantifiedData("Moving in vehicle", new TimeSpan(1, 0, 0)));
_listData.Add(new MyQuantifiedData("Unknwon", new TimeSpan(1, 0, 0)));
}
}

Двоичные данные
Activities/Help/LumiaSensorCoreSDK.chm

Двоичный файл не отображается.

Просмотреть файл

@ -48,7 +48,7 @@
<ListView x:Name="ActivityListView" Grid.Row="2" Margin="24,0" ItemsSource="{Binding Path=ListData, Mode=OneWay}" Background="#3FFFFFFF" SelectionMode="None" MinHeight="310">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Margin="0" Height="60" Width="{Binding ActualWidth, ElementName=ActivityListView, Mode=OneWay}">
<Grid Margin="0" Width="{Binding ActualWidth, ElementName=ActivityListView, Mode=OneWay}">
<Grid.RowDefinitions >
<RowDefinition Height="10"/>
<RowDefinition Height="auto"/>
@ -66,20 +66,20 @@
<TextBlock Text="{Binding Path=ActivityTime, Converter={StaticResource ResourceKey=TimeToString}}" FontSize="{StaticResource TextStyleMediumFontSize}" Foreground="White" Margin="12,0,0,0" VerticalAlignment="Center"/>
</StackPanel>
<!-- Activity description -->
<TextBlock Grid.Row="2" Text="{Binding Path=ActivityName, Converter={StaticResource ResourceKey=ActivityToHint}}" FontSize="{StaticResource TextStyleSmallFontSize}" Foreground="White" VerticalAlignment="Center" Margin="12,1,12.667,5.833" Height="14"/>
<TextBlock Grid.Row="2" Text="{Binding Path=ActivityName, Converter={StaticResource ResourceKey=ActivityToHint}}" FontSize="{StaticResource TextStyleSmallFontSize}" Foreground="White" VerticalAlignment="Center" Margin="12,0,0,0" TextWrapping="Wrap" />
<!-- Activity duration as a rectangle -->
<Rectangle Grid.Row="3" Grid.Column="0" Width="{Binding Path=ActivityTime, Converter={StaticResource ResourceKey=TimeToWidth}}" Height="6" Fill="White" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Rectangle Grid.Row="3" Margin="0,6,0,0" Grid.Column="0" Width="{Binding Path=ActivityTime, Converter={StaticResource ResourceKey=TimeToWidth}}" Height="6" Fill="White" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<!-- Elipsis added to the end of rectangle if duration > 12h -->
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal" Visibility="{Binding ActivityTime, Converter={StaticResource VisibleElipsis}}">
<Rectangle Margin="6,0,0,0" Width="6" Height="6" Fill="White" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Rectangle Margin="6,0,0,0" Width="6" Height="6" Fill="White" HorizontalAlignment="Right" VerticalAlignment="Top"/>
<Rectangle Margin="6,6,0,0" Width="6" Height="6" Fill="White" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Rectangle Margin="6,6,0,0" Width="6" Height="6" Fill="White" HorizontalAlignment="Right" VerticalAlignment="Top"/>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- x coordinates -->
<Grid Grid.Row="4" Margin="24,0,24,12" >
<Grid Grid.Row="3" Margin="24,0,24,12" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3*"/>

Просмотреть файл

@ -1,4 +1,5 @@
/*
The MIT License (MIT)
Copyright (c) 2015 Microsoft
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -32,6 +33,7 @@ using ActivitiesExample.Data;
using Windows.Security.ExchangeActiveSyncProvisioning;
using Lumia.Sense.Testing;
using Windows.ApplicationModel.Resources;
using ActivitiesExample.ActivateSensorCore;
/// <summary>
/// The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkID=390556
@ -59,6 +61,9 @@ namespace ActivitiesExample
/// </summary>
private readonly ResourceLoader _resourceLoader = ResourceLoader.GetForCurrentView("Resources");
/// The application model
/// </summary>
private ActivitiesExample.App _app = Application.Current as ActivitiesExample.App;
#endregion
/// <summary>
@ -72,7 +77,7 @@ namespace ActivitiesExample
//Using this method to detect if the application runs in the emulator or on a real device. Later the *Simulator API is used to read fake sense data on emulator.
//In production code you do not need this and in fact you should ensure that you do not include the Lumia.Sense.Test reference in your project.
EasClientDeviceInformation x = new EasClientDeviceInformation();
if(x.SystemProductName.StartsWith("Virtual"))
if (x.SystemProductName.StartsWith("Virtual"))
{
_runningInEmulator = true;
}
@ -84,7 +89,7 @@ namespace ActivitiesExample
/// <param name="sender">The sender of the event</param>
/// <param name="e">Event argument</param>
async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
{
if (!_runningInEmulator && !await ActivityMonitor.IsSupportedAsync())
{
// Nothing to do if we cannot use the API
@ -92,10 +97,9 @@ namespace ActivitiesExample
// e.g. if access to Activity Monitor is not mission critical, let the app run without showing any error message
// simply hide the features that depend on it
MessageDialog md = new MessageDialog(this._resourceLoader.GetString("FeatureNotSupported/Message"), this._resourceLoader.GetString("FeatureNotSupported/Title"));
await md.ShowAsync();
await md.ShowAsync();
Application.Current.Exit();
}
Initialize();
}
/// <summary>
@ -103,17 +107,71 @@ namespace ActivitiesExample
/// </summary>
private async void Initialize()
{
if (!(await ActivityMonitor.IsSupportedAsync()))
{
MessageDialog dlg = new MessageDialog("Unfortunately this device does not support activities.");
await dlg.ShowAsync();
Application.Current.Exit();
}
else
{
uint apiSet = await SenseHelper.GetSupportedApiSetAsync();
MotionDataSettings settings = await SenseHelper.GetSettingsAsync();
// Devices with old location settings
if (settings.Version < 2 && !settings.LocationEnabled)
{
MessageDialog dlg = new MessageDialog("In order to recognize activities you need to enable location in system settings. Do you want to open settings now? if no, applicatoin will exit", "Information");
dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async (cmd) => await SenseHelper.LaunchLocationSettingsAsync())));
dlg.Commands.Add(new UICommand("No", new UICommandInvokedHandler((cmd) =>{ Application.Current.Exit();})));
await dlg.ShowAsync();
}
if (!settings.PlacesVisited)
{
MessageDialog dlg = null;
if (settings.Version < 2)
{
//device which has old motion data settings.
//this is equal to motion data settings on/off in old system settings(SDK1.0 based)
dlg = new MessageDialog("In order to recognize activities you need to enable Motion data in Motion data settings. Do you want to open settings now? if no, application will exit", "Information");
dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async (cmd) => await SenseHelper.LaunchSenseSettingsAsync())));
dlg.Commands.Add(new UICommand("No", new UICommandInvokedHandler((cmd) =>{ Application.Current.Exit();})));
await dlg.ShowAsync();
}
else
{
dlg = new MessageDialog("In order to recognize activities you need to 'enable Places visited' and 'DataQuality to detailed' in Motion data settings. Do you want to open settings now? ", "Information");
dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async (cmd) => await SenseHelper.LaunchSenseSettingsAsync())));
dlg.Commands.Add(new UICommand("No"));
await dlg.ShowAsync();
}
}
else if (apiSet >= 3 && settings.DataQuality == DataCollectionQuality.Basic)
{
MessageDialog dlg = new MessageDialog("In order to recognize biking you need to enable detailed data collection in Motion data settings. Do you want to open settings now?", "Information");
dlg.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async (cmd) => await SenseHelper.LaunchSenseSettingsAsync())));
dlg.Commands.Add(new UICommand("No"));
await dlg.ShowAsync();
}
}
if (_activityMonitor == null)
{
if(_runningInEmulator)
if (_runningInEmulator)
{
await CallSensorCoreApiAsync(async () => { _activityMonitor = await ActivityMonitorSimulator.GetDefaultAsync(); });
if (await CallSensorCoreApiAsync(async () => { _activityMonitor = await ActivityMonitorSimulator.GetDefaultAsync(); }))
{
Debug.WriteLine("ActivityMonitorSimulator initialized.");
}
else return;
}
else
{
await CallSensorCoreApiAsync(async () => { _activityMonitor = await ActivityMonitor.GetDefaultAsync(); });
if (await CallSensorCoreApiAsync(async () => { _activityMonitor = await ActivityMonitor.GetDefaultAsync(); }))
{
Debug.WriteLine("ActivityMonitor initialized.");
}
else return;
}
if (_activityMonitor!=null)
if (_activityMonitor != null)
{
// Set activity observer
_activityMonitor.ReadingChanged += activityMonitor_ReadingChanged;
@ -177,23 +235,16 @@ namespace ActivitiesExample
if (failure != null)
{
try
{
{
MessageDialog dialog = null;
switch (SenseHelper.GetSenseError(failure.HResult))
{
case SenseError.LocationDisabled:
dialog = new MessageDialog(this._resourceLoader.GetString("FeatureDisabled/Location"), this._resourceLoader.GetString("FeatureDisabled/Title"));
dialog.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async (cmd) => await SenseHelper.LaunchLocationSettingsAsync())));
dialog.Commands.Add(new UICommand("No"));
await dialog.ShowAsync();
new System.Threading.ManualResetEvent(false).WaitOne(500);
return false;
case SenseError.SenseDisabled:
dialog = new MessageDialog(this._resourceLoader.GetString("FeatureDisabled/MotionData"), this._resourceLoader.GetString("FeatureDisabled/InTitle"));
dialog.Commands.Add(new UICommand("Yes", new UICommandInvokedHandler(async (cmd) => await SenseHelper.LaunchSenseSettingsAsync())));
dialog.Commands.Add(new UICommand("No"));
await dialog.ShowAsync();
new System.Threading.ManualResetEvent(false).WaitOne(500);
if (!_app.SensorCoreActivationStatus.onGoing)
{
this.Frame.Navigate(typeof(ActivateSensorCore.ActivateSensorCore));
}
return false;
default:
dialog = new MessageDialog("Failure: " + SenseHelper.GetSenseError(failure.HResult), "");
@ -217,12 +268,29 @@ namespace ActivitiesExample
/// Called when navigating to this page
/// </summary>
/// <param name="e">Event arguments</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
ActivateSensorCoreStatus status = _app.SensorCoreActivationStatus;
if (e.NavigationMode == NavigationMode.Back && status.onGoing)
{
status.onGoing = false;
if (status.activationRequestResult != ActivationRequestResults.AllEnabled)
{
MessageDialog dialog = new MessageDialog(_resourceLoader.GetString("NoLocationOrMotionDataError/Text"), _resourceLoader.GetString("Information/Text"));
dialog.Commands.Add(new UICommand("Ok", new UICommandInvokedHandler(async (cmd) => await SenseHelper.LaunchSenseSettingsAsync())));
await dialog.ShowAsync();
new System.Threading.ManualResetEvent(false).WaitOne(500);
Application.Current.Exit();
}
}
if (_activityMonitor != null)
{
_activityMonitor.ReadingChanged += activityMonitor_ReadingChanged;
}
else
{
Initialize();
}
}
/// <summary>
@ -246,7 +314,7 @@ namespace ActivitiesExample
{
await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
MyData.Instance().ActivityEnum = args.Mode;
MyData.Instance().ActivityEnum = args.Mode;
});
}
@ -259,8 +327,8 @@ namespace ActivitiesExample
{
if (!await CallSensorCoreApiAsync(async () =>
{
// Get the data for the current 24h time window
MyData.Instance().History = await _activityMonitor.GetActivityHistoryAsync(DateTime.Now.Date.AddDays(MyData.Instance().TimeWindow), new TimeSpan(24,0,0 ));
// Get the data for the current 24h time window
MyData.Instance().History = await _activityMonitor.GetActivityHistoryAsync(DateTime.Now.Date.AddDays(MyData.Instance().TimeWindow), new TimeSpan(24, 0, 0));
}))
{
Debug.WriteLine("Reading the history failed.");

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="NokiaDeveloper.ActivitiesLumiaSensorCoreSDKsample" Publisher="CN=4AD6DA08-6C39-4A10-98CC-3243374DA59C" Version="1.1.0.13" />
<Identity Name="NokiaDeveloper.ActivitiesLumiaSensorCoreSDKsample" Publisher="CN=4AD6DA08-6C39-4A10-98CC-3243374DA59C" Version="1.1.0.17" />
<Properties>
<DisplayName>Activities – Lumia SensorCore SDK sample</DisplayName>
<PublisherDisplayName>Lumia SDK</PublisherDisplayName>

Просмотреть файл

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="LaterButton.Content" xml:space="preserve">
<value>Later</value>
</data>
<data name="LocationActivationButton.Content" xml:space="preserve">
<value>Switch on</value>
</data>
<data name="LocationActivationExplanation.Text" xml:space="preserve">
<value>This application requires location data in order to work correctly</value>
</data>
<data name="LocationActivationTitle.Text" xml:space="preserve">
<value>Switch on location data</value>
</data>
<data name="MotionDataActivationButton.Content" xml:space="preserve">
<value>Switch on</value>
</data>
<data name="MotionDataActivationExplanation.Text" xml:space="preserve">
<value>This application requires motion data in order to work correctly</value>
</data>
<data name="MotionDataActivationTitle.Text" xml:space="preserve">
<value>Switch on motion data</value>
</data>
<data name="NeverButton.Content" xml:space="preserve">
<value>Do not ask again</value>
</data>
</root>

Просмотреть файл

@ -147,15 +147,24 @@
<data name="ApplicationSuite.Text" xml:space="preserve">
<value>LUMIA SENSORCORE SAMPLE</value>
</data>
<data name="BikingFeatureDisabled.DataCollectionQuality" xml:space="preserve">
<value>In order to recognize biking or moving in vehicle you need to enable detailed data collection in Motion data settings. Do you want to open settings now?</value>
</data>
<data name="CurrentActivityHeader.Text" xml:space="preserve">
<value>Current activity:</value>
</data>
<data name="DetailedSetting.DataCollectionQuality" xml:space="preserve">
<value>To get more accurate data you need to enable detailed data collection in Motion data settings. Do you want to open settings now?</value>
</data>
<data name="FeatureDisabled.Location" xml:space="preserve">
<value>Location has been disabled. Do you want to open Location settings now?</value>
</data>
<data name="FeatureDisabled.MotionData" xml:space="preserve">
<value>Motion data has been disabled. Do you want to open Motion data settings now?</value>
</data>
<data name="FeatureDisabled.MotionDataSettings" xml:space="preserve">
<value>Unfortunately this device does not support biking or moving in vehicle recognition</value>
</data>
<data name="FeatureDisabled.Title" xml:space="preserve">
<value>Information</value>
</data>
@ -167,24 +176,36 @@ The application will now exit.</value>
<data name="FeatureNotSupported.Title" xml:space="preserve">
<value>Lumia SensorCore</value>
</data>
<data name="Hint.Biking" xml:space="preserve">
<value>Biking activity</value>
</data>
<data name="Hint.Idle" xml:space="preserve">
<value>The phone was laying still, for example, on a table.</value>
</data>
<data name="Hint.Moving" xml:space="preserve">
<value>Some movement was detected, other than walking or running.</value>
</data>
<data name="Hint.MovingInVehicle" xml:space="preserve">
<value>Moving in vehicle</value>
</data>
<data name="Hint.Running" xml:space="preserve">
<value>The user was running with the phone.</value>
</data>
<data name="Hint.Stationary" xml:space="preserve">
<value>The phone was handled but the user was not moving around.</value>
</data>
<data name="Hint.Unknown" xml:space="preserve">
<value>Activity could not be determined, for example the device is swithced off</value>
</data>
<data name="Hint.Walking" xml:space="preserve">
<value>The user was walking with the phone.</value>
</data>
<data name="NextButton.Label" xml:space="preserve">
<value>next day</value>
</data>
<data name="NoLocationOrMotionDataError.Text" xml:space="preserve">
<value>This application does not function without location and motion data. The application will be closed.</value>
</data>
<data name="PrevButton.Label" xml:space="preserve">
<value>previous day</value>
</data>

Просмотреть файл

@ -14,7 +14,7 @@
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{76F1466A-8B6D-4E39-A767-685A06062A39};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
<AppxBundlePlatforms>arm</AppxBundlePlatforms>
<PackageCertificateThumbprint>5F7524CDD75F3F41BAC31F01C368A249D987521B</PackageCertificateThumbprint>
@ -75,8 +75,6 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
@ -93,6 +91,10 @@
<Compile Include="AboutPage.xaml.cs">
<DependentUpon>AboutPage.xaml</DependentUpon>
</Compile>
<Compile Include="ActivateSensorCore\ActivateSensorCore.xaml.cs">
<DependentUpon>ActivateSensorCore.xaml</DependentUpon>
</Compile>
<Compile Include="ActivateSensorCore\SensorCoreActivationStatus.cs" />
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
@ -123,25 +125,27 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ActivateSensorCore\ActivateSensorCore.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Content Include="Assets\Activities\biking.png" />
<Content Include="Assets\Activities\movinginvehicle.png" />
<Content Include="Assets\Activities\idle.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Activities\moving.png" />
<Content Include="Assets\Activities\running.png" />
<Content Include="Assets\Activities\stationary.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Activities\running.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Activities\walking.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\Activities\walking.png" />
<Content Include="Assets\back.png" />
<Content Include="Assets\next.png" />
<Content Include="Assets\refresh.png" />
@ -158,32 +162,13 @@
<ItemGroup>
<None Include="Help\LumiaSensorCoreSDK.chm" />
<None Include="packages.config" />
<PRIResource Include="Strings\en-US\ActivateSensorCore.resw" />
</ItemGroup>
<ItemGroup>
<Reference Include="Lumia.Sense, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LumiaSensorCoreSDK.1.0.3.263\lib\portable-wpa81+wp81\x86\Lumia.Sense.winmd</HintPath>
</Reference>
<Reference Include="Lumia.Sense.Testing, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LumiaSensorCoreSDKTesting.1.0.3.263\lib\portable-wpa81+wp81\x86\Lumia.Sense.Testing.winmd</HintPath>
</Reference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' ">
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '12.0' ">
<VisualStudioVersion>12.0</VisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetPlatformIdentifier)' == '' ">
<TargetPlatformIdentifier>WindowsPhoneApp</TargetPlatformIdentifier>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\$(TargetPlatformVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Import Project="..\packages\LumiaSensorCoreSDK.1.0.3.263\build\wpa81\LumiaSensorCoreSDK.targets" Condition="Exists('..\packages\LumiaSensorCoreSDK.1.0.3.263\build\wpa81\LumiaSensorCoreSDK.targets')" />
<Import Project="..\packages\LumiaSensorCoreSDKTesting.1.0.3.263\build\wpa81\LumiaSensorCoreSDKTesting.targets" Condition="Exists('..\packages\LumiaSensorCoreSDKTesting.1.0.3.263\build\wpa81\LumiaSensorCoreSDKTesting.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -1,5 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LumiaSensorCoreSDK" version="1.0.3.263" targetFramework="wpa81" />
<package id="LumiaSensorCoreSDKTesting" version="1.0.3.263" targetFramework="wpa81" />
</packages>

Просмотреть файл

@ -77,6 +77,8 @@ file the capabilities required for it to work:
3. Version history
--------------------------------------------------------------------------------
* Version 1.1.0.17:
* Updated to use latest Lumia SensorCore SDK 1.1 Preview
* Version 1.1.0.13:
* Some bug fixes made in this release.
* Version 1.0: The first release.
@ -86,6 +88,7 @@ file the capabilities required for it to work:
| Project | Release | Download |
| ------- | --------| -------- |
| Activities | v1.1.0.17 | [activities-1.1.0.17.zip](https://github.com/Microsoft/activities/archive/v1.1.0.17.zip) |
| Activities | v1.1.0.13 | [activities-1.1.0.13.zip](https://github.com/Microsoft/activities/archive/v1.1.0.13.zip) |
| Activities | v1.0 | [activities-1.0.zip](https://github.com/Microsoft/activities/archive/v1.0.zip) |