-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes some long standing bugs e.g. the wrong menubar items are activated on app launch and if a navigation is reset. Coordinate selection crashes the app if the textfield is cleared. CLLocationSpeed is used in more places to indicate the unit of the speed in m/s. An CLLocationSpeed extension helps with converting between km/h and m/s. Merge Add missing files
- Loading branch information
1 parent
936629c
commit 9112536
Showing
25 changed files
with
534 additions
and
56 deletions.
There are no files selected for viewing
Submodule Localization
updated
4 files
+9 −0 | Base.lproj/Localizable.strings | |
+ − | cs.lproj/Localizable.strings | |
+9 −0 | de.lproj/Localizable.strings | |
+9 −0 | en.lproj/Localizable.strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// LocationSimulator-Bridging-Header.h | ||
// LocationSimulator | ||
// | ||
// Created by David Klopp on 30.01.23. | ||
// Copyright © 2023 David Klopp. All rights reserved. | ||
// | ||
|
||
#ifndef LocationSimulator_Bridging_Header_h | ||
#define LocationSimulator_Bridging_Header_h | ||
|
||
#import <AppKit/AppKit.h> | ||
|
||
@interface NSMenuItem(Private) | ||
- (void)_corePerformAction; | ||
- (BOOL)_viewHandlesEvents; | ||
@end | ||
|
||
#endif /* LocationSimulator_Bridging_Header_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// CoordinateSelectionAlert.swift | ||
// LocationSimulator | ||
// | ||
// Created by David Klopp on 21.12.20. | ||
// Copyright © 2020 David Klopp. All rights reserved. | ||
// | ||
|
||
import AppKit | ||
import CoreLocation | ||
|
||
typealias SpeedSelectionCompletionHandler = ((NSApplication.ModalResponse, Double) -> Void) | ||
|
||
/// Alert view which lets the user update the speed value. | ||
class SpeedSelectionAlert: NSAlert { | ||
|
||
public var speedSelectionView = SpeedSelectionView(frame: CGRect(x: 0, y: 0, width: 170, height: 40)) | ||
|
||
init(defaultValue: CLLocationSpeed) { | ||
super.init() | ||
|
||
self.messageText = "CHANGE_SPEED".localized | ||
self.addButton(withTitle: "CANCEL".localized) | ||
self.addButton(withTitle: "OK".localized) | ||
self.alertStyle = .informational | ||
|
||
var frame = self.speedSelectionView.frame | ||
frame.size.width = 200 | ||
let contentView = NSView(frame: frame) | ||
|
||
let offX = (frame.width - self.speedSelectionView.frame.width) / 2 | ||
self.speedSelectionView.frame.origin.x = offX | ||
self.speedSelectionView.speed = defaultValue.inKmH | ||
|
||
contentView.addSubview(self.speedSelectionView) | ||
self.accessoryView = contentView | ||
} | ||
|
||
override func beginSheetModal(for sheetWindow: NSWindow, | ||
completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil) { | ||
fatalError("Do not use this function. Use the two argument implementation instead.") | ||
} | ||
|
||
/// Implementation to handle the response more nicely and add a second argument. | ||
func beginSheetModal(for sheetWindow: NSWindow, | ||
completionHandler handler: SpeedSelectionCompletionHandler? = nil) { | ||
// Show the actual coordinate selection. | ||
super.beginSheetModal(for: sheetWindow) { [unowned self] response in | ||
// Get the user entered coordinates | ||
let speed = self.speedSelectionView.getSpeed() | ||
switch response { | ||
// User canceled | ||
case .alertFirstButtonReturn: handler?(.cancel, speed) | ||
// Navigate or teleport depending on whether navigate is available | ||
case .alertSecondButtonReturn: handler?(.OK, speed) | ||
default: break | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
LocationSimulator/Extensions/CoreLocation/CLLocationSpeed.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// CLLocationSpeed.swift | ||
// LocationSimulator | ||
// | ||
// Created by David Klopp on 31.01.23. | ||
// Copyright © 2023 David Klopp. All rights reserved. | ||
// | ||
|
||
import CoreLocation | ||
|
||
extension CLLocationSpeed { | ||
init(inKmH speed: Double) { | ||
self = (speed * 1000)/(60*60) | ||
} | ||
|
||
var inKmH: Double { | ||
return (self * (60 * 60)) / 1000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.