Skip to content

Commit a79eb1c

Browse files
committed
[todo11] port to iOS 11
1 parent 704ae58 commit a79eb1c

File tree

107 files changed

+3065
-40
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3065
-40
lines changed

To9o/To11oIntentUI/Entitlements.plist

Lines changed: 0 additions & 6 deletions
This file was deleted.

Todo11/Todo11.sln

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Todo11", "Todo11\Todo11.csproj", "{08A1E777-C427-42A1-9DB4-F7C9105E389B}"
5+
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Todo11Intent", "Todo11Intent\Todo11Intent.csproj", "{60E28139-F7B6-4BD8-8C77-2D8A0E062BCC}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Todo11ntentUI", "Todo11IntentUI\Todo11ntentUI.csproj", "{74B7D001-16ED-4DD3-B1BB-2EDD79EE2829}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|iPhoneSimulator = Debug|iPhoneSimulator
13+
Release|iPhoneSimulator = Release|iPhoneSimulator
14+
Debug|iPhone = Debug|iPhone
15+
Release|iPhone = Release|iPhone
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{08A1E777-C427-42A1-9DB4-F7C9105E389B}.Debug|iPhone.ActiveCfg = Debug|iPhone
19+
{08A1E777-C427-42A1-9DB4-F7C9105E389B}.Debug|iPhone.Build.0 = Debug|iPhone
20+
{08A1E777-C427-42A1-9DB4-F7C9105E389B}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
21+
{08A1E777-C427-42A1-9DB4-F7C9105E389B}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
22+
{08A1E777-C427-42A1-9DB4-F7C9105E389B}.Release|iPhone.ActiveCfg = Release|iPhone
23+
{08A1E777-C427-42A1-9DB4-F7C9105E389B}.Release|iPhone.Build.0 = Release|iPhone
24+
{08A1E777-C427-42A1-9DB4-F7C9105E389B}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
25+
{08A1E777-C427-42A1-9DB4-F7C9105E389B}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
26+
{60E28139-F7B6-4BD8-8C77-2D8A0E062BCC}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
27+
{60E28139-F7B6-4BD8-8C77-2D8A0E062BCC}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
28+
{60E28139-F7B6-4BD8-8C77-2D8A0E062BCC}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
29+
{60E28139-F7B6-4BD8-8C77-2D8A0E062BCC}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
30+
{60E28139-F7B6-4BD8-8C77-2D8A0E062BCC}.Debug|iPhone.ActiveCfg = Debug|iPhone
31+
{60E28139-F7B6-4BD8-8C77-2D8A0E062BCC}.Debug|iPhone.Build.0 = Debug|iPhone
32+
{60E28139-F7B6-4BD8-8C77-2D8A0E062BCC}.Release|iPhone.ActiveCfg = Release|iPhone
33+
{60E28139-F7B6-4BD8-8C77-2D8A0E062BCC}.Release|iPhone.Build.0 = Release|iPhone
34+
{74B7D001-16ED-4DD3-B1BB-2EDD79EE2829}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
35+
{74B7D001-16ED-4DD3-B1BB-2EDD79EE2829}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
36+
{74B7D001-16ED-4DD3-B1BB-2EDD79EE2829}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
37+
{74B7D001-16ED-4DD3-B1BB-2EDD79EE2829}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
38+
{74B7D001-16ED-4DD3-B1BB-2EDD79EE2829}.Debug|iPhone.ActiveCfg = Debug|iPhone
39+
{74B7D001-16ED-4DD3-B1BB-2EDD79EE2829}.Debug|iPhone.Build.0 = Debug|iPhone
40+
{74B7D001-16ED-4DD3-B1BB-2EDD79EE2829}.Release|iPhone.ActiveCfg = Release|iPhone
41+
{74B7D001-16ED-4DD3-B1BB-2EDD79EE2829}.Release|iPhone.Build.0 = Release|iPhone
42+
EndGlobalSection
43+
EndGlobal

Todo11/Todo11/AppDelegate.cs

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
using Foundation;
6+
using UIKit;
7+
using System.IO;
8+
using SQLite;
9+
using CoreSpotlight;
10+
11+
using Intents;
12+
using UserNotifications;
13+
14+
namespace To11oApp
15+
{
16+
// The UIApplicationDelegate for the application. This class is responsible for launching the
17+
// User Interface of the application, as well as listening (and optionally responding) to
18+
// application events from iOS.
19+
[Register ("AppDelegate")]
20+
public partial class AppDelegate : UIApplicationDelegate
21+
{
22+
public override UIWindow Window {
23+
get;
24+
set;
25+
}
26+
27+
public static INSiriAuthorizationStatus SiriAuthorizationStatus { get; set; }
28+
29+
#region Database set-up
30+
public static AppDelegate Current { get; private set; }
31+
public TodoManager TodoMgr { get; set; }
32+
SQLite.SQLiteConnection conn;
33+
#endregion
34+
35+
36+
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
37+
{
38+
Current = this;
39+
40+
41+
42+
#region Database set-up
43+
var sqliteFilename = "TodoDB.db3";
44+
// we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
45+
// (they don't want non-user-generated data in Documents)
46+
string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
47+
string libraryPath = Path.Combine (documentsPath, "..", "Library"); // Library folder
48+
var path = Path.Combine(libraryPath, sqliteFilename);
49+
conn = new SQLite.SQLiteConnection(path);
50+
TodoMgr = new TodoManager(conn);
51+
#endregion
52+
53+
#region Theme
54+
UINavigationBar.Appearance.TintColor = UIColor.FromRGB (0x61, 0x4C, 0xA0); // 614CA0 dark-purple
55+
UINavigationBar.Appearance.BarTintColor = UIColor.FromRGB (0xCE, 0xC0, 0xEC); // CEC0EC light-purple
56+
57+
UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes() {
58+
TextColor = UIColor.FromRGB (0x61, 0x4C, 0xA0), // 614CA0 dark-purple
59+
TextShadowColor = UIColor.Clear
60+
});
61+
#endregion
62+
63+
Console.WriteLine ("bbbbbbbbbb FinishedLaunching");
64+
65+
#region Quick Action
66+
var shouldPerformAdditionalDelegateHandling = true;
67+
68+
// Get possible shortcut item
69+
if (launchOptions != null) {
70+
LaunchedShortcutItem = launchOptions [UIApplication.LaunchOptionsShortcutItemKey] as UIApplicationShortcutItem;
71+
shouldPerformAdditionalDelegateHandling = (LaunchedShortcutItem == null);
72+
}
73+
#endregion
74+
75+
return shouldPerformAdditionalDelegateHandling;
76+
}
77+
78+
#region Quick Action
79+
//
80+
// if app is already running (otherwise went through FinishedLaunching)
81+
public override void PerformActionForShortcutItem (UIApplication application, UIApplicationShortcutItem shortcutItem, UIOperationHandler completionHandler)
82+
{
83+
Console.WriteLine ("dddddddd PerformActionForShortcutItem");
84+
// Perform action
85+
var handled = HandleShortcutItem(shortcutItem);
86+
completionHandler(handled);
87+
}
88+
89+
public UIApplicationShortcutItem LaunchedShortcutItem { get; set; }
90+
public override void OnActivated (UIApplication application)
91+
{
92+
Console.WriteLine ("ccccccc OnActivated");
93+
94+
// Handle any shortcut item being selected
95+
HandleShortcutItem(LaunchedShortcutItem);
96+
97+
// Clear shortcut after it's been handled
98+
LaunchedShortcutItem = null;
99+
}
100+
101+
102+
public bool HandleShortcutItem(UIApplicationShortcutItem shortcutItem) {
103+
Console.WriteLine ("eeeeeeeeeee HandleShortcutItem ");
104+
var handled = false;
105+
106+
// Anything to process?
107+
if (shortcutItem == null) return false;
108+
109+
// Take action based on the shortcut type
110+
switch (shortcutItem.Type) {
111+
case ShortcutIdentifiers.Add:
112+
Console.WriteLine ("QUICKACTION: Add new item");
113+
114+
handled = true;
115+
break;
116+
case ShortcutIdentifiers.Share:
117+
Console.WriteLine ("QUICKACTION: Share summary of items");
118+
handled = true;
119+
break;
120+
}
121+
122+
//HACK: show the detail viewcontroller
123+
ContinueNavigation ();
124+
125+
Console.Write (handled);
126+
// Return results
127+
return handled;
128+
}
129+
#endregion
130+
131+
#region NSUserActivity AND CoreSpotlight
132+
// http://www.raywenderlich.com/84174/ios-8-handoff-tutorial
133+
public override bool ContinueUserActivity (UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
134+
{
135+
Console.WriteLine ("ffffffff ContinueUserActivity");
136+
137+
UIViewController tvc = null;
138+
139+
// NSUserActivity
140+
if ((userActivity.ActivityType == ActivityTypes.Add)
141+
|| (userActivity.ActivityType == ActivityTypes.Detail))
142+
{
143+
if (userActivity.UserInfo.Count == 0) {
144+
// new item
145+
146+
} else {
147+
var uid = userActivity.UserInfo.ObjectForKey ((NSString)"id").ToString ();
148+
if (uid == "0") {
149+
Console.WriteLine ("No userinfo found for " + ActivityTypes.Detail);
150+
} else {
151+
Console.WriteLine ("Should display id " + uid);
152+
// handled in DetailViewController.RestoreUserActivityState
153+
}
154+
}
155+
tvc = ContinueNavigation ();
156+
157+
}
158+
// CoreSpotlight
159+
if (userActivity.ActivityType == CSSearchableItem.ActionType) {
160+
var uid = userActivity.UserInfo.ObjectForKey
161+
(CSSearchableItem.ActivityIdentifier).ToString();
162+
163+
System.Console.WriteLine ("Show the detail for id:" + uid);
164+
165+
tvc = ContinueNavigation ();
166+
167+
}
168+
completionHandler(new NSObject[] {tvc});
169+
170+
return true;
171+
}
172+
#endregion
173+
174+
//
175+
// called for Quick Action AND NSUserActivity
176+
UIViewController ContinueNavigation (){
177+
Console.WriteLine ("gggggggggg ContinueNavigation");
178+
179+
// 1. load screen
180+
var sb = UIStoryboard.FromName ("MainStoryboard", null);
181+
var tvc = sb.InstantiateViewController("detailvc") as DetailViewController;
182+
183+
// 2. set initial state
184+
var r = Window.RootViewController as UINavigationController;
185+
r.PopToRootViewController (false);
186+
187+
// 3. populate and display screen
188+
tvc.SetTodo (new TodoItem {Name="(new action)"}); // from 3D Touch menu
189+
tvc.Delegate = CollectionController.Current;
190+
r.PushViewController (tvc, false);
191+
return tvc;
192+
}
193+
194+
195+
}
196+
}

0 commit comments

Comments
 (0)