Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit 8fb8830

Browse files
committed
Fixed Pinned Repo Image issue, added Enable Enterprise support
1 parent 6ca7aa5 commit 8fb8830

14 files changed

Lines changed: 290 additions & 16 deletions

CodeHub.Core/Services/IFeaturesService.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public interface IFeaturesService
77
{
88
bool IsPushNotificationsActivated { get; set; }
99

10+
bool IsEnterpriseSupportActivated { get; set; }
11+
1012
void Activate(string id);
1113

1214
bool IsActivated(string id);
@@ -17,6 +19,7 @@ public interface IFeaturesService
1719
public static class FeatureIds
1820
{
1921
public const string PushNotifications = "com.dillonbuchanan.codehub.push";
22+
public const string EnterpriseSupport = "com.dillonbuchanan.codehub.enterprise_support";
2023
}
2124
}
2225

CodeHub.iOS/CodeHub.iOS.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
6-
<ProductVersion>8.0.30703</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
86
<ProjectGuid>{B061316A-F386-4FE2-93B7-555584234FF8}</ProjectGuid>
97
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
108
<OutputType>Exe</OutputType>
@@ -221,6 +219,11 @@
221219
<Compile Include="Views\App\AboutView.cs" />
222220
<Compile Include="Views\Teams\TeamsView.cs" />
223221
<Compile Include="Views\Teams\TeamMembersView.cs" />
222+
<Compile Include="Views\App\EnableEnterpriseViewController.cs" />
223+
<Compile Include="Views\App\EnableEnterpriseViewController.designer.cs">
224+
<DependentUpon>EnableEnterpriseViewController.cs</DependentUpon>
225+
</Compile>
226+
<InterfaceDefinition Include="Views\App\EnableEnterpriseViewController.xib" />
224227
</ItemGroup>
225228
<ItemGroup>
226229
<ProjectReference Include="..\lib\CodeFramework\CodeFramework.iOS\CodeFramework.iOS.csproj">
@@ -284,9 +287,6 @@
284287
<HintPath>..\lib\CodeFramework\lib\iOS\MTiRate.dll</HintPath>
285288
</Reference>
286289
<Reference Include="System.Net.Http" />
287-
<Reference Include="OHAttributedLabel">
288-
<HintPath>..\lib\CodeFramework\lib\iOS\OHAttributedLabel.dll</HintPath>
289-
</Reference>
290290
</ItemGroup>
291291
<ItemGroup>
292292
<Content Include="Images\anonymous%402x.png" />
@@ -436,6 +436,7 @@
436436
<BundleResource Include="Images\MarkdownComposer\picture.png" />
437437
<BundleResource Include="Images\login_user_unknown%402x.png" />
438438
<BundleResource Include="Images\login_user_unknown.png" />
439+
<BundleResource Include="Images\enterprise.png" />
439440
</ItemGroup>
440441
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
441442
<ItemGroup>

CodeHub.iOS/Images/Images.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public static Uri GitHubRepoForkUrl
6464

6565
public static class Logos
6666
{
67-
public static UIImage GitHub { get { return UIImage.FromFile("Images/Logos/github.png"); } }
67+
public static UIImage GitHub { get { return UIImage.FromFile("Images/Logos/github.png"); } }
68+
public static UIImage Enterprise { get { return UIImage.FromFile("Images/enterprise.png"); } }
6869
}
6970

7071
public static class Buttons

CodeHub.iOS/Images/enterprise.png

15 KB
Loading

CodeHub.iOS/InAppPurchases.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public static async Task<SKProductsResponse> RequestProductData (params string[]
5555
productsRequest.ReceivedResponse += (sender, e) => tcs.SetResult(e.Response);
5656
productsRequest.RequestFailed += (sender, e) => tcs.SetException(new Exception(e.Error.LocalizedDescription));
5757
productsRequest.Start();
58-
return await tcs.Task;
58+
var ret = await tcs.Task;
59+
productsRequest.Dispose();
60+
return ret;
5961
}
6062

6163
public static bool CanMakePayments()

CodeHub.iOS/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<key>CFBundleIdentifier</key>
2222
<string>com.dillonbuchanan.codehub</string>
2323
<key>CFBundleShortVersionString</key>
24-
<string>2.3.1</string>
24+
<string>2.3.2</string>
2525
<key>CFBundleIconFiles</key>
2626
<array>
2727
<string>Icon-60@2x</string>
@@ -68,6 +68,6 @@
6868
</dict>
6969
</array>
7070
<key>CFBundleVersion</key>
71-
<string>2.3.1</string>
71+
<string>2.3.2</string>
7272
</dict>
7373
</plist>

CodeHub.iOS/Services/FeaturesService.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ public bool IsPushNotificationsActivated
3232
}
3333
}
3434

35+
public bool IsEnterpriseSupportActivated
36+
{
37+
get
38+
{
39+
return IsActivated(FeatureIds.EnterpriseSupport);
40+
}
41+
set
42+
{
43+
_defaultValueService.Set(FeatureIds.EnterpriseSupport, value);
44+
}
45+
}
46+
3547
public void Activate(string id)
3648
{
3749
InAppPurchases.Instance.PurchaseProduct(id);
@@ -45,11 +57,14 @@ public bool IsActivated(string id)
4557

4658
public async Task<IEnumerable<string>> GetAvailableFeatureIds()
4759
{
60+
var ids = new List<string>();
61+
ids.Add(FeatureIds.EnterpriseSupport);
4862
var client = _httpClientService.Create();
4963
client.Timeout = new TimeSpan(0, 0, 15);
5064
var response = await client.GetAsync("http://push.codehub-app.com/in-app");
5165
var data = await response.Content.ReadAsStringAsync();
52-
return _jsonSerializationService.Deserialize<List<string>>(data).ToArray();
66+
ids.AddRange(_jsonSerializationService.Deserialize<List<string>>(data));
67+
return ids;
5368
}
5469
}
5570
}

CodeHub.iOS/Views/Accounts/NewAccountView.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
using CodeHub.Core.ViewModels.Accounts;
55
using MonoTouch;
66
using MonoTouch.UIKit;
7+
using Cirrious.CrossCore;
8+
using CodeHub.Core.Services;
9+
using CodeHub.iOS.Views.App;
710

811
namespace CodeHub.iOS.Views.Accounts
912
{
@@ -34,11 +37,28 @@ public override void ViewDidLoad()
3437
EnterpriseButton.Layer.ShadowOpacity = 0.3f;
3538

3639
var set = this.CreateBindingSet<NewAccountView, NewAccountViewModel>();
37-
set.Bind(EnterpriseButton).To(x => x.GoToEnterpriseLoginCommand);
3840
set.Bind(InternetButton).To(x => x.GoToDotComLoginCommand);
39-
set.Apply();
41+
set.Apply();
42+
43+
EnterpriseButton.TouchUpInside += (object sender, System.EventArgs e) => GoToEnterprise();
4044

4145
ScrollView.ContentSize = new SizeF(View.Bounds.Width, EnterpriseButton.Frame.Bottom + 10f);
46+
}
47+
48+
private void GoToEnterprise()
49+
{
50+
var features = Mvx.Resolve<IFeaturesService>();
51+
if (features.IsEnterpriseSupportActivated)
52+
((NewAccountViewModel)ViewModel).GoToEnterpriseLoginCommand.Execute(null);
53+
else
54+
{
55+
var ctrl = new EnableEnterpriseViewController();
56+
ctrl.Dismissed += (sender, e) => {
57+
if (features.IsEnterpriseSupportActivated)
58+
((NewAccountViewModel)ViewModel).GoToEnterpriseLoginCommand.Execute(null);
59+
};
60+
PresentViewController(ctrl, true, null);
61+
}
4262
}
4363
}
4464
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
using System;
2+
using System.Drawing;
3+
using MonoTouch.Foundation;
4+
using MonoTouch.UIKit;
5+
using CodeFramework.iOS.Utils;
6+
using Cirrious.CrossCore;
7+
using CodeHub.Core.Services;
8+
9+
namespace CodeHub.iOS.Views.App
10+
{
11+
public partial class EnableEnterpriseViewController : UIViewController
12+
{
13+
private IHud _hud;
14+
15+
public EnableEnterpriseViewController() : base("EnableEnterpriseViewController", null)
16+
{
17+
}
18+
19+
public event EventHandler Dismissed;
20+
21+
private void OnDismissed()
22+
{
23+
var handler = Dismissed;
24+
if (handler != null)
25+
handler(this, EventArgs.Empty);
26+
}
27+
28+
public override void ViewDidLoad()
29+
{
30+
base.ViewDidLoad();
31+
32+
this.View.AutosizesSubviews = true;
33+
34+
ImageView.Image = Images.Logos.Enterprise;
35+
ImageView.Layer.CornerRadius = 24f;
36+
ImageView.Layer.MasksToBounds = true;
37+
38+
CancelButton.SetBackgroundImage(Images.Buttons.GreyButton.CreateResizableImage(new UIEdgeInsets(18, 18, 18, 18)), UIControlState.Normal);
39+
CancelButton.TintColor = UIColor.Black;
40+
CancelButton.Layer.ShadowColor = UIColor.Black.CGColor;
41+
CancelButton.Layer.ShadowOffset = new SizeF(0, 1);
42+
CancelButton.Layer.ShadowOpacity = 0.3f;
43+
CancelButton.TouchUpInside += (sender, e) => DismissViewController(true, OnDismissed);
44+
45+
EnableButton.SetBackgroundImage(Images.Buttons.BlackButton.CreateResizableImage(new UIEdgeInsets(18, 18, 18, 18)), UIControlState.Normal);
46+
EnableButton.TintColor = UIColor.White;
47+
EnableButton.Layer.ShadowColor = UIColor.Black.CGColor;
48+
EnableButton.Layer.ShadowOffset = new SizeF(0, 1);
49+
EnableButton.Layer.ShadowOpacity = 0.3f;
50+
EnableButton.TouchUpInside += EnablePushNotifications;
51+
52+
_hud = new Hud(View);
53+
}
54+
55+
public override void ViewWillLayoutSubviews()
56+
{
57+
base.ViewWillLayoutSubviews();
58+
59+
ContainerView.Frame = new RectangleF(View.Bounds.Width / 2 - ContainerView.Frame.Width / 2,
60+
View.Bounds.Height / 2 - ContainerView.Frame.Height / 2,
61+
ContainerView.Frame.Width, ContainerView.Frame.Height);
62+
}
63+
64+
public override void ViewDidAppear(bool animated)
65+
{
66+
base.ViewDidAppear(animated);
67+
InAppPurchases.Instance.PurchaseSuccess += HandlePurchaseSuccess;
68+
InAppPurchases.Instance.PurchaseError += HandlePurchaseError;
69+
}
70+
71+
public override void ViewDidDisappear(bool animated)
72+
{
73+
base.ViewDidDisappear(animated);
74+
InAppPurchases.Instance.PurchaseSuccess -= HandlePurchaseSuccess;
75+
InAppPurchases.Instance.PurchaseError -= HandlePurchaseError;
76+
}
77+
78+
void HandlePurchaseError (object sender, Exception e)
79+
{
80+
_hud.Hide();
81+
}
82+
83+
void HandlePurchaseSuccess (object sender, string e)
84+
{
85+
_hud.Hide();
86+
DismissViewController(true, OnDismissed);
87+
}
88+
89+
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations()
90+
{
91+
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
92+
return UIInterfaceOrientationMask.Portrait;
93+
return base.GetSupportedInterfaceOrientations();
94+
}
95+
96+
public override UIInterfaceOrientation PreferredInterfaceOrientationForPresentation()
97+
{
98+
if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
99+
return UIInterfaceOrientation.Portrait;
100+
return base.PreferredInterfaceOrientationForPresentation();
101+
}
102+
103+
private void EnablePushNotifications(object sender, EventArgs e)
104+
{
105+
_hud.Show("Enabling...");
106+
var featureService = Mvx.Resolve<IFeaturesService>();
107+
featureService.Activate(FeatureIds.EnterpriseSupport);
108+
}
109+
}
110+
}
111+

CodeHub.iOS/Views/App/EnableEnterpriseViewController.designer.cs

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)