Add user messages
This commit is contained in:
parent
cece4d1e16
commit
1ecb839042
41
flutter_02.log
Normal file
41
flutter_02.log
Normal file
@ -0,0 +1,41 @@
|
||||
Flutter crash report; please file at https://github.com/flutter/flutter/issues.
|
||||
|
||||
## command
|
||||
|
||||
flutter --no-color run --machine --track-widget-creation --device-id=89AY052S4 lib/main.dart
|
||||
|
||||
## exception
|
||||
|
||||
_InternalLinkedHashMap<String, dynamic>: {code: 105, message: Isolate must be runnable, data: {request: {method: _reloadSources, params: {pause: true, rootLibUri: file:///data/user/0/com.keyboardcrumbs.haclient/code_cache/ha_clientWYMXDL/ha_client/lib/main.dart.incremental.dill, packagesUri: file:///data/user/0/com.keyboardcrumbs.haclient/code_cache/ha_clientWYMXDL/ha_client/.packages, isolateId: isolates/289688365}}, details: Isolate must be runnable before this request is made.}}
|
||||
|
||||
```
|
||||
null```
|
||||
|
||||
## flutter doctor
|
||||
|
||||
```
|
||||
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Linux, locale en_US.UTF-8)
|
||||
• Flutter version 1.7.8+hotfix.4 at /home/estevez/sdk/flutter
|
||||
• Framework revision 20e59316b8 (6 weeks ago), 2019-07-18 20:04:33 -0700
|
||||
• Engine revision fee001c93f
|
||||
• Dart version 2.4.0
|
||||
|
||||
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
|
||||
• Android SDK at /home/estevez/Android/Sdk
|
||||
• Android NDK location not configured (optional; useful for native profiling support)
|
||||
• Platform android-29, build-tools 29.0.2
|
||||
• Java binary at: /home/estevez/bin/android-studio/jre/bin/java
|
||||
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
|
||||
• All Android licenses accepted.
|
||||
|
||||
[✓] Android Studio (version 3.5)
|
||||
• Android Studio at /home/estevez/bin/android-studio
|
||||
• Flutter plugin version 38.2.3
|
||||
• Dart plugin version 191.8423
|
||||
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
|
||||
|
||||
[✓] Connected device (1 available)
|
||||
• Pixel 3 XL • 89AY052S4 • android-arm64 • Android 9 (API 28)
|
||||
|
||||
• No issues found!
|
||||
```
|
@ -106,6 +106,7 @@ part 'managers/location_manager.class.dart';
|
||||
part 'managers/mobile_app_integration_manager.class.dart';
|
||||
part 'managers/connection_manager.class.dart';
|
||||
part 'managers/device_info_manager.class.dart';
|
||||
part 'managers/startup_user_messages_manager.class.dart';
|
||||
part 'ui_class/ui.dart';
|
||||
part 'ui_class/view.class.dart';
|
||||
part 'ui_class/card.class.dart';
|
||||
@ -211,6 +212,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
StreamSubscription _showPopupDialogSubscription;
|
||||
StreamSubscription _showPopupMessageSubscription;
|
||||
StreamSubscription _reloadUISubscription;
|
||||
StreamSubscription _showPageSubscription;
|
||||
int _previousViewCount;
|
||||
bool _showLoginButton = false;
|
||||
|
||||
@ -290,6 +292,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
ConnectionManager().init(loadSettings: true, forceReconnect: true).then((__){
|
||||
LocationManager();
|
||||
_fetchData();
|
||||
StartupUserMessagesManager().checkMessagesToShow();
|
||||
}, onError: (e) {
|
||||
_setErrorState(e);
|
||||
});
|
||||
@ -302,6 +305,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
ConnectionManager().init(loadSettings: false, forceReconnect: false).then((_){
|
||||
LocationManager().updateDeviceLocation();
|
||||
_fetchData();
|
||||
StartupUserMessagesManager().checkMessagesToShow();
|
||||
}, onError: (e) {
|
||||
_setErrorState(e);
|
||||
});
|
||||
@ -405,6 +409,13 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
});
|
||||
}
|
||||
|
||||
if (_showPageSubscription == null) {
|
||||
_showPageSubscription =
|
||||
eventBus.on<ShowPageEvent>().listen((event) {
|
||||
_showPage(event.path);
|
||||
});
|
||||
}
|
||||
|
||||
if (_showErrorSubscription == null) {
|
||||
_showErrorSubscription = eventBus.on<ShowErrorEvent>().listen((event){
|
||||
_showErrorBottomBar(event.error);
|
||||
@ -499,6 +510,13 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
);
|
||||
}
|
||||
|
||||
void _showPage(String path) {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
path
|
||||
);
|
||||
}
|
||||
|
||||
List<Tab> buildUIViewTabs() {
|
||||
List<Tab> result = [];
|
||||
|
||||
@ -938,6 +956,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
|
||||
_showErrorSubscription?.cancel();
|
||||
_startAuthSubscription?.cancel();
|
||||
_subscription?.cancel();
|
||||
_showPageSubscription?.cancel();
|
||||
_reloadUISubscription?.cancel();
|
||||
//TODO disconnect
|
||||
//widget.homeAssistant?.disconnect();
|
||||
|
@ -78,13 +78,13 @@ class LocationManager {
|
||||
}
|
||||
|
||||
LocationManager._internal() {
|
||||
_startLocationService();
|
||||
startLocationService();
|
||||
}
|
||||
|
||||
final int defaultUpdateIntervalMinutes = 15;
|
||||
final int alarmId = 34901199;
|
||||
|
||||
void _startLocationService() async {
|
||||
void startLocationService() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.reload();
|
||||
bool enabled = prefs.getBool("location-enabled") ?? false;
|
||||
|
73
lib/managers/startup_user_messages_manager.class.dart
Normal file
73
lib/managers/startup_user_messages_manager.class.dart
Normal file
@ -0,0 +1,73 @@
|
||||
part of '../main.dart';
|
||||
|
||||
class StartupUserMessagesManager {
|
||||
|
||||
static final StartupUserMessagesManager _instance = StartupUserMessagesManager
|
||||
._internal();
|
||||
|
||||
factory StartupUserMessagesManager() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
StartupUserMessagesManager._internal() {}
|
||||
|
||||
bool _locationTrackingMessageShown;
|
||||
bool _supportAppDevelopmentMessageShown;
|
||||
static final _locationTrackingMessageKey = "user-message-shown-location_1";
|
||||
static final _supportAppDevelopmentMessageKey = "user-message-shown-support-development_1";
|
||||
|
||||
void checkMessagesToShow() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.reload();
|
||||
_locationTrackingMessageShown = prefs.getBool(_locationTrackingMessageKey) ?? false;
|
||||
_supportAppDevelopmentMessageShown = prefs.getBool(_supportAppDevelopmentMessageKey) ?? false;
|
||||
if (!_locationTrackingMessageShown) {
|
||||
_showLocationTrackingMessage();
|
||||
} else if (!_supportAppDevelopmentMessageShown) {
|
||||
_showSupportAppDevelopmentMessage();
|
||||
}
|
||||
}
|
||||
|
||||
void _showLocationTrackingMessage() {
|
||||
eventBus.fire(ShowPopupDialogEvent(
|
||||
title: "Device location tracking is here!",
|
||||
body: "HA Client now support sending your device gps data to device_tracker instance created for current app integration. You can control location tracking in Configuration.",
|
||||
positiveText: "Enable now",
|
||||
negativeText: "Cancel",
|
||||
onPositive: () {
|
||||
SharedPreferences.getInstance().then((prefs) {
|
||||
prefs.setBool("location-enabled", true);
|
||||
prefs.setBool(_locationTrackingMessageKey, true);
|
||||
LocationManager().startLocationService();
|
||||
LocationManager().updateDeviceLocation();
|
||||
});
|
||||
},
|
||||
onNegative: () {
|
||||
SharedPreferences.getInstance().then((prefs) {
|
||||
prefs.setBool(_locationTrackingMessageKey, true);
|
||||
});
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
void _showSupportAppDevelopmentMessage() {
|
||||
eventBus.fire(ShowPopupDialogEvent(
|
||||
title: "Hi!",
|
||||
body: "As you may have noticed this app contains no ads. Also all app features are available for you for free. Following the principles of free and open source softwere this will not be changed in nearest future. But still you can support this application development materially. There is several options available, please check them in main menu -> Support app development. Thanks.",
|
||||
positiveText: "Take me there",
|
||||
negativeText: "Nope",
|
||||
onPositive: () {
|
||||
SharedPreferences.getInstance().then((prefs) {
|
||||
prefs.setBool(_supportAppDevelopmentMessageKey, true);
|
||||
eventBus.fire(ShowPageEvent("/configuration"));
|
||||
});
|
||||
},
|
||||
onNegative: () {
|
||||
SharedPreferences.getInstance().then((prefs) {
|
||||
prefs.setBool(_supportAppDevelopmentMessageKey, true);
|
||||
});
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ class EntityViewPage extends StatefulWidget {
|
||||
EntityViewPage({Key key, @required this.entityId, @required this.homeAssistant }) : super(key: key);
|
||||
|
||||
final String entityId;
|
||||
//TODO remove it!
|
||||
final HomeAssistant homeAssistant;
|
||||
|
||||
@override
|
||||
|
@ -193,7 +193,7 @@ class _ConfigPanelWidgetState extends State<ConfigPanelWidget> {
|
||||
void dispose() {
|
||||
if (_needToRestartLocationTracking) {
|
||||
Logger.d("Location tracking settings was changed. Restarting location service...");
|
||||
LocationManager()._startLocationService();
|
||||
LocationManager().startLocationService();
|
||||
if (_locationTrackingEnabled) {
|
||||
LocationManager().updateDeviceLocation();
|
||||
}
|
||||
|
@ -199,6 +199,12 @@ class ShowEntityPageEvent {
|
||||
ShowEntityPageEvent(this.entity);
|
||||
}
|
||||
|
||||
class ShowPageEvent {
|
||||
String path;
|
||||
|
||||
ShowPageEvent(this.path);
|
||||
}
|
||||
|
||||
class ShowErrorEvent {
|
||||
final HAError error;
|
||||
|
||||
|
Reference in New Issue
Block a user