Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/port objc to swift #2

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9702a53
initial commit of partially translated code from objective-c to swift
sreilly Jan 23, 2017
041309d
Remove non-compiling code
subsymbolic Jan 24, 2017
7cbf496
Add launch screen
subsymbolic Jan 24, 2017
a57b609
Add private browser
subsymbolic Jan 24, 2017
1afef50
Update private browser to clear in non-persitence cache used by webview
subsymbolic Jan 25, 2017
cec3b5e
Add AppCode generated files to gitignore
subsymbolic Jan 25, 2017
c49747b
Update ddg url query params to hide website search bar in app
subsymbolic Jan 25, 2017
8a85201
Move private browsing specific logic into extension
subsymbolic Jan 25, 2017
40930e3
Added search / link entry support and progress bar
subsymbolic Jan 26, 2017
b54f809
Remove unused code
subsymbolic Jan 26, 2017
76b7486
Cleanup and more tests
subsymbolic Jan 26, 2017
b3bf1dc
Implement private browser
subsymbolic Jan 27, 2017
ff00bd2
Merge branch 'develop' into feature/private_browsing
subsymbolic Jan 30, 2017
4c9a096
Improve navigation and browsing experience
subsymbolic Jan 30, 2017
4ece84b
added code migrated from old app
sreilly Jan 31, 2017
d7650c3
Merge branch 'feature/navigation' of github.com:TheInfiniteKind/duckd…
sreilly Jan 31, 2017
ea36c84
Remove unused view controller from storyboard
subsymbolic Jan 31, 2017
d902fe3
migrated browser controller now working with gestures and toolbar beh…
sreilly Jan 31, 2017
157140e
Merge branch 'feature/navigation' of github.com:TheInfiniteKind/duckd…
sreilly Jan 31, 2017
7a4931a
minor cleanup - fix warnings, xib file connections, etc
sreilly Jan 31, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ DerivedData/
*.perspectivev3
!default.perspectivev3
xcuserdata/
.idea

## Other
*.moved-aside
Expand Down
734 changes: 734 additions & 0 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

111 changes: 111 additions & 0 deletions DuckDuckGo.xcodeproj/xcshareddata/xcschemes/DuckDuckGo.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84E341911E2F7EFB00BDBA6F"
BuildableName = "DuckDuckGo.app"
BlueprintName = "DuckDuckGo"
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84E341A51E2F7EFB00BDBA6F"
BuildableName = "DuckDuckGoTests.xctest"
BlueprintName = "DuckDuckGoTests"
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84E341B01E2F7EFC00BDBA6F"
BuildableName = "DuckDuckGoUITests.xctest"
BlueprintName = "DuckDuckGoUITests"
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84E341911E2F7EFB00BDBA6F"
BuildableName = "DuckDuckGo.app"
BlueprintName = "DuckDuckGo"
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84E341911E2F7EFB00BDBA6F"
BuildableName = "DuckDuckGo.app"
BlueprintName = "DuckDuckGo"
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "84E341911E2F7EFB00BDBA6F"
BuildableName = "DuckDuckGo.app"
BlueprintName = "DuckDuckGo"
ReferencedContainer = "container:DuckDuckGo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
84 changes: 84 additions & 0 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// AppDelegate.swift
// DuckDuckGo
//
// Created by Mia Alexiou on 18/01/2017.
// Copyright © 2017 DuckDuckGo. All rights reserved.
//

import UIKit

let DDGSettingRegion = "region"
let DDGSettingAutocomplete = "autocomplete"
let DDGSettingSuppressBangTooltip = "suppress_bang_tooltip"
let DDGSettingStoriesReadabilityMode = "readability_mode"


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
var duckController: DDGSearchController?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
application.statusBarStyle = .lightContent

NSSetUncaughtExceptionHandler { exception in print("CRASH: \(exception)") }

self.duckController = DDGSearchController()
self.duckController?.pushContentViewController(DDGDuckViewController(searchController:self.duckController!), animated: false)

self.window = UIWindow(frame:UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.duckSearchBarBackground
self.window?.rootViewController = self.duckController
self.window?.makeKeyAndVisible()

self.updateShortcuts()

if let shortcutItem = launchOptions?[.shortcutItem] {
self.handleShortCutItem(shortcutItem as! UIApplicationShortcutItem)
}

return true
}


func handleShortCutItem(_ shortcutItem: UIApplicationShortcutItem) {
print("handleShortCutItem: \(shortcutItem.type)")
switch shortcutItem.type {
case "com.duckduckgo.mobile.ios.search":
self.duckController?.loadQueryOrURL(shortcutItem.localizedTitle)
case "com.duckduckgo.mobile.ios.searchclipboard":
if let pasteboardString = UIPasteboard.general.string {
self.duckController?.loadQueryOrURL(pasteboardString)
} else {
self.duckController?.clearAddressBar()
}
case "com.duckduckgo.mobile.ios.newSearch":
self.duckController?.clearAddressBar()
default:
break
}
}


// update the 3D/force-touch home screen shortcuts
func updateShortcuts() {
let app = UIApplication.shared
var shortcuts:[UIApplicationShortcutItem] = []

let searchIcon = UIApplicationShortcutIcon.init(templateImageName: "Tab-Search")
//let faveIcon = UIApplicationShortcutIcon.init(templateImageName: "Tab-Favorites")

shortcuts.append(UIApplicationShortcutItem(type: "com.duckduckgo.mobile.ios.searchclipboard",
localizedTitle: "Open Clipboard",
localizedSubtitle: "Open URL or search DuckDuckGo for the contents of your clipboard",
icon: searchIcon,
userInfo: nil))
app.shortcutItems = shortcuts
}


}

28 changes: 28 additions & 0 deletions DuckDuckGo/AppUrls.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// AppUrls.swift
// DuckDuckGo
//
// Created by Mia Alexiou on 24/01/2017.
// Copyright © 2017 DuckDuckGo. All rights reserved.
//

import Foundation

struct AppUrls {

static let duckDuckGoBase = "duckduckgo.com"

static let home = "https://www.duckduckgo.com?ko=-1&kl=wt-wt"

static func search(text: String) -> URL? {
guard let encodedQuery = URL.encode(queryText: text) else {
return nil
}
let url = "\(home)&q=\(encodedQuery)"
return URL(string: url)
}

static func isDuckDuckGo(url: URL) -> Bool {
return url.absoluteString.contains(duckDuckGoBase)
}
}