Skip to content

Commit

Permalink
Release: Preview 4 (v0.8-alpha)
Browse files Browse the repository at this point in the history
See Releases.
  • Loading branch information
Justin Bush committed Apr 9, 2020
1 parent ae02357 commit 3509df9
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 60 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions Themes for Music.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 400;
CURRENT_PROJECT_VERSION = 540;
DEVELOPMENT_TEAM = 85N3S3DG8M;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Themes for Music/Info.plist";
Expand All @@ -381,7 +381,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 400;
CURRENT_PROJECT_VERSION = 540;
DEVELOPMENT_TEAM = 85N3S3DG8M;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Themes for Music/Info.plist";
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion Themes for Music/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if hideLogo { toggleLogoMenu.state = .on }
else { toggleLogoMenu.state = .off }

print("signedIn: \(signedIn)")
if debug { print("User is signed in: \(signedIn)") }

if signedIn { toggleLoginMenu.title = "Sign Out" }
else { toggleLoginMenu.title = "Sign In" }
Expand Down
6 changes: 4 additions & 2 deletions Themes for Music/Customizer/CustomizerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ class CustomizerViewController: NSViewController, WKUIDelegate, WKNavigationDele
}

override func viewDidAppear() {
if delegate != nil { print("Delegate is GOOD") }
else { print("Delegate = nil")}
if debug {
if delegate != nil { print("Customizable delegate is set to ViewController") }
else { print("Error: Customizable delegate = nil")}
}
}

// MARK: Customizer Setup
Expand Down
78 changes: 39 additions & 39 deletions Themes for Music/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,44 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http:https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020 Justin Bush. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticTermination</key>
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.music</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020 Justin Bush. All rights reserved.</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticTermination</key>
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
</dict>
</plist>
36 changes: 20 additions & 16 deletions Themes for Music/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var nowURL = "" // Saves current URL to memory
var lastURL = "" // Saves previous URL to memory
var initLaunch = true // Determines if app just launched

let debug = false // Activates debugger functions on true
let debug = true // Activates debugger functions on true

class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWindowDelegate, Customizable { //, WKScriptMessageHandler {

Expand Down Expand Up @@ -122,7 +122,8 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi
override func viewWillDisappear() {
saveDefaults() // Save Active.values to Defaults
saveDefaultSettings() // Save UI Settings to Defaults
print(self.view.window!.frame.size)
if debug { print("Saved User Session") }
if debug { print("Window Size: \(view.window!.frame.size)") }
}


Expand Down Expand Up @@ -181,6 +182,7 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi
/// Slide-out Customizer menu with animation and slightly fade main player `webView`
func showCustomizer() {
customizerView.isHidden = false
customizerButton.image = NSImage(named: "NSStopProgressFreestandingTemplate")
NSAnimationContext.runAnimationGroup({ (context) -> Void in
context.duration = 0.2 //length of the animation time in seconds
customizerConstraint.animator().constant = 280
Expand All @@ -191,6 +193,7 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi
}
/// Slide-back/hide Customizer menu with animation and fade-in main player `webView` from slightly translucent state
func hideCustomizer() {
customizerButton.image = NSImage(named: "NSSmartBadgeTemplate")
NSAnimationContext.runAnimationGroup({ (context) -> Void in
context.duration = 0.2 //length of the animation time in seconds
customizerConstraint.animator().constant = 0
Expand Down Expand Up @@ -220,7 +223,7 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi
// MARK: Manage URL

@IBAction func runJSCode(_ sender: Any) {
print("LoginWindow is open: \(loginWindowIsOpen())")
if debug { print("LoginWindow is open: \(loginWindowIsOpen())") }
}

func updateLoginStatus() {
Expand Down Expand Up @@ -263,9 +266,11 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi
if key == 0 { signedIn = true; User.isSignedIn = true }
else if key == 1 { signedIn = false; User.isSignedIn = false }
}

print("signedIn: \(signedIn)\nloginWindowState: \(loginWindowState)")
print("login isKeyWindow: \(isKeyWindow)")
if debug {
print("signedIn: \(signedIn)")
print("loginWindowState: \(loginWindowState)")
print("login isKeyWindow: \(isKeyWindow)")
}

if signedIn && loginWindowState {
if isKeyWindow {
Expand Down Expand Up @@ -531,7 +536,7 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi
/// Sets global variable `artwork` to input image string
func setArtwork(_ image: String) {
artwork = image
print("setArtwork: \(artwork)")
if debug { print("setArtwork: \(artwork)") }
}

// <audio id="apple-music-player" preload="metadata" title="Get Free (feat. Amber Coffman) - Major Lazer - Get Free - Single" src="blob:https://beta.music.apple.com/12e4f769-3bb7-3b4f-ad49-7b1bcf635f1c"></audio>
Expand Down Expand Up @@ -600,8 +605,10 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi
loadDefaults()
setStyle(Active.style)
if Active.clear { setTransparent() }
if Active.image.contains("file:https://") { Active.image = "" }
setImage(Active.image)
else {
if Active.image.contains("file:https://") { Active.image = "" }
setImage(Active.image)
}
}

/// Sets app Style and NSAppearance (Light/Dark - based on Style)
Expand Down Expand Up @@ -836,16 +843,17 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi
let title = "Confirm Sign Out"
let text = "Are you sure that you want to sign out of Apple Music?"
if showAlert(title: title, text: text, withAction: true) {
print("\(consoleDiv)\nAttempting to clear cookies...")
print("\(consoleDiv)\nAttempting to clear cookies & cache...")
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
print("[WebCacheCleaner] All cookies deleted")

WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
records.forEach { record in
WKWebsiteDataStore.default().removeData(ofTypes: record.dataTypes, for: [record], completionHandler: {})
print("[WebCacheCleaner] Record \(record) deleted")
if debug { print("[WebCacheCleaner] Record \(record) deleted") }
}
}
print("Successfully cleared cookies & cache.")
webView.load(Music.url)
return true
}
Expand Down Expand Up @@ -1066,10 +1074,6 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi



// MARK: CUSTOMIZER HERE



// MARK: Extra Setup

// Handle segues
Expand Down Expand Up @@ -1132,7 +1136,7 @@ class ViewController: NSViewController, WKUIDelegate, WKNavigationDelegate, NSWi

// Print new window dimensions when resized
func windowDidResize(_ notification: Notification) {
print("WindowDidResize:", view.window!.frame.size)
if debug { print("WindowDidResize:", view.window!.frame.size) }
}

var lastConsoleEntry = ""
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Themes for Music/WebCustomizer/themes.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<div class="row">

<div class="hover cards">
<card><a onclick="setClear()"><img src="images/themes/transparent.png"></a></card>
<card><a onclick="setCustom()"><img src="images/themes/custom.png"></a></card>
<card><a onclick="setWave()"><img src="images/themes/wave.png"></a></card>
<card><a onclick="setSpring()"><img src="images/themes/spring.png"></a></card>
Expand All @@ -31,6 +32,7 @@
<script>
function closeWindow(){ window.webkit.messageHandlers.jsHandler.postMessage("close"); }

function setClear() { window.webkit.messageHandlers.jsHandler.postMessage("clear"); }
function setCustom() { window.webkit.messageHandlers.jsHandler.postMessage("custom"); }

function setDefault() { window.webkit.messageHandlers.jsHandler.postMessage("preset"); }
Expand Down

0 comments on commit 3509df9

Please sign in to comment.