Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Haishi2016 committed Mar 30, 2016
2 parents cdc14d8 + fcd19f3 commit 0ac6962
Show file tree
Hide file tree
Showing 25 changed files with 365 additions and 232 deletions.
113 changes: 0 additions & 113 deletions src/MobileApps/Licenses/XamarinInsights.LICENSE

This file was deleted.

4 changes: 2 additions & 2 deletions src/MobileApps/MyDriving/MyDriving.Shared/PlatformLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void Track(string trackIdentifier, IDictionary<string, string> t
#if __ANDROID__
HockeyApp.Metrics.MetricsManager.TrackEvent(trackIdentifier);
#elif __IOS__
HockeyApp.BITHockeyManager.SharedHockeyManager.MetricsManager.TrackEvent(trackIdentifier);
HockeyApp.BITHockeyManager.SharedHockeyManager?.MetricsManager?.TrackEvent(trackIdentifier);
#endif
base.Track(trackIdentifier, table);
}
Expand All @@ -54,7 +54,7 @@ public override void Track(string trackIdentifier, string key, string value)
#if __ANDROID__
HockeyApp.Metrics.MetricsManager.TrackEvent(trackIdentifier);
#elif __IOS__
HockeyApp.BITHockeyManager.SharedHockeyManager.MetricsManager.TrackEvent(trackIdentifier);
HockeyApp.BITHockeyManager.SharedHockeyManager?.MetricsManager?.TrackEvent(trackIdentifier);
#endif
base.Track(trackIdentifier, key, value);
}
Expand Down
47 changes: 22 additions & 25 deletions src/MobileApps/MyDriving/MyDriving.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using MyDriving.Utils;
using MyDriving.UWP.Helpers;
using MyDriving.UWP.Views;
using MyDriving.UWP.Controls;

namespace MyDriving.UWP
{
Expand All @@ -20,6 +21,7 @@ namespace MyDriving.UWP
/// </summary>
sealed partial class App
{

/// <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().
Expand All @@ -42,59 +44,50 @@ public App()
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
SplitViewShell shell = Window.Current.Content as SplitViewShell;

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

//Register platform specific implementations of shared interfaces
ServiceLocator.Instance.Add<IAuthentication, Authentication>();
ServiceLocator.Instance.Add<Utils.Interfaces.ILogger, PlatformLogger>();
ServiceLocator.Instance.Add<IOBDDevice, OBDDevice>();

rootFrame.NavigationFailed += OnNavigationFailed;

if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}

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

if (rootFrame.Content == null)
{
// 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 (Settings.Current.IsLoggedIn)
{
//When the first screen of the app is launched after user has logged in, initialize the processor that manages connection to OBD Device and to the IOT Hub
MyDriving.Services.OBDDataProcessor.GetProcessor().Initialize(ViewModel.ViewModelBase.StoreManager);

SplitViewShell shell = new SplitViewShell(rootFrame);
Window.Current.Content = shell;
// Create the shell and set it to current trip
shell = new SplitViewShell(rootFrame);
shell.SetTitle("CURRENT TRIP");
shell.SetSelectedPage("CURRENT TRIP");
rootFrame.Navigate(typeof(CurrentTripView), e.Arguments);
Window.Current.Content = shell;
}
else if (Settings.Current.FirstRun)
{
rootFrame.Navigate(typeof (GetStarted1), e.Arguments);
rootFrame.Navigate(typeof(GetStarted1), e.Arguments);
Window.Current.Content = rootFrame;
}
else
{
rootFrame.Navigate(typeof (LoginView), e.Arguments);
rootFrame.Navigate(typeof(LoginView), e.Arguments);
Window.Current.Content = rootFrame;
}
}

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


/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
Expand Down Expand Up @@ -122,8 +115,12 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
public static void SetTitle(string title)
{
SplitViewShell shell = Window.Current.Content as SplitViewShell;
if(shell != null)
if (shell != null)
{
shell.SetTitle(title);
shell.SetSelectedPage(title);
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" >
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Background="Transparent">
<Image Name="Image" Style="{StaticResource SplitViewIconStyle}" Source="{x:Bind DefaultImageSource}"/>
<TextBlock Name="Label" Style="{StaticResource SplitViewText}" Foreground="{x:Bind defaultTextColor}" Text="{x:Bind LabelText}"/>
</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace MyDriving.UWP.Controls
{
public sealed partial class SplitViewButtonContent
{
readonly SolidColorBrush defaultTextColor = new SolidColorBrush(Color.FromArgb(0xFF, 0xad, 0xac, 0xac));
readonly SolidColorBrush defaultTextColor = new SolidColorBrush(Colors.White);

readonly SolidColorBrush selectedTextColor = new SolidColorBrush(Color.FromArgb(0xFF, 0x1b, 0xa0, 0xe1));
public BitmapImage DefaultImageSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@

namespace MyDriving.UWP.Converters
{
//Input value is UserPictureSourceKind
//Actual values of the image source are pulled from Settings.Current
public class ImageSourceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var imageUrl = value as string;
if (string.IsNullOrWhiteSpace(imageUrl))
return null;

string url = value as string;
if (!string.IsNullOrEmpty(url))
if (!string.IsNullOrWhiteSpace(url))
{
try
{
Expand Down
11 changes: 7 additions & 4 deletions src/MobileApps/MyDriving/MyDriving.UWP/Resources/Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,26 @@


<Style x:Key="SplitViewText" TargetType="TextBlock">
<Setter Property="Foreground" Value="#adacac" />
<Setter Property="Foreground" Value="White" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="8,0,0,0" />
<Setter Property="Margin" Value="20,0,0,0" />
</Style>

<Style x:Key="SplitViewIconStyle" TargetType="Image">
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="24" />
<Setter Property="Margin" Value="4,0,0,0" />
</Style>

<Style x:Key="SplitViewButtonStyle" TargetType="Button">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Height" Value="32" />
<Setter Property="Width" Value="164" />
<Setter Property="Height" Value="48" />
<Setter Property="Width" Value="200" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="VerticalAlignment" Value="Top" />
</Style>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace MyDriving.UWP.Views
/// </summary>
public sealed partial class CurrentTripView : INotifyPropertyChanged
{

private bool recordButtonIsBusy = false;
private ImageSource recordButtonImage;

private ExtendedExecutionSession session;
Expand Down Expand Up @@ -74,6 +74,7 @@ private void MyMap_Loaded(object sender, RoutedEventArgs e)
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
App.SetTitle("CURRENT TRIP");
ViewModel.PropertyChanged += OnPropertyChanged;
await StartTrackingAsync();
UpdateStats();
Expand Down Expand Up @@ -220,7 +221,7 @@ private void ClearExtendedExecution()

private async void SessionRevoked(object sender, ExtendedExecutionRevokedEventArgs args)
{
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
{
switch (args.Reason)
{
Expand All @@ -234,15 +235,18 @@ await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
}

ClearExtendedExecution();
await BeginExtendedExecution();
});
}


private async void StartRecordBtn_Click(object sender, RoutedEventArgs e)
{
if (ViewModel?.CurrentPosition == null || ViewModel.IsBusy)
if (ViewModel?.CurrentPosition == null || ViewModel.IsBusy || recordButtonIsBusy)
return;

recordButtonIsBusy = true;

var basicGeoposition = new BasicGeoposition()
{
Latitude = ViewModel.CurrentPosition.Latitude,
Expand All @@ -255,7 +259,10 @@ private async void StartRecordBtn_Click(object sender, RoutedEventArgs e)
UpdateMap_PositionChanged(basicGeoposition);

if (!await ViewModel.StopRecordingTrip())
{
recordButtonIsBusy = false;
return;
}

// Need to add the end marker only when we are able to stop the trip.
AddEndMarker(basicGeoposition);
Expand All @@ -265,13 +272,16 @@ private async void StartRecordBtn_Click(object sender, RoutedEventArgs e)
var recordedTripSummary = ViewModel.TripSummary;
await ViewModel.SaveRecordingTripAsync();
// Launch Trip Summary Page.
Frame.Navigate(typeof (TripSummaryView), recordedTripSummary);
}

Frame.Navigate(typeof(TripSummaryView), recordedTripSummary);
}
else
{
if (!await ViewModel.StartRecordingTrip())
{
recordButtonIsBusy = false;
return;
}

if (ViewModel.CurrentTrip.HasSimulatedOBDData)
App.SetTitle("CURRENT TRIP (SIMULATED OBD)");
Expand All @@ -284,6 +294,7 @@ private async void StartRecordBtn_Click(object sender, RoutedEventArgs e)
UpdateMap_PositionChanged(basicGeoposition);
UpdateStats();
}
recordButtonIsBusy = false;
}

private async void UpdateMap_PositionChanged(BasicGeoposition basicGeoposition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)
var trip = e.Parameter as Trip;
base.OnNavigatedTo(e);
viewModel.Trip = trip;

App.SetTitle("PAST TRIPS");
MyMap.Loaded += MyMap_Loaded;
MyMap.MapElements.Clear();
var success = await viewModel.ExecuteLoadTripCommandAsync(trip.Id);
Expand Down
38 changes: 20 additions & 18 deletions src/MobileApps/MyDriving/MyDriving.UWP/Views/PastTripsMenuView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,43 @@
</Page.BottomAppBar>

<Grid Background="{StaticResource MainBackgroundColor}">
<ListView x:Name="ListView" ItemsSource="{x:Bind ViewModel.Trips}" Margin="0,10,10,0" SelectionChanged="listView_SelectionChanged">
<ListView x:Name="ListView" ItemsSource="{x:Bind ViewModel.Trips, Mode=OneWay}" SelectionChanged="listView_SelectionChanged" >
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Margin" Value="0,4,0,0" />
<Setter Property="Background" Value="{StaticResource MainBackgroundColor2}" />
<Setter Property="BorderThickness" Value="3" />
<Setter Property="BorderBrush" Value="{StaticResource PastTripsBorderColor}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="0,0,0,0" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:Trip">
<StackPanel Holding="ListViewItem_Holding">
<Grid Holding="ListViewItem_Holding" HorizontalAlignment="Stretch">
<FlyoutBase.AttachedFlyout>
<MenuFlyout>
<MenuFlyoutItem Text="Delete"
Click="DeleteButton_Click" />
</MenuFlyout>
</FlyoutBase.AttachedFlyout>
<Image x:Name="Image" Source="{x:Bind MainPhotoUrl}" HorizontalAlignment="Stretch" MaxHeight="125" Stretch="UniformToFill" />
<TextBlock Text="{x:Bind Name}" Margin="0,5,0,0"/>
<Grid Margin="0" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="1" HorizontalAlignment="Stretch" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{x:Bind TimeAgo}" HorizontalAlignment="Left" Foreground="{StaticResource CalculationTextColor}" Margin="0,0,0,5" FontSize="13.333"/>
<TextBlock Text="{x:Bind TotalDistance}" HorizontalAlignment="Right" Foreground="{StaticResource CalculationTextColor}" Margin="0,0,0,5" FontSize="13.333"/>
</Grid>


<Grid HorizontalAlignment="Stretch" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Image x:Name="Image" Source="{x:Bind MainPhotoUrl, Converter={StaticResource ImageSourceConverter}, Mode=OneWay}" HorizontalAlignment="Stretch" Stretch="UniformToFill" />
<TextBlock Text="{x:Bind Name}" Margin="12,5,0,0" HorizontalAlignment="Left" Grid.Row="1"/>
<TextBlock Text="{x:Bind TimeAgo}" HorizontalAlignment="Left" Foreground="{StaticResource CalculationTextColor}" Margin="12,0,0,5" FontSize="13.333" Grid.Row="2"/>
<TextBlock Text="{x:Bind TotalDistance}" HorizontalAlignment="Right" Foreground="{StaticResource CalculationTextColor}" Margin="0,0,12,5" FontSize="13.333" Grid.Row="2"/>

</Grid>
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);

App.SetTitle("PAST TRIPS");
// Enable back button behavior
SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();
systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public ProfileView()
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
App.SetTitle("PROFILE");
// Enable back button behavior
SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();
systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public SettingsView()
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
App.SetTitle("SETTINGS");
// Enable back button behavior
SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();
systemNavigationManager.BackRequested += SystemNavigationManager_BackRequested;
Expand Down
Loading

0 comments on commit 0ac6962

Please sign in to comment.