Skip to content

Commit 375d6f8

Browse files
committed
Document and Image Picker bug fix along with inline text submission
Fix WebController bug where inline text wouldn't be allowed and removed option to take picture and upload because it seems to invalidate Webview cookies
1 parent 0ce997c commit 375d6f8

File tree

7 files changed

+33
-60
lines changed

7 files changed

+33
-60
lines changed

SakaiClientiOS.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@
223223
5113C13D2092D8F1001929DA /* SiteCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SiteCell.swift; sourceTree = "<group>"; };
224224
5118956421194D0500BD86D1 /* SakaiClientiOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SakaiClientiOS.entitlements; sourceTree = "<group>"; };
225225
511D7579208DAA9600371998 /* HomeController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeController.swift; sourceTree = "<group>"; };
226-
512183CA21E98FE2008BD3D1 /* NoDataView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = NoDataView.swift; path = ../../../../ReusableSource/ReusableSource/NoDataView.swift; sourceTree = "<group>"; };
227226
512183D021EA1AF3008BD3D1 /* AppSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettings.swift; sourceTree = "<group>"; };
228227
5126915421CEEE09004B20E7 /* FilterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilterViewController.swift; sourceTree = "<group>"; };
229228
512748BC210D29A400A5A74E /* ResourcePageController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResourcePageController.swift; sourceTree = "<group>"; };
@@ -672,7 +671,6 @@
672671
511114B820D881450077F872 /* PageView.swift */,
673672
518AC34D2137840300037087 /* LoadingIndicator.swift */,
674673
51EF2BC721DF5B5E003CAA57 /* InsetUILabel.swift */,
675-
512183CA21E98FE2008BD3D1 /* NoDataView.swift */,
676674
);
677675
path = Reusable;
678676
sourceTree = "<group>";

SakaiClientiOS/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>1.2.0</string>
2121
<key>CFBundleVersion</key>
22-
<string>1544</string>
22+
<string>1563</string>
2323
<key>Fabric</key>
2424
<dict>
2525
<key>APIKey</key>

SakaiClientiOS/Sources/Assignment/PagesController.swift

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class PagesController: UIViewController {
103103
guard let tabBarController = tabBarController as? TabController else {
104104
return
105105
}
106+
tabBarController.popupController = nil
106107
// If a new tab is selected, the UITabBarController will handle
107108
// presentation and dismissal of the popup bar
108109
if tabBarController.isMovingToNewTabFromPages {
@@ -122,23 +123,9 @@ class PagesController: UIViewController {
122123
}
123124
tabBarController.popupController = popupController
124125

125-
if tabBarController.shouldOpenPopup {
126-
// If the user is trying to submit, presenting the Document
127-
// Picker or Image Picker will dismiss the popup due to a
128-
// WebKit bug. So, the popup should be reopened once the picker
129-
// has dismissed and should not reload the page to save any
130-
// potential submission
131-
webController.setNeedsLoad(to: false)
132-
tabBarController.presentPopupBar(withContentViewController: popupController,
133-
openPopup: true,
134-
animated: true,
135-
completion: nil)
136-
tabBarController.shouldOpenPopup = false
137-
} else {
138-
tabBarController.presentPopupBar(withContentViewController: popupController,
139-
animated: true,
140-
completion: nil)
141-
}
126+
tabBarController.presentPopupBar(withContentViewController: popupController,
127+
animated: true,
128+
completion: nil)
142129
// When popping back to PagesController, LNPopupController
143130
// encounters a bug where it is entirely removed from the view
144131
// hierarchy and causes a black space to appear in its place.

SakaiClientiOS/Sources/Models/Networking/SakaiEndpoint.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ enum SakaiEndpoint {
2020
case announcements(Int, Int), siteAnnouncements(String, Int, Int)
2121
case siteGradebook(String), siteAssignments(String), siteResources(String)
2222

23+
2324
func getEndpoint() -> String {
2425
switch self {
2526
case .sites:

SakaiClientiOS/Sources/TabController.swift

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ class TabController: UITabBarController, UITabBarControllerDelegate {
1515
/// the tabBarController that it is currently presenting a popup
1616
weak var popupController: UIViewController?
1717

18-
/// Determines if the popup should be opened when a view controller is
19-
/// presenting the popup bar.
20-
///
21-
/// See PagesController
22-
var shouldOpenPopup = false
23-
2418
var isMovingToNewTabFromPages = false
2519

2620
override func viewDidLoad() {
@@ -37,19 +31,24 @@ class TabController: UITabBarController, UITabBarControllerDelegate {
3731
override func present(_ viewControllerToPresent: UIViewController,
3832
animated flag: Bool,
3933
completion: (() -> Void)? = nil) {
40-
if popupController != nil &&
41-
(viewControllerToPresent is UIDocumentPickerViewController ||
42-
viewControllerToPresent is UIImagePickerController) {
43-
// If a Document or Image Picker is being shown, a WebKit bug
44-
// will cause the popupController to be closed. So, once a
45-
// document or image has been selected, the popup controller
46-
// should reopen once the picker controller is dismissed. This
47-
// property will be used in PagesController
48-
shouldOpenPopup = true
34+
35+
if let picker = viewControllerToPresent as? UIImagePickerController, picker.sourceType == .camera {
36+
presentErrorAlert(string: "Taking a picture with the Camera is not supported for upload")
37+
picker.delegate?.imagePickerControllerDidCancel?(picker)
38+
return
39+
}
40+
41+
if popupController != nil && isPicker(viewControllerToPresent) {
42+
let visible = (popupController as? UINavigationController)?.visibleViewController
43+
visible?.present(viewControllerToPresent, animated: true, completion: nil)
44+
return
4945
}
50-
super.present(viewControllerToPresent,
51-
animated: flag,
52-
completion: completion)
46+
super.present(viewControllerToPresent, animated: flag, completion: completion)
47+
}
48+
49+
private func isPicker(_ viewController: UIViewController) -> Bool {
50+
return viewController is UIDocumentPickerViewController ||
51+
viewController is UIImagePickerController
5352
}
5453

5554
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {

SakaiClientiOS/Sources/Web/WebController.swift

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ class WebController: UIViewController {
3434

3535
private lazy var toolBarArray: [UIBarButtonItem] = {
3636
let backImage = UIImage(named: "back_button")
37-
let back = UIBarButtonItem(image: backImage, style: .plain, target: self, action: #selector(goBack))
37+
let back = UIBarButtonItem(image: backImage, style: .plain, target: webView, action: #selector(webView.goBack))
3838

3939
let forwardImage = UIImage(named: "forward_button")
40-
let forward = UIBarButtonItem(image: forwardImage, style: .plain, target: self, action: #selector(goForward))
40+
let forward = UIBarButtonItem(image: forwardImage, style: .plain, target: webView, action: #selector(webView.goForward))
4141

4242
let action = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(presentActions))
4343
let flex = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
@@ -135,16 +135,16 @@ class WebController: UIViewController {
135135
self?.webView = webView
136136
self?.loadURL(urlOpt: self?.url)
137137
self?.didInitialize = true
138-
}
139138

140-
super.viewDidLoad()
139+
self?.setToolbarItems(self?.toolBarArray, animated: true)
141140

142-
setToolbarItems(toolBarArray, animated: true)
141+
self?.navigationItem.leftBarButtonItem
142+
= UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self?.dismissController))
143+
self?.navigationItem.rightBarButtonItem
144+
= UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(self?.loadWebview))
145+
}
143146

144-
navigationItem.leftBarButtonItem
145-
= UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(dismissController))
146-
navigationItem.rightBarButtonItem
147-
= UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(loadWebview))
147+
super.viewDidLoad()
148148
}
149149

150150
override func observeValue(forKeyPath keyPath: String?,
@@ -256,6 +256,7 @@ extension WebController: WKUIDelegate, WKNavigationDelegate {
256256
decidePolicyFor navigationAction: WKNavigationAction,
257257
decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
258258

259+
259260
guard let url = navigationAction.request.url else {
260261
decisionHandler(.cancel)
261262
return
@@ -293,8 +294,6 @@ extension WebController: WKUIDelegate, WKNavigationDelegate {
293294
$('.Mrphs-siteHierarchy').remove();
294295
$('#toolMenuWrap').remove();
295296
$('#skipNav').remove();
296-
var selectedElement = document.querySelector('#content');
297-
document.body.innerHTML = selectedElement.innerHTML;
298297
""")
299298
}
300299

@@ -312,17 +311,6 @@ extension WebController: WKUIDelegate, WKNavigationDelegate {
312311
// MARK: Selector actions
313312

314313
extension WebController {
315-
@objc private func goBack() {
316-
if webView.canGoBack {
317-
webView.goBack()
318-
}
319-
}
320-
321-
@objc private func goForward() {
322-
if webView.canGoForward {
323-
webView.goForward()
324-
}
325-
}
326314

327315
@objc private func dismissController() {
328316
dismissAction()

0 commit comments

Comments
 (0)