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

Menu 2.0 #1058

Merged
merged 42 commits into from Jun 6, 2019
Merged

Menu 2.0 #1058

Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
57860c2
MVP for iPhone
iccub Apr 2, 2019
d2a4044
Migrate urlbar items to stackview
iccub Apr 3, 2019
0e2a935
Better naming and file separation for toolbar objects
iccub Apr 3, 2019
799f2c7
WIP: menu actions
iccub Apr 6, 2019
1f25420
Long press actions: dismissal and refactor.
iccub Apr 8, 2019
2cb5750
Remove HomeViewController
iccub Apr 8, 2019
191f371
BookmarksVC cleanup: remove unused code
iccub Apr 8, 2019
7926cfe
folder hirerarchy alpha version
iccub Apr 11, 2019
17afd7d
Make separator line work.
iccub Apr 11, 2019
bbdaa80
Add bookmark mvp, can add at root level.
iccub Apr 14, 2019
7d19867
Merge branch 'development' of github.com:brave/brave-ios into feature…
iccub Apr 14, 2019
ea4f0d8
Adding bookmark works.
iccub Apr 15, 2019
c3a737a
Add folders mvp
iccub Apr 15, 2019
ee76b6a
xcode 10.2
iccub Apr 15, 2019
f06a617
Correct buttons when adding a folder.
iccub Apr 16, 2019
02dab4c
Dismiss view when bookmark is selected.
iccub Apr 16, 2019
c0d29cd
Support editing modes in AddEditBookmarkVC
iccub Apr 16, 2019
736fc5e
Edit without saving location mvp.
iccub Apr 16, 2019
5138870
Edit bookmark location mvp
iccub Apr 17, 2019
ada5f14
Fetch favicon to bookmark details
iccub Apr 17, 2019
134d4a9
whitespace
iccub Apr 17, 2019
d68cad8
Add localized strings
iccub Apr 17, 2019
c022eb5
Edit improvements, title for add/edit screen
iccub Apr 17, 2019
7e30962
Remove unused BookmarkEditViewController
iccub Apr 17, 2019
f781004
Update image assets.
iccub Apr 17, 2019
1d5d612
Make folder detail height equal to folder hierarchy cells height.
iccub Apr 17, 2019
e6c7a1c
Harden against sync changes.
iccub Apr 17, 2019
93c9a24
Make updated url bar work with safe area insets
iccub Apr 17, 2019
880de9e
Show share menu popover at correct location.
iccub Apr 17, 2019
40f11b9
Design feedback from James.
iccub Apr 18, 2019
99b171f
Bookmark/folder detail views refactor.
iccub Apr 18, 2019
0bf5ddc
Header view refactor.
iccub Apr 18, 2019
c57f709
AddEditBookmarkTableViewController refactor.
iccub Apr 19, 2019
1d9e0c3
MenuViewController refactor.
iccub Apr 19, 2019
de90bd1
final touches
iccub Apr 19, 2019
32e1e30
Fix unit tests.
iccub Apr 19, 2019
bc45a12
review
iccub Apr 23, 2019
f7fd274
Make folderCellTag private
iccub Apr 23, 2019
839602c
Merge branch 'development' of github.com:brave/brave-ios into feature…
iccub Apr 23, 2019
8ad53f3
Swift 4.2 conformance
iccub Apr 23, 2019
21d08ed
Fix title helper function
iccub Apr 23, 2019
76ab847
Set syncParentUUID when updating location.
iccub Apr 23, 2019
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Merge branch 'development' of github.com:brave/brave-ios into feature…

…/menu2.0
  • Loading branch information
iccub committed Apr 14, 2019
commit 7d198671e338e4433d616bc0817e0c0a4f4494ca
@@ -1,5 +1,5 @@
language: swift
osx_image: xcode10.1
osx_image: xcode10.2
cache:
directories:
- Carthage
@@ -9,7 +9,7 @@ install: true
before_install:
- brew install carthage || true
- brew install swiftlint || true
- gem update fastlane --no-ri --no-rdoc --no-document
- gem update fastlane --no-document

before_script:
- bash bootstrap.sh
@@ -29,6 +29,7 @@ struct ReferralData {
init?(json: JSON) {
guard let downloadId = json["download_id"].string, let code = json["referral_code"].string else {
log.error("Failed to unwrap json to Referral struct.")
UrpLog.log("Failed to unwrap json to Referral struct. \(json)")
return nil
}

@@ -46,6 +46,7 @@ struct UrpService {
func referralCodeLookup(completion: @escaping (ReferralData?, UrpError?) -> Void) {
guard var endPoint = try? host.asURL() else {
completion(nil, .endpointError)
UrpLog.log("Host not a url: \(host)")
return
}
endPoint.appendPathComponent("promo/initialize/ua")
@@ -54,6 +55,7 @@ struct UrpService {

sessionManager.urpApiRequest(endPoint: endPoint, params: params) { response in
log.debug("Referral code lookup response: \(response)")
UrpLog.log("Referral code lookup response: \(response)")
let json = JSON(response.data as Any)

let referral = ReferralData(json: json)
@@ -29,7 +29,7 @@ public class UserReferralProgram {
return Bundle.main.infoDictionary?[key] as? String
}

let host = AppConstants.BuildChannel == .release ? HostUrl.prod : HostUrl.staging
let host = AppConstants.BuildChannel == .developer ? HostUrl.staging : HostUrl.prod

guard let apiKey = getPlistString(for: UserReferralProgram.apiKeyPlistKey) else {
log.error("Urp init error, failed to get values from Brave.plist.")
@@ -81,16 +81,14 @@ public class UserReferralProgram {
}

private func initRetryPingConnection(numberOfTimes: Int32) {
let _10minutes: TimeInterval = 10 * 60
if AppConstants.BuildChannel == .developer {
Preferences.URP.nextCheckDate.value = Date().timeIntervalSince1970 + _10minutes
} else {
let _30daysInSeconds = Double(30 * 24 * 60 * 60)
if AppConstants.BuildChannel.isRelease {
// Adding some time offset to be extra safe.
let offset = Double(1 * 60 * 60)
let _30daysFromToday = Date().timeIntervalSince1970 + _30daysInSeconds + offset

let offset = 1.hours
let _30daysFromToday = Date().timeIntervalSince1970 + 30.days + offset
Preferences.URP.nextCheckDate.value = _30daysFromToday
} else {
// For local and beta builds use a short timer
Preferences.URP.nextCheckDate.value = Date().timeIntervalSince1970 + 10.minutes
}

Preferences.URP.retryCountdown.value = Int(numberOfTimes)
@@ -173,8 +171,7 @@ public class UserReferralProgram {
// Appending ref code to dau ping if user used installed the app via user referral program.
if Preferences.URP.referralCodeDeleteDate.value == nil {
UrpLog.log("Setting new date for deleting referral code.")
let timeToDelete = AppConstants.BuildChannel == .developer ? TimeInterval(20 * 60) : TimeInterval(90 * 24 * 60 * 60)

let timeToDelete = AppConstants.BuildChannel.isRelease ? 90.days : 20.minutes
Preferences.URP.referralCodeDeleteDate.value = Date().timeIntervalSince1970 + timeToDelete
}

@@ -1,15 +1,15 @@
github "Alamofire/Alamofire" "4.7.3"
github "sleroux/Deferred" "Swift3.0"
github "SnapKit/SnapKit" "4.0.0"
github "rs/SDWebImage" "4.4.2"
github "swisspol/GCDWebServer" "3.4.2"
github "kif-framework/KIF" "v3.7.4"
github "mozilla-mobile/SwiftKeychainWrapper" "3.0.1"
github "DaveWoodCom/XCGLogger" "6.0.4"
github "cezheng/Fuzi" "2.1.0"
github "SwiftyJSON/SwiftyJSON" "4.1.0"
github "farhanpatel/JSONSchema.swift" "master"
github "path/FastImageCache" "1.5.1"
github "facebook/pop" "1.0.10"
github "xmartlabs/Eureka" "4.2.0"
github "venmo/Static" "v2.5.0"
github "Alamofire/Alamofire" "4.8.2"
github "garvankeeley/Deferred" "9.9.2"
github "SnapKit/SnapKit" "4.2.0"
github "rs/SDWebImage" "4.4.6"
github "swisspol/GCDWebServer" "3.5.2"
github "kif-framework/KIF" "v3.7.5"
github "jrendel/SwiftKeychainWrapper" "3.2.0"
github "DaveWoodCom/XCGLogger" "7.0.0"
github "cezheng/Fuzi" "2.2.1"
github "SwiftyJSON/SwiftyJSON" "4.2.0"
github "garvankeeley/JSONSchema.swift" "9.9.0"
github "path/FastImageCache" "1.5.1"
github "facebook/pop" "1.0.12"
github "xmartlabs/Eureka" "4.3.1"
github "venmo/Static" "v3.0.3"
@@ -1,15 +1,15 @@
github "Alamofire/Alamofire" "4.7.3"
github "DaveWoodCom/XCGLogger" "6.0.4"
github "SnapKit/SnapKit" "4.0.0"
github "SwiftyJSON/SwiftyJSON" "4.1.0"
github "cezheng/Fuzi" "2.1.0"
github "facebook/pop" "1.0.10"
github "farhanpatel/JSONSchema.swift" "1c052b83baa8c497e12cde6a8afca0f54574612f"
github "kif-framework/KIF" "v3.7.4"
github "mozilla-mobile/SwiftKeychainWrapper" "3.0.1"
github "Alamofire/Alamofire" "4.8.2"
github "DaveWoodCom/XCGLogger" "7.0.0"
github "SnapKit/SnapKit" "4.2.0"
github "SwiftyJSON/SwiftyJSON" "4.2.0"
github "cezheng/Fuzi" "2.2.1"
github "facebook/pop" "1.0.12"
github "garvankeeley/Deferred" "9.9.2"
github "garvankeeley/JSONSchema.swift" "9.9.0"
github "jrendel/SwiftKeychainWrapper" "3.2.0"
github "kif-framework/KIF" "v3.7.5"
github "path/FastImageCache" "1.5.1"
github "rs/SDWebImage" "4.4.2"
github "sleroux/Deferred" "35b8927c1b94ce074e10793c57e1f80d0e2227fa"
github "swisspol/GCDWebServer" "3.4.2"
github "venmo/Static" "v2.5.0"
github "xmartlabs/Eureka" "4.2.0"
github "rs/SDWebImage" "4.4.6"
github "swisspol/GCDWebServer" "3.5.2"
github "venmo/Static" "v3.0.3"
github "xmartlabs/Eureka" "4.3.1"
@@ -61,7 +61,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati
self.window!.backgroundColor = UIColor.Photon.White100

AdBlockStats.shared.startLoading()
AdblockResourceDownloader.shared.regionalAdblockResourcesSetup()

HttpsEverywhereStats.shared.startLoading()

@@ -245,6 +244,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati
log.error("Failed to initialize user referral program")
UrpLog.log("Failed to initialize user referral program")
}

AdblockResourceDownloader.shared.regionalAdblockResourcesSetup()

UINavigationBar.appearance().tintColor = BraveUX.BraveOrange

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -16,7 +16,7 @@ BASE_BUNDLE_ID = $(FRAMEWORK_BASE_BUNDLE_ID).ios

DEVELOPMENT_TEAM = KL8N8XSYF4

BRAVE_VERSION = 1.9
BRAVE_VERSION = 1.9.1
BRAVE_BUILD_ID=$(GENERATED_BUILD_ID)

// Additional Info //
@@ -26,6 +26,7 @@ class AppAuthenticator {
let w = UIWindow()
w.backgroundColor = .clear
w.rootViewController = self.blurController
w.windowLevel = UIWindow.Level(UIWindowLevelStatusBar - 1)
_window = w
}
return _window
@@ -665,11 +665,7 @@ class BrowserViewController: UIViewController {
webViewContainerTopOffset = make.top.equalTo(readerModeBar?.snp.bottom ?? self.header.snp.bottom).constraint

let findInPageHeight = (findInPageBar == nil) ? 0 : UIConstants.ToolbarHeight
if let toolbar = self.toolbar {
make.bottom.equalTo(toolbar.snp.top).offset(-findInPageHeight)
} else {
make.bottom.equalTo(self.view).offset(-findInPageHeight)
}
make.bottom.equalTo(self.footer.snp.top).offset(-findInPageHeight)
}

// Setup the bottom toolbar
@@ -681,6 +677,9 @@ class BrowserViewController: UIViewController {
footer.snp.remakeConstraints { make in
scrollController.footerBottomConstraint = make.bottom.equalTo(self.view.snp.bottom).constraint
make.leading.trailing.equalTo(self.view)
if self.toolbar == nil {
make.height.equalTo(0.0)
}
}

urlBar.setNeedsUpdateConstraints()
@@ -691,22 +690,16 @@ class BrowserViewController: UIViewController {
webViewContainerTopOffset = make.top.equalTo(readerModeBar?.snp.bottom ?? self.header.snp.bottom).constraint

make.left.right.equalTo(self.view)
if self.homePanelIsInline {
make.bottom.equalTo(self.toolbar?.snp.top ?? self.view.snp.bottom)
} else {
make.bottom.equalTo(self.view.snp.bottom)
}
make.bottom.equalTo(self.footer.snp.top)
}

alertStackView.snp.remakeConstraints { make in
make.centerX.equalTo(self.view)
make.width.equalTo(self.view.snp.width)
if let keyboardHeight = keyboardState?.intersectionHeightForView(self.view), keyboardHeight > 0 {
make.bottom.equalTo(self.view).offset(-keyboardHeight)
} else if let toolbar = self.toolbar {
make.bottom.equalTo(toolbar.snp.top)
} else {
make.bottom.equalTo(self.view)
make.bottom.equalTo(self.footer.snp.top)
}
}
}
@@ -23,25 +23,18 @@ class ContextMenuHelper: NSObject {

fileprivate var nativeHighlightLongPressRecognizer: UILongPressGestureRecognizer?
fileprivate var elements: Elements?
private var kvoInfo: (layer: CALayer?, observation: NSKeyValueObservation?) = (nil, nil)

required init(tab: Tab) {
super.init()
self.tab = tab
}

// BVC KVO events for all changes on the webview will call this. It is called a lot during a page load.
// BVC KVO events for all changes on the webview will call this.
// It is called frequently during a page load (particularly on progress changes and URL changes).
// As of iOS 12, WKContentView gesture setup is async, but it has been called by the time
// the webview is ready to load an URL. After this has happened, we can override the gesture.
func replaceGestureHandlerIfNeeded() {
// If the main layer changes, re-install KVO observation.
// It seems the main layer changes only once after intialization of the webview,
// so the if condition only runs twice.
guard let layer = self.tab?.webView?.scrollView.subviews[0].layer, layer != kvoInfo.layer else {
return
}

kvoInfo.layer = layer
kvoInfo.observation = layer.observe(\.bounds) { (_, _) in
// The layer bounds updates when the document context (and gestures) have been setup
DispatchQueue.main.async {
if self.gestureRecognizerWithDescriptionFragment("ContextMenuHelper") == nil {
self.replaceWebViewLongPress()
}
@@ -189,6 +189,8 @@ class Tab: NSObject {
configuration!.preferences = WKPreferences()
configuration!.preferences.javaScriptCanOpenWindowsAutomatically = false
configuration!.allowsInlineMediaPlayback = true
// Enables Zoom in website by ignoring their javascript based viewport Scale limits.
configuration!.ignoresViewportScaleLimits = true
let webView = TabWebView(frame: .zero, configuration: configuration!)
webView.delegate = self
configuration = nil
@@ -22,11 +22,11 @@ class TabScrollingController: NSObject {
weak var tab: Tab? {
willSet {
self.scrollView?.delegate = nil
self.scrollView?.removeGestureRecognizer(panGesture)
self.scrollView?.panGestureRecognizer.removeTarget(self, action: nil)
}

didSet {
self.scrollView?.addGestureRecognizer(panGesture)
self.scrollView?.panGestureRecognizer.addTarget(self, action: #selector(handlePan))
scrollView?.delegate = self
}
}
@@ -52,7 +52,7 @@ class TabScrollingController: NSObject {

fileprivate var headerTopOffset: CGFloat = 0 {
didSet {
headerTopConstraint?.update(offset: headerTopOffset - tabsBarOffset)
headerTopConstraint?.update(offset: headerTopOffset)
header?.superview?.setNeedsLayout()
}
}
@@ -70,13 +70,6 @@ class TabScrollingController: NSObject {
}
}

fileprivate lazy var panGesture: UIPanGestureRecognizer = {
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan))
panGesture.maximumNumberOfTouches = 1
panGesture.delegate = self
return panGesture
}()

fileprivate var scrollView: UIScrollView? { return tab?.webView?.scrollView }
fileprivate var contentOffset: CGPoint { return scrollView?.contentOffset ?? .zero }
fileprivate var contentSize: CGSize { return scrollView?.contentSize ?? .zero }
@@ -251,20 +244,9 @@ private extension TabScrollingController {
}

func animateToolbarsWithOffsets(_ animated: Bool, duration: TimeInterval, headerOffset: CGFloat, footerOffset: CGFloat, alpha: CGFloat, completion: ((_ finished: Bool) -> Void)?) {
guard let scrollView = scrollView else { return }
let initialContentOffset = scrollView.contentOffset

// If this function is used to fully animate the toolbar from hidden to shown, keep the page from scrolling by adjusting contentOffset,
// Otherwise when the toolbar is hidden and a link navigated, showing the toolbar will scroll the page and
// produce a ~50px page jumping effect in response to tap navigations.
let isShownFromHidden = headerTopOffset == -topScrollHeight && headerOffset == 0

self.headerTopOffset = headerOffset
self.footerBottomOffset = footerOffset
let animation: () -> Void = {
if isShownFromHidden {
scrollView.contentOffset = CGPoint(x: initialContentOffset.x, y: initialContentOffset.y + self.topScrollHeight)
}
self.headerTopOffset = headerOffset + self.tabsBarOffset
self.footerBottomOffset = footerOffset
self.urlBar?.updateAlphaForSubviews(alpha)
self.tabsBar?.view.alpha = alpha
self.header?.superview?.layoutIfNeeded()
@@ -985,6 +985,7 @@ fileprivate class EmptyPrivateTabsView: UIView {
$0.setTitle(Strings.Private_Tab_Link, for: [])
$0.setTitleColor(UIConstants.PrivateModeTextHighlightColor, for: [])
$0.titleLabel?.font = EmptyPrivateTabsViewUX.LearnMoreFont
$0.titleLabel?.numberOfLines = 0
}

let iconImageView = UIImageView(image: #imageLiteral(resourceName: "private_glasses")).then {
No changes.
@@ -46,8 +46,7 @@ class AdblockDebugMenuTableViewController: TableViewController {
"""

var section = Section(header: .title("Available lists"), footer: .title(footerNote))
guard let store = WKContentRuleListStore.default() else { return completion }

let store = ContentBlockerHelper.ruleStore
var rows = [Row]()

func bundleOrDocumentsData(for name: String) -> Data? {
@@ -102,7 +102,7 @@ class BlocklistName: CustomStringConvertible, ContentBlocker {
}

func compile(data: Data?,
ruleStore: WKContentRuleListStore = WKContentRuleListStore.default()) -> Deferred<()> {
ruleStore: WKContentRuleListStore = ContentBlockerHelper.ruleStore) -> Deferred<()> {
let completion = Deferred<()>()
guard let data = data, let dataString = String(data: data, encoding: .utf8) else {
log.error("Could not read data for content blocker compilation.")
@@ -35,7 +35,7 @@ if [ ! -z "$XCS_BOT_ID" ]; then
CARTHAGE_VERBOSE="--verbose"
fi

SWIFT_VERSION=4.0 carthage bootstrap $CARTHAGE_VERBOSE --platform ios --color auto --cache-builds --no-use-binaries
SWIFT_VERSION=4.2 carthage bootstrap $CARTHAGE_VERBOSE --platform ios --color auto --cache-builds --no-use-binaries

# Install Node.js dependencies and build user scripts

@@ -38,15 +38,15 @@ platform :ios do
code_coverage: true,
skip_testing: [
"DataTests/BookmarkTests",
"DataTests/CRUDProtocolsTests",
"DataTests/CoreDataTestCase",
"DataTests/DataControllerTests",
"DataTests/DeviceTests",
"DataTests/DomainTests",
"DataTests/FaviconMOTests",
"DataTests/HistoryTests",
"DataTests/TabMOTests",
"DataTests/FavoriteTests",
"DataTests/CRUDProtocolsTests",
"DataTests/CoreDataTestCase",
"DataTests/DataControllerTests",
"DataTests/DeviceTests",
"DataTests/DomainTests",
"DataTests/FaviconMOTests",
"DataTests/HistoryTests",
"DataTests/TabMOTests",
"DataTests/FavoriteTests",
"ClientTests/TabManagerTests/testQueryAddedTabs",
"ClientTests/TabManagerTests/testQueryAddedPrivateTabs",
"ClientTests/TabManagerTests/testQueryAddedMixedTabs",
@@ -73,8 +73,6 @@ platform :ios do
configuration: "Release",
)

badge(dark: true)

gym(
scheme: "FirefoxBeta",
output_directory: "./builds/",
You are viewing a condensed version of this merge commit. You can view the full changes here.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.