From 624488265f2751cffce6efb496eeaf22dad44bdd Mon Sep 17 00:00:00 2001 From: michal Date: Wed, 27 Jan 2021 22:38:13 +0100 Subject: [PATCH] * Configured AdMob and release signing keys on Android. --- android/app/build.gradle | 19 ++++++++++-- lib/page/about.dart | 2 +- lib/page/flights.dart | 62 +++++++++++++++++----------------------- pubspec.yaml | 2 +- 4 files changed, 44 insertions(+), 41 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index fc2cb47..94aa0c3 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,6 +26,12 @@ apply plugin: 'kotlin-android' apply plugin: 'com.google.gms.google-services' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +def keystoreProperties = new Properties() +def keystorePropertiesFile = rootProject.file('key.properties') +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} + android { compileSdkVersion 30 @@ -42,14 +48,21 @@ android { multiDexEnabled true } + signingConfigs { + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null + storePassword keystoreProperties['storePassword'] + } + } + buildTypes { debug { applicationIdSuffix ".debug" } release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig signingConfigs.release } } } diff --git a/lib/page/about.dart b/lib/page/about.dart index 1e9500b..40b4327 100644 --- a/lib/page/about.dart +++ b/lib/page/about.dart @@ -32,7 +32,7 @@ class _AboutDialog extends StatelessWidget { final repoLinkText = "source code"; final privacyLinkText = "privacy policy"; final mainText = - "Feel free to check out the source code of this app if you're interested. Mandatory link to privacy policy belongs here too.\n\nšŸµ Please DO NOT feed the monkeys! šŸµ"; + "Feel free to check out the source code of this app if you're interested. Mandatory link to privacy policy belongs here too."; final repoLinkIndex = mainText.indexOf(repoLinkText); final repoLinkIndexEnd = repoLinkIndex + repoLinkText.length; final privacyLinkIndex = mainText.indexOf(privacyLinkText); diff --git a/lib/page/flights.dart b/lib/page/flights.dart index fc38583..04e0395 100644 --- a/lib/page/flights.dart +++ b/lib/page/flights.dart @@ -11,6 +11,9 @@ import 'package:gibraltar_flights/util/scrappy.dart'; import 'package:intl/intl.dart' hide TextDirection; import 'package:pull_to_refresh/pull_to_refresh.dart'; +// const String testDevice = '77773931FCB634D6B0C83152B6D99482'; +const String testDevice = null; + class FlightsPage extends StatefulWidget { const FlightsPage({Key key, @required this.title}) : super(key: key); final title; @@ -22,14 +25,18 @@ class FlightsPage extends StatefulWidget { class _FlightsPageState extends State { Flights flights; RefreshController _refreshController = - RefreshController(initialRefresh: true); + RefreshController(initialRefresh: true); double _refreshButtonOpacity = 1; BannerAd _bannerAd; + static const MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo( + testDevices: testDevice != null ? [testDevice] : null); + static BannerAd createBannerAd() { return BannerAd( adUnitId: "ca-app-pub-3670766355752604/4950986030", size: AdSize.banner, + targetingInfo: targetingInfo, listener: (MobileAdEvent event) { print("BannerAd event $event"); }, @@ -40,7 +47,9 @@ class _FlightsPageState extends State { void initState() { super.initState(); flights = Flights(items: []); - FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId); + FirebaseAdMob.instance + .initialize(appId: "ca-app-pub-3670766355752604~8697825200"); + _bannerAd = createBannerAd() ..load() ..show(); @@ -63,19 +72,17 @@ class _FlightsPageState extends State { Icons.info_outline, color: Colors.white, ), - onPressed: () => - about.showAboutDialog(context: context) - ) + onPressed: () => about.showAboutDialog(context: context)) ], ), body: Center( child: SmartRefresher( - enablePullDown: true, - enablePullUp: false, - controller: _refreshController, - onRefresh: () => _onRefresh(context), - child: _listView(), - ))); + enablePullDown: true, + enablePullUp: false, + controller: _refreshController, + onRefresh: () => _onRefresh(context), + child: _listView(), + ))); } Widget _listView() { @@ -104,9 +111,7 @@ class _FlightsPageState extends State { child: Text("refresh".toUpperCase()), style: TextButton.styleFrom( primary: Colors.white, - backgroundColor: Theme - .of(context) - .accentColor, + backgroundColor: Theme.of(context).accentColor, onSurface: Colors.grey, )), ), @@ -200,9 +205,7 @@ class _FlightsPageState extends State { void _showError(BuildContext context, String message) { ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text(message), backgroundColor: Theme - .of(context) - .errorColor)); + content: Text(message), backgroundColor: Theme.of(context).errorColor)); } } @@ -263,20 +266,13 @@ class HeadingItem implements ListItem { return Container( child: Text( heading, - style: Theme - .of(context) - .textTheme - .headline5, + style: Theme.of(context).textTheme.headline5, ), alignment: Alignment.center, padding: EdgeInsets.all(4), decoration: BoxDecoration( - color: Theme - .of(context) - .primaryColorLight, - border: Border.all(color: Theme - .of(context) - .accentColor), + color: Theme.of(context).primaryColorLight, + border: Border.all(color: Theme.of(context).accentColor), borderRadius: BorderRadius.circular(8)), ); } @@ -315,9 +311,7 @@ class FlightItem implements ListItem { textDirection: TextDirection.ltr, child: SvgPicture.asset( type == "arrival" ? IconNames.arrivals : IconNames.departures, - color: Theme - .of(context) - .accentColor, + color: Theme.of(context).accentColor, matchTextDirection: true, )), ); @@ -331,18 +325,14 @@ class FlightItem implements ListItem { mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Text(time, style: Theme - .of(context) - .textTheme - .headline5), + Text(time, style: Theme.of(context).textTheme.headline5), Container( padding: EdgeInsets.all(4), decoration: BoxDecoration( color: _getStatusColor(), borderRadius: BorderRadius.circular(4)), child: Text(status, - style: Theme - .of(context) + style: Theme.of(context) .textTheme .caption .apply(color: Colors.white)), diff --git a/pubspec.yaml b/pubspec.yaml index 24348b4..4cfeb93 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,7 +44,7 @@ dev_dependencies: sdk: flutter integration_test: sdk: flutter - flutter_launcher_icons: "^0.8.1" + flutter_launcher_icons: ^0.8.1 flutter_icons: ios: true