Skip to content

Commit

Permalink
Update NSExtensionPointVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelhanneken committed Mar 3, 2019
1 parent 21a6b76 commit 0bb2f60
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
4 changes: 3 additions & 1 deletion Apple Juice Widget/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionPointVersion</key>
<string>2.0</string>
<string>3.0</string>
</dict>
<key>NSExtensionMainNibFile</key>
<string>TodayViewController</string>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.widget-extension</string>
<key>NSExtensionPrincipalClass</key>
Expand Down
4 changes: 2 additions & 2 deletions Apple Juice.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "io.raphaelhanneken.applejuice.Apple-Juice-Widget";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -538,7 +538,7 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.12;
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = "io.raphaelhanneken.applejuice.Apple-Juice-Widget";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
8 changes: 4 additions & 4 deletions Apple Juice/ApplicationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ final class ApplicationController: NSObject {
do {
self.battery = try BatteryService()
self.statusItem = StatusBarItem(forBattery: self.battery,
withTarget: self,
andAction: #selector(ApplicationController.displayAppMenu(_:)))
withTarget: self,
andAction: #selector(ApplicationController.displayAppMenu(_:)))

self.statusItem?.update(batteryInfo: self.battery)
self.registerAsObserver()
} catch {
self.statusItem = StatusBarItem(forError: error as? BatteryError,
withTarget: self,
andAction: #selector(ApplicationController.displayAppMenu(_:)))
withTarget: self,
andAction: #selector(ApplicationController.displayAppMenu(_:)))
}
}

Expand Down
24 changes: 12 additions & 12 deletions Apple Juice/BatteryService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ final class BatteryService {
}
if charging {
return .charging(percentage: percentage)
} else {
return .discharging(percentage: percentage)
}

return .discharging(percentage: percentage)
}

/// The remaining time until the battery is empty or fully charged
/// in a human readable format, e.g. hh:mm.
var timeRemainingFormatted: String {
// Unwrap required information.
guard let charged = isCharged, let plugged = isPlugged else {
return NSLocalizedString("Unknown", comment: "Translate Unknown")
return NSLocalizedString("Unknown", comment: "")
}
// Check if the battery is charged and plugged into an unlimited power supply.
if charged && plugged {
return NSLocalizedString("Charged", comment: "Translate Charged")
return NSLocalizedString("Charged", comment: "")
}
// The battery is (dis)charging, display the remaining time.
if let time = timeRemaining {
return String(format: "%d:%02d", arguments: [time / 60, time % 60])
} else {
return NSLocalizedString("Calculating", comment: "Translate Calculating")
}

return NSLocalizedString("Calculating", comment: "")
}

/// The remaining time in _minutes_ until the battery is empty or fully charged.
Expand All @@ -80,7 +80,7 @@ final class BatteryService {
}
return nil
default:
// Return the estimated time divided by 60 (seconds to minutes).
// The estimated time in minutes
return Int(time / 60)
}
}
Expand All @@ -103,14 +103,14 @@ final class BatteryService {
/// The source from which the Mac currently draws its power.
var powerSource: String {
guard let plugged = isPlugged else {
return NSLocalizedString("Unknown", comment: "Translate Unknown")
return NSLocalizedString("Unknown", comment: "")
}
// Check whether the MacBook currently is plugged into a power adapter.
if plugged {
return NSLocalizedString("Power Adapter", comment: "Translate Power Adapter")
} else {
return NSLocalizedString("Battery", comment: "Translate Battery")
return NSLocalizedString("Power Adapter", comment: "")
}

return NSLocalizedString("Battery", comment: "")
}

/// Checks whether the battery is charging and connected to a power outlet.
Expand All @@ -135,7 +135,7 @@ final class BatteryService {
let amperage = getRegistryProperty(forKey: .amperage) as? Double else {
return nil
}
return round(((voltage * amperage) / 1_000_000) * 10) / 10
return round((voltage * amperage) / 1_000_000)
}

/// Current flowing into or out of the battery.
Expand Down
4 changes: 2 additions & 2 deletions Apple Juice/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.7.0</string>
<string>1.7.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>333</string>
<string>334</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit 0bb2f60

Please sign in to comment.