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

Bugfixes #95

Merged
merged 47 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e9a0896
fix typo caused by merging cleanup into main
nucleus-ffm Aug 7, 2023
a829298
Correct version that was confused.
nucleus-ffm Aug 7, 2023
cfdc29c
add proguard rule to fix crash at startup caused by the local notific…
nucleus-ffm Aug 7, 2023
53851f6
increase displayed version to distinguish test-versions
nucleus-ffm Aug 7, 2023
66b53dc
Refactor and upgrade dependencies
MatsG23 Aug 10, 2023
84d0c8d
Upgrade shared_preferences_foundation
MatsG23 Aug 15, 2023
48c5575
Improved detection of urls with bordered text
nucleus-ffm Aug 19, 2023
39492e1
Merge remote-tracking branch 'origin/bugfixes' into bugfixes
nucleus-ffm Aug 19, 2023
d22313b
Update Flutter
MatsG23 Aug 30, 2023
2192f22
Update Flutter (3.13.3)
MatsG23 Sep 9, 2023
29c5c45
Rely on translations being available
MatsG23 Sep 9, 2023
853628a
Revert build.gradle change
MatsG23 Sep 9, 2023
12a5718
Remove comma before brackets in NinaPlace name
MatsG23 Sep 9, 2023
3e424ee
Trigger background task callback on register
MatsG23 Sep 9, 2023
dd28d6a
Use Severity enum in sortWarnings
MatsG23 Sep 9, 2023
65c2db2
Move code out of setState in SortByDialog
MatsG23 Sep 9, 2023
878d734
cleanup
nucleus-ffm Sep 20, 2023
95cf3e2
fix sorting
nucleus-ffm Sep 20, 2023
ece8f3f
merge
nucleus-ffm Sep 20, 2023
becd69e
fix flutter version
nucleus-ffm Sep 20, 2023
fae25fc
fix sorting
nucleus-ffm Sep 20, 2023
fcf75c5
fix not saved changes of read and read status
nucleus-ffm Sep 20, 2023
43021ec
change read to notified again
nucleus-ffm Sep 20, 2023
8ba59d2
change called function when app is resumed to show loading screen
nucleus-ffm Sep 20, 2023
a15622a
add timeouts of 15 seconds for http requests
nucleus-ffm Sep 20, 2023
183c3ea
add legacy handler to reset the settings if old data is stored
nucleus-ffm Sep 30, 2023
8653256
fix legacy issue with from data format
nucleus-ffm Sep 30, 2023
525980c
add null check again
nucleus-ffm Sep 30, 2023
d0e206e
save settings when user taps outside of the keyboard
nucleus-ffm Oct 1, 2023
86175bb
remove old unused code
nucleus-ffm Oct 1, 2023
a79692f
remove old comment
nucleus-ffm Oct 15, 2023
a6b9958
use variable for timeout and reduce timeout to 8 sec
nucleus-ffm Oct 15, 2023
9573462
use regex to extract phone numbers
nucleus-ffm Oct 15, 2023
21e364a
use unittest to test phone number extraction
nucleus-ffm Oct 15, 2023
59fc92c
delete example test
nucleus-ffm Oct 15, 2023
610be06
new cleaner design without radio buttons.
nucleus-ffm Oct 15, 2023
665cf54
Update Flutter & Gradle
MatsG23 Oct 24, 2023
d8f3805
Remove redundant setters and getters
MatsG23 Oct 24, 2023
40f625a
Remove unused imports
MatsG23 Oct 24, 2023
06c8f3f
Improved compatibility with Android 14
MatsG23 Oct 24, 2023
99db413
show notification in legacy handler to get the users attention even i…
nucleus-ffm Oct 24, 2023
bb5af70
add some docu and fix wrong named notification channel
nucleus-ffm Oct 24, 2023
468ce13
Merge branch 'bugfixes' of Github:nucleus-ffm/foss_warn into bugfixes
nucleus-ffm Oct 24, 2023
e3cf555
use simple dialog for font size dialog
nucleus-ffm Oct 24, 2023
dbf66a4
Add more tests and refactor web address extractor
MatsG23 Oct 25, 2023
78fee50
Merge remote-tracking branch 'origin/bugfixes' into bugfixes
MatsG23 Oct 25, 2023
1e38d67
roll back compileSdk and targetSdkVersion to 33
nucleus-ffm Oct 26, 2023
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
4 changes: 4 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ android {
}
minifyEnabled true
shrinkResources true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
##---------------Begin: proguard configuration for Gson ----------
## Gson rules
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature

# For using GSON @Expose annotation
-keepattributes *Annotation*

# Gson specific classes
-dontwarn sun.misc.**
#-keep class com.google.gson.stream.** { *; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * extends com.google.gson.TypeAdapter
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}

# Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher.
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
##---------------End: proguard configuration for Gson ----------
18 changes: 10 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = "1.9.0"
ext.kotlin_version = "1.9.10"
repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:8.1.0"
classpath "com.android.tools.build:gradle:8.1.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -17,21 +17,23 @@ allprojects {
mavenCentral()
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
// to see deprecation warnings
//options.compilerArgs << "-Xlint:deprecation"
tasks.withType(JavaCompile).tap {
configureEach {
// to see deprecation warnings
options.compilerArgs << "-Xlint:deprecation"
}
}
}
}

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

tasks.register("clean", Delete) {
delete rootProject.buildDir
delete rootProject.layout.buildDirectory
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
22 changes: 7 additions & 15 deletions lib/class/abstract_Place.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:foss_warn/services/saveAndLoadSharedPreferences.dart';
import 'package:provider/provider.dart';

import '../main.dart';
Expand All @@ -9,29 +10,17 @@ import 'class_WarnMessage.dart';

abstract class Place {
final String _name;
int _countWarnings = 0;
List<WarnMessage> _warnings = [];
String _eTag = "";

String get eTag => _eTag;

set eTag(String newETag) {
_eTag = newETag;
}
String eTag = "";

Place({required String name, required List<WarnMessage> warnings, required String eTag}) : _warnings = warnings, _name = name {
_countWarnings = this._warnings.length;
_eTag = eTag;
eTag = eTag;
}

String get name => _name;
int get countWarnings=> _countWarnings;
int get countWarnings=> this.warnings.length;
List<WarnMessage> get warnings => _warnings;

// control the number of warnings
void incrementNumberOfWarnings() => _countWarnings++;
void decrementNumberOfWarnings() => _countWarnings--;

// control the list for warnings
void addWarningToList(WarnMessage warnMessage) => _warnings.add(warnMessage);
void removeWarningFromList(WarnMessage warnMessage) => _warnings.remove(warnMessage);
Expand Down Expand Up @@ -66,6 +55,7 @@ abstract class Place {
Future<void> sendNotificationForWarnings() async {
for (WarnMessage myWarnMessage in _warnings) {
print(myWarnMessage.headline);
print("Read: " + myWarnMessage.read.toString() + " notified " + myWarnMessage.notified.toString());
print("should notify? :" +
((!myWarnMessage.read && !myWarnMessage.notified) &&
_checkIfEventShouldBeNotified(myWarnMessage.event))
Expand Down Expand Up @@ -111,6 +101,7 @@ abstract class Place {
}
final updater = Provider.of<Update>(context, listen: false);
updater.updateReadStatusInList();
saveMyPlacesList();
}

/// return [true] or false if the warning should be irgnored or not
Expand All @@ -125,5 +116,6 @@ abstract class Place {
return true;
}
}

Map<String, dynamic> toJson();
}
23 changes: 9 additions & 14 deletions lib/class/class_Area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@ import '../services/createAreaListFromJson.dart';
import 'class_Geocode.dart';

class Area {
String _areaDesc; // Kreisname
List<Geocode> _geocodeList; // Liste mit Ortschaften
Area({required String areaDesc, required List<Geocode> geocodeList})
: _geocodeList = geocodeList,
_areaDesc = areaDesc;
String areaDescription; // Kreisname
List<Geocode> geocodeList; // Liste mit Ortschaften

/// returns the description (kreisname)
String get areaDescription => _areaDesc;
void set areaDescription(String desc) => _areaDesc = desc;
List<Geocode> get geocodeList => _geocodeList;
void set geocodeList(List<Geocode> list) => _geocodeList = list;
Area({required String areaDesc, required List<Geocode> geocodeList})
: this.areaDescription = areaDesc,
this.geocodeList = geocodeList;

Area.fromJson(Map<String, dynamic> json)
: _areaDesc = json['areaDesc'],
_geocodeList = geocodeListFromJson(json['geocodeList']);
: areaDescription = json['areaDesc'],
geocodeList = geocodeListFromJson(json['geocodeList']);

Map<String, dynamic> toJson() => {
'areaDesc': _areaDesc,
'geocodeList': _geocodeList,
'areaDesc': areaDescription,
'geocodeList': geocodeList,
};
}
2 changes: 1 addition & 1 deletion lib/class/class_NinaPlace.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class NinaPlace extends Place {

/// returns the name of the place with the state
@override
String get name => "${super.name}, (${_geocode.stateName})";
String get name => "${super.name} (${_geocode.stateName})";

String get nameWithoutState => super.name;

Expand Down
2 changes: 1 addition & 1 deletion lib/class/class_NotificationService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class NotificationService {
await _flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestPermission();
?.requestNotificationsPermission();

// init the different notifications channels
try {
Expand Down
4 changes: 3 additions & 1 deletion lib/class/class_userPreferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ class UserPreferences {
bool showAllWarnings = false;
bool areWarningsFromCache = false;

String versionNumber = "0.6.0-alpha_2 "; // shown in the about view
String versionNumber = "0.6.0-alpha_3 "; // shown in the about view

bool activateAlertSwiss = false;
bool isFirstStart = true;

Duration networkTimeout = Duration(seconds: 8);
}
26 changes: 13 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:foss_warn/class/class_alarmManager.dart';
import 'package:foss_warn/class/class_userPreferences.dart';
import 'package:foss_warn/services/geocodeHandler.dart';
import 'package:foss_warn/services/legacyHandler.dart';
import 'package:foss_warn/services/listHandler.dart';
import 'package:foss_warn/views/AboutView.dart';
import 'package:provider/provider.dart';
Expand All @@ -19,7 +20,6 @@ import 'class/class_NotificationService.dart';

import 'services/updateProvider.dart';
import 'services/saveAndLoadSharedPreferences.dart';
import 'services/sortWarnings.dart';

import 'widgets/SourceStatusWidget.dart';
import 'widgets/dialogs/SortByDialog.dart';
Expand All @@ -31,16 +31,15 @@ final UserPreferences userPreferences = UserPreferences();

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await legacyHandler();
await NotificationService().init();
// TODO: run Legacy handler, use improved shared preferences types and names

await loadSettings();

if (userPreferences.shouldNotifyGeneral) {
print("Background notification enabled");
// AlarmManager().cancelBackgroundTask(); // just for debug
AlarmManager.callback();
AlarmManager().initialize();
AlarmManager().registerBackgroundTask();
print("Background notification enabled");
} else {
print("Background notification disabled due to user setting");
}
Expand Down Expand Up @@ -103,6 +102,8 @@ class _HomeViewState extends State<HomeView> {
print("call geocode handler");
geocodeHandler();
}
//display information if the app had to be resetted
showMigrationDialog(context);
}

void listenNotifications() {
Expand Down Expand Up @@ -147,7 +148,6 @@ class _HomeViewState extends State<HomeView> {
return SortByDialog();
},
);
sortWarnings();
final updater = Provider.of<Update>(context, listen: false);
updater.updateReadStatusInList();
},
Expand All @@ -159,7 +159,7 @@ class _HomeViewState extends State<HomeView> {
}
final snackBar = SnackBar(
content: Text(
AppLocalizations.of(context)
AppLocalizations.of(context)!
.main_app_bar_tooltip_mark_all_warnings_as_read,
style: TextStyle(color: Colors.black),
),
Expand All @@ -171,7 +171,7 @@ class _HomeViewState extends State<HomeView> {
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
icon: Icon(Icons.mark_chat_read),
tooltip: AppLocalizations.of(context)
tooltip: AppLocalizations.of(context)!
.main_app_bar_tooltip_mark_all_warnings_as_read,
),
PopupMenuButton(
Expand All @@ -194,12 +194,12 @@ class _HomeViewState extends State<HomeView> {
},
itemBuilder: (context) => <PopupMenuEntry>[
PopupMenuItem(
child: Text(AppLocalizations.of(context)
child: Text(AppLocalizations.of(context)!
.main_dot_menu_settings),
value: 0),
PopupMenuItem(
child: Text(
AppLocalizations.of(context).main_dot_menu_about),
child: Text(AppLocalizations.of(context)!
.main_dot_menu_about),
value: 1)
])
],
Expand All @@ -208,11 +208,11 @@ class _HomeViewState extends State<HomeView> {
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.add_alert),
label: AppLocalizations.of(context).main_nav_bar_all_warnings,
label: AppLocalizations.of(context)!.main_nav_bar_all_warnings,
),
BottomNavigationBarItem(
icon: Icon(Icons.place),
label: AppLocalizations.of(context).main_nav_bar_my_places,
label: AppLocalizations.of(context)!.main_nav_bar_my_places,
),
],
currentIndex: _selectedIndex,
Expand Down
4 changes: 3 additions & 1 deletion lib/services/alertSwiss.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:convert';

import 'package:foss_warn/main.dart';

import '../class/class_AlertSwissPlace.dart';
import '../class/abstract_Place.dart';
import '../class/class_WarnMessage.dart';
Expand All @@ -25,7 +27,7 @@ Future callAlertSwissAPI() async {
await loadETags();

// get overview if warnings exits for myplaces
response = await get(Uri.parse(url));
response = await get(Uri.parse(url)).timeout(userPreferences.networkTimeout);

// check if request was sucsessfully
if (response.statusCode == 200) {
Expand Down
11 changes: 5 additions & 6 deletions lib/services/apiHandler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ Future<void> callAPI() async {
else if (place is NinaPlace) {
try {
Response _response;
_response = await getDashboard(place, _baseUrl);
_response =
await getDashboard(place, _baseUrl).timeout(userPreferences.networkTimeout);

// 304 = with etag no change since last request
if (_response.statusCode == 304) {
Expand All @@ -56,7 +57,8 @@ Future<void> callAPI() async {
_data = jsonDecode(utf8.decode(_response.bodyBytes));
_tempWarnMessageList.clear();
// parse the _data into List of Warnings
_tempWarnMessageList = await parseNinaJsonData(_data, _baseUrl, place);
_tempWarnMessageList = await parseNinaJsonData(_data, _baseUrl, place)
.timeout(userPreferences.networkTimeout);
// remove old warning
removeOldWarningFromList(place, _tempWarnMessageList);
userPreferences.areWarningsFromCache = false;
Expand Down Expand Up @@ -145,8 +147,7 @@ Future<Response> getDashboard(NinaPlace place, String baseUrl) async {
// get overview if warnings exits for myplaces
print("Etag for: ${place.name} is ${place.eTag}");

_response =
await get(_urlDashboard, headers: {'If-None-Match': place.eTag});
_response = await get(_urlDashboard, headers: {'If-None-Match': place.eTag});

place.eTag = _response.headers["etag"]!;
print("new etag for: ${place.name} is: ${_response.headers["etag"]}");
Expand Down Expand Up @@ -177,7 +178,6 @@ Future<List<WarnMessage>> parseNinaJsonData(
" " +
temp.notified.toString());
place.addWarningToList(temp);
place.incrementNumberOfWarnings();
}

// } //@todo: fix displaying warnings twice
Expand Down Expand Up @@ -205,6 +205,5 @@ void removeOldWarningFromList(
}
for (WarnMessage message in warnMessagesToRemove) {
place.removeWarningFromList(message);
place.decrementNumberOfWarnings();
}
}
Loading
Loading