Skip to content

Commit

Permalink
Merge branch 'feature/oguzhnatly#28-obfuscation' into combined
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Sep 19, 2022
2 parents 222854c + eb228d8 commit 1eae162
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
6 changes: 3 additions & 3 deletions ios/Classes/FCPEnums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//

enum FCPConnectionTypes {
static let connected = "CONNECTED"
static let background = "BACKGROUND"
static let disconnected = "DISCONNECTED"
static let connected = "connected"
static let background = "background"
static let disconnected = "disconnected"
}

enum FCPChannelTypes {
Expand Down
20 changes: 18 additions & 2 deletions lib/carplay_worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class FlutterCarplay {
_carPlayController.methodChannel.invokeMethod('setRootTemplate', <String, dynamic>{
'rootTemplate': rootTemplate.toJson(),
'animated': animated,
'runtimeType': "F" + rootTemplate.runtimeType.toString(),
'runtimeType': "F" + _getTemplateType(rootTemplate),
}).then((value) {
if (value) {
FlutterCarPlayController.currentRootTemplate = rootTemplate;
Expand Down Expand Up @@ -251,7 +251,7 @@ class FlutterCarplay {
bool isCompleted = await _carPlayController.reactToNativeModule(FCPChannelTypes.pushTemplate, <String, dynamic>{
"template": template.toJson(),
"animated": animated,
"runtimeType": "F" + template.runtimeType.toString(),
"runtimeType": "F" + _getTemplateType(template),
});
if (isCompleted) {
_carPlayController.addTemplateToHistory(template);
Expand All @@ -262,6 +262,22 @@ class FlutterCarplay {
}
}

static String _getTemplateType(dynamic template) {
if (template is CPTabBarTemplate) {
return 'CPTabBarTemplate';
} else if (template is CPGridTemplate) {
return 'CPGridTemplate';
} else if (template is CPInformationTemplate) {
return 'CPInformationTemplate';
} else if (template is CPPointOfInterestTemplate) {
return 'CPPointOfInterestTemplate';
} else if (template is CPListTemplate) {
return 'CPListTemplate';
} else {
throw TypeError();
}
}

/// Navigate to the shared instance of the NowPlaying Template
///
/// - If animated is true, CarPlay animates the transition between templates.
Expand Down
18 changes: 9 additions & 9 deletions lib/controllers/carplay_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ class FlutterCarPlayController {
}

void addTemplateToHistory(dynamic template) {
if (template.runtimeType == CPTabBarTemplate ||
template.runtimeType == CPGridTemplate ||
template.runtimeType == CPInformationTemplate ||
template.runtimeType == CPPointOfInterestTemplate ||
template.runtimeType == CPListTemplate) {
if (template is CPTabBarTemplate ||
template is CPGridTemplate ||
template is CPInformationTemplate ||
template is CPPointOfInterestTemplate ||
template is CPListTemplate) {
templateHistory.add(template);
} else {
throw TypeError();
Expand Down Expand Up @@ -120,7 +120,7 @@ class FlutterCarPlayController {
CPGridButton? gridButton;
l1:
for (var t in templateHistory) {
if (t.runtimeType.toString() == "CPGridTemplate") {
if (t is CPGridTemplate) {
for (var b in t.buttons) {
if (b.uniqueId == elementId) {
gridButton = b;
Expand All @@ -136,7 +136,7 @@ class FlutterCarPlayController {
CPBarButton? barButton;
l1:
for (var t in templateHistory) {
if (t.runtimeType.toString() == "CPListTemplate") {
if (t is CPListTemplate) {
barButton = t.backButton;
break l1;
}
Expand All @@ -147,7 +147,7 @@ class FlutterCarPlayController {
void processFCPTextButtonPressed(String elementId) {
l1:
for (var t in templateHistory) {
if (t.runtimeType.toString() == "CPPointOfInterestTemplate") {
if (t is CPPointOfInterestTemplate) {
for (CPPointOfInterest p in t.poi) {
if (p.primaryButton != null && p.primaryButton!.uniqueId == elementId) {
p.primaryButton!.onPress();
Expand All @@ -159,7 +159,7 @@ class FlutterCarPlayController {
}
}
} else {
if (t.runtimeType.toString() == "CPInformationTemplate") {
if (t is CPInformationTemplate) {
l2:
for (CPTextButton b in t.actions) {
if (b.uniqueId == elementId) {
Expand Down
4 changes: 2 additions & 2 deletions lib/helpers/carplay_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class FlutterCarplayHelper {
l1:
for (var t in templates) {
List<CPListTemplate> listTemplates = [];
if (t.runtimeType.toString() == (CPTabBarTemplate).toString()) {
if (t is CPTabBarTemplate) {
for (var template in t.templates) {
listTemplates.add(template);
}
} else if (t.runtimeType.toString() == (CPListTemplate).toString()) {
} else if (t is CPListTemplate) {
listTemplates.add(t);
}
if (listTemplates.isNotEmpty) {
Expand Down

0 comments on commit 1eae162

Please sign in to comment.