Skip to content

Commit

Permalink
Merge pull request #95 from nucleus-ffm/bugfixes
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
nucleus-ffm authored Oct 26, 2023
2 parents 8977876 + 1e38d67 commit f7f947f
Show file tree
Hide file tree
Showing 51 changed files with 936 additions and 774 deletions.
6 changes: 5 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if (keystorePropertiesFile.exists()) {

android {
namespace "de.nucleus.foss_warn"
compileSdkVersion 33
compileSdk 33

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down 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 ----------
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> -->
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<!-- For apps with targetSDK=31 (Android 12) -->
<!-- For apps with targetSDK >= 31 (Android 12+) -->
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<queries>
<!-- If your app opens https URLs -->
Expand Down
20 changes: 10 additions & 10 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,21 @@ 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"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
rootProject.layout.buildDirectory = "../build"
subprojects {
project.layout.buildDirectory = "${rootProject.layout.buildDirectory.asFile.get()}/${project.name}"
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
70 changes: 35 additions & 35 deletions lib/class/class_NotificationService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:foss_warn/services/translateAndColorizeWarning.dart';
import 'package:rxdart/rxdart.dart';
import 'package:flutter/material.dart';

///
/// ID 2: Status notification
/// ID 3: No Places selected warning
/// ID 4: legacy warning
class NotificationService {
static final _flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
Expand Down Expand Up @@ -126,39 +129,36 @@ class NotificationService {
iOS: initializationSettingsIOS,
macOS: null);

// Request notifications permission (Android 13+)
await _flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.requestPermission();

// init the different notifications channels
try {
await _flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(AndroidNotificationChannel(
"foss_warn_notifications_minor", "Warnstufe: Gering"));

await _flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(AndroidNotificationChannel(
"foss_warn_notifications_moderate", "Warnstufe: Mittel"));

await _flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(AndroidNotificationChannel(
"foss_warn_notifications_severe", "Warnstufe: Schwer"));

await _flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(AndroidNotificationChannel(
"foss_warn_notifications_extreme", "Warnstufe: Extrem"));
} catch (e) {
print("Error while creating notification channels: " + e.toString());
final androidNotificationPlugin =
_flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>();
if (androidNotificationPlugin != null) {
// Request notifications permission (Android 13+)
await androidNotificationPlugin.requestNotificationsPermission();

// Request schedule exact alarm permission (Android 14+)
await androidNotificationPlugin.requestExactAlarmsPermission();

// init the different notifications channels
try {
await androidNotificationPlugin.createNotificationChannel(
AndroidNotificationChannel(
"foss_warn_notifications_minor", "Warnstufe: Gering"));

await androidNotificationPlugin.createNotificationChannel(
AndroidNotificationChannel(
"foss_warn_notifications_moderate", "Warnstufe: Mittel"));

await androidNotificationPlugin.createNotificationChannel(
AndroidNotificationChannel(
"foss_warn_notifications_severe", "Warnstufe: Schwer"));

await androidNotificationPlugin.createNotificationChannel(
AndroidNotificationChannel(
"foss_warn_notifications_extreme", "Warnstufe: Extrem"));
} catch (e) {
print("Error while creating notification channels: " + e.toString());
}
}

// when App is closed
Expand All @@ -184,7 +184,7 @@ class NotificationService {
channelIds.add("foss_warn_notifications_moderate");
channelIds.add("foss_warn_notifications_extreme");
channelIds.add("foss_warn_status");
channelIds.add("foss_warn_other");
channelIds.add("foss_warn_notifications_other");

print("[android notification channels]");
List<AndroidNotificationChannel>? temp =
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);
}
Loading

0 comments on commit f7f947f

Please sign in to comment.