Compare commits

...

13 Commits

12 changed files with 53 additions and 22 deletions

View File

@ -46,7 +46,7 @@ public class MainActivity extends FlutterActivity {
updateTokenTask.execute(token);
result.success(token);
} else {
result.error("fcm_error", task.getException().getMessage(), task.getException());
result.error("fcm_error", task.getException().getMessage(), null);
}
}
});

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

@ -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

@ -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

@ -1,7 +1,7 @@
name: hass_client
description: Home Assistant Android Client
version: 1.1.0+1154
version: 1.1.0+1157
environment:
@ -25,7 +25,7 @@ dependencies:
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