Skip to content

Commit

Permalink
Issue #437: Fix missing battery icon when battery powered not set
Browse files Browse the repository at this point in the history
  • Loading branch information
mipolansk committed Dec 6, 2024
1 parent 2c1404b commit 6c5d5d9
Show file tree
Hide file tree
Showing 34 changed files with 2,715 additions and 2,668 deletions.
4 changes: 4 additions & 0 deletions SUPLA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
A517DFED2CFD9C2300D6148C /* SAProfileServer+Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = A517DFEC2CFD9C1C00D6148C /* SAProfileServer+Mock.swift */; };
A517DFEF2CFDA4AD00D6148C /* ChannelStateRepositoryMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = A517DFEE2CFDA4A700D6148C /* ChannelStateRepositoryMock.swift */; };
A517DFF12D009DC500D6148C /* GetChannelIssuesForSlavesUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = A517DFF02D009DC000D6148C /* GetChannelIssuesForSlavesUseCase.swift */; };
A517DFF32D03241D00D6148C /* KotlinBoolean+iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = A517DFF22D03241500D6148C /* KotlinBoolean+iOS.swift */; };
A51BE8E72AA705AD00718F2F /* StandardDetailVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51BE8E52AA705AD00718F2F /* StandardDetailVM.swift */; };
A51BE8E82AA705AD00718F2F /* StandardDetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51BE8E62AA705AD00718F2F /* StandardDetailVC.swift */; };
A51BE8EB2AA7136000718F2F /* ThermostatDetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A51BE8EA2AA7136000718F2F /* ThermostatDetailVC.swift */; };
Expand Down Expand Up @@ -1864,6 +1865,7 @@
A517DFEC2CFD9C1C00D6148C /* SAProfileServer+Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SAProfileServer+Mock.swift"; sourceTree = "<group>"; };
A517DFEE2CFDA4A700D6148C /* ChannelStateRepositoryMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelStateRepositoryMock.swift; sourceTree = "<group>"; };
A517DFF02D009DC000D6148C /* GetChannelIssuesForSlavesUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetChannelIssuesForSlavesUseCase.swift; sourceTree = "<group>"; };
A517DFF22D03241500D6148C /* KotlinBoolean+iOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KotlinBoolean+iOS.swift"; sourceTree = "<group>"; };
A51BE8E52AA705AD00718F2F /* StandardDetailVM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StandardDetailVM.swift; sourceTree = "<group>"; };
A51BE8E62AA705AD00718F2F /* StandardDetailVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StandardDetailVC.swift; sourceTree = "<group>"; };
A51BE8EA2AA7136000718F2F /* ThermostatDetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThermostatDetailVC.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4827,6 +4829,7 @@
A58D1B7C2CDCB10700B5A019 /* Shared */ = {
isa = PBXGroup;
children = (
A517DFF22D03241500D6148C /* KotlinBoolean+iOS.swift */,
A54260212CE38CC300BE74FE /* ListItemIssues+iOS.swift */,
A58D1B832CDCF28100B5A019 /* Supla+Shareable.swift */,
A58D1B812CDCE29000B5A019 /* KotlinInt+iOS.swift */,
Expand Down Expand Up @@ -6867,6 +6870,7 @@
A5B3CBDF2B62504D00F95AC3 /* GetChannelValueUseCase.swift in Sources */,
A5A15FED2C298A6A0049AA73 /* StatusVC.swift in Sources */,
A58A9C072AA1D64A00D28848 /* ChannelRelationRepository.swift in Sources */,
A517DFF32D03241D00D6148C /* KotlinBoolean+iOS.swift in Sources */,
A5AE7A8B2A3ADF330097FA8B /* TitleSwitchCell.swift in Sources */,
A598CAC32CC246DF00A784FA /* ImpulseCounterValueProvider.swift in Sources */,
01C1719A22C7F55B005983E1 /* SAMeasurementItem+CoreDataProperties.m in Sources */,
Expand Down
7 changes: 2 additions & 5 deletions SUPLA/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
SALog.debug("Application did enter background")
wasInBackground = true

var settings = settings
settings.backgroundEntryTime = dateProvider.currentTimestamp()

disconnectUseCase.invokeSynchronous(reason: .appInBackground)
Expand All @@ -112,7 +111,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
SALog.debug("Push token: \(token)")
#endif

var settings = settings
settings.pushToken = deviceToken
UpdateTokenTask().update(token: deviceToken) { SALog.info("Token update task finished") }
}
Expand All @@ -133,7 +131,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
}

func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler(.alert)
completionHandler([.list, .banner])
}

private func registerForNotifications() {
Expand All @@ -144,8 +142,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
DispatchQueue.main.async { UIApplication.shared.registerForRemoteNotifications() }
} else {
SALog.error("Notifications not allowed \(String(describing: error))")
var settings = self?.settings
settings?.pushToken = nil
self?.settings.pushToken = nil
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions SUPLA/Core/Shared/KotlinBoolean+iOS.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
/*
Copyright (C) AC SOFTWARE SP. Z O.O.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

import SharedCore

extension KotlinBoolean {
static func from(_ value: Bool?) -> KotlinBoolean? {
if let value {
return .init(bool: value)
} else {
return nil
}
}
}
2 changes: 1 addition & 1 deletion SUPLA/Model/CoreData/Extensions/SAChannel+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ extension SAChannel {

if state.batteryPowered != nil || state.batteryLevel != nil {
return BatteryInfo(
batteryPowered: state.batteryPowered?.boolValue ?? false,
batteryPowered: KotlinBoolean.from(state.batteryPowered?.boolValue),
level: KotlinInt.from(state.batteryLevel),
health: KotlinInt.from(state.batteryHealth)
)
Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/Default.strings
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"channel_caption_garage_door" = "Garage door";
"channel_caption_pump_switch" = "Pump sitch";
"channel_caption_heat_or_cold_source_switch" = "Heat or cold source switch";
"channel_caption_humidity" = "Humidity";
"channel_offline" = "Channel is offline";
"channel_battery_level" = "Battery level (%d - %@): %d%%";

Expand Down
2 changes: 1 addition & 1 deletion SUPLA/Resources/LocalizedStringId+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension LocalizedStringId {
case .channelCaptionPowerSwitch: NSLocalizedString("Power switch", comment: "")
case .channelCaptionLightswitch: NSLocalizedString("Lighting switch", comment: "")
case .channelCaptionThermometer: NSLocalizedString("Thermometer", comment: "")
case .channelCaptionHumidity: NSLocalizedString("Humidity", comment: "")
case .channelCaptionHumidity: Strings.General.Channel.captionHumidity
case .channelCaptionHumidityAndTemperature: NSLocalizedString("Humidity and temperature", comment: "")
case .channelCaptionWindSensor: NSLocalizedString("Wind sensor", comment: "")
case .channelCaptionPressureSensor: NSLocalizedString("Pressure sensor", comment: "")
Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ struct Strings {
static let captionGarageDoor = "channel_caption_garage_door".toLocalized()
static let captionPumpSwitch = "channel_caption_pump_switch".toLocalized()
static let captionHeatOrCouldSourceSwitch = "channel_caption_heat_or_cold_source_switch".toLocalized()
static let captionHumidity = "channel_caption_humidity".toLocalized()

static let batteryLevel = "channel_battery_level".toLocalized()
}
Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/cs.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@
"channel_caption_alarm_armament" = "Snímač nastavení alarmu";
"channel_caption_general_purpose_measurment" = "Kanál měření";
"channel_caption_general_purpose_meter" = "Počítací kanál";
"channel_caption_humidity" = "Vlhkost";
"channel_offline" = "Kanál je v režimu offline";
"channel_battery_level" = "Stav baterie (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
"channel_caption_garage_door" = "Garagentor";
"channel_caption_pump_switch" = "Pumpenschalter";
"channel_caption_heat_or_cold_source_switch" = "Wärme- oder Kältequellenschalter";
"channel_caption_humidity" = "Feuchtigkeitssensor";
"channel_offline" = "Das Kanal ist offline";
"channel_battery_level" = "Batteriefüllstand (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/el.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
"channel_caption_garage_door" = "Γκαραζόπορτα";
"channel_caption_pump_switch" = "Διακόπτης αντλίας";
"channel_caption_heat_or_cold_source_switch" = "Διακόπτης πηγής θερμότητας ή κρύου";
"channel_caption_humidity" = "Υγρασία";
"channel_offline" = "Το κανάλι είναι εκτός σύνδεσης";
"channel_battery_level" = "Επίπεδο μπαταρίας (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@
"channel_caption_garage_door" = "Puerta de garaje";
"channel_caption_pump_switch" = "Interruptor de la bomba";
"channel_caption_heat_or_cold_source_switch" = "Interruptor para fuente de calor o frío";
"channel_caption_humidity" = "Humedad";
"channel_offline" = "El canal está offline";
"channel_battery_level" = "Nivel de batería (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
"channel_caption_facade_blinds" = "Store externe";
"channel_caption_pump_switch" = "Interrupteur de pompe";
"channel_caption_heat_or_cold_source_switch" = "Interrupteur pour la source de chaleur ou de froid";
"channel_caption_humidity" = "Humidité";
"channel_offline" = "La chaîne est hors ligne";
"channel_battery_level" = "Livello batteria (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@
"channel_caption_garage_door" = "Portone di garage";
"channel_caption_pump_switch" = "Commutatore della pompa";
"channel_caption_heat_or_cold_source_switch" = "Commutatore della fonte di calore o di freddo";
"channel_caption_humidity" = "Umidità";
"channel_offline" = "Il canale è offline";
"channel_battery_level" = "Livello batteria (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/lt.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@
"channel_caption_hotelcard" = "Viešbučio kortelės jutiklis";
"channel_caption_pump_switch" = "Siurblio perjungiklis";
"channel_caption_heat_or_cold_source_switch" = "Šilumos arba vėsinimo šaltinio perjungiklis";
"channel_caption_humidity" = "Drėgmė";
"channel_offline" = "Kanalas yra offline";
"channel_battery_level" = "Baterijos lygis (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/nb.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@
"channel_caption_garage_door" = "Garasjeporten";
"channel_caption_pump_switch" = "Pumpebryter";
"channel_caption_heat_or_cold_source_switch" = "Bryter for varme- eller kuldekilde";
"channel_caption_humidity" = "Fuktighet";
"channel_offline" = "Kanalen er offline";
"channel_battery_level" = "Batterinivå (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/nl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
"channel_caption_garage_door" = "Garagedeur";
"channel_caption_pump_switch" = "Pompschakelaar";
"channel_caption_heat_or_cold_source_switch" = "Schakelaar voor warmte- of koudebron";
"channel_caption_humidity" = "Vochtigheid";
"channel_offline" = "Het kanaal is offline";
"channel_battery_level" = "Batterijniveau (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/pl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@
"channel_caption_garage_door" = "Brama garażowa";
"channel_caption_pump_switch" = "Przełącznik pompy";
"channel_caption_heat_or_cold_source_switch" = "Przełącznik źródła ciepła lub chłodu";
"channel_caption_humidity" = "Wilgotność";
"channel_offline" = "Kanał jest offline";
"channel_battery_level" = "Poziom baterii (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/pt-PT.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
"channel_caption_garage_door" = "Portão de garagem";
"channel_caption_pump_switch" = "Interruptor da bomba";
"channel_caption_heat_or_cold_source_switch" = "Interruptor da fonte de calor ou frio";
"channel_caption_humidity" = "Humidade";
"channel_offline" = "O canal está offline";
"channel_battery_level" = "Nível de bateria (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/sk-SK.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
"channel_caption_garage_door" = "Garážová brána";
"channel_caption_pump_switch" = "Spínač čerpadla";
"channel_caption_heat_or_cold_source_switch" = "Prepínač pre zdroj tepla alebo chladu";
"channel_caption_humidity" = "Vlhkosť";
"channel_offline" = "Kanál je v režime offline";
"channel_battery_level" = "Úroveň batérie (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/sl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
"channel_caption_garage_door" = "Garažna vrata";
"channel_caption_pump_switch" = "Stikalo črpalke";
"channel_caption_heat_or_cold_source_switch" = "Stikalo za vir toplote ali hladu";
"channel_caption_humidity" = "Vlažnost";
"channel_offline" = "Kanal je brez povezave";
"channel_battery_level" = "Raven baterije (%d - %@): %d%%";

Expand Down
1 change: 1 addition & 0 deletions SUPLA/Resources/uk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
"channel_caption_garage_door" = "Гаражні двері";
"channel_caption_pump_switch" = "Перемикач насоса";
"channel_caption_heat_or_cold_source_switch" = "Перемикач джерела тепла або холоду";
"channel_caption_humidity" = "Вологість";
"channel_offline" = "Канал не в мережі";
"channel_battery_level" = "Рівень заряду батареї (%d - %@): %d%%";

Expand Down
10 changes: 5 additions & 5 deletions SharedCore.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>SharedCore.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>SharedCore.framework/SharedCore</string>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>SharedCore.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ Classes:
- Name: "batteryPowered"
PropertyKind: "Instance"
SwiftName: "batteryPowered"
Type: "BOOL"
Type: "SharedCoreBoolean * _Nullable"
- Name: "health"
PropertyKind: "Instance"
SwiftName: "health"
Expand All @@ -1616,7 +1616,7 @@ Classes:
SwiftName: "init(batteryPowered:level:health:)"
Parameters:
- Position: 0
Type: "BOOL"
Type: "SharedCoreBoolean * _Nullable"
- Position: 1
Type: "SharedCoreInt * _Nullable"
- Position: 2
Expand All @@ -1627,7 +1627,7 @@ Classes:
ResultType: "SharedCoreBatteryInfo * _Nonnull"
Parameters:
- Position: 0
Type: "BOOL"
Type: "SharedCoreBoolean * _Nullable"
- Position: 1
Type: "SharedCoreInt * _Nullable"
- Position: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ __attribute__((swift_name("ThermostatSubfunction.Companion")))
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("BatteryInfo")))
@interface SharedCoreBatteryInfo : SharedCoreBase
@property (readonly) BOOL batteryPowered __attribute__((swift_name("batteryPowered")));
@property (readonly) SharedCoreBoolean * _Nullable batteryPowered __attribute__((swift_name("batteryPowered")));
@property (readonly) SharedCoreInt * _Nullable health __attribute__((swift_name("health")));
@property (readonly) SharedCoreInt * _Nullable level __attribute__((swift_name("level")));
- (instancetype)initWithBatteryPowered:(BOOL)batteryPowered level:(SharedCoreInt * _Nullable)level health:(SharedCoreInt * _Nullable)health __attribute__((swift_name("init(batteryPowered:level:health:)"))) __attribute__((objc_designated_initializer));
- (SharedCoreBatteryInfo *)doCopyBatteryPowered:(BOOL)batteryPowered level:(SharedCoreInt * _Nullable)level health:(SharedCoreInt * _Nullable)health __attribute__((swift_name("doCopy(batteryPowered:level:health:)")));
- (instancetype)initWithBatteryPowered:(SharedCoreBoolean * _Nullable)batteryPowered level:(SharedCoreInt * _Nullable)level health:(SharedCoreInt * _Nullable)health __attribute__((swift_name("init(batteryPowered:level:health:)"))) __attribute__((objc_designated_initializer));
- (SharedCoreBatteryInfo *)doCopyBatteryPowered:(SharedCoreBoolean * _Nullable)batteryPowered level:(SharedCoreInt * _Nullable)level health:(SharedCoreInt * _Nullable)health __attribute__((swift_name("doCopy(batteryPowered:level:health:)")));
- (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)")));
- (NSUInteger)hash __attribute__((swift_name("hash()")));
- (NSString *)description __attribute__((swift_name("description()")));
Expand Down
Binary file not shown.
Binary file modified SharedCore.xcframework/ios-arm64/SharedCore.framework/SharedCore
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 6c5d5d9

Please sign in to comment.