瀏覽代碼

icon

tags/v1.4.0
boB Rudis 5 年前
父節點
當前提交
84a254fa9b
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 1D7529BE14E2BBA9
  1. 6
      Podfile
  2. 2
      Podfile.lock
  3. 2
      Pods/Manifest.lock
  4. 4
      Pods/Pods.xcodeproj/project.pbxproj
  5. 4
      RSwitch.xcodeproj/project.pbxproj
  6. 71
      RSwitch/AppDelegate.swift
  7. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-128-1x.png
  8. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-128-2x.png
  9. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-16-1x.png
  10. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-16-2x.png
  11. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-256-1x.png
  12. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-256-2x.png
  13. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-32-1x.png
  14. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-32-2x.png
  15. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-512-1x.png
  16. 二進制
      RSwitch/Assets.xcassets/AppIcon.appiconset/rs-512-2x.png
  17. 4
      RSwitch/Base.lproj/Main.storyboard
  18. 42
      RSwitch/String+Version.swift

6
Podfile

@ -1,11 +1,9 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
platform :osx, '10.14'
target 'RSwitch' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for RSwitch
pod 'SwiftSoup'
end

2
Podfile.lock

@ -11,6 +11,6 @@ SPEC REPOS:
SPEC CHECKSUMS:
SwiftSoup: 230991361c5ba249d140161860a3864a28b63860
PODFILE CHECKSUM: 31d048fe80d57b70a2af7f59ae745d8fd46a1fad
PODFILE CHECKSUM: d5db68a23a6fb36f3d94717563c9d5199d9f3bdf
COCOAPODS: 1.7.5

2
Pods/Manifest.lock

@ -11,6 +11,6 @@ SPEC REPOS:
SPEC CHECKSUMS:
SwiftSoup: 230991361c5ba249d140161860a3864a28b63860
PODFILE CHECKSUM: 31d048fe80d57b70a2af7f59ae745d8fd46a1fad
PODFILE CHECKSUM: d5db68a23a6fb36f3d94717563c9d5199d9f3bdf
COCOAPODS: 1.7.5

4
Pods/Pods.xcodeproj/project.pbxproj

@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 51;
objects = {
/* Begin PBXBuildFile section */
@ -396,7 +396,7 @@
LastUpgradeCheck = 1100;
};
buildConfigurationList = 4821239608C13582E20E6DA73FD5F1F9 /* Build configuration list for PBXProject "Pods" */;
compatibilityVersion = "Xcode 9.3";
compatibilityVersion = "Xcode 10.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (

4
RSwitch.xcodeproj/project.pbxproj

@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
01073F0F2311AE2E007162C9 /* String+Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01073F0E2311AE2E007162C9 /* String+Version.swift */; };
0178970D230ED25100F8F5BC /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0178970C230ED25100F8F5BC /* AboutViewController.swift */; };
01F3EF0C230E635300DF5DF9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F3EF0B230E635300DF5DF9 /* AppDelegate.swift */; };
01F3EF0E230E635300DF5DF9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01F3EF0D230E635300DF5DF9 /* ViewController.swift */; };
@ -16,6 +17,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
01073F0E2311AE2E007162C9 /* String+Version.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+Version.swift"; sourceTree = "<group>"; };
0178970C230ED25100F8F5BC /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
01F3EF08230E635300DF5DF9 /* RSwitch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RSwitch.app; sourceTree = BUILT_PRODUCTS_DIR; };
01F3EF0B230E635300DF5DF9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@ -66,6 +68,7 @@
01F3EF0F230E635500DF5DF9 /* Assets.xcassets */,
01F3EF11230E635500DF5DF9 /* Main.storyboard */,
0178970C230ED25100F8F5BC /* AboutViewController.swift */,
01073F0E2311AE2E007162C9 /* String+Version.swift */,
01F3EF14230E635500DF5DF9 /* Info.plist */,
);
path = RSwitch;
@ -205,6 +208,7 @@
0178970D230ED25100F8F5BC /* AboutViewController.swift in Sources */,
01F3EF0E230E635300DF5DF9 /* ViewController.swift in Sources */,
01F3EF0C230E635300DF5DF9 /* AppDelegate.swift in Sources */,
01073F0F2311AE2E007162C9 /* String+Version.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

71
RSwitch/AppDelegate.swift

@ -21,14 +21,19 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
var mainStoryboard: NSStoryboard!
var abtController: NSWindowController!
let macos_r_framework_dir = "/Library/Frameworks/R.framework/Versions" // Where the official R installs go
let mac_r_project_url = "https://mac.r-project.org/"
let macos_cran_url = "https://cran.rstudio.org/bin/macosx/"
let r_sig_mac_url = "https://stat.ethz.ch/pipermail/r-sig-mac/"
let rstudio_dailies_url = "https://dailies.rstudio.com/rstudio/oss/mac/"
let latest_rstudio_dailies_url = "https://www.rstudio.org/download/latest/daily/desktop/mac/RStudio-latest.dmg"
let browse_r_admin_macos_url = "https://cran.rstudio.org/doc/manuals/R-admin.html#Installing-R-under-macOS"
struct app_urls {
static let mac_r_project = "https://mac.r-project.org/"
static let macos_cran = "https://cran.rstudio.org/bin/macosx/"
static let r_sig_mac = "https://stat.ethz.ch/pipermail/r-sig-mac/"
static let rstudio_dailies = "https://dailies.rstudio.com/rstudio/oss/mac/"
static let latest_rstudio_dailies = "https://www.rstudio.org/download/latest/daily/desktop/mac/RStudio-latest.dmg"
static let browse_r_admin_macos = "https://cran.rstudio.org/doc/manuals/R-admin.html#Installing-R-under-macOS"
static let version_check = "https://rud.is/rswitch/releases/current-version.txt"
static let releases = "https://git.rud.is/hrbrmstr/RSwitch/releases"
}
// Get the bar setup
let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
@ -54,6 +59,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
rdevel_enabled = true
rstudio_enabled = true
URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)
}
@ -111,32 +118,32 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
// browse macOS dev page
@objc func browse_r_macos_dev_page(_ sender: NSMenuItem?) {
let url = URL(string: mac_r_project_url)!
let url = URL(string: app_urls.mac_r_project)!
NSWorkspace.shared.open(url)
}
// browse macOS dev page
@objc func browse_r_macos_cran_page(_ sender: NSMenuItem?) {
let url = URL(string: macos_cran_url)!
let url = URL(string: app_urls.macos_cran)!
NSWorkspace.shared.open(url)
}
// browse macOS dev page
@objc func browse_r_sig_mac_page(_ sender: NSMenuItem?) {
let url = URL(string: r_sig_mac_url)!
let url = URL(string: app_urls.r_sig_mac)!
NSWorkspace.shared.open(url)
}
// browse RStudio macOS Dailies
@objc func browse_rstudio_mac_dailies_page(_ sender: NSMenuItem?) {
let url = URL(string: rstudio_dailies_url)!
let url = URL(string: app_urls.rstudio_dailies)!
NSWorkspace.shared.open(url)
}
// browse R Install/Admin macOS section
@objc func browse_r_admin_macos_page(_ sender: NSMenuItem?) {
let url = URL(string: browse_r_admin_macos_url)!
let url = URL(string: app_urls.browse_r_admin_macos)!
NSWorkspace.shared.open(url)
}
@ -159,13 +166,35 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
@objc func launchRApp(_ sender: NSMenuItem?) {
NSWorkspace.shared.launchApplication("R.app")
}
// Launch R.app
@objc func checkForUpdate(_ sender: NSMenuItem?) {
let url = URL(string: app_urls.version_check)
do {
URLCache.shared.removeAllCachedResponses()
var version = try String.init(contentsOf: url!)
version = version.trimmingCharacters(in: .whitespacesAndNewlines)
if (version.isVersion(greaterThan: Bundle.main.releaseVersionNumber!)) {
let url = URL(string: app_urls.releases)
NSWorkspace.shared.open(url!)
} else {
self.notifyUser(title: "RSwitch", text: "You are running the latest version of RSwitch.")
}
} catch {
self.notifyUser(title: "Action failed", subtitle: "Update check", text: "Error: \(error)")
}
}
// Download latest rstudio daily build
@objc func download_latest_rstudio(_ sender: NSMenuItem?) {
self.rstudio_enabled = false
let url = URL(string: rstudio_dailies_url)
let url = URL(string: app_urls.rstudio_dailies)
do {
@ -300,6 +329,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
}
extension Bundle {
var releaseVersionNumber: String? {
return infoDictionary?["CFBundleShortVersionString"] as? String
}
var buildVersionNumber: String? {
return infoDictionary?["CFBundleVersion"] as? String
}
var releaseVersionNumberPretty: String {
return "v\(releaseVersionNumber ?? "1.0.0")"
}
}
extension AppDelegate: NSMenuDelegate {
func menuWillOpen(_ menu: NSMenu) {
@ -384,6 +425,10 @@ extension AppDelegate: NSMenuDelegate {
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(title: NSLocalizedString("Launch R GUI", comment: "Launch R GUI item"), action: #selector(launchRApp), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: NSLocalizedString("Launch RStudio", comment: "Launch RStudio item"), action: #selector(launchRStudio), keyEquivalent: ""))
// Add a About item
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(title: NSLocalizedString("Check for update…", comment: "Check for update item"), action: #selector(checkForUpdate), keyEquivalent: ""))
// Add a About item
menu.addItem(NSMenuItem.separator())

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-128-1x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 8.0 KiB

之後

寬度:  |  高度:  |  大小: 11 KiB

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-128-2x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 16 KiB

之後

寬度:  |  高度:  |  大小: 25 KiB

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-16-1x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 1.6 KiB

之後

寬度:  |  高度:  |  大小: 1.6 KiB

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-16-2x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 2.6 KiB

之後

寬度:  |  高度:  |  大小: 2.7 KiB

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-256-1x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 16 KiB

之後

寬度:  |  高度:  |  大小: 25 KiB

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-256-2x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 32 KiB

之後

寬度:  |  高度:  |  大小: 64 KiB

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-32-1x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 2.6 KiB

之後

寬度:  |  高度:  |  大小: 2.7 KiB

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-32-2x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 4.3 KiB

之後

寬度:  |  高度:  |  大小: 5.4 KiB

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-512-1x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 32 KiB

之後

寬度:  |  高度:  |  大小: 64 KiB

二進制
RSwitch/Assets.xcassets/AppIcon.appiconset/rs-512-2x.png

未顯示二進位檔案。

之前

寬度:  |  高度:  |  大小: 69 KiB

之後

寬度:  |  高度:  |  大小: 152 KiB

4
RSwitch/Base.lproj/Main.storyboard

@ -754,11 +754,11 @@ MIT Licensed
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
</attributes>
</fragment>
<fragment content="https://git.rud.is/hrbrmstr/RSwitch">
<fragment content="https://rud.is/rswitch/">
<attributes>
<color key="NSColor" name="textColor" catalog="System" colorSpace="catalog"/>
<font key="NSFont" metaFont="label" size="17"/>
<url key="NSLink" string="https://git.rud.is/hrbrmstr/RSwitch"/>
<url key="NSLink" string="https://rud.is/rswitch/"/>
<paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
</attributes>
</fragment>

42
RSwitch/String+Version.swift

@ -0,0 +1,42 @@
//
// String+Version.swift
// Pods
//
// Created by DragonCherry on 5/11/17.
//
//
import Foundation
extension String {
/// Inner comparison utility to handle same versions with different length. (Ex: "1.0.0" & "1.0")
private func compare(toVersion targetVersion: String) -> ComparisonResult {
let versionDelimiter = "."
var result: ComparisonResult = .orderedSame
var versionComponents = components(separatedBy: versionDelimiter)
var targetComponents = targetVersion.components(separatedBy: versionDelimiter)
let spareCount = versionComponents.count - targetComponents.count
if spareCount == 0 {
result = compare(targetVersion, options: .numeric)
} else {
let spareZeros = repeatElement("0", count: abs(spareCount))
if spareCount > 0 {
targetComponents.append(contentsOf: spareZeros)
} else {
versionComponents.append(contentsOf: spareZeros)
}
result = versionComponents.joined(separator: versionDelimiter)
.compare(targetComponents.joined(separator: versionDelimiter), options: .numeric)
}
return result
}
public func isVersion(equalTo targetVersion: String) -> Bool { return compare(toVersion: targetVersion) == .orderedSame }
public func isVersion(greaterThan targetVersion: String) -> Bool { return compare(toVersion: targetVersion) == .orderedDescending }
public func isVersion(greaterThanOrEqualTo targetVersion: String) -> Bool { return compare(toVersion: targetVersion) != .orderedAscending }
public func isVersion(lessThan targetVersion: String) -> Bool { return compare(toVersion: targetVersion) == .orderedAscending }
public func isVersion(lessThanOrEqualTo targetVersion: String) -> Bool { return compare(toVersion: targetVersion) != .orderedDescending }
}
載入中…
取消
儲存