Skip to content

Commit

Permalink
Merge pull request #10 from tesla-android/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
mikegapinski authored Nov 13, 2022
2 parents 109e0cd + b9c1fee commit e83f562
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 74 deletions.
21 changes: 16 additions & 5 deletions lib/common/di/app_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flavor/flavor.dart';
import 'package:flutter/material.dart';
import 'package:injectable/injectable.dart' hide Environment;
import 'package:shared_preferences/shared_preferences.dart';
import 'dart:html';

@module
abstract class AppModule {
Expand All @@ -10,14 +11,24 @@ abstract class AppModule {
Environment.production,
color: Colors.red,
properties: {
'touchscreenWebSocket': 'ws://9.9.0.1:9999',
'videoLayerUrl' : 'http://9.9.0.1:9090/',
'virtualDisplayWidth': 1378,
'virtualDisplayHeight': 1050,
'touchscreenWebSocket': 'ws://' + (window.location.hostname ?? "9.9.0.1") + ':9999',
'videoLayerUrl' : 'http://' + (window.location.hostname ?? "9.9.0.1") + ':9090/',
'virtualDisplayWidth': 1034,
'virtualDisplayHeight': 788,
},
);
// Flavor get provideFlavor => Flavor.create(
// Environment.dev,
// color: Colors.green,
// properties: {
// 'touchscreenWebSocket': 'ws://9.9.0.1:9999',
// 'videoLayerUrl' : 'http://9.9.0.1:9090/',
// 'virtualDisplayWidth': 1034,
// 'virtualDisplayHeight': 788,
// },
// );

@singleton
@preResolve
Future<SharedPreferences> get sharedPreferences => SharedPreferences.getInstance();
}
}
27 changes: 3 additions & 24 deletions lib/feature/androidViewer/android_viewer_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,11 @@ class AndroidViewerPage extends StatelessWidget {
final bloc = BlocProvider.of<TouchscreenCubit>(context);
return Scaffold(
body: Stack(
children: [
children: const [
Center(
child: BlocListener(
bloc: bloc,
listener: (BuildContext context, state) {
final scaffoldMessenger = ScaffoldMessenger.of(context);
if (state == false) {
scaffoldMessenger.showSnackBar(
SnackBar(
content: const Text(
'Virtual touchscreen is not active. Wait for Android to boot up.'),
duration: TATiming.snackBarDuration,
action: SnackBarAction(
label: 'Dismiss',
onPressed: scaffoldMessenger.hideCurrentSnackBar,
),
),
);
} else {
scaffoldMessenger.hideCurrentSnackBar();
}
},
child: const DisplayView(touchScreenView: TouchScreenView()),
),
child: DisplayView(touchScreenView: TouchScreenView())
),
const VersionRibbon()
VersionRibbon()
],
),
);
Expand Down
55 changes: 13 additions & 42 deletions lib/feature/androidViewer/touchscreen/touchscreen_view.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:tesla_android/common/ui/constants/ta_timing.dart';
import 'package:tesla_android/feature/androidViewer/touchscreen/cubit/touchscreen_cubit.dart';

class TouchScreenView extends StatelessWidget {
Expand All @@ -11,46 +10,18 @@ class TouchScreenView extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cubit = BlocProvider.of<TouchscreenCubit>(context);
return _touchScreenStateListener(
cubit,
LayoutBuilder(builder: (context, constraints) {
return Listener(
onPointerDown: (event) => cubit.dispatchTouchEvent(
event.pointer, event.localPosition, true, constraints),
onPointerMove: (event) => cubit.dispatchTouchEvent(
event.pointer, event.localPosition, true, constraints),
onPointerCancel: (event) => cubit.dispatchTouchEvent(
event.pointer, event.localPosition, false, constraints),
onPointerUp: (event) => cubit.dispatchTouchEvent(
event.pointer, event.localPosition, false, constraints),
child: Container(color: Colors.transparent),
);
}),
);
}

Widget _touchScreenStateListener(Cubit cubit, Widget child) {
return BlocListener(
bloc: cubit,
listener: (BuildContext context, state) {
final scaffoldMessenger = ScaffoldMessenger.of(context);
if (state == false) {
scaffoldMessenger.showSnackBar(
SnackBar(
content: const Text(
'Virtual touchscreen is not active. Wait for Android to boot up.'),
duration: TATiming.snackBarDuration,
action: SnackBarAction(
label: 'Dismiss',
onPressed: scaffoldMessenger.hideCurrentSnackBar,
),
),
);
} else {
scaffoldMessenger.hideCurrentSnackBar();
}
},
child: child,
);
return LayoutBuilder(builder: (context, constraints) {
return Listener(
onPointerDown: (event) => cubit.dispatchTouchEvent(
event.pointer, event.localPosition, true, constraints),
onPointerMove: (event) => cubit.dispatchTouchEvent(
event.pointer, event.localPosition, true, constraints),
onPointerCancel: (event) => cubit.dispatchTouchEvent(
event.pointer, event.localPosition, false, constraints),
onPointerUp: (event) => cubit.dispatchTouchEvent(
event.pointer, event.localPosition, false, constraints),
child: Container(color: Colors.transparent),
);
});
}
}
59 changes: 59 additions & 0 deletions lib/feature/releaseNotes/repository/release_notes_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,65 @@ import 'package:tesla_android/feature/releaseNotes/model/version.dart';
@injectable
class ReleaseNotesRepository {
static const ReleaseNotes _releaseNotes = ReleaseNotes(versions: [
Version(
versionName: "2022.45.1",
changelogItems: [
ChangelogItem(
title: "Google Apps",
shortDescription: "Usability improvements",
descriptionMarkdown:
"Version 2022.45.1 brings back Google Play Store and other Google Services that were removed in 2022.25.1. Device ID registration for Google Play is not longer required. Not all apps can be installed using Google Play Store due to lack of device certification, they need to be installed manually.",
),
ChangelogItem(
title: "Android Platform",
shortDescription: "Stability improvements",
descriptionMarkdown:
"Tesla Android system services initialisation has been improved, all components(web server, touchscreen, display etc.) will automatically restart on failure. In previous versions a full system reboot would be needed in this scenario.",
),
ChangelogItem(
title: "Virtual display",
shortDescription: "DRM playback",
descriptionMarkdown:
"Version 2022.45.1 fixes DRM video playback and enables access to secure layers that are usually blacked out in screen capture.",
),
ChangelogItem(
title: "CarPlay",
shortDescription: "Visual improvements",
descriptionMarkdown:
"Three row layout for CarPlay is now selected as default.",
),
ChangelogItem(
title: "Virtual touchscreen",
shortDescription: "Stability improvements",
descriptionMarkdown:
"Flutter app no longer displays information about virtual touchscreen initialisation, it is irrelevant for the single board stack and should have been removed earlier.",
),
ChangelogItem(
title: "Bluetooth",
shortDescription: "Stability improvements",
descriptionMarkdown:
"Restarting the system after disabling Bluetooth is no longer required.",
),
ChangelogItem(
title: "Internet access",
shortDescription: "USB tethering for Android",
descriptionMarkdown:
"USB tethering from Android phones is now supported in Tesla Android. No configuration is required to enable this feature. Your Android phone will be detected as an external ethernet interface when you enable tethering.",
),
ChangelogItem(
title: "Internet access",
shortDescription: "LTE modem support",
descriptionMarkdown:
"2022.45.1 introduces support for USB network devices using the cdc_ncm driver - it has been validated and works without any additional steps from the user. Experimental changes that might enable support for cdc_mbim and rndis_host drivers are also included. Previous versions supported only the cdc_ether driver.",
),
ChangelogItem(
title: "Internet access",
shortDescription: "Support for external routers",
descriptionMarkdown:
"Tesla Android webserver and other services can now be accessed externally using ethernet. This can be used to access the device in your home network or in the car with an external router.",
),
],
),
Version(
versionName: "2022.44.1",
changelogItems: [
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Tesla Android

publish_to: 'none'

version: 2022.44.1+1
version: 2022.45.1+1

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
3 changes: 2 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
</script>
<script src="pcmplayer.js"></script>
<script>
var socketURL = 'ws://9.9.0.1:8080/sound';
var hostname = window.location.hostname;
var socketURL = 'ws://' + hostname +':8080/sound';
var lastEventDate = Date.now();
var playbackTimeout = 1500;
var player;
Expand Down
7 changes: 6 additions & 1 deletion web/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
</style>
</head>
<body>
<img src="http://9.9.0.1:9090/stream"/>
<img id="player"/>
<script>
var player = document.getElementById("player");
var hostname = window.location.hostname;
player.src = "http://" + hostname + ":9090/stream"
</script>
</body>
</html>

0 comments on commit e83f562

Please sign in to comment.