Compare commits
13 Commits
beta/0.7.3
...
beta/0.7.5
Author | SHA1 | Date | |
---|---|---|---|
6cb5463b13 | |||
63a789ebfb | |||
a0994e9a60 | |||
8d1b728194 | |||
1a9fec8b98 | |||
e634253282 | |||
64b23ec7cc | |||
afe207a878 | |||
4bac0c092f | |||
74c8ae35a1 | |||
7856637456 | |||
965f80a6ca | |||
198c2ba49a |
@ -6,6 +6,7 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||||
|
|
||||||
@ -19,8 +20,7 @@
|
|||||||
android:name=".Application"
|
android:name=".Application"
|
||||||
android:label="HA Client"
|
android:label="HA Client"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true">
|
||||||
android:networkSecurityConfig="@xml/network_security_config">
|
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<network-security-config>
|
|
||||||
<base-config>
|
|
||||||
<trust-anchors>
|
|
||||||
<certificates src="system"/>
|
|
||||||
<certificates src="user"/>
|
|
||||||
</trust-anchors>
|
|
||||||
</base-config>
|
|
||||||
</network-security-config>
|
|
@ -218,9 +218,6 @@ class HomeAssistant {
|
|||||||
try {
|
try {
|
||||||
//bool isThereCardOptionsInside = rawCard["card"] != null;
|
//bool isThereCardOptionsInside = rawCard["card"] != null;
|
||||||
var rawCardInfo = rawCard["card"] ?? rawCard;
|
var rawCardInfo = rawCard["card"] ?? rawCard;
|
||||||
if (rawCardInfo['state_filter'] != null) {
|
|
||||||
Logger.d("Hey!!!!!! We found a card with state filter: ${rawCardInfo['state_filter']}");
|
|
||||||
}
|
|
||||||
HACard card = HACard(
|
HACard card = HACard(
|
||||||
id: "card",
|
id: "card",
|
||||||
name: rawCardInfo["title"] ?? rawCardInfo["name"],
|
name: rawCardInfo["title"] ?? rawCardInfo["name"],
|
||||||
|
@ -30,6 +30,7 @@ import 'package:uni_links/uni_links.dart';
|
|||||||
import 'package:workmanager/workmanager.dart' as workManager;
|
import 'package:workmanager/workmanager.dart' as workManager;
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:battery/battery.dart';
|
import 'package:battery/battery.dart';
|
||||||
|
import 'package:sentry/sentry.dart';
|
||||||
|
|
||||||
import 'utils/logger.dart';
|
import 'utils/logger.dart';
|
||||||
|
|
||||||
@ -138,18 +139,39 @@ part 'entities/media_player/widgets/media_player_progress_bar.widget.dart';
|
|||||||
part 'pages/whats_new.page.dart';
|
part 'pages/whats_new.page.dart';
|
||||||
|
|
||||||
EventBus eventBus = new EventBus();
|
EventBus eventBus = new EventBus();
|
||||||
|
final SentryClient _sentry = SentryClient(dsn: "https://03ef364745cc4c23a60ddbc874c69925@sentry.io/1836118");
|
||||||
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
|
||||||
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
|
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
|
||||||
const String appName = "HA Client";
|
const String appName = "HA Client";
|
||||||
const appVersionNumber = "0.7.2";
|
const appVersionNumber = "0.7.5";
|
||||||
const appVersionAdd = "";
|
const appVersionAdd = "";
|
||||||
const appVersion = "$appVersionNumber-$appVersionAdd";
|
const appVersion = "$appVersionNumber$appVersionAdd";
|
||||||
|
|
||||||
|
Future<void> _reportError(dynamic error, dynamic stackTrace) async {
|
||||||
|
// Print the exception to the console.
|
||||||
|
if (Logger.isInDebugMode) {
|
||||||
|
Logger.e('Caught error: $error');
|
||||||
|
Logger.p(stackTrace);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
Logger.e('Caught error: $error. Reporting to Senrty.');
|
||||||
|
// Send the Exception and Stacktrace to Sentry in Production mode.
|
||||||
|
_sentry.captureException(
|
||||||
|
exception: error,
|
||||||
|
stackTrace: stackTrace,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
FlutterError.onError = (errorDetails) {
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
Logger.e( "${errorDetails.exception}");
|
Logger.e(" Caut Flutter runtime error: ${details.exception}");
|
||||||
if (Logger.isInDebugMode) {
|
if (Logger.isInDebugMode) {
|
||||||
FlutterError.dumpErrorToConsole(errorDetails);
|
FlutterError.dumpErrorToConsole(details);
|
||||||
|
} else {
|
||||||
|
// In production mode, report to the application zone to report to
|
||||||
|
// Sentry.
|
||||||
|
Zone.current.handleUncaughtError(details.exception, details.stack);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -161,11 +183,7 @@ void main() async {
|
|||||||
runApp(new HAClientApp());
|
runApp(new HAClientApp());
|
||||||
|
|
||||||
}, onError: (error, stack) {
|
}, onError: (error, stack) {
|
||||||
Logger.e("$error");
|
_reportError(error, stack);
|
||||||
Logger.e("$stack");
|
|
||||||
if (Logger.isInDebugMode) {
|
|
||||||
debugPrint("$stack");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ class LocationManager {
|
|||||||
_isRunning = prefs.getBool("location-enabled") ?? false;
|
_isRunning = prefs.getBool("location-enabled") ?? false;
|
||||||
if (_isRunning) {
|
if (_isRunning) {
|
||||||
await _startLocationService();
|
await _startLocationService();
|
||||||
updateDeviceLocation(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +83,7 @@ class LocationManager {
|
|||||||
Logger.d("Scheduling location update task #$i for every ${interval.inMinutes} minutes in $delay minutes...");
|
Logger.d("Scheduling location update task #$i for every ${interval.inMinutes} minutes in $delay minutes...");
|
||||||
await workManager.Workmanager.registerPeriodicTask(
|
await workManager.Workmanager.registerPeriodicTask(
|
||||||
"$backgroundTaskId$n",
|
"$backgroundTaskId$n",
|
||||||
"haClientLocationTracking",
|
"haClientLocationTracking-0$n",
|
||||||
tag: backgroundTaskTag,
|
tag: backgroundTaskTag,
|
||||||
inputData: {
|
inputData: {
|
||||||
"webhookId": webhookId,
|
"webhookId": webhookId,
|
||||||
@ -108,14 +107,9 @@ class LocationManager {
|
|||||||
await workManager.Workmanager.cancelByTag(backgroundTaskTag);
|
await workManager.Workmanager.cancelByTag(backgroundTaskTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDeviceLocation(bool force) async {
|
updateDeviceLocation() async {
|
||||||
if (!force && !_isRunning) {
|
|
||||||
Logger.d("[Foreground location] Not enabled. Aborting.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Logger.d("[Foreground location] Started");
|
Logger.d("[Foreground location] Started");
|
||||||
//Logger.d("[Foreground location] Forcing Android location manager...");
|
Geolocator geolocator = Geolocator();
|
||||||
Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true;
|
|
||||||
var battery = Battery();
|
var battery = Battery();
|
||||||
String webhookId = ConnectionManager().webhookId;
|
String webhookId = ConnectionManager().webhookId;
|
||||||
String httpWebHost = ConnectionManager().httpWebHost;
|
String httpWebHost = ConnectionManager().httpWebHost;
|
||||||
@ -155,14 +149,15 @@ class LocationManager {
|
|||||||
|
|
||||||
void updateDeviceLocationIsolate() {
|
void updateDeviceLocationIsolate() {
|
||||||
workManager.Workmanager.executeTask((backgroundTask, data) {
|
workManager.Workmanager.executeTask((backgroundTask, data) {
|
||||||
//print("[Background $backgroundTask] Started");
|
print("[Background $backgroundTask] Started");
|
||||||
Geolocator geolocator = Geolocator()..forceAndroidLocationManager = true;
|
final SentryClient sentryBackgroundClient = SentryClient(dsn: "https://5c868e5ef26947e2b61b189e391ec31b@sentry.io/1836366");
|
||||||
|
Geolocator geolocator = Geolocator();
|
||||||
var battery = Battery();
|
var battery = Battery();
|
||||||
int batteryLevel = 100;
|
int batteryLevel = 100;
|
||||||
String webhookId = data["webhookId"];
|
String webhookId = data["webhookId"];
|
||||||
String httpWebHost = data["httpWebHost"];
|
String httpWebHost = data["httpWebHost"];
|
||||||
if (webhookId != null && webhookId.isNotEmpty) {
|
if (webhookId != null && webhookId.isNotEmpty) {
|
||||||
//print("[Background $backgroundTask] hour=$battery");
|
print("[Background $backgroundTask] hour=$battery");
|
||||||
String url = "$httpWebHost/api/webhook/$webhookId";
|
String url = "$httpWebHost/api/webhook/$webhookId";
|
||||||
Map<String, String> headers = {};
|
Map<String, String> headers = {};
|
||||||
headers["Content-Type"] = "application/json";
|
headers["Content-Type"] = "application/json";
|
||||||
@ -174,36 +169,28 @@ void updateDeviceLocationIsolate() {
|
|||||||
"battery": batteryLevel
|
"battery": batteryLevel
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//print("[Background $backgroundTask] Getting battery level...");
|
print("[Background $backgroundTask] Getting battery level...");
|
||||||
battery.batteryLevel.then((val) => data["data"]["battery"] = val).whenComplete((){
|
battery.batteryLevel.then((val) => data["data"]["battery"] = val).whenComplete((){
|
||||||
//print("[Background $backgroundTask] Getting device location...");
|
print("[Background $backgroundTask] Getting device location...");
|
||||||
geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high, locationPermissionLevel: GeolocationPermission.locationAlways).then((location) {
|
geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high, locationPermissionLevel: GeolocationPermission.locationAlways).then((location) {
|
||||||
//print("[Background $backgroundTask] Got location: ${location.latitude} ${location.longitude}");
|
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
|
print("[Background $backgroundTask] Got location: ${location.latitude} ${location.longitude}");
|
||||||
data["data"]["gps"] = [location.latitude, location.longitude];
|
data["data"]["gps"] = [location.latitude, location.longitude];
|
||||||
data["data"]["gps_accuracy"] = location.accuracy;
|
data["data"]["gps_accuracy"] = location.accuracy;
|
||||||
//print("[Background $backgroundTask] Sending data home...");
|
print("[Background $backgroundTask] Sending data home.");
|
||||||
http.post(
|
http.post(
|
||||||
url,
|
url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: json.encode(data)
|
body: json.encode(data)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
throw "Can't get device location. Location is null";
|
||||||
}
|
}
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
//print("[Background $backgroundTask] Error getting current location: ${e.toString()}. Trying last known...");
|
sentryBackgroundClient.captureException(
|
||||||
geolocator.getLastKnownPosition(desiredAccuracy: LocationAccuracy.medium).then((location){
|
exception: "${e.toString()}"
|
||||||
//print("[Background $backgroundTask] Got last known location: ${location.latitude} ${location.longitude}");
|
);
|
||||||
if (location != null) {
|
print("[Background $backgroundTask] Error getting current location: ${e.toString()}");
|
||||||
data["data"]["gps"] = [location.latitude, location.longitude];
|
|
||||||
data["data"]["gps_accuracy"] = location.accuracy;
|
|
||||||
//print("[Background $backgroundTask] Sending data home...");
|
|
||||||
http.post(
|
|
||||||
url,
|
|
||||||
headers: headers,
|
|
||||||
body: json.encode(data)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class _IntegrationSettingsPageState extends State<IntegrationSettingsPage> {
|
|||||||
|
|
||||||
_switchLocationTrackingState(bool state) async {
|
_switchLocationTrackingState(bool state) async {
|
||||||
if (state) {
|
if (state) {
|
||||||
await LocationManager().updateDeviceLocation(true);
|
await LocationManager().updateDeviceLocation();
|
||||||
}
|
}
|
||||||
await LocationManager().setSettings(_locationTrackingEnabled, _locationInterval);
|
await LocationManager().setSettings(_locationTrackingEnabled, _locationInterval);
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -122,8 +122,6 @@ class _MainPageState extends ReceiveShareState<MainPage> with WidgetsBindingObse
|
|||||||
_showInfoBottomBar(progress: true,);
|
_showInfoBottomBar(progress: true,);
|
||||||
ConnectionManager().init(loadSettings: false, forceReconnect: false).then((_){
|
ConnectionManager().init(loadSettings: false, forceReconnect: false).then((_){
|
||||||
_fetchData();
|
_fetchData();
|
||||||
LocationManager().updateDeviceLocation(false);
|
|
||||||
//StartupUserMessagesManager().checkMessagesToShow();
|
|
||||||
}, onError: (e) {
|
}, onError: (e) {
|
||||||
_setErrorState(e);
|
_setErrorState(e);
|
||||||
});
|
});
|
||||||
|
@ -23,6 +23,10 @@ class Logger {
|
|||||||
return inDebugMode;
|
return inDebugMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void p(data) {
|
||||||
|
print(data);
|
||||||
|
}
|
||||||
|
|
||||||
static void e(String message) {
|
static void e(String message) {
|
||||||
_writeToLog("Error", message);
|
_writeToLog("Error", message);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: hass_client
|
name: hass_client
|
||||||
description: Home Assistant Android Client
|
description: Home Assistant Android Client
|
||||||
|
|
||||||
version: 0.7.2+720
|
version: 0.7.5+750
|
||||||
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
@ -18,7 +18,7 @@ dependencies:
|
|||||||
url_launcher: any
|
url_launcher: any
|
||||||
date_format: any
|
date_format: any
|
||||||
charts_flutter: ^0.8.1
|
charts_flutter: ^0.8.1
|
||||||
flutter_markdown: any
|
flutter_markdown: 0.3.0
|
||||||
in_app_purchase: ^0.2.1+4
|
in_app_purchase: ^0.2.1+4
|
||||||
flutter_custom_tabs: ^0.6.0
|
flutter_custom_tabs: ^0.6.0
|
||||||
firebase_messaging: ^5.1.6
|
firebase_messaging: ^5.1.6
|
||||||
@ -29,6 +29,7 @@ dependencies:
|
|||||||
geolocator: ^5.1.5
|
geolocator: ^5.1.5
|
||||||
workmanager: ^0.1.3
|
workmanager: ^0.1.3
|
||||||
battery: ^0.3.1+1
|
battery: ^0.3.1+1
|
||||||
|
sentry: ^2.3.1
|
||||||
share:
|
share:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/d-silveira/flutter-share.git
|
url: https://github.com/d-silveira/flutter-share.git
|
||||||
|
Reference in New Issue
Block a user