Skip to content

Commit

Permalink
Used forms and added a makefile. See CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
theRookieCoder committed May 23, 2021
1 parent 5be47e2 commit c05b88a
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 95 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ lib/generated_plugin_registrant.dart
# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json
/ios/build/
ios/build/
.firebase/

# build related

*.apk
*.ipa
Payload
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [1.3.2]

- Added makefile with building related functionality
- Removed landscape orientations
- Upgraded to Flutter 2.2 and Dart 2.13
- Updated Gradle Java path in `gradle.properties`
- Raised `minSdkVersion` in `build.gradle`
- Updated permissions in `AndroidManifest.xml`
- Refactored some code
- Made the open log file force webview
- Used a `Form` for the `TextField` and added validators
- Removed `maxLength` in `TextField`s
- Updated FAB to work with validators

## [1.3.1]

- Fixed keyboard immediately closing
Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {

defaultConfig {
applicationId "com.therookiecoder.bp_logger"
minSdkVersion 16
minSdkVersion 19
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
6 changes: 3 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="BP Logger"
Expand All @@ -17,7 +16,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:screenOrientation="portrait">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.java.home = /Users/ilesh/Library/Java/JavaVirtualMachines/openjdk-15.0.2/Contents/Home/
org.gradle.java.home = /Users/ilesh/Library/Java/JavaVirtualMachines/adopt-openjdk-15.0.2/Contents/Home/
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
3 changes: 1 addition & 2 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
Expand Down
Binary file not shown.
Binary file modified ios/build/XCBuildData/build.db
Binary file not shown.
183 changes: 108 additions & 75 deletions lib/HomePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ class HomePage extends StatefulWidget {
}

class _HomePageState extends State<HomePage> {
static DateTime date = new DateTime.now();
var textFieldController1 = TextEditingController(); // Diastolic
var textFieldController2 = TextEditingController(); // Systolic
DateTime date = new DateTime.now();
TextEditingController diastolicTEC = TextEditingController(); // Diastolic
TextEditingController systolicTEC = TextEditingController(); // Systolic
late DriveHelper driveHelper; // "Backend" interface
final formKey = GlobalKey<FormState>();

// Runs when the program starts
@override
Expand Down Expand Up @@ -159,11 +160,12 @@ class _HomePageState extends State<HomePage> {
color: Colors.blue,
),
recognizer: TapGestureRecognizer()
..onTap = () async {
launch(
..onTap = () async => launch(
"https://www.github.com/theRookieCoder/bp_logger",
);
},
forceWebView: true,
enableJavaScript: true,
statusBarBrightness:
Theme.of(context).brightness),
),
TextSpan(
text: " under the AGPL 3.0 License",
Expand All @@ -184,84 +186,115 @@ class _HomePageState extends State<HomePage> {
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// Invisible container to center the text
Container(width: 50),
// For displaying the date
Padding(
padding: const EdgeInsets.all(5.0),
child: Text(
DateFormat("d/M/y").format(date),
style: Theme.of(context).textTheme.headline3,
child: Form(
key: formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// Invisible container to center the text
Container(width: 50),
// For displaying the date
Padding(
padding: const EdgeInsets.all(5.0),
child: Text(
DateFormat("d/M/y").format(date),
style: Theme.of(context).textTheme.headline3,
),
),
),
// For changing the date
IconButton(
icon: Icon(Icons.edit),
iconSize: 30.0,
tooltip: "Edit date",
onPressed: () async {
await _selectDate(context);
// For changing the date
IconButton(
icon: Icon(Icons.edit),
iconSize: 30.0,
tooltip: "Edit date",
onPressed: () async {
await _selectDate(context);
},
),
],
),
Padding(
padding: const EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 5.0),
child: TextFormField(
validator: (value) {
late int val;
if (value != "" && value != null) {
val = int.parse(value);
} else {
return "Enter a value";
}
if (val > 120) {
return "Too high";
} else if (val < 60) {
return "Too low";
} else {
return null;
}
},
controller: diastolicTEC,
style: TextStyle(
fontSize: 25.0,
),
decoration: InputDecoration(
border: new OutlineInputBorder(
borderSide: new BorderSide(),
),
labelText: "Diastolic",
),
// Only digits, everything else gets rejected even if typed in
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
keyboardType: TextInputType.number, // Number only keyboard
),
],
),
// For entering the diastolic value
Padding(
padding: const EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 5.0),
child: TextField(
maxLength: 3,
controller: textFieldController1,
style: TextStyle(
fontSize: 25.0,
),
decoration: InputDecoration(
counterText: "",
border: new OutlineInputBorder(borderSide: new BorderSide()),
labelText: "Diastolic",
),
// Only digits, everything else gets rejected even if typed in
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
keyboardType: TextInputType.number, // Number only keyboard
),
),
// For entering the systolic value
Padding(
padding: const EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 5.0),
child: TextField(
maxLength: 3,
controller: textFieldController2,
style: TextStyle(
fontSize: 25.0,
),
decoration: InputDecoration(
counterText: "",
border: new OutlineInputBorder(borderSide: new BorderSide()),
labelText: "Systolic",
Padding(
padding: const EdgeInsets.fromLTRB(20.0, 5.0, 20.0, 5.0),
child: TextFormField(
validator: (value) {
late int val;
if (value != "" && value != null) {
val = int.parse(value);
} else {
return "Enter a value";
}
if (val > 200) {
return "Too high";
} else if (val < 100) {
return "Too low";
} else {
return null;
}
},
controller: systolicTEC,
style: TextStyle(
fontSize: 25.0,
),
decoration: InputDecoration(
border: new OutlineInputBorder(
borderSide: new BorderSide(),
),
labelText: "Systolic",
),
// Only digits everything else is rejected even of typed in
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
keyboardType: TextInputType.number, // Number only keyboard
),
// Only digits everything else is rejected even of typed in
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
keyboardType: TextInputType.number, // Number only keyboard
),
),
],
],
),
),
),
floatingActionButton: FloatingActionButton.extended(
icon: Icon(Icons.storage),
label: Text("ADD TO FILE"),
onPressed: () async {
// Get values from TextFieldControllers
String diastolic = textFieldController1.text;
String systolic = textFieldController2.text;

// Don"t run if values are not filled in
if (diastolic != "" && systolic != "") {
// Don"t run if values are not correct
if (formKey.currentState != null &&
formKey.currentState!.validate()) {
// Get values from TextFieldControllers
String diastolic = diastolicTEC.text;
String systolic = systolicTEC.text;
// Dismiss keyboard once button is pressed
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
Expand All @@ -283,8 +316,8 @@ class _HomePageState extends State<HomePage> {
barrierDismissible: false,
);

textFieldController1.clear();
textFieldController2.clear();
diastolicTEC.clear();
systolicTEC.clear();
}
},
),
Expand Down
24 changes: 24 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.PHONY: all build clean

debug:
flutter run

test:
flutter run --release

clean:
flutter clean
rm -vrf Payload
rm *.apk
rm *.ipa

build:
flutter pub get
flutter build apk
flutter build ios
cd build
mkdir -p Payload
cp -R ~/flutter_projects/bp_logger/build/ios/iphoneos/Runner.app "Payload/BP Logger.app"
zip "bp_logger_v${VERSION}.ipa" Payload
mv ~/flutter_projects/bp_logger/build/app/outputs/flutter-apk/app-release.apk bp_logger_v${VERSION}.apk
gh release create v${VERSION} "bp_logger_v${VERSION}.ipa" "bp_logger_v${VERSION}.apk" -t "BP Logger ${VERSION}" -n "Native builds for sideloading"
Loading

0 comments on commit c05b88a

Please sign in to comment.