Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
Merge pull request #408 from dreautall/develop
  • Loading branch information
dreautall authored Jun 22, 2024
2 parents 1c30b39 + 0486cb1 commit 98eefc3
Show file tree
Hide file tree
Showing 20 changed files with 21,420 additions and 178 deletions.
22 changes: 19 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.dreautall.waterflyiii">
<application android:label="Waterfly III" android:name="${applicationName}" android:icon="@mipmap/ic_launcher" android:enableOnBackInvokedCallback="false" android:usesCleartextTraffic="true">
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<application
android:label="Waterfly III"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:enableOnBackInvokedCallback="false"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
>
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
>
<!-- 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 All @@ -27,7 +42,8 @@
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data android:name="flutterEmbedding" android:value="2" />
<!-- Try Impeller - see https://docs.flutter.dev/perf/impeller#android -->
<meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="true" />
<!-- Disabled due to https://github.com/dreautall/waterfly-iii/issues/406 -->
<meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="false" />
</application>

<!-- Permissions -->
Expand Down
9 changes: 9 additions & 0 deletions android/app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config>
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</base-config>
</network-security-config>
4 changes: 4 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/322.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- BREAKING CHANGE: The app now uses the Android Certificate Store, and does not have the option to provide a custom server certificate anymore. If you are using a self-signed certificate, please add it to the Android Store to keep using the app. (#77)
- Thank you @j1mbl3s for testing this!
- Net Worth chart removed for the time being due to API issues in latest Firefly version.
- Bugfixes (#379, #394, #405, #406)
4 changes: 2 additions & 2 deletions fastlane/metadata/android/version.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
versionName=1.0.4
versionCode=312
versionName=1.0.5
versionCode=322
42 changes: 9 additions & 33 deletions lib/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:cronet_http/cronet_http.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:http/http.dart' as http;
import 'package:http/io_client.dart';
import 'package:logging/logging.dart';

import 'package:chopper/chopper.dart'
Expand Down Expand Up @@ -53,25 +53,6 @@ class APITZReplyData {
}
}

class SSLHttpOverride extends HttpOverrides {
SSLHttpOverride(this.validCert);
final String validCert;

@override
HttpClient createHttpClient(SecurityContext? context) {
// Needed for issue #75
//context ??= SecurityContext.defaultContext;
//context.useCertificateChainBytes(chainBytes);
//context.usePrivateKeyBytes(keyBytes);
return super.createHttpClient(context)
..badCertificateCallback = (X509Certificate cert, _, __) {
log.fine("Using SSLHttpOverride");
return cert.pem.replaceAll("\r", "").trim() ==
validCert.replaceAll("\r", "").trim();
};
}
}

// :TODO: translate strings. cause returns just an identifier for the translation.
class AuthError implements Exception {
const AuthError(this.cause);
Expand Down Expand Up @@ -113,7 +94,10 @@ class AuthErrorNoInstance extends AuthError {
final String host;
}

http.Client get httpClient => IOClient(HttpClient());
http.Client get httpClient => CronetClient.fromCronetEngine(
CronetEngine.build(),
closeEngine: false,
);

class APIRequestInterceptor implements Interceptor {
APIRequestInterceptor(this.headerFunc);
Expand Down Expand Up @@ -195,7 +179,7 @@ class AuthUser {
final http.Request request = http.Request(HttpMethod.Get, aboutUri);
request.headers[HttpHeaders.authorizationHeader] = "Bearer $apiKey";
request.followRedirects = false;
final http.StreamedResponse response = await request.send();
final http.StreamedResponse response = await client.send(request);

if (response.isRedirect) {
throw const AuthErrorApiKey();
Expand Down Expand Up @@ -270,17 +254,16 @@ class FireflyService with ChangeNotifier {
_storageSignInException = null;
String? apiHost = await storage.read(key: 'api_host');
String? apiKey = await storage.read(key: 'api_key');
String? cert = await storage.read(key: 'api_cert');

log.config(
"storage: $apiHost, apiKey ${apiKey?.isEmpty ?? true ? "unset" : "set"}, cert ${cert?.isEmpty ?? true ? "unset" : "set"}");
"storage: $apiHost, apiKey ${apiKey?.isEmpty ?? true ? "unset" : "set"}");

if (apiHost == null || apiKey == null) {
return false;
}

try {
return await signIn(apiHost, apiKey, cert);
return await signIn(apiHost, apiKey);
} catch (e) {
_storageSignInException = e;
log.finest(() => "notify FireflyService->signInFromStorage");
Expand All @@ -302,17 +285,11 @@ class FireflyService with ChangeNotifier {
notifyListeners();
}

Future<bool> signIn(String host, String apiKey, [String? cert]) async {
Future<bool> signIn(String host, String apiKey) async {
log.config("FireflyService->signIn($host)");
host = host.strip().rightStrip('/');
apiKey = apiKey.strip();

if (cert != null && cert.isNotEmpty) {
HttpOverrides.global = SSLHttpOverride(cert);
} else {
HttpOverrides.global = null;
}

_lastTriedHost = host;
_currentUser = await AuthUser.create(host, apiKey);
if (_currentUser == null || !hasApi) return false;
Expand Down Expand Up @@ -357,7 +334,6 @@ class FireflyService with ChangeNotifier {

storage.write(key: 'api_host', value: host);
storage.write(key: 'api_key', value: apiKey);
storage.write(key: 'api_cert', value: cert);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9218,6 +9218,7 @@ class RuleTrigger {
this.updatedAt,
required this.type,
required this.$value,
this.prohibited,
this.order,
this.active,
this.stopProcessing,
Expand All @@ -9244,6 +9245,8 @@ class RuleTrigger {
final enums.RuleTriggerKeyword type;
@JsonKey(name: 'value', includeIfNull: false)
final String $value;
@JsonKey(name: 'prohibited', includeIfNull: false, defaultValue: false)
final bool? prohibited;
@JsonKey(name: 'order', includeIfNull: false)
final int? order;
@JsonKey(name: 'active', includeIfNull: false, defaultValue: true)
Expand All @@ -9263,6 +9266,7 @@ extension $RuleTriggerExtension on RuleTrigger {
DateTime? updatedAt,
enums.RuleTriggerKeyword? type,
String? $value,
bool? prohibited,
int? order,
bool? active,
bool? stopProcessing}) {
Expand All @@ -9272,6 +9276,7 @@ extension $RuleTriggerExtension on RuleTrigger {
updatedAt: updatedAt ?? this.updatedAt,
type: type ?? this.type,
$value: $value ?? this.$value,
prohibited: prohibited ?? this.prohibited,
order: order ?? this.order,
active: active ?? this.active,
stopProcessing: stopProcessing ?? this.stopProcessing);
Expand All @@ -9283,6 +9288,7 @@ extension $RuleTriggerExtension on RuleTrigger {
Wrapped<DateTime?>? updatedAt,
Wrapped<enums.RuleTriggerKeyword>? type,
Wrapped<String>? $value,
Wrapped<bool?>? prohibited,
Wrapped<int?>? order,
Wrapped<bool?>? active,
Wrapped<bool?>? stopProcessing}) {
Expand All @@ -9292,6 +9298,7 @@ extension $RuleTriggerExtension on RuleTrigger {
updatedAt: (updatedAt != null ? updatedAt.value : this.updatedAt),
type: (type != null ? type.value : this.type),
$value: ($value != null ? $value.value : this.$value),
prohibited: (prohibited != null ? prohibited.value : this.prohibited),
order: (order != null ? order.value : this.order),
active: (active != null ? active.value : this.active),
stopProcessing: (stopProcessing != null
Expand All @@ -9307,6 +9314,7 @@ class RuleTriggerStore {
required this.$value,
this.order,
this.active,
this.prohibited,
this.stopProcessing,
});

Expand All @@ -9329,6 +9337,8 @@ class RuleTriggerStore {
final int? order;
@JsonKey(name: 'active', includeIfNull: false, defaultValue: true)
final bool? active;
@JsonKey(name: 'prohibited', includeIfNull: false, defaultValue: false)
final bool? prohibited;
@JsonKey(name: 'stop_processing', includeIfNull: false, defaultValue: false)
final bool? stopProcessing;
static const fromJsonFactory = _$RuleTriggerStoreFromJson;
Expand All @@ -9343,12 +9353,14 @@ extension $RuleTriggerStoreExtension on RuleTriggerStore {
String? $value,
int? order,
bool? active,
bool? prohibited,
bool? stopProcessing}) {
return RuleTriggerStore(
type: type ?? this.type,
$value: $value ?? this.$value,
order: order ?? this.order,
active: active ?? this.active,
prohibited: prohibited ?? this.prohibited,
stopProcessing: stopProcessing ?? this.stopProcessing);
}

Expand All @@ -9357,12 +9369,14 @@ extension $RuleTriggerStoreExtension on RuleTriggerStore {
Wrapped<String>? $value,
Wrapped<int?>? order,
Wrapped<bool?>? active,
Wrapped<bool?>? prohibited,
Wrapped<bool?>? stopProcessing}) {
return RuleTriggerStore(
type: (type != null ? type.value : this.type),
$value: ($value != null ? $value.value : this.$value),
order: (order != null ? order.value : this.order),
active: (active != null ? active.value : this.active),
prohibited: (prohibited != null ? prohibited.value : this.prohibited),
stopProcessing: (stopProcessing != null
? stopProcessing.value
: this.stopProcessing));
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -961,14 +961,6 @@
"@settingsVersionChecking": {
"description": "Shown while checking for app version"
},
"splashCustomSSLCert": "Eigenes SSL Zertifikat",
"@splashCustomSSLCert": {
"description": "Button text & Dialog title for using a custom SSL certificate"
},
"splashFormLabelCustomSSLCertPEM": "Zertifikats-Datei (PEM)",
"@splashFormLabelCustomSSLCertPEM": {
"description": "Label for certificate file text input in PEM format"
},
"transactionAttachments": "Anhänge",
"@transactionAttachments": {
"description": "Button Label: Attachments"
Expand Down
8 changes: 0 additions & 8 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -961,14 +961,6 @@
"@settingsVersionChecking": {
"description": "Shown while checking for app version"
},
"splashCustomSSLCert": "Custom SSL certificate",
"@splashCustomSSLCert": {
"description": "Button text & Dialog title for using a custom SSL certificate"
},
"splashFormLabelCustomSSLCertPEM": "Certificate File (PEM)",
"@splashFormLabelCustomSSLCertPEM": {
"description": "Label for certificate file text input in PEM format"
},
"transactionAttachments": "Attachments",
"@transactionAttachments": {
"description": "Button Label: Attachments"
Expand Down
8 changes: 0 additions & 8 deletions lib/l10n/app_sl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -961,14 +961,6 @@
"@settingsVersionChecking": {
"description": "Shown while checking for app version"
},
"splashCustomSSLCert": "SSL potrdilo po meri",
"@splashCustomSSLCert": {
"description": "Button text & Dialog title for using a custom SSL certificate"
},
"splashFormLabelCustomSSLCertPEM": "Datoteka potrdila (PEM)",
"@splashFormLabelCustomSSLCertPEM": {
"description": "Label for certificate file text input in PEM format"
},
"transactionAttachments": "Priponke",
"@transactionAttachments": {
"description": "Button Label: Attachments"
Expand Down
12 changes: 4 additions & 8 deletions lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,10 @@
}
}
},
"homeTransactionsSettingsShowTags": "在交易列表中显示标签",
"@homeTransactionsSettingsShowTags": {
"description": "Setting label to show tags in transactioon list."
},
"liabilityDirectionCredit": "我欠了这笔债",
"@liabilityDirectionCredit": {
"description": "Firefly Translation String: liability_direction_credit"
Expand Down Expand Up @@ -957,14 +961,6 @@
"@settingsVersionChecking": {
"description": "Shown while checking for app version"
},
"splashCustomSSLCert": "自定义 SSL 证书",
"@splashCustomSSLCert": {
"description": "Button text & Dialog title for using a custom SSL certificate"
},
"splashFormLabelCustomSSLCertPEM": "证书文件(PEM)",
"@splashFormLabelCustomSSLCertPEM": {
"description": "Label for certificate file text input in PEM format"
},
"transactionAttachments": "附件",
"@transactionAttachments": {
"description": "Button Label: Attachments"
Expand Down
9 changes: 6 additions & 3 deletions lib/pages/home/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class _HomeMainState extends State<HomeMain>
lastDaysIncome.clear();

// With a new API the number of API calls is reduced from 14 to 2
if (context.read<FireflyService>().apiVersion! >= Version(2, 0, 7)) {
// :TODO: currently there is a bug in the APIv2 call, disabled this for now..
if (context.read<FireflyService>().apiVersion! >= Version(99, 0, 7)) {
final FireflyIiiV2 apiV2 = context.read<FireflyService>().apiV2;

final List<int> accounts = <int>[];
Expand Down Expand Up @@ -775,7 +776,8 @@ class _HomeMainState extends State<HomeMain>
),
),
const SizedBox(height: 8),
if (context.read<FireflyService>().apiVersion! >= Version(2, 0, 7))
// :TODO: currently there is a bug in the APIv2 call, disabled this for now..
if (context.read<FireflyService>().apiVersion! >= Version(99, 0, 7))
ChartCard(
title: S.of(context).homeMainChartNetWorthTitle,
future: _fetchBalance(),
Expand Down Expand Up @@ -923,7 +925,8 @@ class _HomeMainState extends State<HomeMain>
liabilities: lastMonthsLiabilities,
),
),
if (context.read<FireflyService>().apiVersion! >= Version(2, 0, 7))
// :TODO: currently there is a bug in the APIv2 call, disabled this for now..
if (context.read<FireflyService>().apiVersion! >= Version(99, 0, 7))
const SizedBox(height: 8),
AnimatedHeight(
child: FutureBuilder<List<BudgetLimitRead>>(
Expand Down
Loading

0 comments on commit 98eefc3

Please sign in to comment.