Skip to content

Commit

Permalink
extract api key's, build signing
Browse files Browse the repository at this point in the history
  • Loading branch information
gmonso committed Jul 3, 2024
1 parent 9829354 commit 022a89e
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .env

This file was deleted.

4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NASA_API_KEY=
PRECISELY_API_KEY=
PRECISELY_API_SECRET=
GOOGLE_MAPS_APY_KEY=
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

android/secrets.properties

.env

keystore/keys.txt
29 changes: 27 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ plugins {
id "dev.flutter.flutter-gradle-plugin"
}

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}


def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -12,6 +19,14 @@ if (localPropertiesFile.exists()) {
}
}

def secretsProperties = new Properties()
def secretsPropertiesFile = rootProject.file('secrets.properties')
if (secretsPropertiesFile.exists()) {
secretsPropertiesFile.withReader('UTF-8') { reader ->
secretsProperties.load(reader)
}
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand Down Expand Up @@ -41,21 +56,31 @@ android {
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "lg.wildfiretracker"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

manifestPlaceholders += [MAPS_API_KEY: secretsProperties.getProperty('MAPS_API_KEY')]
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
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
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:value="2" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCgxeVrZewwcexEMz-MFGLsX74KMKU2YFc"/>
android:value="${MAPS_API_KEY}"/>

<!-- Add these lines for location permissions -->

Expand Down
4 changes: 4 additions & 0 deletions android/key.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
storePassword=<password-from-previous-step>
keyPassword=<password-from-previous-step>
keyAlias=upload
storeFile=<keystore-file-location>
1 change: 1 addition & 0 deletions android/local.defaults.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MAPS_API_KEY=DEFAULT_API_KEY
1 change: 1 addition & 0 deletions android/secrets.properties.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MAPS_API_KEY=
2 changes: 0 additions & 2 deletions keystore/keys.txt

This file was deleted.

3 changes: 2 additions & 1 deletion lib/screens/preciesly_usa_forest_fire_risk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:convert';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:geolocator/geolocator.dart';
import 'package:get_it/get_it.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
Expand Down Expand Up @@ -263,7 +264,7 @@ class _AddressInputScreenState extends State<PreciselyUsaForestFireRisk> {
String _sessionToken = '1234567890';
List<dynamic> _placeList = [];

final String googleApiKey = 'AIzaSyBXWiedpaiODFgXjsm1VMguHJo5Bf3jqtI';
final String googleApiKey = dotenv.get('GOOGLE_MAPS_APY_KEY');

GoogleMapController? mapController;
LatLng? pickedLocation = const LatLng(37.7749, -122.4194);
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_dotenv:
dependency: "direct main"
description:
name: flutter_dotenv
sha256: "9357883bdd153ab78cbf9ffa07656e336b8bbb2b5a3ca596b0b27e119f7c7d77"
url: "https://pub.dev"
source: hosted
version: "5.1.0"
flutter_lints:
dependency: "direct dev"
description:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dependencies:
geolocator: ^12.0.0
uuid: ^4.4.0
google_places_flutter: ^2.0.8
flutter_dotenv: ^5.1.0


dev_dependencies:
Expand All @@ -79,6 +80,7 @@ flutter:

# To add assets to your application, add an assets section, like this:
assets:
- .env
- assets/images/
- assets/gencat/
# - images/a_dot_burr.jpeg
Expand Down

0 comments on commit 022a89e

Please sign in to comment.