From f18e1dc301b4b4d2b97a14d428c80342c18f0ea9 Mon Sep 17 00:00:00 2001 From: Trent Palmer Date: Mon, 5 Aug 2019 22:56:02 -0700 Subject: [PATCH] implement share to mapquest --- README.md | 2 +- archive_sha256sums.md | 4 + lib/about.dart | 5 +- lib/global_helper_functions.dart | 13 +++ lib/lnl_dec.dart | 132 ++++++++++++++++++++++++++++++- lib/main.dart | 12 +-- lib/settings.dart | 39 +++++++++ pubspec.yaml | 2 +- 8 files changed, 197 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 49bf6c8..1e3b574 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ _____ ## road map * * add more things to be implemented -* add input from Bing Maps, Mapquest apps +* add input from Bing Maps, OSM? * add other elevation api server options * include shared-prefs import/export in history import/export diff --git a/archive_sha256sums.md b/archive_sha256sums.md index 89d0909..c06bb24 100644 --- a/archive_sha256sums.md +++ b/archive_sha256sums.md @@ -6,3 +6,7 @@ eddc2f07cd8aaf710cdebeead84b1c5d6b82312b4a099bd6cb09372713f0ddd3 libre_gps_pars 8c32da0c647d3b464678fe327cffe3a6750e402088552fcee7fa16b8789ecb02 libre_gps_parser/0.1.4/armv11/app-release.apk 9bef42c7919074e3661c8680cb69aa786102c4df47495dd4731efff163a8ed9b libre_gps_parser/0.1.4/arm64v12/app.aab 21460b736f6045e569443db8cdac7942c352085b3222628d100814dd5a7217d5 libre_gps_parser/0.1.4/arm64v12/app-release.apk +14ea6f6ce2566cf02ad5e2f783099eaa178714a5917077774a44b3ba2685bf64 libre_gps_parser/0.1.5/armv13/app.aab +4a26beeafff34e0d4dd1f08a235fa36ca32746c279cef637d4b47b657ab60c95 libre_gps_parser/0.1.5/armv13/app-release.apk +248eff0408748b089d13d55266aae1d542d6666ffaa7155bd948b2addf3c5efe libre_gps_parser/0.1.5/arm64v14/app.aab +412e83dcc9112b8814f3e261a452cee924a38eb8e14c90a96e3140148caededf libre_gps_parser/0.1.5/arm64v14/app-release.apk diff --git a/lib/about.dart b/lib/about.dart index 2e4fe0d..94cd858 100644 --- a/lib/about.dart +++ b/lib/about.dart @@ -55,7 +55,7 @@ InkWell aboutApp(BuildContext context) { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - 'Version: 0.1.4\n', + 'Version: 0.1.5\n', style: TextStyle( color: candyApple, ), @@ -166,7 +166,8 @@ InkWell aboutApp(BuildContext context) { ], ), ); - }); + } + ); }, ); } diff --git a/lib/global_helper_functions.dart b/lib/global_helper_functions.dart index f327050..1fa6210 100644 --- a/lib/global_helper_functions.dart +++ b/lib/global_helper_functions.dart @@ -435,6 +435,19 @@ Future setPreferenceUseWeather(bool useWeather) async { return (committed); } +Future getPreferenceUseShareToMapQuest() async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + bool _useShareToMapQuest = prefs.getBool("useShareToMapQuest") ?? false; + return _useShareToMapQuest; +} + +Future setPreferenceUseShareToMapQuest(bool useShareToMapQuest) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + bool committed = await prefs.setBool("useShareToMapQuest", useShareToMapQuest); + return (committed); +} + + Future getPreferenceDBExportFileName() async { SharedPreferences prefs = await SharedPreferences.getInstance(); String dbExportFileName = diff --git a/lib/lnl_dec.dart b/lib/lnl_dec.dart index e97893c..27c88c8 100644 --- a/lib/lnl_dec.dart +++ b/lib/lnl_dec.dart @@ -5,8 +5,9 @@ import 'package:share/share.dart'; final double textHeight = 1.5; -Row lnlDec(String latnLong) { - Future _launchLnL() async { +Row lnlDec(String latnLong,BuildContext context) { + + Future _launchLnLgMaps() async { AndroidIntent intent = AndroidIntent( action: 'action_view', data: Uri.encodeFull('geo:$latnLong?z=12'), @@ -15,6 +16,133 @@ Row lnlDec(String latnLong) { await intent.launch(); } + Future _launchLnLqMaps() async { + AndroidIntent intent = AndroidIntent( + action: 'action_view', + data: Uri.encodeFull('geo:$latnLong'), + package: 'com.mapquest.android.ace', + ); + await intent.launch(); + } + + Future _launchLnL() async { + bool _useShareToMapQuest = await getPreferenceUseShareToMapQuest(); + if (_useShareToMapQuest) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + backgroundColor: ivory, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(6.0)), + ), + content: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Flexible( + child: SingleChildScrollView( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only( + top: 40, + bottom: 10, + ), + child: Wrap( + runSpacing: 30, + alignment: WrapAlignment.center, + children: [ + Container( + margin: EdgeInsets.symmetric( + horizontal: 15, + ), + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + ), + height: 75, + child: RaisedButton( + color: peacockBlue, + child: Icon( + Icons.arrow_back, + size: 48.0, + color: Colors.white, + ), + onPressed: () { + Navigator.of(context).pop(); + }), + ), + ), + Container( + margin: EdgeInsets.symmetric( + horizontal: 15, + ), + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + ), + height: 75, + child: RaisedButton( + color: peacockBlue, + child: Text( + "MapQuest", + style: TextStyle( + height: textHeight, + color: Colors.white, + fontSize: 24, + ), + ), + onPressed: () { + _launchLnLqMaps(); + }), + ), + ), + Container( + margin: EdgeInsets.symmetric( + horizontal: 15, + ), + child: ButtonTheme( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(6.0)), + ), + height: 75, + child: RaisedButton( + color: peacockBlue, + child: Text( + "GoogleMaps", + style: TextStyle( + height: textHeight, + color: Colors.white, + fontSize: 24, + ), + ), + onPressed: () { + _launchLnLgMaps(); + } + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ], + ), + ); + } + ); + } else { + await _launchLnLgMaps(); + } + } + List _latNLong = ['x', 'y']; if ((latnLong == 'none') || (latnLong == null)) { return Row( diff --git a/lib/main.dart b/lib/main.dart index 005b5b2..c5b66e1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -286,8 +286,8 @@ class _LatNLongState extends State { padding: myBoxPadding, decoration: myBoxDecoration(ivory), child: (this.latnLong != null) - ? lnlDec(this.latnLong) - : lnlDec('none'), + ? lnlDec(this.latnLong,context) + : lnlDec('none',context), ), IntrinsicHeight( child: Row( @@ -493,8 +493,8 @@ class _LatNLongState extends State { padding: myBoxPadding, decoration: myBoxDecoration(ivory), child: (this.latnLong != null) - ? lnlDec(this.latnLong) - : lnlDec('none'), + ? lnlDec(this.latnLong,context) + : lnlDec('none',context), ), IntrinsicHeight( child: Row( @@ -641,8 +641,8 @@ class _LatNLongState extends State { padding: myBoxPadding, decoration: myBoxDecoration(ivory), child: (this.latnLong != null) - ? lnlDec(this.latnLong) - : lnlDec('none'), + ? lnlDec(this.latnLong,context) + : lnlDec('none',context), ), ), Expanded( diff --git a/lib/settings.dart b/lib/settings.dart index 3123ab8..32cbf1c 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -22,6 +22,7 @@ class _SettingsState extends State { final _oWMKController = TextEditingController(); bool _useElevation = false; bool _useWeather = false; + bool _useShareToMapQuest = false; double textHeight = 1.5; @override @@ -600,6 +601,42 @@ class _SettingsState extends State { ), ) : Container()), + Container( + padding: myBoxPadding, + decoration: myBoxDecoration(ivory), + child: Row( + children: [ + Expanded( + child: Text( + 'Enable Share Decimal Coordinates to MapQuest?', + style: TextStyle( + height: textHeight, + fontSize: 20, + ), + ), + ), + Container( + padding: EdgeInsets.all(15.0), + child: Transform.scale( + scale: 2, + child: Switch( + value: this._useShareToMapQuest, + onChanged: (value) { + setPreferenceUseShareToMapQuest(value).then((bool committed) { + setState(() { + this._useShareToMapQuest = value; + }); + }); + }, + activeTrackColor: peacockBlue, + activeColor: navy, + inactiveThumbColor: candyApple, + ), + ), + ), + ], + ), + ), Container( padding: myBoxPadding, decoration: myBoxDecoration(ivory), @@ -706,6 +743,7 @@ class _SettingsState extends State { String _dbEFNS = await getPreferenceDBExportFileName(); bool _useElev = await getPreferenceUseElevation(); bool _useWTHR = await getPreferenceUseWeather(); + bool _useShareToMQst = await getPreferenceUseShareToMapQuest(); setState(() { this.elevationServer = _evServer; this.openWeatherMapKey = _oWMK; @@ -713,6 +751,7 @@ class _SettingsState extends State { this._useWeather = _useWTHR; this.shortOWMAK = _oWMK.substring(0, 5); this._dbExportFileNameString = _dbEFNS; + this._useShareToMapQuest = _useShareToMQst; }); } diff --git a/pubspec.yaml b/pubspec.yaml index 4fdf0ef..b4b9650 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: A new Flutter project. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.1.2+12 +version: 0.1.5+14 environment: sdk: ">=2.1.0 <3.0.0"