Skip to content

Commit

Permalink
- Updated for Xcode 9.3
Browse files Browse the repository at this point in the history
- Merging iOS and Android localization files (wip)
- Minor cosmetic code fixes
  • Loading branch information
antonio-openroad committed Apr 11, 2018
1 parent f658ab1 commit d19f8b8
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 15 deletions.
6 changes: 5 additions & 1 deletion Bluefruit.xcodeproj/project.pbxproj
Expand Up @@ -1742,7 +1742,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = Adafruit;
TargetAttributes = {
A9286C951E3A9216008E5F81 = {
Expand Down Expand Up @@ -2419,13 +2419,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down Expand Up @@ -2475,13 +2477,15 @@
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
Expand Down
8 changes: 8 additions & 0 deletions Bluefruit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Expand Up @@ -9,7 +9,6 @@
import Foundation

class BleUUIDNames {

// Manager
static let shared = BleUUIDNames()

Expand Down
Expand Up @@ -102,5 +102,4 @@ class UartPacketManagerBase {
receivedBytes = 0
sentBytes = 0
}

}
2 changes: 1 addition & 1 deletion Bluefruit/Common/Modules/ControllerModuleManager.swift
Expand Up @@ -127,7 +127,7 @@ class ControllerModuleManager: NSObject {

// MARK: -
private func startUpdatingData() {
pollTimer = MSWeakTimer.scheduledTimer(withTimeInterval: pollInterval, target: self, selector: #selector(updateSensors), userInfo: nil, repeats: true, dispatchQueue: DispatchQueue.main)
pollTimer = MSWeakTimer.scheduledTimer(withTimeInterval: pollInterval, target: self, selector: #selector(updateSensors), userInfo: nil, repeats: true, dispatchQueue: .main)
}

private func stopUpdatingData() {
Expand Down
Expand Up @@ -170,10 +170,10 @@ class InfoModeViewController: PeripheralModeViewController {
elementsDiscovered = 0

// Order services so "DIS" is at the top (if present)
let kDisServiceUUID = "180A" // DIS service UUID
let kDisServiceUUID = CBUUID(string: InfoModeViewController.kDeviceInformationService)
if let unorderedServices = services {
services = unorderedServices.sorted(by: { (serviceA, serviceB) -> Bool in
let isServiceBDis = serviceB.uuid.isEqual(CBUUID(string: kDisServiceUUID))
let isServiceBDis = serviceB.uuid.isEqual(kDisServiceUUID)
return !isServiceBDis
})
}
Expand Down
Expand Up @@ -13,7 +13,7 @@ import UIColor_Hex

class UartBaseViewController: PeripheralModeViewController {
// Config
fileprivate static var dataRxFont = UIFont(name: "CourierNewPSMT", size: 14)! //Font.systemFontOfSize(Font.systemFontSize())
fileprivate static var dataRxFont = UIFont(name: "CourierNewPSMT", size: 14)!
fileprivate static var dataTxFont = UIFont(name: "CourierNewPS-BoldMT", size: 14)!

// Export
Expand Down Expand Up @@ -122,6 +122,10 @@ class UartBaseViewController: PeripheralModeViewController {
}
}

// Localization
sendInputButton.setTitle(localizationManager.localizedString("uart_send_action"), for: .normal)
sendPeripheralButton?.setTitle(localizationManager.localizedString("uart_send_toall_action"), for: .normal) // Default value

// Note: uartData should be initialized on the subclasses

}
Expand Down Expand Up @@ -283,7 +287,7 @@ class UartBaseViewController: PeripheralModeViewController {
fileprivate func updateBytesUI() {
let localizationManager = LocalizationManager.sharedInstance
let sentBytesMessage = String(format: localizationManager.localizedString("uart_sentbytes_format"), arguments: [uartData.sentBytes])
let receivedBytesMessage = String(format: localizationManager.localizedString("uart_recievedbytes_format"), arguments: [uartData.receivedBytes])
let receivedBytesMessage = String(format: localizationManager.localizedString("uart_receivedbytes_format"), arguments: [uartData.receivedBytes])

statsLabel.text = String(format: "%@ %@", arguments: [sentBytesMessage, receivedBytesMessage])
}
Expand Down
Expand Up @@ -10,7 +10,6 @@ import UIKit

class UartModeViewController: UartBaseViewController {


// MARK: - View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
Expand Down Expand Up @@ -50,7 +49,7 @@ class UartModeViewController: UartBaseViewController {
guard let context = self else { return }

let peripheralName = blePeripheral.name ?? blePeripheral.identifier.uuidString
DispatchQueue.main.async { [unowned context] in
DispatchQueue.main.async {
guard error == nil else {
DLog("Error initializing uart")
context.dismiss(animated: true, completion: { [weak self] () -> Void in
Expand All @@ -77,7 +76,7 @@ class UartModeViewController: UartBaseViewController {
blePeripheral.uartEnable(uartRxHandler: uartData.rxPacketReceived) { [weak self] error in
guard let context = self else { return }

DispatchQueue.main.async { [unowned context] in
DispatchQueue.main.async {
guard error == nil else {
DLog("Error initializing uart")
context.dismiss(animated: true, completion: { [weak self] in
Expand Down Expand Up @@ -148,12 +147,11 @@ class UartModeViewController: UartBaseViewController {
return color ?? UIColor.black
}


// MARK: - MqttManagerDelegate
override func onMqttMessageReceived(message: String, topic: String) {
guard let blePeripheral = blePeripheral else { return }

DispatchQueue.main.async { [unowned self] in
DispatchQueue.main.async {
guard let uartData = self.uartData as? UartPacketManager else { DLog("Error send with invalid uartData class"); return }
uartData.send(blePeripheral: blePeripheral, text: message, wasReceivedFromMqtt: true)
}
Expand Down
Expand Up @@ -69,10 +69,10 @@ extension UartSelectPeripheralViewController: UITableViewDelegate {

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

let localizationManager = LocalizationManager.sharedInstance
if indexPath.row == 0 {
delegate?.onUartSendToChanged(uuid: nil, name: "To All")
delegate?.onUartSendToChanged(uuid: nil, name: localizationManager.localizedString("uart_send_toall_action"))
} else {
let localizationManager = LocalizationManager.sharedInstance
let peripheral = connectedPeripherals[indexPath.row-1]
let name = peripheral.name ?? localizationManager.localizedString("scanner_unnamed")
delegate?.onUartSendToChanged(uuid: peripheral.identifier, name: name)
Expand Down

0 comments on commit d19f8b8

Please sign in to comment.