Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings checkbox update #55

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down
1 change: 0 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package="com.example.envirocar_app_main">

<!-- Added for flutter blue -->

<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
Expand Down
12 changes: 5 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
delete rootProject.buildDir
}
}
18 changes: 16 additions & 2 deletions lib/screens/loginScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class _LoginScreenState extends State<LoginScreen> {
String _username;
String _password;
bool _wrongCredentials = false;
bool _isObscure = true;

Future<void> _showDialogbox(String message) async {
_logger.i('Showing dialog');
Expand All @@ -53,7 +54,7 @@ class _LoginScreenState extends State<LoginScreen> {
EdgeInsets.fromLTRB(deviceWidth * 0.05, 0, deviceWidth * 0.05, 0),
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overscroll) {
overscroll.disallowGlow();
overscroll.disallowIndicator();
return;
},
child: Form(
Expand Down Expand Up @@ -95,9 +96,22 @@ class _LoginScreenState extends State<LoginScreen> {

// Password
TextFormField(
obscureText: true,
obscureText: _isObscure,
decoration: inputDecoration.copyWith(
labelText: 'Password',
suffixIcon: IconButton(
icon: Icon(
_isObscure
? Icons.visibility_off_outlined
: Icons.visibility_outlined,
color: Colors.white,
),
onPressed: () {
setState(() {
_isObscure = !_isObscure;
});
},
),
),
// validator: (value) {
// return validator.validatePassword(value);
Expand Down
33 changes: 30 additions & 3 deletions lib/screens/registerScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
bool _acceptedTerms = false;
bool _acceptedPrivacy = false;
bool _showError = false;
bool _isObscure = true;

Future<void> _showDialogbox(String message) async {
_logger.i('Showing dialog');
Expand Down Expand Up @@ -58,7 +59,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
EdgeInsets.fromLTRB(deviceWidth * 0.05, 0, deviceWidth * 0.05, 0),
child: NotificationListener<OverscrollIndicatorNotification>(
onNotification: (OverscrollIndicatorNotification overscroll) {
overscroll.disallowGlow();
overscroll.disallowIndicator();
return;
},
child: Form(
Expand Down Expand Up @@ -113,9 +114,22 @@ class _RegisterScreenState extends State<RegisterScreen> {

// Password
TextFormField(
obscureText: true,
obscureText: _isObscure,
decoration: inputDecoration.copyWith(
labelText: 'Password',
suffixIcon: IconButton(
icon: Icon(
_isObscure
? Icons.visibility_off_outlined
: Icons.visibility_outlined,
color: Colors.white,
),
onPressed: () {
setState(() {
_isObscure = !_isObscure;
});
},
),
),
// validator: (value) {
// return validator.validatePassword(value);
Expand All @@ -131,9 +145,22 @@ class _RegisterScreenState extends State<RegisterScreen> {

// Confirm Password
TextFormField(
obscureText: true,
obscureText: _isObscure,
decoration: inputDecoration.copyWith(
labelText: 'Password',
suffixIcon: IconButton(
icon: Icon(
_isObscure
? Icons.visibility_off_outlined
: Icons.visibility_outlined,
color: Colors.white,
),
onPressed: () {
setState(() {
_isObscure = !_isObscure;
});
},
),
),
validator: (value) {
if (_confirmPassword.compareTo(_password) != 0) {
Expand Down
26 changes: 16 additions & 10 deletions lib/values/settingsValues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,27 @@ List<SettingsTileModel> generalSettings = [
title: 'Automatic Upload',
subtitle:
'Enables the automatic upload of recorded tracks after the recording has been finished. It is only tried to upload the track directly afterwards. If the upload fails (e.g. no internet connection), the track has to be uploaded manually.',
isChecked: false,
isChecked: (preferences.get('Automatic Upload') ?? 'false') == 'true',
),
SettingsTileModel(
title: 'Keep the screen on',
subtitle:
'When checked, this setting keeps the screen on while the application is running.',
isChecked: false,
isChecked: (preferences.get('Keep the screen on') ?? 'false') == 'true',
),
SettingsTileModel(
title: 'Verbal Announcements',
subtitle:
'Enabling the verbal announcements of specific events, e.g. OBD-II connection established/lost, track finished.',
isChecked: false,
isChecked: (preferences.get('Verbal Announcements') ?? 'false') == 'true',
),
SettingsTileModel(
title: 'Anonymize Start and Destination',
subtitle:
'Only upload measurements which are taken 250 meter (820 feet) and one minute after start and before end of each track.',
isChecked: false,
isChecked:
(preferences.get('Anonymize Start and Destination') ?? 'false') ==
'true',
),
];

Expand All @@ -37,19 +39,20 @@ List<SettingsTileModel> obdModeSettings = [
title: 'Auto Connect',
subtitle:
'In case of OBD track, it automatically connects to the OBD-II adapter and starts the recording of a track. This feature periodically checks whether the selected OBD-II adapter is within range. In case of GPS track, it uses activity recognition features and automatically starts the GPS based track once it detects that the user is IN_VEHICLE. Therefore, this setting requires additional battery power.',
isChecked: false,
isChecked: (preferences.get('Auto Connect') ?? 'false') == 'true',
),
SettingsTileModel(
title: 'Discovery Interval',
subtitle:
'The search interval at which the final String device searches for the selected OBD-II final String device. Note: the higher the value, the more the battery gets drained.',
isChecked: false,
isChecked: (preferences.get('Discovery Interval') ?? 'false') == 'true',
),
SettingsTileModel(
title: 'Diesel Consumption Estimation',
subtitle:
'Enables the estimation of consumption values for diesel. NOTE: This feature is just a beta feature.',
isChecked: false,
isChecked:
(preferences.get('Diesel Consumption Estimation') ?? 'false') == 'true',
),
];

Expand All @@ -59,21 +62,24 @@ List<SettingsTileModel> gpsModeSettings = [
title: 'Enable GPS based track recording',
subtitle:
"Activates an additional recording mode that enables the recording of plain GPS based tracks that does not require an OBD-II adapter.\n\nNOTE: This feature is just a beta feature.",
isChecked: false,
isChecked:
(preferences.get('Enable GPS based track recording') ?? 'false') ==
'true',
),
SettingsTileModel(
title: 'Automatic Recording (GPS)',
subtitle:
'Activates automatic recording of GPS-based trips based on activity detection mechanisms.\n\nNote: This Android function does not work reliably on some smartphone models.',
isChecked: false,
isChecked:
(preferences.get('Automatic Recording (GPS)') ?? 'false') == 'true',
),
];

List<SettingsTileModel> debuggingSettings = [
SettingsTileModel(
title: 'Enable Debug Logging',
subtitle: 'Increase the log level (used in issue/problem report)',
isChecked: false,
isChecked: (preferences.get('Enable Debug Logging') ?? 'false') == 'true',
),
];

Expand Down
5 changes: 5 additions & 0 deletions lib/widgets/settingsScreenWidgets/settingsListWidget.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';

import '../../globals.dart';
import '../../models/settingsTileModel.dart';

// List of checkbox settings tile on settings screen
Expand All @@ -22,6 +23,10 @@ class _SettingsListWidgetState extends State<SettingsListWidget> {
final bool currentVal = widget.settings[index].isChecked;
widget.settings[index].isChecked = !currentVal;
});
preferences.setString(
widget.settings[index].title,
'${widget.settings[index].isChecked}',
);
}

@override
Expand Down
Loading