Compare commits

...

12 Commits

15 changed files with 69 additions and 28 deletions

View File

@ -145,7 +145,7 @@ public class MessagingService extends FirebaseMessagingService {
connection.connect();
InputStream input = connection.getInputStream();
return BitmapFactory.decodeStream(input);
} catch (IOException e) {
} catch (Exception e) {
return null;
}
}

View File

@ -1,6 +1,4 @@
org.gradle.jvmargs=-Xmx2g
org.gradle.daemon=true
org.gradle.caching=true
org.gradle.jvmargs=-Xmx512m
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true

View File

@ -90,6 +90,12 @@ class CardData {
return BadgesData(rawData);
break;
default:
if (rawData.containsKey('entity')) {
rawData['entities'] = [rawData['entity']];
}
if (rawData.containsKey('entities') && rawData['entities'] is List) {
return EntitiesCardData(rawData);
}
return CardData(null);
}
} catch (error, stacktrace) {
@ -103,7 +109,11 @@ class CardData {
type = rawData['type'];
conditions = rawData['conditions'] ?? [];
showEmpty = rawData['show_empty'] ?? true;
stateFilter = rawData['state_filter'] ?? [];
if (rawData.containsKey('state_filter') && rawData['state_filter'] is List) {
stateFilter = rawData['state_filter'];
} else {
stateFilter = [];
}
} else {
type = CardType.UNKNOWN;
conditions = [];
@ -374,7 +384,13 @@ class LightCardData extends CardData {
@override
Widget buildCardWidget() {
return LightCard(card: this);
if (this.entity != null && this.entity.entity is LightEntity) {
return LightCard(card: this);
}
return ErrorCard(
errorText: 'Specify an entity from within the light domain.',
showReportButton: false,
);
}
LightCardData(rawData) : super(rawData) {

View File

@ -2,12 +2,21 @@ part of '../main.dart';
class ErrorCard extends StatelessWidget {
final ErrorCardData card;
final String errorText;
final bool showReportButton;
const ErrorCard({Key key, this.card}) : super(key: key);
const ErrorCard({Key key, this.card, this.errorText, this.showReportButton: true}) : super(key: key);
@override
Widget build(BuildContext context) {
String error;
if (errorText == null) {
error = 'There was an error showing ${card?.type}';
} else {
error = errorText;
}
return CardWrapper(
color: Theme.of(context).errorColor,
child: Padding(
padding: EdgeInsets.fromLTRB(Sizes.leftWidgetPadding, Sizes.rowPadding, Sizes.rightWidgetPadding, Sizes.rowPadding),
child: Column(
@ -15,21 +24,25 @@ class ErrorCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'There was an error rendering card: ${card.type}. Please copy card config to clipboard and report this issue. Thanks!',
error,
textAlign: TextAlign.center,
),
card != null ?
RaisedButton(
onPressed: () {
Clipboard.setData(new ClipboardData(text: card.cardConfig));
},
child: Text('Copy card config'),
),
) :
Container(width: 0, height: 0),
showReportButton ?
RaisedButton(
onPressed: () {
Launcher.launchURLInBrowser("https://github.com/estevez-dev/ha_client/issues/new?assignees=&labels=&template=bug_report.md&title=");
},
child: Text('Report issue'),
)
) :
Container(width: 0, height: 0)
],
),
)

View File

@ -7,6 +7,6 @@ class UnsupportedCard extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
return Container(height: 20);
}
}

View File

@ -4,12 +4,14 @@ class CardWrapper extends StatelessWidget {
final Widget child;
final EdgeInsets padding;
final Color color;
const CardWrapper({Key key, this.child, this.padding: const EdgeInsets.all(0)}) : super(key: key);
const CardWrapper({Key key, this.child, this.color, this.padding: const EdgeInsets.all(0)}) : super(key: key);
@override
Widget build(BuildContext context) {
return Card(
color: color,
child: Padding(
padding: padding,
child: child

View File

@ -40,8 +40,8 @@ class CoverEntity extends Entity {
CoverEntity.SUPPORT_SET_TILT_POSITION);
double get currentPosition => _getDoubleAttributeValue('current_position');
double get currentTiltPosition => _getDoubleAttributeValue('current_tilt_position');
double get currentPosition => _getDoubleAttributeValue('current_position') ?? 0;
double get currentTiltPosition => _getDoubleAttributeValue('current_tilt_position') ?? 0;
bool get canBeOpened => ((state != EntityState.opening) && (state != EntityState.open)) || (state == EntityState.open && currentPosition != null && currentPosition > 0.0 && currentPosition < 100.0);
bool get canBeClosed => ((state != EntityState.closing) && (state != EntityState.closed));
bool get canTiltBeOpened => currentTiltPosition < 100;

View File

@ -8,8 +8,8 @@ class TimerEntity extends Entity {
@override
void update(Map rawData, String webHost) {
super.update(rawData, webHost);
String durationSource = "${attributes["duration"]}";
if (durationSource != null && durationSource.isNotEmpty) {
if (attributes.containsKey('duration')) {
String durationSource = "${attributes["duration"]}";
try {
List<String> durationList = durationSource.split(":");
if (durationList.length == 1) {

View File

@ -149,7 +149,7 @@ class EntityCollection {
}
bool isExist(String entityId) {
return _allEntities[entityId] != null;
return _allEntities.containsKey(entityId);
}
List<Entity> getByDomains({List<String> includeDomains: const [], List<String> excludeDomains: const [], List<String> stateFiler}) {

View File

@ -221,7 +221,7 @@ class HomeAssistant {
var data = json.decode(prefs.getString('cached_services'));
_parseServices(data ?? {});
} catch (e, stacktrace) {
Logger.e(e, stacktrace: stacktrace);
Logger.e(e, stacktrace: stacktrace, skipCrashlytics: true);
}
}
await ConnectionManager().sendSocketMessage(type: "get_services").then((data) => _parseServices(data)).catchError((e) {
@ -261,7 +261,7 @@ class HomeAssistant {
var data = json.decode(sharedPrefs.getString('cached_panels'));
_parsePanels(data ?? {});
} catch (e, stacktrace) {
Logger.e(e, stacktrace: stacktrace);
Logger.e(e, stacktrace: stacktrace, skipCrashlytics: true);
panels.clear();
}
} else {

View File

@ -160,7 +160,7 @@ EventBus eventBus = new EventBus();
//FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
const String appName = 'HA Client';
const String appVersion = String.fromEnvironment('versionName', defaultValue: '0.0.0');
const whatsNewUrl = 'http://ha-client.app/service/whats_new_1.1.0-b2.md';
const whatsNewUrl = 'http://ha-client.app/service/whats_new_1.1.2.md';
Future<void> _reportError(dynamic error, dynamic stackTrace) async {
// Print the exception to the console.
@ -249,6 +249,7 @@ class _HAClientAppState extends State<HAClientApp> {
positiveText: "Ok"
)
));
InAppPurchaseConnection.instance.completePurchase(purchase[0]);
} else {
Logger.d("Purchase change handler: ${purchase[0].status}");
}

View File

@ -5,9 +5,9 @@ class MobileAppIntegrationManager {
static final _appRegistrationData = {
"device_name": "",
"app_version": "$appVersion",
"manufacturer": DeviceInfoManager().manufacturer,
"model": DeviceInfoManager().model,
"os_version": DeviceInfoManager().osVersion,
"manufacturer": DeviceInfoManager().manufacturer ?? "unknown",
"model": DeviceInfoManager().model ?? "unknown",
"os_version": DeviceInfoManager().osVersion ?? "0",
"app_data": {
"push_token": "",
"push_url": "https://us-central1-ha-client-c73c4.cloudfunctions.net/pushNotifyV3"

View File

@ -63,7 +63,18 @@ class _PurchasePageState extends State<PurchasePage> {
}
List<Widget> _buildProducts() {
List<Widget> productWidgets = [];
List<Widget> productWidgets = [
Card(
child: Padding(
padding: EdgeInsets.all(15),
child: Text(
'This will not unlock any additional functionality. This is only a donation to the HA Client open source project.',
style: Theme.of(context).textTheme.headline5,
textAlign: TextAlign.center,
)
)
)
];
for (ProductDetails product in _products) {
productWidgets.add(
ProductPurchase(

View File

@ -15,7 +15,7 @@ class ProductPurchase extends StatelessWidget {
String buttonText = '';
String buttonTextInactive = '';
if (product.id.contains("year")) {
period += "/ year";
period += "once a year";
buttonText = "Subscribe";
buttonTextInactive = "Already";
priceColor = Colors.amber;

View File

@ -1,7 +1,7 @@
name: hass_client
description: Home Assistant Android Client
version: 1.1.0+1156
version: 1.1.2+1159
environment:
@ -19,13 +19,13 @@ dependencies:
date_format: ^1.0.8
charts_flutter: ^0.8.1
flutter_markdown: ^0.3.3
in_app_purchase: ^0.3.0+3
in_app_purchase: ^0.3.4
flutter_custom_tabs: ^0.6.0
flutter_webview_plugin: ^0.3.10+1
webview_flutter: ^0.3.19+7
hive: ^1.4.1+1
hive_flutter: ^0.3.0+2
device_info: ^0.4.1+4
device_info: ^0.4.2+4
geolocator: ^5.3.1
workmanager: ^0.2.2
battery: ^1.0.0