implement share from MapQuest for Android

This commit is contained in:
Trent Palmer 2019-07-27 15:34:01 -07:00
parent 286024eb9f
commit 7e435afe20
19 changed files with 2351 additions and 2151 deletions

View File

@ -39,3 +39,9 @@ _____
* add more things to be implemented * add more things to be implemented
* add input from Bing Maps, Mapquest apps * add input from Bing Maps, Mapquest apps
* add other elevation api server options * add other elevation api server options
* include shared-prefs import/export in history import/export
## archive
* [Previous Versions of Libre Gps Parser](https://trentsonlinedocs.xyz/android_app_archive/libre_gps_parser/)
* [archive sha256sums](https://raw.githubusercontent.com/TrentSPalmer/libre_gps_parser/master/archive_sha256sums.md)

4
archive_sha256sums.md Normal file
View File

@ -0,0 +1,4 @@
153330a42f353d19443581d436b5627b6d05c87808e67a2e713ff950e5317de4 libre_gps_parser/0.1.3/armv9/app.aab
ea3f466315375d1f0eea49c0a224b36bcce8517f6ca45c6c2ed558015a97c21a libre_gps_parser/0.1.3/armv9/app-release.apk
cb45d4e5ac5f2a71ccd2ad9a2c4c081725fe2d65dd5db7a95bd196f3be70b108 libre_gps_parser/0.1.3/arm64v10/app.aab
6f145facdf75c83d42bf6ab76a3e27166eac75b0557a990634659944f031a0b9 libre_gps_parser/0.1.3/arm64v10/app-release.apk

View File

@ -28,10 +28,12 @@ InkWell aboutApp(BuildContext context) {
Future<void> _launchLicense() async { Future<void> _launchLicense() async {
AndroidIntent intent = AndroidIntent( AndroidIntent intent = AndroidIntent(
action: 'action_view', action: 'action_view',
data: Uri.encodeFull('https://github.com/TrentSPalmer/libre_gps_parser/blob/master/LICENSE'), data: Uri.encodeFull(
'https://github.com/TrentSPalmer/libre_gps_parser/blob/master/LICENSE'),
); );
await intent.launch(); await intent.launch();
} }
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor: ivory,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@ -53,12 +55,13 @@ InkWell aboutApp(BuildContext context) {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
'Version: 0.1.2\n', 'Version: 0.1.3\n',
style: TextStyle( style: TextStyle(
color: candyApple, color: candyApple,
), ),
), ),
Text( Text(
'Edit: new feature, you can now share a location to Libre Gps Parser from Mapquest for Android.\n\n'
'The essence of Libre Gps Parser, is to parse gps coordinates from ' 'The essence of Libre Gps Parser, is to parse gps coordinates from '
'a map link that you share from the Google Maps Application. ' 'a map link that you share from the Google Maps Application. '
'After that you can use the gps coordinates to make api calls for ' 'After that you can use the gps coordinates to make api calls for '
@ -87,7 +90,8 @@ InkWell aboutApp(BuildContext context) {
), ),
child: ButtonTheme( child: ButtonTheme(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
height: 75, height: 75,
child: RaisedButton( child: RaisedButton(
@ -99,8 +103,7 @@ InkWell aboutApp(BuildContext context) {
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }),
),
), ),
), ),
Container( Container(
@ -109,7 +112,8 @@ InkWell aboutApp(BuildContext context) {
), ),
child: ButtonTheme( child: ButtonTheme(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
height: 75, height: 75,
child: RaisedButton( child: RaisedButton(
@ -124,8 +128,7 @@ InkWell aboutApp(BuildContext context) {
), ),
onPressed: () { onPressed: () {
_launchLicense(); _launchLicense();
} }),
),
), ),
), ),
Container( Container(
@ -136,7 +139,8 @@ InkWell aboutApp(BuildContext context) {
height: 75, height: 75,
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -149,8 +153,7 @@ InkWell aboutApp(BuildContext context) {
), ),
onPressed: () { onPressed: () {
showLicensePage(context: context); showLicensePage(context: context);
} }),
),
), ),
), ),
], ],
@ -163,8 +166,7 @@ InkWell aboutApp(BuildContext context) {
], ],
), ),
); );
} });
);
}, },
); );
} }

View File

@ -47,10 +47,7 @@ class DatabaseHelper {
// this opens the database (and creates it if it doesn't exist) // this opens the database (and creates it if it doesn't exist)
_initDatabase() async { _initDatabase() async {
Directory documentsDirectory = await getApplicationDocumentsDirectory(); Directory documentsDirectory = await getApplicationDocumentsDirectory();
String path = join( String path = join(documentsDirectory.path, _databaseName);
documentsDirectory.path,
_databaseName
);
return await openDatabase( return await openDatabase(
path, path,
version: _databaseVersion, version: _databaseVersion,
@ -64,7 +61,8 @@ class DatabaseHelper {
// you can only ADD one column at a time? // you can only ADD one column at a time?
Future _onUpgrade(Database db, int oldVersion, int newVersion) async { Future _onUpgrade(Database db, int oldVersion, int newVersion) async {
if ((oldVersion == 1) || (oldVersion == 2)) { if ((oldVersion == 1) || (oldVersion == 2)) {
await db.execute('''ALTER TABLE $table ADD $columnIsAutoTimeOffset INT'''); await db
.execute('''ALTER TABLE $table ADD $columnIsAutoTimeOffset INT''');
await db.execute('''ALTER TABLE $table ADD $columnNotes TEXT'''); await db.execute('''ALTER TABLE $table ADD $columnNotes TEXT''');
} else if (oldVersion == 3) { } else if (oldVersion == 3) {
await db.execute('''ALTER TABLE $table ADD $columnNotes TEXT'''); await db.execute('''ALTER TABLE $table ADD $columnNotes TEXT''');
@ -144,12 +142,9 @@ class DatabaseHelper {
Database db = await instance.database; Database db = await instance.database;
List<Map> result = await db.rawQuery( List<Map> result = await db.rawQuery(
'SELECT $columnMapLocation FROM $table ORDER BY $columnViewTime DESC LIMIT 2'); 'SELECT $columnMapLocation FROM $table ORDER BY $columnViewTime DESC LIMIT 2');
return (result.length == 2) return (result.length == 2) ? result[1]['mapLocation'] : 'none';
? result[1]['mapLocation']
: 'none';
} }
Future<List<String>> sortedMapLocations() async { Future<List<String>> sortedMapLocations() async {
Database db = await instance.database; Database db = await instance.database;
var result = await db.rawQuery( var result = await db.rawQuery(
@ -257,7 +252,8 @@ class DatabaseHelper {
Future<String> queryDBExport() async { Future<String> queryDBExport() async {
Database db = await instance.database; Database db = await instance.database;
List<Map> result = await db.rawQuery('SELECT $columnMapLocation,$columnNotes,$columnIsAutoTimeOffset,$columnTimeOffSet FROM $table'); List<Map> result = await db.rawQuery(
'SELECT $columnMapLocation,$columnNotes,$columnIsAutoTimeOffset,$columnTimeOffSet FROM $table');
return (jsonEncode(result)); return (jsonEncode(result));
} }
} }

View File

@ -18,7 +18,6 @@ class EditNotes extends StatefulWidget {
} }
class _EditNotesState extends State<EditNotes> { class _EditNotesState extends State<EditNotes> {
final double textHeight = 1.5; final double textHeight = 1.5;
final _textEditingController = TextEditingController(); final _textEditingController = TextEditingController();
final dbHelper = DatabaseHelper.instance; final dbHelper = DatabaseHelper.instance;
@ -77,8 +76,7 @@ class _EditNotesState extends State<EditNotes> {
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }),
),
), ),
), ),
Container( Container(
@ -100,8 +98,7 @@ class _EditNotesState extends State<EditNotes> {
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
Navigator.of(context).pop(); Navigator.of(context).pop();
} }),
),
), ),
), ),
], ],
@ -110,8 +107,7 @@ class _EditNotesState extends State<EditNotes> {
], ],
), ),
); );
} });
);
return Future.value(false); return Future.value(false);
} else { } else {
return Future.value(true); return Future.value(true);
@ -134,8 +130,7 @@ class _EditNotesState extends State<EditNotes> {
DatabaseHelper.columnNotes: this._inputText, DatabaseHelper.columnNotes: this._inputText,
}; };
await dbHelper.update(row); await dbHelper.update(row);
} }),
),
], ],
), ),
body: Column( body: Column(
@ -160,11 +155,7 @@ class _EditNotesState extends State<EditNotes> {
child: ButtonTheme( child: ButtonTheme(
height: 55, height: 55,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 5, top: 5, right: 12, bottom: 12, left: 10),
right: 12,
bottom: 12,
left: 10
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(Radius.circular(6.0)),
@ -179,19 +170,27 @@ class _EditNotesState extends State<EditNotes> {
), ),
), ),
onPressed: () async { onPressed: () async {
Map<PermissionGroup, PermissionStatus> _storagePermissions; Map<PermissionGroup, PermissionStatus>
PermissionStatus _storagePermission = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage); _storagePermissions;
PermissionStatus _storagePermission =
await PermissionHandler().checkPermissionStatus(
PermissionGroup.storage);
if (_storagePermission == PermissionStatus.denied) { if (_storagePermission == PermissionStatus.denied) {
_storagePermissions = await PermissionHandler().requestPermissions([PermissionGroup.storage]); _storagePermissions = await PermissionHandler()
.requestPermissions([PermissionGroup.storage]);
} }
if ((_storagePermission == PermissionStatus.granted) || (_storagePermissions.toString() == PermissionStatus.granted.toString())) { if ((_storagePermission ==
PermissionStatus.granted) ||
(_storagePermissions.toString() ==
PermissionStatus.granted.toString())) {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor: ivory,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
title: Text( title: Text(
'You can import a markdown (or plain text) file.', 'You can import a markdown (or plain text) file.',
@ -214,11 +213,12 @@ class _EditNotesState extends State<EditNotes> {
top: 5, top: 5,
right: 12, right: 12,
bottom: 12, bottom: 12,
left: 10 left: 10),
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius:
BorderRadius.all(
Radius.circular(6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -231,84 +231,109 @@ class _EditNotesState extends State<EditNotes> {
), ),
onPressed: () async { onPressed: () async {
String _filePath; String _filePath;
_filePath = await FilePicker.getFilePath(type: FileType.ANY); _filePath = await FilePicker
.getFilePath(
type: FileType.ANY);
Navigator.of(context).pop(); Navigator.of(context).pop();
try { try {
String _contents = await File(_filePath).readAsString(); String _contents =
await File(_filePath)
.readAsString();
setState(() { setState(() {
this._textEditingController.text = _contents; this
this._inputText = _contents; ._textEditingController
.text = _contents;
this._inputText =
_contents;
}); });
} catch (e) { } catch (e) {
print(e); print(e);
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext
context) {
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor:
shape: RoundedRectangleBorder( ivory,
borderRadius: BorderRadius.all(Radius.circular(6.0)), shape:
RoundedRectangleBorder(
borderRadius: BorderRadius
.all(Radius
.circular(
6.0)),
), ),
title: Text( title: Text(
'Oops, something went wrong', 'Oops, something went wrong',
textAlign: TextAlign.center, textAlign:
TextAlign
.center,
style: TextStyle( style: TextStyle(
color: candyApple, color:
candyApple,
), ),
), ),
content: Column( content: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize:
children: <Widget>[ MainAxisSize
.min,
children: <
Widget>[
Container( Container(
margin: EdgeInsets.only( margin:
EdgeInsets
.only(
top: 40, top: 40,
bottom: 10, bottom: 10,
), ),
child: ButtonTheme( child:
ButtonTheme(
height: 55, height: 55,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 5, top: 5,
right: 12, right:
bottom: 12, 12,
left: 10 bottom:
), 12,
left:
10),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius:
BorderRadius.all(Radius.circular(6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
'OK', 'OK',
style: TextStyle( style:
height: textHeight, TextStyle(
color: Colors.white, height:
fontSize: 24, textHeight,
color:
Colors.white,
fontSize:
24,
), ),
), ),
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context)
} .pop();
), }),
), ),
), ),
], ],
), ),
); );
});
} }
); }),
}
}
),
), ),
), ),
], ],
), ),
); );
});
} }
); }),
}
}
),
), ),
), ),
], ],

View File

@ -105,7 +105,8 @@ InkWell elevAtion(BuildContext context, int elevation, int feetElevation) {
top: 10, top: 10,
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: <Widget>[ children: <Widget>[
Text( Text(
'github', 'github',
@ -140,16 +141,15 @@ InkWell elevAtion(BuildContext context, int elevation, int feetElevation) {
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
urlLaunch('https://github.com/Jorl17/open-elevation/blob/master/docs/host-your-own.md'); urlLaunch(
} 'https://github.com/Jorl17/open-elevation/blob/master/docs/host-your-own.md');
), }),
), ),
), ),
], ],
), ),
); );
} });
);
}, },
); );
} }

View File

@ -38,7 +38,8 @@ Future<List<int>> refreshTimeOffSet(String mapLocation, String latLong) async {
['total_offset_min'] ?? ['total_offset_min'] ??
2000; 2000;
} catch (e) { } catch (e) {
print('$e in source file global_helper_functions.dart.getTimeOffSet, can\'t assign Map<String, dynamic> responseJson'); print(
'$e in source file global_helper_functions.dart.getTimeOffSet, can\'t assign Map<String, dynamic> responseJson');
} }
Map<String, dynamic> row = { Map<String, dynamic> row = {
DatabaseHelper.columnMapLocation: mapLocation, DatabaseHelper.columnMapLocation: mapLocation,
@ -85,7 +86,8 @@ Future<List<int>> getTimeOffSet(String mapLocation, String latLong) async{
['total_offset_min'] ?? ['total_offset_min'] ??
2000; 2000;
} catch (e) { } catch (e) {
print('$e in source file global_helper_functions.dart.getTimeOffSet, can\'t assign Map<String, dynamic> responseJson'); print(
'$e in source file global_helper_functions.dart.getTimeOffSet, can\'t assign Map<String, dynamic> responseJson');
} }
Map<String, dynamic> row = { Map<String, dynamic> row = {
DatabaseHelper.columnMapLocation: mapLocation, DatabaseHelper.columnMapLocation: mapLocation,
@ -132,7 +134,9 @@ Future<String> getWeather(
Response response = await get(weatherApiUrl); Response response = await get(weatherApiUrl);
if (response.statusCode == 200) { if (response.statusCode == 200) {
Map<String, dynamic> responseJson = jsonDecode(response.body); Map<String, dynamic> responseJson = jsonDecode(response.body);
weatherID = (responseJson['id'] != 0) ? responseJson['id'] : generateFakeWeatherId(lattLong); weatherID = (responseJson['id'] != 0)
? responseJson['id']
: generateFakeWeatherId(lattLong);
Map<String, dynamic> row = { Map<String, dynamic> row = {
DatabaseHelper.columnMapLocation: mapLocation, DatabaseHelper.columnMapLocation: mapLocation,
DatabaseHelper.columnWeatherID: weatherID DatabaseHelper.columnWeatherID: weatherID
@ -151,7 +155,8 @@ Future<String> getWeather(
return response.body; return response.body;
} }
} catch (e) { } catch (e) {
print('$e, can\'t connect to openweathermap in global_helper_functions'); print(
'$e, can\'t connect to openweathermap in global_helper_functions');
weatherID ??= generateFakeWeatherId(lattLong); // assign if null weatherID ??= generateFakeWeatherId(lattLong); // assign if null
String weather = await dbHelper.queryWeather(weatherID); String weather = await dbHelper.queryWeather(weatherID);
return weather ?? 'NA'; return weather ?? 'NA';
@ -178,7 +183,9 @@ Future<String> getWeatherForeCast(
weatherID = generateFakeWeatherId(lattLong); weatherID = generateFakeWeatherId(lattLong);
} }
int weatherIDExists = await dbHelper.queryWeatherIDExists(weatherID); int weatherIDExists = await dbHelper.queryWeatherIDExists(weatherID);
if (weatherIDExists == 0) { stale = true; } if (weatherIDExists == 0) {
stale = true;
}
if ((weatherID == null) || (stale == true)) { if ((weatherID == null) || (stale == true)) {
List<String> latLong = lattLong.split(','); List<String> latLong = lattLong.split(',');
String weatherForeCastApiUrl; String weatherForeCastApiUrl;
@ -213,7 +220,8 @@ Future<String> getWeatherForeCast(
return response.body; return response.body;
} }
} catch (e) { } catch (e) {
print('$e, probably cant connect to openweathermap... no network connection? global_helper_functions.getWeatherForeCast'); print(
'$e, probably cant connect to openweathermap... no network connection? global_helper_functions.getWeatherForeCast');
weatherID ??= generateFakeWeatherId(lattLong); // assign if null weatherID ??= generateFakeWeatherId(lattLong); // assign if null
String weatherForeCast = await dbHelper.queryWeatherForeCast(weatherID); String weatherForeCast = await dbHelper.queryWeatherForeCast(weatherID);
return (weatherForeCast); return (weatherForeCast);
@ -249,6 +257,24 @@ int newTimeStamp() {
} }
Future<String> parseMapUrl(String mapUrl) async { Future<String> parseMapUrl(String mapUrl) async {
if (mapUrl.contains('mapq.st')) {
try {
Response response = await get(mapUrl);
String mapInfo = response.body;
RegExp _latExp = RegExp(
r'(<meta)\s*(property="place:location:latitude")\s*(content=")(.+)"\s*(/>)');
Match _latMatch = _latExp.firstMatch(mapInfo);
RegExp _longExp = RegExp(
r'(<meta)\s*(property="place:location:longitude")\s*(content=")(.+)"\s*(/>)');
Match _longMatch = _longExp.firstMatch(mapInfo);
String result = _latMatch.group(4) + ',' + _longMatch.group(4);
return (result);
} catch (e) {
print(
'$e can\'t connect to internet in global_helper_functions.parseMapUrl');
}
} else if ((mapUrl.contains('maps.google')) ||
(mapUrl.contains('maps.app.goo.gl'))) {
try { try {
Response response = await get(mapUrl); Response response = await get(mapUrl);
RegExp gmapUrl = RegExp( RegExp gmapUrl = RegExp(
@ -258,9 +284,12 @@ Future<String> parseMapUrl(String mapUrl) async {
String subMapInfo = match.group(4); String subMapInfo = match.group(4);
RegExp subGmapUrl = RegExp(r'@([^,]*,[^,]*),([^,]*,[^,]*)'); RegExp subGmapUrl = RegExp(r'@([^,]*,[^,]*),([^,]*,[^,]*)');
Match subMatch = subGmapUrl.firstMatch(subMapInfo); Match subMatch = subGmapUrl.firstMatch(subMapInfo);
return subMatch.group(1); String result = subMatch.group(1);
return (result);
} catch (e) { } catch (e) {
print('$e can\'t connect to internet in global_helper_functions.parseMapUrl'); print(
'$e can\'t connect to internet in global_helper_functions.parseMapUrl');
}
} }
} }
@ -301,7 +330,8 @@ String convertCoordinates(String latNLong) {
lat[0] + '\u00B0 ' + latMinSec + ',' + long[0] + '\u00B0 ' + longMinSec; lat[0] + '\u00B0 ' + latMinSec + ',' + long[0] + '\u00B0 ' + longMinSec;
return gpsDMS; return gpsDMS;
} catch (e) { } catch (e) {
print('$e in source file global_helper_functions.convertCoordinates, function parameter probably not a valid latNLong string'); print(
'$e in source file global_helper_functions.convertCoordinates, function parameter probably not a valid latNLong string');
} }
} }
@ -314,13 +344,14 @@ String getMinSec(String numString) {
return minSecs; return minSecs;
} }
String weatherConditions(String weatherConditions) { String weatherConditions(String weatherConditions) {
int numSpaces = (' '.allMatches(weatherConditions)).length; int numSpaces = (' '.allMatches(weatherConditions)).length;
if (numSpaces > 1) { if (numSpaces > 1) {
int firstSpace = weatherConditions.indexOf(' '); int firstSpace = weatherConditions.indexOf(' ');
int secondSpace = (weatherConditions.indexOf(' ', firstSpace + 1)); int secondSpace = (weatherConditions.indexOf(' ', firstSpace + 1));
return weatherConditions.replaceRange(secondSpace, (secondSpace + 1), '\n').toUpperCase(); return weatherConditions
.replaceRange(secondSpace, (secondSpace + 1), '\n')
.toUpperCase();
} else { } else {
return weatherConditions.toUpperCase(); return weatherConditions.toUpperCase();
} }
@ -338,7 +369,8 @@ int generateFakeWeatherId(String latLong) {
List<String> _latLongParts = latLong.split(','); List<String> _latLongParts = latLong.split(',');
List<String> _shortLat = _latLongParts[0].split('.'); List<String> _shortLat = _latLongParts[0].split('.');
List<String> _shortLong = _latLongParts[1].split('.'); List<String> _shortLong = _latLongParts[1].split('.');
String _fakeIDString = _shortLat[0].replaceFirst('-','8') + _shortLong[0].replaceFirst('-','8'); String _fakeIDString = _shortLat[0].replaceFirst('-', '8') +
_shortLong[0].replaceFirst('-', '8');
// you know a weatherID is fake because it is less than zero // you know a weatherID is fake because it is less than zero
return (0 - int.parse(_fakeIDString)); return (0 - int.parse(_fakeIDString));
} }
@ -394,8 +426,11 @@ Future<bool> setPreferenceUseWeather(bool useWeather) async {
Future<String> getPreferenceDBExportFileName() async { Future<String> getPreferenceDBExportFileName() async {
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
String dbExportFileName = prefs.getString("dbExportFileName") ?? "libre_gps_parser.json"; String dbExportFileName =
return (dbExportFileName.length > 0) ? dbExportFileName : "libre_gps_parser.json"; prefs.getString("dbExportFileName") ?? "libre_gps_parser.json";
return (dbExportFileName.length > 0)
? dbExportFileName
: "libre_gps_parser.json";
} }
Future<bool> setPreferenceDBExportFileName(String dbExportFileName) async { Future<bool> setPreferenceDBExportFileName(String dbExportFileName) async {
@ -410,7 +445,9 @@ Future<bool> importDataBase(String importString) {
List<dynamic> _importJson = jsonDecode(importString); List<dynamic> _importJson = jsonDecode(importString);
int _importJsonLength = _importJson.length; int _importJsonLength = _importJson.length;
for (int i = 0; i < _importJsonLength; i++) { for (int i = 0; i < _importJsonLength; i++) {
dbHelper.queryRowExists(_importJson[i]['mapLocation']).then((int rowExists) { dbHelper
.queryRowExists(_importJson[i]['mapLocation'])
.then((int rowExists) {
if (rowExists == 0) { if (rowExists == 0) {
Map<String, dynamic> row = { Map<String, dynamic> row = {
DatabaseHelper.columnMapLocation: _importJson[i]['mapLocation'], DatabaseHelper.columnMapLocation: _importJson[i]['mapLocation'],

View File

@ -6,7 +6,6 @@ import 'package:share/share.dart';
final double textHeight = 1.5; final double textHeight = 1.5;
Row lnlDec(String latnLong) { Row lnlDec(String latnLong) {
Future<void> _launchLnL() async { Future<void> _launchLnL() async {
AndroidIntent intent = AndroidIntent( AndroidIntent intent = AndroidIntent(
action: 'action_view', action: 'action_view',
@ -125,5 +124,3 @@ Row lnlDec(String latnLong) {
); );
} }
} }

View File

@ -18,7 +18,8 @@ class _LocationState extends State<Location> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final double textHeight = 1.5; final double textHeight = 1.5;
List<String> locationStringList = _getlocationStringList(widget.mapLocation); List<String> locationStringList =
_getlocationStringList(widget.mapLocation);
Future<void> _launchUrl() async { Future<void> _launchUrl() async {
AndroidIntent intent = AndroidIntent( AndroidIntent intent = AndroidIntent(
@ -30,8 +31,7 @@ class _LocationState extends State<Location> {
List<Container> createLocation(List<String> location) { List<Container> createLocation(List<String> location) {
return location.map((line) { return location.map((line) {
line = (line.length < 25) ? line : line = (line.length < 25) ? line : (line.substring(0, 20) + '.....');
(line.substring(0,20) + '.....' );
return Container( return Container(
child: Text( child: Text(
line, line,
@ -93,8 +93,7 @@ class _LocationState extends State<Location> {
], ],
), ),
); );
} });
);
}, },
), ),
), ),
@ -128,7 +127,8 @@ class _LocationState extends State<Location> {
), ),
RaisedButton( RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius:
BorderRadius.all(Radius.circular(6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Container( child: Container(
@ -147,13 +147,11 @@ class _LocationState extends State<Location> {
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }),
),
], ],
), ),
); );
} });
);
}, },
), ),
), ),
@ -170,7 +168,6 @@ class _LocationState extends State<Location> {
), ),
], ],
); );
} }
} }
@ -179,7 +176,8 @@ class _LocationState extends State<Location> {
try { try {
stringList = mapLocation.split('\n'); stringList = mapLocation.split('\n');
} catch (e) { } catch (e) {
print('$e in source file location.dart._getlocationStringList::first_try'); print(
'$e in source file location.dart._getlocationStringList::first_try');
} }
if (stringList.length < 2) { if (stringList.length < 2) {
return ['', 'pending...', '']; return ['', 'pending...', ''];
@ -189,7 +187,8 @@ class _LocationState extends State<Location> {
stringList.removeAt(0); stringList.removeAt(0);
} }
} catch (e) { } catch (e) {
print('$e in source file location.dart._getlocationStringList::second_try'); print(
'$e in source file location.dart._getlocationStringList::second_try');
} }
// split up long address lines on the second to last comma // split up long address lines on the second to last comma
for (int i = 0; i < stringList.length; i++) { for (int i = 0; i < stringList.length; i++) {

View File

@ -42,7 +42,8 @@ class _LatNLongState extends State<LatNLong> {
final dbHelper = DatabaseHelper.instance; final dbHelper = DatabaseHelper.instance;
static const platform = const MethodChannel('app.channel.shared.data'); static const platform = const MethodChannel('app.channel.shared.data');
// "static" variables are hard-coded into the class rather than instances // "static" variables are hard-coded into the class rather than instances
static RegExp gmapExp = RegExp(r'(https://maps.app.goo.gl/|https://maps.google.com/)(.*$)'); static RegExp mapExp = RegExp(
r'(https://maps.app.goo.gl/|https://maps.google.com/|https?://mapq.st/)(.*$)');
String widgetMapLocation = "none"; String widgetMapLocation = "none";
String latnLong = "none"; String latnLong = "none";
String latnLongDMS = "none"; String latnLongDMS = "none";
@ -86,8 +87,7 @@ class _LatNLongState extends State<LatNLong> {
parentAction: this._userTzOffset, parentAction: this._userTzOffset,
timeOffSet: this.timeOffSet, timeOffSet: this.timeOffSet,
timeOffSetTime: this.timeOffSetTime, timeOffSetTime: this.timeOffSetTime,
isAutoTimeOffSet: this.isAutoTimeOffSet isAutoTimeOffSet: this.isAutoTimeOffSet);
);
} }
InkWell _delete() { InkWell _delete() {
@ -143,7 +143,8 @@ class _LatNLongState extends State<LatNLong> {
), ),
child: ButtonTheme( child: ButtonTheme(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius:
BorderRadius.all(Radius.circular(6.0)),
), ),
height: 75, height: 75,
child: RaisedButton( child: RaisedButton(
@ -159,8 +160,7 @@ class _LatNLongState extends State<LatNLong> {
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
_deleteLocation(); _deleteLocation();
} }),
),
), ),
), ),
Container( Container(
@ -171,7 +171,8 @@ class _LatNLongState extends State<LatNLong> {
height: 75, height: 75,
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -184,8 +185,7 @@ class _LatNLongState extends State<LatNLong> {
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }),
),
), ),
), ),
], ],
@ -194,8 +194,7 @@ class _LatNLongState extends State<LatNLong> {
], ],
), ),
); );
} });
);
}, },
); );
} }
@ -219,7 +218,10 @@ class _LatNLongState extends State<LatNLong> {
onTap: () async { onTap: () async {
String _noteText = await Navigator.push( String _noteText = await Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => EditNotes(mapLocation: this.widgetMapLocation,)), MaterialPageRoute(
builder: (context) => EditNotes(
mapLocation: this.widgetMapLocation,
)),
); );
if ((_noteText != null) && (_noteText != this.notes)) { if ((_noteText != null) && (_noteText != this.notes)) {
setState(() { setState(() {
@ -229,7 +231,8 @@ class _LatNLongState extends State<LatNLong> {
}, },
), ),
), ),
((this.notes.length > 0) ? Expanded( ((this.notes.length > 0)
? Expanded(
flex: 5, flex: 5,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@ -254,12 +257,16 @@ class _LatNLongState extends State<LatNLong> {
onTap: () async { onTap: () async {
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute(builder: (context) => RenderNotes(notes: this.notes,)), MaterialPageRoute(
builder: (context) => RenderNotes(
notes: this.notes,
)),
); );
}, },
), ),
), ),
) : Container()), )
: Container()),
], ],
); );
} }
@ -278,7 +285,9 @@ class _LatNLongState extends State<LatNLong> {
), ),
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: (this.latnLong != null) ? lnlDec(this.latnLong) : lnlDec('none') , child: (this.latnLong != null)
? lnlDec(this.latnLong)
: lnlDec('none'),
), ),
IntrinsicHeight( IntrinsicHeight(
child: Row( child: Row(
@ -294,7 +303,9 @@ class _LatNLongState extends State<LatNLong> {
), ),
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: (this.latnLongDMS != null) ? lnlDeg(this.latnLongDMS) : lnlDeg('none'), child: (this.latnLongDMS != null)
? lnlDeg(this.latnLongDMS)
: lnlDeg('none'),
), ),
), ),
], ],
@ -373,7 +384,8 @@ class _LatNLongState extends State<LatNLong> {
child: aboutApp(context), child: aboutApp(context),
), ),
), ),
((this._useElev) ? Expanded( ((this._useElev)
? Expanded(
flex: 4, flex: 4,
child: Container( child: Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
@ -384,9 +396,11 @@ class _LatNLongState extends State<LatNLong> {
), ),
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: elevAtion(context, this.elevation, this.feetElevation), child: elevAtion(
context, this.elevation, this.feetElevation),
), ),
) : Container()), )
: Container()),
Expanded( Expanded(
flex: 3, flex: 3,
child: Container( child: Container(
@ -407,7 +421,8 @@ class _LatNLongState extends State<LatNLong> {
IntrinsicHeight( IntrinsicHeight(
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
((this._useWTHR) ? Expanded( ((this._useWTHR)
? Expanded(
flex: 7, flex: 7,
child: Container( child: Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
@ -420,7 +435,8 @@ class _LatNLongState extends State<LatNLong> {
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: _timezone(), child: _timezone(),
), ),
) : Container()), )
: Container()),
], ],
), ),
), ),
@ -445,7 +461,9 @@ class _LatNLongState extends State<LatNLong> {
), ),
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: (this.latnLongDMS != null) ? lnlDeg(this.latnLongDMS) : lnlDeg('none'), child: (this.latnLongDMS != null)
? lnlDeg(this.latnLongDMS)
: lnlDeg('none'),
), ),
), ),
Expanded( Expanded(
@ -474,7 +492,9 @@ class _LatNLongState extends State<LatNLong> {
), ),
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: (this.latnLong != null) ? lnlDec(this.latnLong) : lnlDec('none') , child: (this.latnLong != null)
? lnlDec(this.latnLong)
: lnlDec('none'),
), ),
IntrinsicHeight( IntrinsicHeight(
child: Row( child: Row(
@ -549,7 +569,8 @@ class _LatNLongState extends State<LatNLong> {
IntrinsicHeight( IntrinsicHeight(
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
((this._useElev) ? Expanded( ((this._useElev)
? Expanded(
flex: 3, flex: 3,
child: Container( child: Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
@ -560,10 +581,13 @@ class _LatNLongState extends State<LatNLong> {
), ),
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: elevAtion(context, this.elevation, this.feetElevation), child: elevAtion(
context, this.elevation, this.feetElevation),
), ),
) : Container()), )
((this._useWTHR) ? Expanded( : Container()),
((this._useWTHR)
? Expanded(
flex: 7, flex: 7,
child: Container( child: Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
@ -576,7 +600,8 @@ class _LatNLongState extends State<LatNLong> {
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: _timezone(), child: _timezone(),
), ),
) : Container()), )
: Container()),
], ],
), ),
), ),
@ -615,7 +640,9 @@ class _LatNLongState extends State<LatNLong> {
), ),
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: (this.latnLong != null) ? lnlDec(this.latnLong) : lnlDec('none'), child: (this.latnLong != null)
? lnlDec(this.latnLong)
: lnlDec('none'),
), ),
), ),
Expanded( Expanded(
@ -649,7 +676,9 @@ class _LatNLongState extends State<LatNLong> {
), ),
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: (this.latnLongDMS != null) ? lnlDeg(this.latnLongDMS) : lnlDeg('none'), child: (this.latnLongDMS != null)
? lnlDeg(this.latnLongDMS)
: lnlDeg('none'),
), ),
), ),
Expanded( Expanded(
@ -702,7 +731,8 @@ class _LatNLongState extends State<LatNLong> {
), ),
), ),
), ),
((this._useElev) ? Expanded( ((this._useElev)
? Expanded(
flex: 2, flex: 2,
child: Container( child: Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
@ -713,10 +743,13 @@ class _LatNLongState extends State<LatNLong> {
), ),
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: elevAtion(context, this.elevation, this.feetElevation), child: elevAtion(
context, this.elevation, this.feetElevation),
), ),
) : Container()), )
((this._useWTHR) ? Expanded( : Container()),
((this._useWTHR)
? Expanded(
flex: 4, flex: 4,
child: Container( child: Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
@ -729,7 +762,8 @@ class _LatNLongState extends State<LatNLong> {
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: _timezone(), child: _timezone(),
), ),
) : Container()), )
: Container()),
], ],
), ),
), ),
@ -764,7 +798,8 @@ class _LatNLongState extends State<LatNLong> {
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[ children: <Widget>[
_top(), _top(),
((this._useWTHR) ? Weather( ((this._useWTHR)
? Weather(
weatherLocationID: this.weatherLocationID, weatherLocationID: this.weatherLocationID,
weatherConditions: this.weatherConditions, weatherConditions: this.weatherConditions,
weatherConditionsIcon: this.weatherConditionsIcon, weatherConditionsIcon: this.weatherConditionsIcon,
@ -781,11 +816,14 @@ class _LatNLongState extends State<LatNLong> {
weatherCurrentDT: this.weatherCurrentDT, weatherCurrentDT: this.weatherCurrentDT,
timeOffSet: this.timeOffSet, timeOffSet: this.timeOffSet,
parentAction: this._refreshWeather, parentAction: this._refreshWeather,
) : Container()), )
((this._useWTHR) ? WeatherForeCast( : Container()),
((this._useWTHR)
? WeatherForeCast(
weatherForeCast: this.weatherForeCast, weatherForeCast: this.weatherForeCast,
timeOffSet: this.timeOffSet, timeOffSet: this.timeOffSet,
) : Container()), )
: Container()),
], ],
), ),
), ),
@ -865,7 +903,7 @@ class _LatNLongState extends State<LatNLong> {
Future<void> updateState() async { Future<void> updateState() async {
var sharedData = await platform.invokeMethod("getSharedText"); var sharedData = await platform.invokeMethod("getSharedText");
if (sharedData != null && sharedData is String) { if (sharedData != null && sharedData is String) {
if (gmapExp.hasMatch(sharedData)) { if (mapExp.hasMatch(sharedData)) {
setState(() { setState(() {
this.widgetMapLocation = sharedData; this.widgetMapLocation = sharedData;
}); });
@ -910,7 +948,8 @@ class _LatNLongState extends State<LatNLong> {
Map<String, dynamic> weatherForeCastJson = jsonDecode(weatherForeCast); Map<String, dynamic> weatherForeCastJson = jsonDecode(weatherForeCast);
int _threeHoursAgo = (newTimeStamp() - 10800); int _threeHoursAgo = (newTimeStamp() - 10800);
if (weatherForeCastJson['list'][1]['dt'] < _threeHoursAgo) { if (weatherForeCastJson['list'][1]['dt'] < _threeHoursAgo) {
weatherForeCast = await getWeatherForeCast(mapLocation, latLong, true); weatherForeCast =
await getWeatherForeCast(mapLocation, latLong, true);
setState(() { setState(() {
this.weatherForeCast = weatherForeCast; this.weatherForeCast = weatherForeCast;
}); });
@ -943,9 +982,12 @@ class _LatNLongState extends State<LatNLong> {
} }
} }
Future<void> _updateWeather(Map<String, dynamic> weatherJson,String latLong) async { Future<void> _updateWeather(
Map<String, dynamic> weatherJson, String latLong) async {
if (this._useWTHR) { if (this._useWTHR) {
int _weatherId = (weatherJson['id'] != 0) ? weatherJson['id']: generateFakeWeatherId(latLong); int _weatherId = (weatherJson['id'] != 0)
? weatherJson['id']
: generateFakeWeatherId(latLong);
if ((_weatherId != this.weatherLocationID) || if ((_weatherId != this.weatherLocationID) ||
(weatherJson['dt'] != this.weatherCurrentDT)) { (weatherJson['dt'] != this.weatherCurrentDT)) {
double tempTemp = (weatherJson['main']['temp'] != null) double tempTemp = (weatherJson['main']['temp'] != null)
@ -1053,7 +1095,7 @@ class _LatNLongState extends State<LatNLong> {
} }
Future<void> _updateLatNLong(int timeStamp, String mapLocation) async { Future<void> _updateLatNLong(int timeStamp, String mapLocation) async {
String mapUrl = gmapExp.stringMatch(mapLocation); String mapUrl = mapExp.stringMatch(mapLocation);
await parseMapUrl(mapUrl).then((String lattLong) { await parseMapUrl(mapUrl).then((String lattLong) {
setState(() { setState(() {
this.latnLong = lattLong; this.latnLong = lattLong;
@ -1124,8 +1166,10 @@ class _LatNLongState extends State<LatNLong> {
Future<void> _userTzOffset(int offset) async { Future<void> _userTzOffset(int offset) async {
if (this._useWTHR) { if (this._useWTHR) {
if (offset > 1999) { // 2001 is magic number for auto if (offset > 1999) {
List<int> _timeOffSet = await refreshTimeOffSet(this.widgetMapLocation,this.latnLong); // 2001 is magic number for auto
List<int> _timeOffSet =
await refreshTimeOffSet(this.widgetMapLocation, this.latnLong);
setState(() { setState(() {
this.timeOffSet = _timeOffSet[0]; this.timeOffSet = _timeOffSet[0];
this.timeOffSetTime = _timeOffSet[1]; this.timeOffSetTime = _timeOffSet[1];

View File

@ -63,14 +63,11 @@ class _RenderNotesState extends State<RenderNotes> {
child: ButtonTheme( child: ButtonTheme(
height: 55, height: 55,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 5, top: 5, right: 12, bottom: 12, left: 10),
right: 12,
bottom: 12,
left: 10
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius:
BorderRadius.all(Radius.circular(6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -82,20 +79,32 @@ class _RenderNotesState extends State<RenderNotes> {
), ),
), ),
onPressed: () async { onPressed: () async {
Map<PermissionGroup, PermissionStatus> _storagePermissions; Map<PermissionGroup, PermissionStatus>
PermissionStatus _storagePermission = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage); _storagePermissions;
if (_storagePermission == PermissionStatus.denied) { PermissionStatus _storagePermission =
_storagePermissions = await PermissionHandler().requestPermissions([PermissionGroup.storage]); await PermissionHandler()
.checkPermissionStatus(
PermissionGroup.storage);
if (_storagePermission ==
PermissionStatus.denied) {
_storagePermissions = await PermissionHandler()
.requestPermissions(
[PermissionGroup.storage]);
} }
if ((_storagePermission == PermissionStatus.granted) || (_storagePermissions.toString() == PermissionStatus.granted.toString())) { if ((_storagePermission ==
Directory sdcard = await getExternalStorageDirectory(); PermissionStatus.granted) ||
(_storagePermissions.toString() ==
PermissionStatus.granted.toString())) {
Directory sdcard =
await getExternalStorageDirectory();
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor: ivory,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
title: Text( title: Text(
'File Name To Save As?', 'File Name To Save As?',
@ -108,8 +117,10 @@ class _RenderNotesState extends State<RenderNotes> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
TextField( TextField(
controller: _textEditingController, controller:
keyboardType: TextInputType.multiline, _textEditingController,
keyboardType:
TextInputType.multiline,
maxLines: null, maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
hintText: 'i.e. timbuktu.md', hintText: 'i.e. timbuktu.md',
@ -129,11 +140,14 @@ class _RenderNotesState extends State<RenderNotes> {
top: 5, top: 5,
right: 12, right: 12,
bottom: 12, bottom: 12,
left: 10 left: 10),
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape:
borderRadius: BorderRadius.all(Radius.circular(6.0)), RoundedRectangleBorder(
borderRadius:
BorderRadius.all(
Radius.circular(
6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -145,46 +159,75 @@ class _RenderNotesState extends State<RenderNotes> {
), ),
), ),
onPressed: () async { onPressed: () async {
if (this._exportFileNameString.length > 0) { if (this
String _fileName = '${sdcard.path}/${this._exportFileNameString}'; ._exportFileNameString
File _file = File(_fileName); .length >
File _result = await _file.writeAsString(widget.notes); 0) {
Navigator.of(context).pop(); String _fileName =
'${sdcard.path}/${this._exportFileNameString}';
File _file =
File(_fileName);
File _result =
await _file
.writeAsString(
widget
.notes);
Navigator.of(context)
.pop();
if (_result == null) { if (_result == null) {
setState(() { setState(() {
this.fileName = _fileName; this.fileName =
_fileName;
}); });
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder:
(BuildContext
context) {
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor:
shape: RoundedRectangleBorder( ivory,
borderRadius: BorderRadius.all(Radius.circular(6.0)), shape:
RoundedRectangleBorder(
borderRadius:
BorderRadius.all(
Radius.circular(6.0)),
), ),
title: Text( title: Text(
'Writing To\n\'$fileName\'\n(sdcard) Failed!', 'Writing To\n\'$fileName\'\n(sdcard) Failed!',
textAlign: TextAlign.center, textAlign:
style: TextStyle( TextAlign
color: candyApple, .center,
style:
TextStyle(
color:
candyApple,
), ),
), ),
content: Column( content:
mainAxisSize: MainAxisSize.min, Column(
children: <Widget>[ mainAxisSize:
MainAxisSize
.min,
children: <
Widget>[
Container( Container(
margin: EdgeInsets.only( margin:
top: 40, EdgeInsets.only(
bottom: 10, top:
40,
bottom:
10,
), ),
child: ButtonTheme( child:
height: 55, ButtonTheme(
height:
55,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 5, top: 5,
right: 12, right: 12,
bottom: 12, bottom: 12,
left: 10 left: 10),
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(Radius.circular(6.0)),
@ -200,50 +243,67 @@ class _RenderNotesState extends State<RenderNotes> {
), ),
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }),
),
), ),
), ),
], ],
), ),
); );
} });
);
} else { } else {
setState(() { setState(() {
this.fileName = _fileName; this.fileName =
_fileName;
}); });
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder:
(BuildContext
context) {
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor:
shape: RoundedRectangleBorder( ivory,
borderRadius: BorderRadius.all(Radius.circular(6.0)), shape:
RoundedRectangleBorder(
borderRadius:
BorderRadius.all(
Radius.circular(6.0)),
), ),
title: Text( title: Text(
'Writing To\n\'$fileName\'\n(sdcard) Succeeded!', 'Writing To\n\'$fileName\'\n(sdcard) Succeeded!',
textAlign: TextAlign.center, textAlign:
style: TextStyle( TextAlign
color: candyApple, .center,
style:
TextStyle(
color:
candyApple,
), ),
), ),
content: Column( content:
mainAxisSize: MainAxisSize.min, Column(
children: <Widget>[ mainAxisSize:
MainAxisSize
.min,
children: <
Widget>[
Container( Container(
margin: EdgeInsets.only( margin:
top: 40, EdgeInsets.only(
bottom: 10, top:
40,
bottom:
10,
), ),
child: ButtonTheme( child:
height: 55, ButtonTheme(
height:
55,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 5, top: 5,
right: 12, right: 12,
bottom: 12, bottom: 12,
left: 10 left: 10),
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(Radius.circular(6.0)),
@ -259,29 +319,24 @@ class _RenderNotesState extends State<RenderNotes> {
), ),
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }),
),
), ),
), ),
], ],
), ),
); );
} });
);
} }
} }
} }),
),
), ),
), ),
], ],
), ),
); );
});
} }
); }),
}
}
),
), ),
), ),
], ],

View File

@ -32,14 +32,17 @@ class _SettingsState extends State<Settings> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Future<void> _showDBImportDialog() async { Future<void> _showDBImportDialog() async {
Map<PermissionGroup, PermissionStatus> _storagePermissions; Map<PermissionGroup, PermissionStatus> _storagePermissions;
PermissionStatus _storagePermission = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage); PermissionStatus _storagePermission = await PermissionHandler()
.checkPermissionStatus(PermissionGroup.storage);
if (_storagePermission == PermissionStatus.denied) { if (_storagePermission == PermissionStatus.denied) {
_storagePermissions = await PermissionHandler().requestPermissions([PermissionGroup.storage]); _storagePermissions = await PermissionHandler()
.requestPermissions([PermissionGroup.storage]);
} }
if ((_storagePermission == PermissionStatus.granted) || (_storagePermissions.toString() == PermissionStatus.granted.toString())) { if ((_storagePermission == PermissionStatus.granted) ||
(_storagePermissions.toString() ==
PermissionStatus.granted.toString())) {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -66,14 +69,11 @@ class _SettingsState extends State<Settings> {
child: ButtonTheme( child: ButtonTheme(
height: 55, height: 55,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 5, top: 5, right: 12, bottom: 12, left: 10),
right: 12,
bottom: 12,
left: 10
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius:
BorderRadius.all(Radius.circular(6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -86,11 +86,14 @@ class _SettingsState extends State<Settings> {
), ),
onPressed: () async { onPressed: () async {
String _filePath; String _filePath;
_filePath = await FilePicker.getFilePath(type: FileType.ANY); _filePath = await FilePicker.getFilePath(
type: FileType.ANY);
Navigator.of(context).pop(); Navigator.of(context).pop();
try { try {
String _importString = await File(_filePath).readAsString(); String _importString =
bool _imported = await importDataBase(_importString); await File(_filePath).readAsString();
bool _imported =
await importDataBase(_importString);
if (_imported) { if (_imported) {
showDialog( showDialog(
context: context, context: context,
@ -98,7 +101,8 @@ class _SettingsState extends State<Settings> {
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor: ivory,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
title: Text( title: Text(
'Importing From\n\'$_filePath\'\n Succeeded!', 'Importing From\n\'$_filePath\'\n Succeeded!',
@ -121,11 +125,14 @@ class _SettingsState extends State<Settings> {
top: 5, top: 5,
right: 12, right: 12,
bottom: 12, bottom: 12,
left: 10 left: 10),
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape:
borderRadius: BorderRadius.all(Radius.circular(6.0)), RoundedRectangleBorder(
borderRadius:
BorderRadius.all(
Radius.circular(
6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -137,16 +144,15 @@ class _SettingsState extends State<Settings> {
), ),
), ),
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context)
} .pop();
), }),
), ),
), ),
], ],
), ),
); );
} });
);
} }
} catch (e) { } catch (e) {
print(e); print(e);
@ -156,7 +162,8 @@ class _SettingsState extends State<Settings> {
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor: ivory,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
title: Text( title: Text(
'Oops, something went wrong', 'Oops, something went wrong',
@ -179,11 +186,14 @@ class _SettingsState extends State<Settings> {
top: 5, top: 5,
right: 12, right: 12,
bottom: 12, bottom: 12,
left: 10 left: 10),
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape:
borderRadius: BorderRadius.all(Radius.circular(6.0)), RoundedRectangleBorder(
borderRadius:
BorderRadius.all(
Radius.circular(
6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -195,36 +205,37 @@ class _SettingsState extends State<Settings> {
), ),
), ),
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context)
} .pop();
), }),
), ),
), ),
], ],
), ),
); );
});
} }
); }),
}
}
),
), ),
), ),
], ],
), ),
); );
} });
);
} }
} }
Future<void> _showDBExportDialog() async { Future<void> _showDBExportDialog() async {
Map<PermissionGroup, PermissionStatus> _storagePermissions; Map<PermissionGroup, PermissionStatus> _storagePermissions;
PermissionStatus _storagePermission = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage); PermissionStatus _storagePermission = await PermissionHandler()
.checkPermissionStatus(PermissionGroup.storage);
if (_storagePermission == PermissionStatus.denied) { if (_storagePermission == PermissionStatus.denied) {
_storagePermissions = await PermissionHandler().requestPermissions([PermissionGroup.storage]); _storagePermissions = await PermissionHandler()
.requestPermissions([PermissionGroup.storage]);
} }
if ((_storagePermission == PermissionStatus.granted) || (_storagePermissions.toString() == PermissionStatus.granted.toString())) { if ((_storagePermission == PermissionStatus.granted) ||
(_storagePermissions.toString() ==
PermissionStatus.granted.toString())) {
Directory sdcard = await getExternalStorageDirectory(); Directory sdcard = await getExternalStorageDirectory();
showDialog( showDialog(
context: context, context: context,
@ -258,7 +269,8 @@ class _SettingsState extends State<Settings> {
hintText: this._dbExportFileNameString, hintText: this._dbExportFileNameString,
), ),
onChanged: (text) { onChanged: (text) {
this._dbExportFileNameString = (text.length > 0) ? text : "libre_gps_parser.json"; this._dbExportFileNameString =
(text.length > 0) ? text : "libre_gps_parser.json";
}, },
), ),
Container( Container(
@ -269,14 +281,11 @@ class _SettingsState extends State<Settings> {
child: ButtonTheme( child: ButtonTheme(
height: 55, height: 55,
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 5, top: 5, right: 12, bottom: 12, left: 10),
right: 12,
bottom: 12,
left: 10
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius:
BorderRadius.all(Radius.circular(6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -290,10 +299,13 @@ class _SettingsState extends State<Settings> {
onPressed: () async { onPressed: () async {
_updatedbExportFileName(); _updatedbExportFileName();
final dbHelper = DatabaseHelper.instance; final dbHelper = DatabaseHelper.instance;
String _dbExportString = await dbHelper.queryDBExport(); String _dbExportString =
String _absoluteDBExportFileName = '${sdcard.path}/${this._dbExportFileNameString}'; await dbHelper.queryDBExport();
String _absoluteDBExportFileName =
'${sdcard.path}/${this._dbExportFileNameString}';
File _file = File(_absoluteDBExportFileName); File _file = File(_absoluteDBExportFileName);
File _result = await _file.writeAsString(_dbExportString); File _result =
await _file.writeAsString(_dbExportString);
Navigator.of(context).pop(); Navigator.of(context).pop();
if (_result == null) { if (_result == null) {
showDialog( showDialog(
@ -302,7 +314,8 @@ class _SettingsState extends State<Settings> {
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor: ivory,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
title: Text( title: Text(
'Writing To\n\'$_absoluteDBExportFileName\'\n(sdcard) Failed!', 'Writing To\n\'$_absoluteDBExportFileName\'\n(sdcard) Failed!',
@ -325,11 +338,14 @@ class _SettingsState extends State<Settings> {
top: 5, top: 5,
right: 12, right: 12,
bottom: 12, bottom: 12,
left: 10 left: 10),
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape:
borderRadius: BorderRadius.all(Radius.circular(6.0)), RoundedRectangleBorder(
borderRadius:
BorderRadius.all(
Radius.circular(
6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -341,16 +357,15 @@ class _SettingsState extends State<Settings> {
), ),
), ),
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context)
} .pop();
), }),
), ),
), ),
], ],
), ),
); );
} });
);
} else { } else {
showDialog( showDialog(
context: context, context: context,
@ -358,7 +373,8 @@ class _SettingsState extends State<Settings> {
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor: ivory,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
title: Text( title: Text(
'Writing To\n\'$_absoluteDBExportFileName\'\n(sdcard) Succeeded!', 'Writing To\n\'$_absoluteDBExportFileName\'\n(sdcard) Succeeded!',
@ -381,11 +397,14 @@ class _SettingsState extends State<Settings> {
top: 5, top: 5,
right: 12, right: 12,
bottom: 12, bottom: 12,
left: 10 left: 10),
),
child: RaisedButton( child: RaisedButton(
shape: RoundedRectangleBorder( shape:
borderRadius: BorderRadius.all(Radius.circular(6.0)), RoundedRectangleBorder(
borderRadius:
BorderRadius.all(
Radius.circular(
6.0)),
), ),
color: peacockBlue, color: peacockBlue,
child: Text( child: Text(
@ -397,26 +416,23 @@ class _SettingsState extends State<Settings> {
), ),
), ),
onPressed: () async { onPressed: () async {
Navigator.of(context).pop(); Navigator.of(context)
} .pop();
), }),
), ),
), ),
], ],
), ),
); );
});
} }
); }),
}
}
),
), ),
), ),
], ],
), ),
); );
} });
);
} }
} }
@ -450,7 +466,8 @@ class _SettingsState extends State<Settings> {
child: Switch( child: Switch(
value: this._useElevation, value: this._useElevation,
onChanged: (value) { onChanged: (value) {
setPreferenceUseElevation(value).then((bool committed) { setPreferenceUseElevation(value)
.then((bool committed) {
setState(() { setState(() {
this._useElevation = value; this._useElevation = value;
}); });
@ -465,7 +482,8 @@ class _SettingsState extends State<Settings> {
], ],
), ),
), ),
((this._useElevation) ? Container( ((this._useElevation)
? Container(
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: Column( child: Column(
@ -503,7 +521,8 @@ class _SettingsState extends State<Settings> {
), ),
], ],
), ),
) : Container()), )
: Container()),
Container( Container(
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
@ -540,7 +559,8 @@ class _SettingsState extends State<Settings> {
], ],
), ),
), ),
((this._useWeather) ? Container( ((this._useWeather)
? Container(
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
child: Column( child: Column(
@ -578,7 +598,8 @@ class _SettingsState extends State<Settings> {
), ),
], ],
), ),
) : Container()), )
: Container()),
Container( Container(
padding: myBoxPadding, padding: myBoxPadding,
decoration: myBoxDecoration(ivory), decoration: myBoxDecoration(ivory),
@ -738,5 +759,4 @@ class _SettingsState extends State<Settings> {
Navigator.pop(context, 3); Navigator.pop(context, 3);
return Future.value(false); return Future.value(false);
} }
} }

View File

@ -53,7 +53,9 @@ class _TimeZoneState extends State<TimeZone> {
text: TextSpan( text: TextSpan(
children: <TextSpan>[ children: <TextSpan>[
TextSpan( TextSpan(
text: (widget.timeOffSet != 2000) ? '$offSet' : 'INVALID', text: (widget.timeOffSet != 2000)
? '$offSet'
: 'INVALID',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.black, color: Colors.black,
@ -76,7 +78,9 @@ class _TimeZoneState extends State<TimeZone> {
text: TextSpan( text: TextSpan(
children: <TextSpan>[ children: <TextSpan>[
TextSpan( TextSpan(
text: (widget.isAutoTimeOffSet == 1) ? 'as of' : 'MANUAL SETTING', text: (widget.isAutoTimeOffSet == 1)
? 'as of'
: 'MANUAL SETTING',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: candyApple, color: candyApple,
@ -84,7 +88,9 @@ class _TimeZoneState extends State<TimeZone> {
), ),
), ),
TextSpan( TextSpan(
text: (widget.isAutoTimeOffSet == 1) ? ' $elapsedHours' : '', text: (widget.isAutoTimeOffSet == 1)
? ' $elapsedHours'
: '',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.black, color: Colors.black,
@ -118,19 +124,21 @@ class _TimeZoneState extends State<TimeZone> {
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
final FixedExtentScrollController scrollController = final FixedExtentScrollController scrollController =
FixedExtentScrollController(initialItem: _getTimeZoneListIndex()); FixedExtentScrollController(
initialItem: _getTimeZoneListIndex());
return AlertDialog( return AlertDialog(
backgroundColor: ivory, backgroundColor: ivory,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(Radius.circular(6.0)),
), ),
content: Column( content:
mainAxisSize: MainAxisSize.min, Column(mainAxisSize: MainAxisSize.min, children: <
children: <Widget>[ Widget>[
ButtonTheme( ButtonTheme(
height: 75, height: 75,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius:
BorderRadius.all(Radius.circular(6.0)),
), ),
child: RaisedButton( child: RaisedButton(
onPressed: () { onPressed: () {
@ -180,7 +188,8 @@ class _TimeZoneState extends State<TimeZone> {
}); });
} }
}, },
children: List<Widget>.generate(timeZoneList.length, (int index) { children: List<Widget>.generate(timeZoneList.length,
(int index) {
return Column( return Column(
children: <Widget>[ children: <Widget>[
Container( Container(
@ -190,19 +199,23 @@ class _TimeZoneState extends State<TimeZone> {
Container( Container(
alignment: Alignment(0.0, 0.0), alignment: Alignment(0.0, 0.0),
height: 80, height: 80,
width: (MediaQuery.of(context).size.width * .9), width: (MediaQuery.of(context).size.width *
.9),
decoration: BoxDecoration( decoration: BoxDecoration(
color: peacockBlue, color: peacockBlue,
border: Border.all( border: Border.all(
width: 2.0, width: 2.0,
), ),
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius: BorderRadius.all(
Radius.circular(6.0)),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
Text( Text(
_parseTimeZoneOffSet(timeZoneList[index]['offset']), _parseTimeZoneOffSet(
timeZoneList[index]['offset']),
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.white, color: Colors.white,
@ -229,13 +242,11 @@ class _TimeZoneState extends State<TimeZone> {
}), }),
), ),
), ),
] ]),
),
); );
}, },
); );
} }),
),
), ),
Expanded( Expanded(
flex: 3, flex: 3,
@ -287,7 +298,8 @@ class _TimeZoneState extends State<TimeZone> {
child: ButtonTheme( child: ButtonTheme(
height: 75, height: 75,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(6.0)), borderRadius:
BorderRadius.all(Radius.circular(6.0)),
), ),
child: RaisedButton( child: RaisedButton(
color: peacockBlue, color: peacockBlue,
@ -299,7 +311,8 @@ class _TimeZoneState extends State<TimeZone> {
top: 10, top: 10,
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: <Widget>[ children: <Widget>[
Text( Text(
'List', 'List',
@ -334,29 +347,29 @@ class _TimeZoneState extends State<TimeZone> {
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
urlLaunch('https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations'); urlLaunch(
} 'https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations');
), }),
), ),
), ),
], ],
), ),
); );
} });
);
}, },
), ),
), ),
), ),
], ],
); );
} }
int _getTimeZoneListIndex() { int _getTimeZoneListIndex() {
// 2001 is a magic number which means auto // 2001 is a magic number which means auto
// as in the tz offset is automatically set // as in the tz offset is automatically set
return timeZoneList.indexOf(timeZoneList.singleWhere((timeZone) => timeZone['offset'] == ((widget.isAutoTimeOffSet == 1) ? 2001 : widget.timeOffSet))); return timeZoneList.indexOf(timeZoneList.singleWhere((timeZone) =>
timeZone['offset'] ==
((widget.isAutoTimeOffSet == 1) ? 2001 : widget.timeOffSet)));
} }
String _parseTimeZoneOffSet(int offset) { String _parseTimeZoneOffSet(int offset) {

View File

@ -1,7 +1,6 @@
// https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations // https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations
final List<Map<String, Object>> timeZoneList = [ final List<Map<String, Object>> timeZoneList = [
{'offset': -720, 'tz': 'BIT, IDLW'}, {'offset': -720, 'tz': 'BIT, IDLW'},
{'offset': -660, 'tz': 'NUT, SST'}, {'offset': -660, 'tz': 'NUT, SST'},
{'offset': -600, 'tz': 'HST, TAHT'}, {'offset': -600, 'tz': 'HST, TAHT'},
@ -44,5 +43,4 @@ final List<Map<String, Object>> timeZoneList = [
{'offset': 840, 'tz': 'LINT'}, {'offset': 840, 'tz': 'LINT'},
{'offset': 2000, 'tz': 'INVLD'}, {'offset': 2000, 'tz': 'INVLD'},
{'offset': 2001, 'tz': 'AUTO'}, {'offset': 2001, 'tz': 'AUTO'},
]; ];

View File

@ -63,7 +63,8 @@ class _WeatherState extends State<Weather> {
final bool _stale = (_staleness > 3600); final bool _stale = (_staleness > 3600);
Expanded _refresh() { Expanded _refresh() {
return _stale ? Expanded( return _stale
? Expanded(
flex: 4, flex: 4,
child: Container( child: Container(
child: IconButton( child: IconButton(
@ -75,11 +76,14 @@ class _WeatherState extends State<Weather> {
widget.parentAction(); widget.parentAction();
}, },
), ),
),) : Expanded(child: Container()); ),
)
: Expanded(child: Container());
} }
Expanded _staleNotice() { Expanded _staleNotice() {
return _stale ? Expanded( return _stale
? Expanded(
flex: 6, flex: 6,
child: RichText( child: RichText(
textAlign: TextAlign.justify, textAlign: TextAlign.justify,
@ -108,7 +112,8 @@ class _WeatherState extends State<Weather> {
), ),
), ),
TextSpan( TextSpan(
text: '. You probably want to check your network connection and then ', text:
'. You probably want to check your network connection and then ',
style: TextStyle( style: TextStyle(
color: Colors.black, color: Colors.black,
fontSize: 16, fontSize: 16,
@ -132,7 +137,8 @@ class _WeatherState extends State<Weather> {
], ],
), ),
), ),
) : Expanded(child: Container()); )
: Expanded(child: Container());
} }
Column _currentConditions() { Column _currentConditions() {
@ -247,8 +253,7 @@ class _WeatherState extends State<Weather> {
), ),
), ),
TextSpan( TextSpan(
text: text: '${widget.weatherCurrentTempMin.round()}\u00B0',
'${widget.weatherCurrentTempMin.round()}\u00B0',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.black, color: Colors.black,
@ -298,8 +303,7 @@ class _WeatherState extends State<Weather> {
), ),
), ),
TextSpan( TextSpan(
text: text: '${widget.weatherCurrentTempMax.round()}\u00B0',
'${widget.weatherCurrentTempMax.round()}\u00B0',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.black, color: Colors.black,
@ -468,8 +472,7 @@ class _WeatherState extends State<Weather> {
text: TextSpan( text: TextSpan(
children: <TextSpan>[ children: <TextSpan>[
TextSpan( TextSpan(
text: text: '${(widget.weatherCurrentWindSpd * 1.60934).round()}',
'${(widget.weatherCurrentWindSpd * 1.60934).round()}',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.black, color: Colors.black,
@ -901,7 +904,8 @@ class _WeatherState extends State<Weather> {
return Container( return Container(
width: 100, width: 100,
child: CachedNetworkImage( child: CachedNetworkImage(
imageUrl: 'http://openweathermap.org/img/w/${widget.weatherConditionsIcon}.png', imageUrl:
'http://openweathermap.org/img/w/${widget.weatherConditionsIcon}.png',
), ),
); );
} }
@ -1215,7 +1219,6 @@ class _WeatherState extends State<Weather> {
), ),
); );
} }
} }
Map<String, String> get3WayTime(int secondsFromEpoch, int timeOffSet) { Map<String, String> get3WayTime(int secondsFromEpoch, int timeOffSet) {
@ -1223,7 +1226,9 @@ class _WeatherState extends State<Weather> {
DateTime.fromMillisecondsSinceEpoch(secondsFromEpoch * 1000).toUtc(); DateTime.fromMillisecondsSinceEpoch(secondsFromEpoch * 1000).toUtc();
DateTime thereTime = utcTime.add(Duration(minutes: timeOffSet)); DateTime thereTime = utcTime.add(Duration(minutes: timeOffSet));
DateTime hereTime = utcTime.toLocal(); DateTime hereTime = utcTime.toLocal();
String there = (timeOffSet != 2000) ? DateFormat('EEEE MMMM d, HH:mm').format(thereTime) : 'UNKNOWN, INVALID'; String there = (timeOffSet != 2000)
? DateFormat('EEEE MMMM d, HH:mm').format(thereTime)
: 'UNKNOWN, INVALID';
String here = DateFormat('EEEE MMMM d, HH:mm').format(hereTime); String here = DateFormat('EEEE MMMM d, HH:mm').format(hereTime);
String utc = DateFormat('EEEE MMMM d, HH:mm').format(utcTime); String utc = DateFormat('EEEE MMMM d, HH:mm').format(utcTime);
return { return {

View File

@ -81,7 +81,8 @@ class _WeatherForeCastState extends State<WeatherForeCast> {
return Container( return Container(
width: 100, width: 100,
child: CachedNetworkImage( child: CachedNetworkImage(
imageUrl: 'http://openweathermap.org/img/w/${foreCast['weather'][0]['icon']}.png', imageUrl:
'http://openweathermap.org/img/w/${foreCast['weather'][0]['icon']}.png',
), ),
); );
} }
@ -183,8 +184,7 @@ class _WeatherForeCastState extends State<WeatherForeCast> {
), ),
), ),
TextSpan( TextSpan(
text: text: '${foreCast['wind']['deg'].round()}\u00B0, ',
'${foreCast['wind']['deg'].round()}\u00B0, ',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.black, color: Colors.black,
@ -225,8 +225,7 @@ class _WeatherForeCastState extends State<WeatherForeCast> {
), ),
), ),
TextSpan( TextSpan(
text: text: '${foreCast['main']['temp'].round()}\u00B0',
'${foreCast['main']['temp'].round()}\u00B0',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.black, color: Colors.black,
@ -276,8 +275,7 @@ class _WeatherForeCastState extends State<WeatherForeCast> {
), ),
), ),
TextSpan( TextSpan(
text: text: '${foreCast['main']['temp_min'].round()}\u00B0',
'${foreCast['main']['temp_min'].round()}\u00B0',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.black, color: Colors.black,
@ -327,8 +325,7 @@ class _WeatherForeCastState extends State<WeatherForeCast> {
), ),
), ),
TextSpan( TextSpan(
text: text: '${foreCast['main']['temp_max'].round()}\u00B0',
'${foreCast['main']['temp_max'].round()}\u00B0',
style: TextStyle( style: TextStyle(
height: textHeight, height: textHeight,
color: Colors.black, color: Colors.black,
@ -1037,7 +1034,9 @@ class _WeatherForeCastState extends State<WeatherForeCast> {
DateTime.fromMillisecondsSinceEpoch(secondsFromEpoch * 1000).toUtc(); DateTime.fromMillisecondsSinceEpoch(secondsFromEpoch * 1000).toUtc();
DateTime thereTime = utcTime.add(Duration(minutes: timeOffSet)); DateTime thereTime = utcTime.add(Duration(minutes: timeOffSet));
DateTime hereTime = utcTime.toLocal(); DateTime hereTime = utcTime.toLocal();
String there = (timeOffSet != 2000) ? DateFormat('EEEE MMMM d, HH:mm').format(thereTime) : 'UNKNOWN, INVALID'; String there = (timeOffSet != 2000)
? DateFormat('EEEE MMMM d, HH:mm').format(thereTime)
: 'UNKNOWN, INVALID';
String here = DateFormat('EEEE MMMM d, HH:mm').format(hereTime); String here = DateFormat('EEEE MMMM d, HH:mm').format(hereTime);
String utc = DateFormat('EEEE MMMM d, HH:mm').format(utcTime); String utc = DateFormat('EEEE MMMM d, HH:mm').format(utcTime);
return { return {

View File

@ -11,7 +11,7 @@ description: A new Flutter project.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.1.2+8 version: 0.1.2+10
environment: environment:
sdk: ">=2.1.0 <3.0.0" sdk: ">=2.1.0 <3.0.0"