summaryrefslogtreecommitdiff
path: root/Example Apps
diff options
context:
space:
mode:
Diffstat (limited to 'Example Apps')
-rw-r--r--Example Apps/Example ObjC/ButtonManager.m12
-rw-r--r--Example Apps/Example ObjC/ConnectionTCPTableViewController.m4
-rw-r--r--Example Apps/Example ObjC/ProxyManager.m30
-rw-r--r--Example Apps/Example Swift/ButtonManager.swift12
-rw-r--r--Example Apps/Example Swift/ProxyManager.swift7
-rw-r--r--Example Apps/Example Swift/ProxyManagerDelegate.swift2
6 files changed, 36 insertions, 31 deletions
diff --git a/Example Apps/Example ObjC/ButtonManager.m b/Example Apps/Example ObjC/ButtonManager.m
index 4ca86be0a..3a82a92e4 100644
--- a/Example Apps/Example ObjC/ButtonManager.m
+++ b/Example Apps/Example ObjC/ButtonManager.m
@@ -77,7 +77,8 @@ NS_ASSUME_NONNULL_BEGIN
SDLSoftButtonState *textState = [[SDLSoftButtonState alloc] initWithStateName:AlertSoftButtonTextState text:AlertSoftButtonText image:nil];
__weak typeof(self) weakself = self;
- SDLSoftButtonObject *alertSoftButton = [[SDLSoftButtonObject alloc] initWithName:AlertSoftButton states:@[imageAndTextState, textState] initialStateName:imageAndTextState.name handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
+ NSString *initialButtonStateName = self.imagesEnabled ? imageAndTextState.name : textState.name;
+ SDLSoftButtonObject *alertSoftButton = [[SDLSoftButtonObject alloc] initWithName:AlertSoftButton states:@[imageAndTextState, textState] initialStateName:initialButtonStateName handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
if (buttonPress == nil) { return; }
if (self.sdlex_isAlertAllowed) {
@@ -99,7 +100,8 @@ NS_ASSUME_NONNULL_BEGIN
SDLSoftButtonState *textState = [[SDLSoftButtonState alloc] initWithStateName:SubtleAlertSoftButtonTextState text:SubtleAlertSoftButtonText image:nil];
__weak typeof(self) weakself = self;
- SDLSoftButtonObject *subtleAlertSoftButton = [[SDLSoftButtonObject alloc] initWithName:SubtleAlertSoftButton states:@[imageAndTextState, textState] initialStateName:imageAndTextState.name handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
+ NSString *initialButtonStateName = self.imagesEnabled ? imageAndTextState.name : textState.name;
+ SDLSoftButtonObject *subtleAlertSoftButton = [[SDLSoftButtonObject alloc] initWithName:SubtleAlertSoftButton states:@[imageAndTextState, textState] initialStateName:initialButtonStateName handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
if (buttonPress == nil) { return; }
if (self.sdlex_isSubtleAlertAllowed) {
@@ -121,7 +123,8 @@ NS_ASSUME_NONNULL_BEGIN
SDLSoftButtonState *textOffState = [[SDLSoftButtonState alloc] initWithStateName:TextVisibleSoftButtonTextOffState text:TextVisibleSoftButtonTextOffText image:nil];
__weak typeof(self) weakself = self;
- SDLSoftButtonObject *textButton = [[SDLSoftButtonObject alloc] initWithName:TextVisibleSoftButton states:@[textOnState, textOffState] initialStateName:textOnState.name handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
+ NSString *initialButtonStateName = self.textEnabled ? textOnState.name : textOffState.name;
+ SDLSoftButtonObject *textButton = [[SDLSoftButtonObject alloc] initWithName:TextVisibleSoftButton states:@[textOnState, textOffState] initialStateName:initialButtonStateName handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
if (buttonPress == nil) { return; }
weakself.textEnabled = !weakself.textEnabled;
@@ -140,7 +143,8 @@ NS_ASSUME_NONNULL_BEGIN
SDLSoftButtonState *imagesOffState = [[SDLSoftButtonState alloc] initWithStateName:ImagesVisibleSoftButtonImageOffState text:ImagesVisibleSoftButtonImageOffText image:nil];
__weak typeof(self) weakself = self;
- SDLSoftButtonObject *imagesButton = [[SDLSoftButtonObject alloc] initWithName:ImagesVisibleSoftButton states:@[imagesOnState, imagesOffState] initialStateName:imagesOnState.name handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
+ NSString *initialButtonStateName = self.imagesEnabled ? imagesOnState.name : imagesOffState.name;
+ SDLSoftButtonObject *imagesButton = [[SDLSoftButtonObject alloc] initWithName:ImagesVisibleSoftButton states:@[imagesOnState, imagesOffState] initialStateName:initialButtonStateName handler:^(SDLOnButtonPress * _Nullable buttonPress, SDLOnButtonEvent * _Nullable buttonEvent) {
if (buttonPress == nil) { return; }
weakself.imagesEnabled = !weakself.imagesEnabled;
diff --git a/Example Apps/Example ObjC/ConnectionTCPTableViewController.m b/Example Apps/Example ObjC/ConnectionTCPTableViewController.m
index c062d5106..3ca9a78a0 100644
--- a/Example Apps/Example ObjC/ConnectionTCPTableViewController.m
+++ b/Example Apps/Example ObjC/ConnectionTCPTableViewController.m
@@ -72,9 +72,7 @@
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.section != 0) {
- return;
- }
+ if (indexPath.section != 0) { return; }
switch (indexPath.row) {
case 0: {
diff --git a/Example Apps/Example ObjC/ProxyManager.m b/Example Apps/Example ObjC/ProxyManager.m
index 06ab5dd02..9a4fa1808 100644
--- a/Example Apps/Example ObjC/ProxyManager.m
+++ b/Example Apps/Example ObjC/ProxyManager.m
@@ -99,29 +99,27 @@ NS_ASSUME_NONNULL_BEGIN
- (void)startWithProxyTransportType:(ProxyTransportType)proxyTransportType {
[self sdlex_updateProxyState:ProxyStateSearchingForConnection];
- SDLLifecycleConfiguration *lifecycleConfig = proxyTransportType == ProxyTransportTypeIAP ? [self.class sdlex_iapLifecycleConfiguration] : [self.class sdlex_tcpLifecycleConfiguration];
- [self sdlex_setupConfigurationWithLifecycleConfiguration:lifecycleConfig];
+ SDLConfiguration *config = (proxyTransportType == ProxyTransportTypeIAP) ? [self.class sdlex_iapConfiguration] : [self.class sdlex_tcpConfiguration];
+ self.sdlManager = [[SDLManager alloc] initWithConfiguration:config delegate:self];
+ [self sdlex_startManager];
}
-+ (SDLLifecycleConfiguration *)sdlex_iapLifecycleConfiguration {
- return [self.class sdlex_setLifecycleConfigurationPropertiesOnConfiguration:[SDLLifecycleConfiguration defaultConfigurationWithAppName:ExampleAppName fullAppId:ExampleFullAppId]];
-}
++ (SDLConfiguration *)sdlex_iapConfiguration {
+ SDLLifecycleConfiguration *lifecycleConfig = [self.class sdlex_setLifecycleConfigurationPropertiesOnConfiguration:[SDLLifecycleConfiguration defaultConfigurationWithAppName:ExampleAppName fullAppId:ExampleFullAppId]];
-+ (SDLLifecycleConfiguration *)sdlex_tcpLifecycleConfiguration {
- return [self.class sdlex_setLifecycleConfigurationPropertiesOnConfiguration:[SDLLifecycleConfiguration debugConfigurationWithAppName:ExampleAppName fullAppId:ExampleFullAppId ipAddress:[Preferences sharedPreferences].ipAddress port:[Preferences sharedPreferences].port]];
+ return [self sdlex_setupManagerConfigurationWithLifecycleConfiguration:lifecycleConfig];
}
-- (void)sdlex_setupConfigurationWithLifecycleConfiguration:(SDLLifecycleConfiguration *)lifecycleConfiguration {
- if (self.sdlManager != nil) {
- // Manager already created, just start it again.
- [self sdlex_startManager];
- return;
- }
++ (SDLConfiguration *)sdlex_tcpConfiguration {
+ SDLLifecycleConfiguration *lifecycleConfig = [self.class sdlex_setLifecycleConfigurationPropertiesOnConfiguration:[SDLLifecycleConfiguration debugConfigurationWithAppName:ExampleAppName fullAppId:ExampleFullAppId ipAddress:[Preferences sharedPreferences].ipAddress port:[Preferences sharedPreferences].port]];
+ return [self sdlex_setupManagerConfigurationWithLifecycleConfiguration:lifecycleConfig];
+}
+
++ (SDLConfiguration *)sdlex_setupManagerConfigurationWithLifecycleConfiguration:(SDLLifecycleConfiguration *)lifecycleConfiguration {
SDLLockScreenConfiguration *lockScreenConfiguration = [SDLLockScreenConfiguration enabledConfigurationWithAppIcon:[UIImage imageNamed:ExampleAppLogoName] backgroundColor:nil];
- SDLConfiguration *config = [[SDLConfiguration alloc] initWithLifecycle:lifecycleConfiguration lockScreen:lockScreenConfiguration logging:[self.class sdlex_logConfiguration] fileManager:[SDLFileManagerConfiguration defaultConfiguration] encryption:[SDLEncryptionConfiguration defaultConfiguration]];
- self.sdlManager = [[SDLManager alloc] initWithConfiguration:config delegate:self];
- [self sdlex_startManager];
+
+ return [[SDLConfiguration alloc] initWithLifecycle:lifecycleConfiguration lockScreen:lockScreenConfiguration logging:[self.class sdlex_logConfiguration] fileManager:[SDLFileManagerConfiguration defaultConfiguration] encryption:[SDLEncryptionConfiguration defaultConfiguration]];
}
+ (SDLLifecycleConfiguration *)sdlex_setLifecycleConfigurationPropertiesOnConfiguration:(SDLLifecycleConfiguration *)config {
diff --git a/Example Apps/Example Swift/ButtonManager.swift b/Example Apps/Example Swift/ButtonManager.swift
index 02d3f7962..197b13e74 100644
--- a/Example Apps/Example Swift/ButtonManager.swift
+++ b/Example Apps/Example Swift/ButtonManager.swift
@@ -63,7 +63,8 @@ extension ButtonManager {
private var softButtonAlert: SDLSoftButtonObject {
let imageAndTextState = SDLSoftButtonState(stateName: AlertSoftButtonImageAndTextState, text: AlertSoftButtonText, image: UIImage(named: AlertBWIconName)?.withRenderingMode(.alwaysTemplate))
let textState = SDLSoftButtonState(stateName: AlertSoftButtonTextState, text: AlertSoftButtonText, image: nil)
- return SDLSoftButtonObject(name: AlertSoftButton, states: [imageAndTextState, textState], initialStateName: imageAndTextState.name) { [weak self] (buttonPress, buttonEvent) in
+ let initialButtonStateName = self.imagesEnabled ? imageAndTextState.name : textState.name
+ return SDLSoftButtonObject(name: AlertSoftButton, states: [imageAndTextState, textState], initialStateName: initialButtonStateName) { [weak self] (buttonPress, buttonEvent) in
guard let self = self, buttonPress != nil else { return }
if (self.isAlertAllowed) {
@@ -80,7 +81,8 @@ extension ButtonManager {
private var softButtonSubtleAlert: SDLSoftButtonObject {
let imageAndTextState = SDLSoftButtonState(stateName: SubtleAlertSoftButtonImageAndTextState, text: SubtleAlertSoftButtonText, image: UIImage(named: BatteryFullBWIconName)?.withRenderingMode(.alwaysTemplate))
let textState = SDLSoftButtonState(stateName: SubtleAlertSoftButtonTextState, text: SubtleAlertSoftButtonText, image: nil)
- return SDLSoftButtonObject(name: SubtleAlertSoftButton, states: [imageAndTextState, textState], initialStateName: imageAndTextState.name) { [weak self] (buttonPress, buttonEvent) in
+ let initialButtonStateName = self.imagesEnabled ? imageAndTextState.name : textState.name
+ return SDLSoftButtonObject(name: SubtleAlertSoftButton, states: [imageAndTextState, textState], initialStateName: initialButtonStateName) { [weak self] (buttonPress, buttonEvent) in
guard let self = self, buttonPress != nil else { return }
if (self.isSubtleAlertAllowed) {
@@ -97,7 +99,8 @@ extension ButtonManager {
private var softButtonTextVisible: SDLSoftButtonObject {
let textVisibleState = SDLSoftButtonState(stateName: TextVisibleSoftButtonTextOnState, text: TextVisibleSoftButtonTextOnText, artwork: nil)
let textNotVisibleState = SDLSoftButtonState(stateName: TextVisibleSoftButtonTextOffState, text: TextVisibleSoftButtonTextOffText, image: nil)
- return SDLSoftButtonObject(name: TextVisibleSoftButton, states: [textVisibleState, textNotVisibleState], initialStateName: textVisibleState.name) { [unowned self] (buttonPress, buttonEvent) in
+ let initialButtonStateName = self.textEnabled ? textVisibleState.name : textNotVisibleState.name
+ return SDLSoftButtonObject(name: TextVisibleSoftButton, states: [textVisibleState, textNotVisibleState], initialStateName: initialButtonStateName) { [unowned self] (buttonPress, buttonEvent) in
guard buttonPress != nil else { return }
self.textEnabled = !self.textEnabled
@@ -111,7 +114,8 @@ extension ButtonManager {
private var softButtonImagesVisible: SDLSoftButtonObject {
let imagesVisibleState = SDLSoftButtonState(stateName: ImagesVisibleSoftButtonImageOnState, text: ImagesVisibleSoftButtonImageOnText, image: nil)
let imagesNotVisibleState = SDLSoftButtonState(stateName: ImagesVisibleSoftButtonImageOffState, text: ImagesVisibleSoftButtonImageOffText, image: nil)
- return SDLSoftButtonObject(name: ImagesVisibleSoftButton, states: [imagesVisibleState, imagesNotVisibleState], initialStateName: imagesVisibleState.name) { [weak self] (buttonPress, buttonEvent) in
+ let initialButtonStateName = self.imagesEnabled ? imagesVisibleState.name : imagesNotVisibleState.name
+ return SDLSoftButtonObject(name: ImagesVisibleSoftButton, states: [imagesVisibleState, imagesNotVisibleState], initialStateName: initialButtonStateName) { [weak self] (buttonPress, buttonEvent) in
guard let self = self, let sdlManager = self.sdlManager, buttonPress != nil else { return }
self.imagesEnabled = !self.imagesEnabled
diff --git a/Example Apps/Example Swift/ProxyManager.swift b/Example Apps/Example Swift/ProxyManager.swift
index feb8f5fc9..efd364784 100644
--- a/Example Apps/Example Swift/ProxyManager.swift
+++ b/Example Apps/Example Swift/ProxyManager.swift
@@ -46,7 +46,8 @@ extension ProxyManager {
/// - Parameter connectionType: The type of transport layer to use.
func start(with proxyTransportType: ProxyTransportType) {
delegate?.didChangeProxyState(ProxyState.searching)
- sdlManager = SDLManager(configuration: proxyTransportType == .iap ? ProxyManager.connectIAP() : ProxyManager.connectTCP(), delegate: self)
+
+ sdlManager = SDLManager(configuration: (proxyTransportType == .iap) ? ProxyManager.iapConfiguration : ProxyManager.tcpConfiguration, delegate: self)
startManager()
}
@@ -71,7 +72,7 @@ private extension ProxyManager {
/// Configures an iAP transport layer.
///
/// - Returns: A SDLConfiguration object
- class func connectIAP() -> SDLConfiguration {
+ class var iapConfiguration: SDLConfiguration {
let lifecycleConfiguration = SDLLifecycleConfiguration(appName: ExampleAppName, fullAppId: ExampleFullAppId)
return setupManagerConfiguration(with: lifecycleConfiguration)
}
@@ -79,7 +80,7 @@ private extension ProxyManager {
/// Configures a TCP transport layer with the IP address and port of the remote SDL Core instance.
///
/// - Returns: A SDLConfiguration object
- class func connectTCP() -> SDLConfiguration {
+ class var tcpConfiguration: SDLConfiguration {
let lifecycleConfiguration = SDLLifecycleConfiguration(appName: ExampleAppName, fullAppId: ExampleFullAppId, ipAddress: AppUserDefaults.shared.ipAddress!, port: UInt16(AppUserDefaults.shared.port!)!)
return setupManagerConfiguration(with: lifecycleConfiguration)
}
diff --git a/Example Apps/Example Swift/ProxyManagerDelegate.swift b/Example Apps/Example Swift/ProxyManagerDelegate.swift
index 4666f9670..e192e2b6b 100644
--- a/Example Apps/Example Swift/ProxyManagerDelegate.swift
+++ b/Example Apps/Example Swift/ProxyManagerDelegate.swift
@@ -8,7 +8,7 @@
import Foundation
-protocol ProxyManagerDelegate: class {
+protocol ProxyManagerDelegate: AnyObject {
var proxyState: ProxyState { get }
func didChangeProxyState(_ newState: ProxyState)