Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* dev:
  minor fix
  update: SnapKit
  fix: typo
  minor changes
  New translations Perference.strings (Chinese Simplified)
  New translations Main.strings (Chinese Simplified)
  update animation's timing function
  New translations InfoPlist.strings (Chinese Simplified)
  l10n info.plist file
  import TouchBarHelper
  prompt user to authorize AppleEvent usage on macOS 10.14
  New translations Perference.strings (Chinese Simplified)
  New translations Main.strings (Chinese Simplified)
  • Loading branch information
ddddxxx committed Sep 29, 2018
2 parents da65419 + d652e3d commit f2f6593
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 137 deletions.
4 changes: 3 additions & 1 deletion Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github "ddddxxx/Semver"

github "ddddxxx/SwiftyOpenCC"

github "SnapKit/SnapKit" ~> 4.0.0
github "ddddxxx/TouchBarHelper"

github "SnapKit/SnapKit"

github "shpakovski/MASShortcut"
3 changes: 2 additions & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
github "SnapKit/SnapKit" "4.0.0"
github "SnapKit/SnapKit" "4.0.1"
github "ddddxxx/GenericID" "v0.3.0"
github "ddddxxx/LyricsProvider" "v0.4.3"
github "ddddxxx/MusicPlayer" "v0.1.1"
github "ddddxxx/Semver" "v0.1.2"
github "ddddxxx/SwiftyOpenCC" "v0.2.2"
github "ddddxxx/TouchBarHelper" "v1.0.0"
github "shpakovski/MASShortcut" "2.3.6"
34 changes: 20 additions & 14 deletions LyricsX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
E91F76EB21211B8D00755698 /* PreferenceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E91F76EA21211B8D00755698 /* PreferenceViewController.swift */; };
E97593E42150F47900D80616 /* Polyfill.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97593E32150F47800D80616 /* Polyfill.swift */; };
E97593E62150F6FB00D80616 /* IBInspection.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97593E52150F6FB00D80616 /* IBInspection.swift */; };
E97AFB55215CAF4400AF74CD /* TouchBarHelper.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E97AFB54215CAF4400AF74CD /* TouchBarHelper.framework */; };
E97AFB56215CAF4400AF74CD /* TouchBarHelper.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E97AFB54215CAF4400AF74CD /* TouchBarHelper.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
E97AFB59215CBF0300AF74CD /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = E97AFB5B215CBF0300AF74CD /* InfoPlist.strings */; };
E9E55138207C4CB000F9958A /* TouchBarLyrics.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9E55137207C4CB000F9958A /* TouchBarLyrics.swift */; };
E9EBDA2521115A150019FDF9 /* Observation.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9EBDA2421115A150019FDF9 /* Observation.swift */; };
/* End PBXBuildFile section */
Expand All @@ -94,6 +97,7 @@
BB58B0851E82B82F00598D4F /* OpenCC.framework in Embed Frameworks */,
BBF83E231FB5502000D76E5B /* MusicPlayer.framework in Embed Frameworks */,
BB4FBE761F0F1E440045A8FA /* LyricsProvider.framework in Embed Frameworks */,
E97AFB56215CAF4400AF74CD /* TouchBarHelper.framework in Embed Frameworks */,
BB34F4AA1EFFBCBC008B9E4B /* MASShortcut.framework in Embed Frameworks */,
BB4141C91E46CDD700A51775 /* SnapKit.framework in Embed Frameworks */,
BBE557981EC0291E00F1EC31 /* GenericID.framework in Embed Frameworks */,
Expand Down Expand Up @@ -177,9 +181,10 @@
E91F76EA21211B8D00755698 /* PreferenceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceViewController.swift; sourceTree = "<group>"; };
E97593E32150F47800D80616 /* Polyfill.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Polyfill.swift; sourceTree = "<group>"; };
E97593E52150F6FB00D80616 /* IBInspection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IBInspection.swift; sourceTree = "<group>"; };
E97AFB54215CAF4400AF74CD /* TouchBarHelper.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TouchBarHelper.framework; path = Carthage/Build/Mac/TouchBarHelper.framework; sourceTree = "<group>"; };
E97AFB5A215CBF0300AF74CD /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
E97AFB5C215CBF0500AF74CD /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
E9E5512F207C4B7600F9958A /* DFRFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DFRFoundation.framework; path = ../../../../System/Library/PrivateFrameworks/DFRFoundation.framework; sourceTree = "<group>"; };
E9E55131207C4BC700F9958A /* TouchBarPrivateAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarPrivateAPI.h; sourceTree = "<group>"; };
E9E55133207C4C2700F9958A /* LyricsX-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "LyricsX-Bridging-Header.h"; sourceTree = "<group>"; };
E9E55137207C4CB000F9958A /* TouchBarLyrics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TouchBarLyrics.swift; sourceTree = "<group>"; };
E9EBDA2421115A150019FDF9 /* Observation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Observation.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand All @@ -195,6 +200,7 @@
BBF83E221FB5502000D76E5B /* MusicPlayer.framework in Frameworks */,
BB4141C81E46CDD700A51775 /* SnapKit.framework in Frameworks */,
BB4FBE751F0F1E440045A8FA /* LyricsProvider.framework in Frameworks */,
E97AFB55215CAF4400AF74CD /* TouchBarHelper.framework in Frameworks */,
BB34F4A91EFFBCBC008B9E4B /* MASShortcut.framework in Frameworks */,
BB58B0841E82B82F00598D4F /* OpenCC.framework in Frameworks */,
BBE557971EC0291E00F1EC31 /* GenericID.framework in Frameworks */,
Expand Down Expand Up @@ -251,7 +257,6 @@
BB063B2F1E8A93CE00A25C3E /* View */,
BB7EC7B41E4ECFFB00A0AC3F /* Controller */,
BB7EC7B61E4ED03900A0AC3F /* Utility */,
E9E55132207C4BFC00F9958A /* CBridge */,
BB4141BC1E45B26800A51775 /* Supporting Files */,
);
path = LyricsX;
Expand All @@ -262,6 +267,7 @@
children = (
BB4141B11E458BA800A51775 /* Assets.xcassets */,
BB0BE9581F444C9E0068FF67 /* Localizable.strings */,
E97AFB5B215CBF0300AF74CD /* InfoPlist.strings */,
BB9BCEB81E84120D001BC54B /* LyricsX.entitlements */,
BB4141B61E458BA900A51775 /* Info.plist */,
BB58B0811E82971400598D4F /* UserDefaults.plist */,
Expand Down Expand Up @@ -293,6 +299,7 @@
BB58B0831E82B82F00598D4F /* OpenCC.framework */,
BB34F7E71F2197C800B7C484 /* Semver.framework */,
BB4141C61E46CDD200A51775 /* SnapKit.framework */,
E97AFB54215CAF4400AF74CD /* TouchBarHelper.framework */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -366,15 +373,6 @@
path = Component;
sourceTree = "<group>";
};
E9E55132207C4BFC00F9958A /* CBridge */ = {
isa = PBXGroup;
children = (
E9E55131207C4BC700F9958A /* TouchBarPrivateAPI.h */,
E9E55133207C4C2700F9958A /* LyricsX-Bridging-Header.h */,
);
path = CBridge;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -487,6 +485,7 @@
buildActionMask = 2147483647;
files = (
BB0BE9561F444C9E0068FF67 /* Localizable.strings in Resources */,
E97AFB59215CBF0300AF74CD /* InfoPlist.strings in Resources */,
BB6139741FCCFA6700CBD808 /* Perference.storyboard in Resources */,
BB4141B21E458BA800A51775 /* Assets.xcassets in Resources */,
BB58B0821E82971400598D4F /* UserDefaults.plist in Resources */,
Expand Down Expand Up @@ -654,6 +653,15 @@
name = Perference.storyboard;
sourceTree = "<group>";
};
E97AFB5B215CBF0300AF74CD /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
E97AFB5A215CBF0300AF74CD /* en */,
E97AFB5C215CBF0500AF74CD /* zh-Hans */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -796,7 +804,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = ddddxxx.LyricsX;
SWIFT_OBJC_BRIDGING_HEADER = "LyricsX/CBridge/LyricsX-Bridging-Header.h";
SWIFT_VERSION = 4.0;
SYSTEM_FRAMEWORK_SEARCH_PATHS = "$(inherited) $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
};
Expand All @@ -822,7 +829,6 @@
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = ddddxxx.LyricsX;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = IS_FOR_MAS;
SWIFT_OBJC_BRIDGING_HEADER = "LyricsX/CBridge/LyricsX-Bridging-Header.h";
SWIFT_VERSION = 4.0;
SYSTEM_FRAMEWORK_SEARCH_PATHS = "$(inherited) $(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
};
Expand Down
5 changes: 0 additions & 5 deletions LyricsX/CBridge/LyricsX-Bridging-Header.h

This file was deleted.

58 changes: 0 additions & 58 deletions LyricsX/CBridge/TouchBarPrivateAPI.h

This file was deleted.

2 changes: 1 addition & 1 deletion LyricsX/Component/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
.PreferBilingualLyrics: isZh,
.ChineseConversionIndex: isHant ? 2 : 0,
.DesktopLyricsXPositionFactor: 0.5,
.DesktopLyricsYPositionFactor: 0.95,
.DesktopLyricsYPositionFactor: 0.9,
])
}
}
Expand Down
2 changes: 1 addition & 1 deletion LyricsX/Controller/LyricsHUDViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class LyricsHUDViewController: NSViewController, NSWindowDelegate, ScrollLyricsV
NSAnimationContext.runAnimationGroup { context in
context.duration = 0.3
context.allowsImplicitAnimation = true
context.timingFunction = .mystery
context.timingFunction = .swiftOut
self.lyricsScrollView.scroll(position: pos)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion LyricsX/Controller/SearchLyricsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class SearchLyricsViewController: NSViewController, NSTableViewDelegate, NSTable
NSAnimationContext.runAnimationGroup({ context in
context.duration = 0.33
context.allowsImplicitAnimation = true
context.timingFunction = .mystery
context.timingFunction = .swiftOut
hideLrcPreviewConstraint?.animator().isActive = false
view.window?.setFrame(windowFrame, display: false, animate: true)
view.needsUpdateConstraints = true
Expand Down
52 changes: 5 additions & 47 deletions LyricsX/Controller/TouchBarLyrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import Cocoa
import LyricsProvider
import OpenCC
import TouchBarHelper

#if IS_FOR_MAS
#else
Expand All @@ -39,7 +40,9 @@ class TouchBarLyrics: NSObject, NSTouchBarDelegate {
touchBar.defaultItemIdentifiers = [.lyrics]

systemTrayItem.view = NSButton(image: #imageLiteral(resourceName: "status_bar_icon"), target: self, action: #selector(presentTouchBar))
self.systemTrayItem.setSystemTrayPresent(true)
systemTrayItem.addSystemTray()
DFRElementSetControlStripPresenceForIdentifier(systemTrayItem.identifier, true)
DFRSystemModalShowsCloseBoxWhenFrontMost(true)

NotificationCenter.default.addObserver(self, selector: #selector(self.handleLyricsDisplay), name: .lyricsShouldDisplay, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.handleLyricsDisplay), name: .currentLyricsChange, object: nil)
Expand All @@ -48,7 +51,7 @@ class TouchBarLyrics: NSObject, NSTouchBarDelegate {
}

deinit {
self.systemTrayItem.setSystemTrayPresent(false)
self.systemTrayItem.removeSystemTray()
}

@objc private func presentTouchBar() {
Expand Down Expand Up @@ -95,20 +98,6 @@ class TouchBarLyrics: NSObject, NSTouchBarDelegate {
}
}

@available(OSX 10.12.2, *)
private extension NSTouchBarItem {

func setSystemTrayPresent(_ isPresent: Bool) {
if isPresent {
NSTouchBarItem.addSystemTrayItem(self)
} else {
NSTouchBarItem.removeSystemTrayItem(self)
}
DFRElementSetControlStripPresenceForIdentifier?(identifier, isPresent)
DFRSystemModalShowsCloseBoxWhenFrontMost?(isPresent)
}
}

@available(OSX 10.12.2, *)
private extension NSTouchBarItem.Identifier {

Expand All @@ -117,37 +106,6 @@ private extension NSTouchBarItem.Identifier {
static let systemTrayItem = NSTouchBarItem.Identifier("ddddxxx.LyricsX.touchBar.systemTrayItem")
}

// MARK: DFRFoundation API

private let DFRFoundationPath = "/System/Library/PrivateFrameworks/DFRFoundation.framework/Versions/A/DFRFoundation"

// swiftlint:disable type_name identifier_name
@available(OSX 10.12.2, *)
private typealias DFRElementSetControlStripPresenceForIdentifierType = @convention(c) (NSTouchBarItem.Identifier, Bool) -> Void

@available(OSX 10.12.2, *)
private typealias DFRSystemModalShowsCloseBoxWhenFrontMostType = @convention(c) (Bool) -> Void

@available(OSX 10.12.2, *)
private let (DFRElementSetControlStripPresenceForIdentifier, DFRSystemModalShowsCloseBoxWhenFrontMost):
(DFRElementSetControlStripPresenceForIdentifierType?, DFRSystemModalShowsCloseBoxWhenFrontMostType?) = {
guard let handle = dlopen(DFRFoundationPath, RTLD_LAZY) else {
return (nil, nil)
}
defer {
dlclose(handle)
}
let f1 = dlsym(handle, "DFRElementSetControlStripPresenceForIdentifier")?.do {
unsafeBitCast($0, to: DFRElementSetControlStripPresenceForIdentifierType.self)
}
let f2 = dlsym(handle, "DFRSystemModalShowsCloseBoxWhenFrontMost")?.do {
unsafeBitCast($0, to: DFRSystemModalShowsCloseBoxWhenFrontMostType.self)
}
return (f1, f2)
}()

// swiftlint:enable type_name identifier_name

// MARK: - NSTextField + Progress

private extension NSTextField {
Expand Down
4 changes: 3 additions & 1 deletion LyricsX/Supporting Files/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>1.4.1</string>
<key>CFBundleVersion</key>
<string>1920</string>
<string>1926</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down Expand Up @@ -104,6 +104,8 @@
</dict>
</dict>
</dict>
<key>NSAppleEventsUsageDescription</key>
<string>LyricsX needs to know what song you're currently playing, to show lyrics accordingly.</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017 Xander Deng. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
Expand Down
1 change: 1 addition & 0 deletions LyricsX/Supporting Files/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"NSAppleEventsUsageDescription" = "LyricsX needs to know what song you're currently playing, to show lyrics accordingly."
1 change: 1 addition & 0 deletions LyricsX/Supporting Files/zh-Hans.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"NSAppleEventsUsageDescription" = "LyricsX 需要获取当前播放的音乐,并据此展示歌词"
1 change: 1 addition & 0 deletions LyricsX/Utility/Global.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let isFromMacAppStore = (try? Bundle.main.appStoreReceiptURL?.checkResourceIsRea

extension CAMediaTimingFunction {
static let mystery = CAMediaTimingFunction(controlPoints: 0.2, 0.1, 0.2, 1)
static let swiftOut = CAMediaTimingFunction(controlPoints: 0.4, 0.0, 0.2, 1)
}

func log(_ message: @autoclosure () -> String, file: String = #file, line: UInt = #line) {
Expand Down
3 changes: 3 additions & 0 deletions LyricsX/Utility/StdExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ extension Comparable {
extension Strideable {

func clamped(to limit: Range<Self>) -> Self {
guard !limit.isEmpty else {
preconditionFailure("Range cannot be empty")
}
let upperBound = limit.upperBound.advanced(by: -1)
return min(max(self, limit.lowerBound), upperBound)
}
Expand Down
2 changes: 0 additions & 2 deletions LyricsX/Utility/Then.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,3 @@ extension CGPoint: Then {}
extension CGRect: Then {}
extension CGSize: Then {}
extension CGVector: Then {}

extension UnsafeMutableRawPointer: Then {}
2 changes: 1 addition & 1 deletion LyricsX/View/KaraokeLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class KaraokeLabel: NSTextField {
override func draw(_ dirtyRect: NSRect) {
let context = NSGraphicsContext.current!.cgContext
context.textMatrix = .identity
context.translateBy(x: 0, y: dirtyRect.height)
context.translateBy(x: 0, y: bounds.height)
context.scaleBy(x: 1.0, y: -1.0)
CTFrameDraw(ctFrame, context)
}
Expand Down
2 changes: 1 addition & 1 deletion LyricsX/View/KaraokeLyricsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class KaraokeLyricsView: NSBox {
NSAnimationContext.runAnimationGroup({ context in
context.duration = 0.25
context.allowsImplicitAnimation = true
context.timingFunction = .mystery
context.timingFunction = .swiftOut
toBeHide.forEach {
stackView.removeArrangedSubview($0)
$0.isHidden = true
Expand Down
4 changes: 2 additions & 2 deletions LyricsX/zh-Hans.lproj/Main.strings
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"o52-Z0-lue.title" = "如果您认为 LyricsX 对您有所帮助,并愿意支持软件的维护,可以扫描下方的二维码向我捐赠。";

/* Class = "NSMenuItem"; title = "Show In Finder"; ObjectID = "DNi-vI-MTr"; */
"DNi-vI-MTr.title" = "Show In Finder";
"DNi-vI-MTr.title" = "Finder 中显示";

/* Class = "NSMenuItem"; title = "Lyrics"; ObjectID = "hxE-X4-sJh"; */
"hxE-X4-sJh.title" = "Lyrics";
"hxE-X4-sJh.title" = "歌词";
2 changes: 1 addition & 1 deletion LyricsX/zh-Hans.lproj/Perference.strings
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@
"slB-q7-1dB.title" = "全局歌词偏移 (ms):";

/* Class = "NSButtonCell"; title = "Draggable"; ObjectID = "T7p-MT-Mrh"; */
"T7p-MT-Mrh.title" = "Draggable";
"T7p-MT-Mrh.title" = "允许拖放";

0 comments on commit f2f6593

Please sign in to comment.