Skip to content

Commit

Permalink
Added support for iPhones 6 features
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike James committed Feb 10, 2016
1 parent 1012bd5 commit d61e436
Show file tree
Hide file tree
Showing 30 changed files with 882 additions and 785 deletions.
11 changes: 0 additions & 11 deletions BeerDrinkin_XamarinStudio.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeerDrinkinAPI", "Shared\Be
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeerDrinkin", "Shared\BeerDrinkin\BeerDrinkin.csproj", "{70F2F312-0E9F-40B2-BA23-37F994708DAE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeerDrinkinClient", "Shared\BeerDrinkinClient\BeerDrinkinClient.csproj", "{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mobile", "Mobile", "{188215A9-41D2-4422-8F02-0DFA601BFFFE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeerDrinkin.iOS", "Mobile\iOS\BeerDrinkin.iOS.csproj", "{586D37FE-B247-44A7-B218-278458571D5A}"
Expand Down Expand Up @@ -41,14 +39,6 @@ Global
{70F2F312-0E9F-40B2-BA23-37F994708DAE}.Release|iPhone.Build.0 = Release|Any CPU
{70F2F312-0E9F-40B2-BA23-37F994708DAE}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{70F2F312-0E9F-40B2-BA23-37F994708DAE}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84}.Debug|iPhone.Build.0 = Debug|Any CPU
{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84}.Release|iPhone.ActiveCfg = Release|Any CPU
{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84}.Release|iPhone.Build.0 = Release|Any CPU
{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{AB1004CB-BECB-4EDD-979F-71B74C5C2539}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{AB1004CB-BECB-4EDD-979F-71B74C5C2539}.Debug|iPhone.Build.0 = Debug|Any CPU
{AB1004CB-BECB-4EDD-979F-71B74C5C2539}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
Expand All @@ -69,7 +59,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{AB1004CB-BECB-4EDD-979F-71B74C5C2539} = {2157A7C6-3D65-4C2A-9B77-186B9740D540}
{70F2F312-0E9F-40B2-BA23-37F994708DAE} = {2157A7C6-3D65-4C2A-9B77-186B9740D540}
{9675233D-18D0-4EBC-B1D4-CB8EBDD1FC84} = {2157A7C6-3D65-4C2A-9B77-186B9740D540}
{586D37FE-B247-44A7-B218-278458571D5A} = {188215A9-41D2-4422-8F02-0DFA601BFFFE}
{F5A40FD3-C77D-4A18-9100-B832B3E38181} = {76E7C1B5-5FCD-47B2-948B-CD2B61018F38}
EndGlobalSection
Expand Down
122 changes: 121 additions & 1 deletion Mobile/iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using JudoDotNetXamarin;
using JudoPayDotNet.Enums;
using BeerDrinkin.Service.DataObjects;
using Social;

namespace BeerDrinkin.iOS
{
Expand Down Expand Up @@ -47,7 +48,7 @@ public override bool FinishedLaunching (UIApplication application, NSDictionary
return true;
}

void ConfigureJudoPayments ()
private void ConfigureJudoPayments ()
{
var configInstance = JudoConfiguration.Instance;

Expand Down Expand Up @@ -121,8 +122,127 @@ public override bool ContinueUserActivity (UIApplication application, NSUserActi
return true;
}

// Minimum number of seconds between a background refresh
// 15 minutes = 15 * 60 = 900 seconds
private const double MINIMUM_BACKGROUND_FETCH_INTERVAL = 900;

private void SetMinimumBackgroundFetchInterval ()
{
UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval (MINIMUM_BACKGROUND_FETCH_INTERVAL);
}

// Called whenever your app performs a background fetch
public override async void PerformFetch (UIApplication application, Action<UIBackgroundFetchResult> completionHandler)
{
// Do Background Fetch
var downloadSuccessful = false;
try {
// Download data
await Client.Instance.BeerDrinkinClient.RefreshAll();
downloadSuccessful = true;

} catch (Exception ex) {
Insights.Report(ex);
}

// If you don't call this, your application will be terminated by the OS.
// Allows OS to collect stats like data cost and power consumption
if (downloadSuccessful) {
completionHandler (UIBackgroundFetchResult.NewData);
} else {
completionHandler (UIBackgroundFetchResult.Failed);
}
}


#endregion

#region Quick Action

public static class ShortcutIdentifier
{
public const string MyBeers = "com.micjames.beerdrinkin.mybeers";
public const string WishList = "com.micjames.beerdrinkin.wishlist";
public const string Search = "com.micjames.beerdrinkin.search";
public const string Me = "com.micjames.beerdrinkin.profile";
}


public UIApplicationShortcutItem LaunchedShortcutItem { get; set; }
public override void OnActivated (UIApplication application)
{
Console.WriteLine ("OnActivated");

// Handle any shortcut item being selected
HandleShortcutItem(LaunchedShortcutItem);

// Clear shortcut after it's been handled
LaunchedShortcutItem = null;
}

// if app is already running
public override void PerformActionForShortcutItem (UIApplication application, UIApplicationShortcutItem shortcutItem, UIOperationHandler completionHandler)
{
Console.WriteLine ("PerformActionForShortcutItem");
// Perform action
var handled = HandleShortcutItem(shortcutItem);
completionHandler(handled);
}
public bool HandleShortcutItem(UIApplicationShortcutItem shortcutItem)
{
Console.WriteLine ("HandleShortcutItem ");
var handled = false;

// Anything to process?
if (shortcutItem == null)
return false;

Xamarin.Insights.Track("3DTouch", "Type", shortcutItem.LocalizedTitle);

// Take action based on the shortcut type
switch (shortcutItem.Type)
{
case ShortcutIdentifier.MyBeers:
if (this.Window.RootViewController.ChildViewControllers[0] is UITabBarController)
{
var tabController = this.Window.RootViewController.ChildViewControllers[0] as UITabBarController;
tabController.SelectedIndex = 0;
}
handled = true;
break;
case ShortcutIdentifier.WishList:
if (this.Window.RootViewController.ChildViewControllers[0] is UITabBarController)
{
var tabController = this.Window.RootViewController.ChildViewControllers[0] as UITabBarController;
tabController.SelectedIndex = 1;
}
handled = true;
break;
case ShortcutIdentifier.Search:
if (this.Window.RootViewController.ChildViewControllers[0] is UITabBarController)
{
var tabController = this.Window.RootViewController.ChildViewControllers[0] as UITabBarController;
tabController.SelectedIndex = 2;
}
handled = true;
break;
case ShortcutIdentifier.Me:
if (this.Window.RootViewController.ChildViewControllers[0] is UITabBarController)
{
var tabController = this.Window.RootViewController.ChildViewControllers[0] as UITabBarController;
tabController.SelectedIndex = 3;
}
handled = true;
break;
}

Console.Write (handled);
// Return results
return handled;
}

#endregion

static void PurgeCrashReports (object sender, bool isStartupCrash)
{
if (isStartupCrash) {
Expand Down
104 changes: 64 additions & 40 deletions Mobile/iOS/BeerDrinkin.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@
<Reference Include="Acr.Support.iOS">
<HintPath>..\..\packages\Acr.Support.1.1.1\lib\Xamarin.iOS10\Acr.Support.iOS.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Insights">
<HintPath>..\..\packages\Xamarin.Insights.1.11.2\lib\Xamarin.iOS10\Xamarin.Insights.dll</HintPath>
</Reference>
<Reference Include="PLCrashReporterUnifiedBinding">
<HintPath>..\..\packages\Xamarin.Insights.1.11.2\lib\Xamarin.iOS10\PLCrashReporterUnifiedBinding.dll</HintPath>
</Reference>
<Reference Include="Calabash">
<HintPath>..\..\packages\Xamarin.TestCloud.Agent.0.16.4\lib\Xamarin.iOS10\Calabash.dll</HintPath>
</Reference>
Expand All @@ -166,42 +160,9 @@
<Reference Include="Plugin.Geolocator.Abstractions">
<HintPath>..\..\packages\Xam.Plugin.Geolocator.3.0.1\lib\Xamarin.iOS10\Plugin.Geolocator.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Acr.UserDialogs">
<HintPath>..\..\packages\Acr.UserDialogs.4.2.0\lib\Xamarin.iOS10\Acr.UserDialogs.dll</HintPath>
</Reference>
<Reference Include="Acr.UserDialogs.Interface">
<HintPath>..\..\packages\Acr.UserDialogs.4.2.0\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll</HintPath>
</Reference>
<Reference Include="BTProgressHUD">
<HintPath>..\..\packages\Acr.UserDialogs.4.2.0\lib\Xamarin.iOS10\BTProgressHUD.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Formatting">
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\portable-wp8+netcore45+net45+wp81+wpa81\System.Net.Http.Formatting.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Mobile">
<HintPath>..\..\packages\Microsoft.Azure.Mobile.Client.2.0.0\lib\Xamarin.iOS10\Microsoft.WindowsAzure.Mobile.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Mobile.Ext">
<HintPath>..\..\packages\Microsoft.Azure.Mobile.Client.2.0.0\lib\Xamarin.iOS10\Microsoft.WindowsAzure.Mobile.Ext.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wpa81\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wpa81\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Hyak.Common">
<HintPath>..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common">
<HintPath>..\..\packages\Microsoft.Azure.Common.2.0.4\lib\portable-net45+wp8+wpa81+win\Microsoft.Azure.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Spatial">
<HintPath>..\..\packages\Microsoft.Spatial.6.10.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.Spatial.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Search">
<HintPath>..\..\packages\Microsoft.Azure.Search.0.13.0-preview\lib\portable-net45+wp8+wpa81+win\Microsoft.Azure.Search.dll</HintPath>
</Reference>
<Reference Include="RZTransitions">
<HintPath>..\..\Components\RZTransitions-1.2.0.0\lib\ios-unified\RZTransitions.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -232,6 +193,60 @@
<Reference Include="Plugin.Connectivity.Abstractions">
<HintPath>..\..\packages\Xam.Plugin.Connectivity.2.0.2\lib\Xamarin.iOS10\Plugin.Connectivity.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Acr.UserDialogs">
<HintPath>..\..\packages\Acr.UserDialogs.4.2.1\lib\Xamarin.iOS10\Acr.UserDialogs.dll</HintPath>
</Reference>
<Reference Include="Acr.UserDialogs.Interface">
<HintPath>..\..\packages\Acr.UserDialogs.4.2.1\lib\Xamarin.iOS10\Acr.UserDialogs.Interface.dll</HintPath>
</Reference>
<Reference Include="BTProgressHUD">
<HintPath>..\..\packages\Acr.UserDialogs.4.2.1\lib\Xamarin.iOS10\BTProgressHUD.dll</HintPath>
</Reference>
<Reference Include="System.Collections" />
<Reference Include="System.Diagnostics.Debug" />
<Reference Include="System.Diagnostics.Tools" />
<Reference Include="System.Globalization" />
<Reference Include="System.IO" />
<Reference Include="System.Linq" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Primitives" />
<Reference Include="System.ObjectModel" />
<Reference Include="System.Reflection" />
<Reference Include="System.Reflection.Extensions" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Text.Encoding" />
<Reference Include="Microsoft.WindowsAzure.Mobile">
<HintPath>..\..\packages\Microsoft.Azure.Mobile.Client.2.0.1\lib\Xamarin.iOS10\Microsoft.WindowsAzure.Mobile.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Mobile.Ext">
<HintPath>..\..\packages\Microsoft.Azure.Mobile.Client.2.0.1\lib\Xamarin.iOS10\Microsoft.WindowsAzure.Mobile.Ext.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Insights">
<HintPath>..\..\packages\Xamarin.Insights.1.11.3\lib\Xamarin.iOS10\Xamarin.Insights.dll</HintPath>
</Reference>
<Reference Include="PLCrashReporterUnifiedBinding">
<HintPath>..\..\packages\Xamarin.Insights.1.11.3\lib\Xamarin.iOS10\PLCrashReporterUnifiedBinding.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime">
<HintPath>..\..\packages\Microsoft.Rest.ClientRuntime.1.8.1\lib\portable-net45+win+wpa81\Microsoft.Rest.ClientRuntime.dll</HintPath>
</Reference>
<Reference Include="System.Threading" />
<Reference Include="System.Threading.Tasks" />
<Reference Include="System.Xml.ReaderWriter" />
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
<HintPath>..\..\packages\Microsoft.Rest.ClientRuntime.Azure.2.5.2\lib\portable-net45+win+wpa81\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
</Reference>
<Reference Include="System.Linq.Expressions" />
<Reference Include="System.Xml.XmlSerializer" />
<Reference Include="Microsoft.Spatial">
<HintPath>..\..\packages\Microsoft.Spatial.6.13.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.Spatial.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Search">
<HintPath>..\..\packages\Microsoft.Azure.Search.1.0.2-preview\lib\portable-net403+win8+wpa81\Microsoft.Azure.Search.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Shared\BeerDrinkinAPI\BeerDrinkinAPI.csproj">
Expand Down Expand Up @@ -447,6 +462,11 @@
<Compile Include="DataSources\BeerDescriptionDataSource.cs" />
<Compile Include="Helpers\Style.cs" />
<Compile Include="DataSources\CheckInDataSource.cs" />
<Compile Include="Custom Controls\PlaceholderTextView.cs" />
<Compile Include="RateBeerViewController.cs" />
<Compile Include="RateBeerViewController.designer.cs">
<DependentUpon>RateBeerViewController.cs</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Import Project="..\packages\Xamarin.Insights.1.10.5\build\Xamarin.iOS10\Xamarin.Insights.targets" Condition="Exists('..\packages\Xamarin.Insights.1.10.5\build\Xamarin.iOS10\Xamarin.Insights.targets')" />
Expand Down Expand Up @@ -549,6 +569,10 @@
<BundleResource Include="Resources\account_settings.png" />
<BundleResource Include="Resources\account_starBlueEmpty.png" />
<BundleResource Include="Resources\account_starBlueFull.png" />
<BundleResource Include="Resources\checkin_addLocation.png" />
<BundleResource Include="Resources\checkin_camera.png" />
<BundleResource Include="Resources\checkin_starEmpty.png" />
<BundleResource Include="Resources\checkin_starFilled.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Properties\_SettingsStarted.txt" />
Expand Down Expand Up @@ -611,7 +635,7 @@
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
</Target>
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<Import Project="..\..\packages\Xamarin.Insights.1.11.2\build\Xamarin.iOS10\Xamarin.Insights.targets" Condition="Exists('..\..\packages\Xamarin.Insights.1.11.2\build\Xamarin.iOS10\Xamarin.Insights.targets')" />
<Import Project="..\..\packages\Xamarin.Insights.1.11.3\build\Xamarin.iOS10\Xamarin.Insights.targets" Condition="Exists('..\..\packages\Xamarin.Insights.1.11.3\build\Xamarin.iOS10\Xamarin.Insights.targets')" />
<ItemGroup />
<ItemGroup>
<ImageAsset Include="Resources\Icons.xcassets\AppIcons.appiconset\Contents.json" />
Expand Down
52 changes: 52 additions & 0 deletions Mobile/iOS/Custom Controls/PlaceholderTextView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using CoreGraphics;
using Foundation;
using UIKit;

namespace BeerDrinkin.iOS.CustomControls
{
[Register("PlaceholderTextView")]
public class PlaceholderTextView : UITextView
{
/// <summary>
/// Gets or sets the placeholder to show prior to editing - doesn't exist on UITextView by default
/// </summary>
public string Placeholder { get; set; }

public PlaceholderTextView ()
{
Initialize ();
}

public PlaceholderTextView (CGRect frame)
: base(frame)
{
Initialize ();
}

public PlaceholderTextView (IntPtr handle)
: base(handle)
{
Initialize ();
}

void Initialize ()
{
Placeholder = "Write a comment";

ShouldBeginEditing = t => {
if (Text == Placeholder)
Text = string.Empty;

return true;
};
ShouldEndEditing = t => {
if (string.IsNullOrEmpty (Text))
Text = Placeholder;

return true;
};
}
}
}

Loading

0 comments on commit d61e436

Please sign in to comment.