-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Refactor FXIOS-10467 - Remove force_cast violations from Sistem services & Logging #23150
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -2,10 +2,17 @@ | |
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import Common | ||
import UIKit | ||
import Shared | ||
|
||
class MenuBuilderHelper { | ||
private let logger: Logger | ||
|
||
init(logger: Logger = DefaultLogger.shared) { | ||
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. That looks good, i'd only move the init after the structs, so the init is with the other methods |
||
self.logger = logger | ||
} | ||
|
||
struct MenuIdentifiers { | ||
static let history = UIMenu.Identifier("com.mozilla.firefox.menus.history") | ||
static let bookmarks = UIMenu.Identifier("com.mozilla.firefox.menus.bookmarks") | ||
|
@@ -67,7 +74,13 @@ class MenuBuilderHelper { | |
] | ||
) | ||
fileMenu.children.forEach { | ||
($0 as! UIKeyCommand).wantsPriorityOverSystemBehavior = true | ||
guard let fileMenuKeyCommand = $0 as? UIKeyCommand else { | ||
logger.log("Failed to cast file menu child to UIKeyCommand in MenuBuilderHelper class", | ||
level: .fatal, | ||
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'd log those as a |
||
category: .library) | ||
return | ||
} | ||
fileMenuKeyCommand.wantsPriorityOverSystemBehavior = true | ||
} | ||
|
||
let findMenu = UIMenu( | ||
|
@@ -90,7 +103,13 @@ class MenuBuilderHelper { | |
] | ||
) | ||
findMenu.children.forEach { | ||
($0 as! UIKeyCommand).wantsPriorityOverSystemBehavior = true | ||
guard let findMenuKeyCommand = $0 as? UIKeyCommand else { | ||
logger.log("Failed to cast find menu child to UIKeyCommand in MenuBuilderHelper class", | ||
level: .fatal, | ||
category: .library) | ||
return | ||
} | ||
findMenuKeyCommand.wantsPriorityOverSystemBehavior = true | ||
} | ||
|
||
var viewMenuChildren: [UIMenuElement] = [ | ||
|
@@ -137,7 +156,13 @@ class MenuBuilderHelper { | |
|
||
let viewMenu = UIMenu(options: .displayInline, children: viewMenuChildren) | ||
viewMenu.children.forEach { | ||
($0 as! UIKeyCommand).wantsPriorityOverSystemBehavior = true | ||
guard let viewMenuKeyCommand = $0 as? UIKeyCommand else { | ||
logger.log("Failed to cast view menu child to UIKeyCommand in MenuBuilderHelper class", | ||
level: .fatal, | ||
category: .library) | ||
return | ||
} | ||
viewMenuKeyCommand.wantsPriorityOverSystemBehavior = true | ||
} | ||
|
||
let historyMenu = UIMenu( | ||
|
@@ -255,7 +280,13 @@ class MenuBuilderHelper { | |
|
||
if #available(iOS 15, *) { | ||
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. We can also remove the |
||
windowMenu.children.forEach { | ||
($0 as! UIKeyCommand).wantsPriorityOverSystemBehavior = true | ||
guard let windowMenuKeyCommand = $0 as? UIKeyCommand else { | ||
logger.log("Failed to cast window menu child to UIKeyCommand in MenuBuilderHelper class", | ||
level: .fatal, | ||
category: .library) | ||
return | ||
} | ||
windowMenuKeyCommand.wantsPriorityOverSystemBehavior = true | ||
} | ||
} | ||
|
||
|
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.
Also here i'd go to
.info