-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Refactor FXIOS-10468 [SwiftLint] Fix force_unwrapping in /Widgets and /OpenInFocus #29669
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,8 +33,11 @@ extension NSItemProvider { | |
} | ||
} | ||
|
||
class ActionViewController: SLComposeServiceViewController { | ||
private var isKlar: Bool { return (Bundle.main.infoDictionary!["CFBundleIdentifier"] as! String).contains("Klar") } | ||
final class ActionViewController: SLComposeServiceViewController { | ||
private var isKlar: Bool { | ||
guard let string = Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String else { return false } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw this duplicated so adding the file in the same PR. I was thinking of making an extension on Bundle since its duplicated but wasn't sure where, I don't think its a big deal. Let me know if otherwise where should I add it. |
||
return string.contains("Klar") | ||
} | ||
private var urlScheme: String { return isKlar ? "firefox-klar" : "firefox-focus" } | ||
|
||
override func isContentValid() -> Bool { return true } | ||
|
@@ -97,21 +100,21 @@ class ActionViewController: SLComposeServiceViewController { | |
} | ||
|
||
private func handleUrl(_ url: NSURL) { | ||
// From http://stackoverflow.com/questions/24297273/openurl-not-work-in-action-extension | ||
// From https://stackoverflow.com/questions/24297273/openurl-not-work-in-action-extension | ||
var responder = self as UIResponder? | ||
let selectorOpenURL = sel_registerName("openURL:") | ||
while responder != nil { | ||
while let currentResponder = responder { | ||
if #available(iOS 18.0, *) { | ||
if let application = responder as? UIApplication { | ||
application.open(url as URL, options: [:], completionHandler: nil) | ||
} | ||
} else { | ||
if responder!.responds(to: selectorOpenURL) { | ||
responder!.callSelector(selector: selectorOpenURL, object: url, delay: 0) | ||
if currentResponder.responds(to: selectorOpenURL) { | ||
currentResponder.callSelector(selector: selectorOpenURL, object: url, delay: 0) | ||
} | ||
} | ||
|
||
responder = responder!.next | ||
responder = currentResponder.next | ||
} | ||
finish() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,10 @@ struct FocusWidgets_Previews: PreviewProvider { | |
|
||
fileprivate extension String { | ||
static var appNameForBundle: String { | ||
var isKlar: Bool { return (Bundle.main.infoDictionary!["CFBundleIdentifier"] as! String).contains("Klar") } | ||
var isKlar: Bool { | ||
guard let string = Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String else { return false } | ||
return string.contains("Klar") | ||
} | ||
return isKlar ? "Klar" : "Focus" | ||
} | ||
// Quick Action - Small Size - Gallery View | ||
|
@@ -100,7 +103,7 @@ fileprivate extension Bool { | |
} | ||
|
||
fileprivate extension URL { | ||
static let deepLinkURL = URL(string: "firefox-focus://widget")! | ||
static let deepLinkURL = URL(string: "firefox-focus://widget") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 34 accepts |
||
} | ||
|
||
fileprivate extension View { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule does not make sense here because count is an
Int
I bumped into this because my git pre-push hook wasn't allowing me to push.
Let me know if I should revert this since its unrelated.