Skip to content

Commit

Permalink
Merge pull request #832 from givtnl/develop
Browse files Browse the repository at this point in the history
Production release 4.2.22
  • Loading branch information
TammiLion committed Jun 24, 2024
2 parents ece37e6 + 640e2b3 commit 70e643a
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 23 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
working-directory: 'android'

- uses: actions/setup-java@v4
with:
Expand All @@ -78,10 +80,11 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
flutter-version: ${{ inputs.flutter-version }}

- name: Run Fastlane
uses: maierj/fastlane-action@v2.3.0
uses: maierj/fastlane-action@v3.1.0
with:
lane: android build_and_deploy
subdirectory: android
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ jobs:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
working-directory: 'ios'

- name: Auth codesigning
uses: webfactory/ssh-agent@v0.9.0
Expand All @@ -78,10 +80,11 @@ jobs:
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
flutter-version: ${{ inputs.flutter-version }}

- name: Run Fastlane
uses: maierj/fastlane-action@v2.3.0
uses: maierj/fastlane-action@v3.1.0
with:
lane: ios release
subdirectory: ios
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: givt_app

concurrency:
group: $-$
group: ci-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
push:
branches:
- main
Expand Down
6 changes: 6 additions & 0 deletions lib/core/logging/log_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class LogMessage extends Equatable {
this.appVersion,
this.lang,
this.deviceId,
this.correlationId,
});

String? guid;
Expand All @@ -33,6 +34,7 @@ class LogMessage extends Equatable {
String? appVersion;
String? lang;
String? deviceId;
String? correlationId;

Map<String, dynamic> toJson() => {
'guid': guid,
Expand All @@ -49,6 +51,7 @@ class LogMessage extends Equatable {
'appVersion': appVersion,
'lang': lang,
'deviceId': deviceId,
'correlation-id': correlationId,
};

LogMessage copyWith({
Expand All @@ -66,6 +69,7 @@ class LogMessage extends Equatable {
String? appVersion,
String? lang,
String? deviceId,
String? correlationId,
}) {
return LogMessage(
guid: guid ?? this.guid,
Expand All @@ -82,6 +86,7 @@ class LogMessage extends Equatable {
appVersion: appVersion ?? this.appVersion,
lang: lang ?? this.lang,
deviceId: deviceId ?? this.deviceId,
correlationId: correlationId ?? this.correlationId,
);
}

Expand All @@ -101,5 +106,6 @@ class LogMessage extends Equatable {
appVersion,
lang,
deviceId,
correlationId,
];
}
24 changes: 23 additions & 1 deletion lib/core/logging/logging_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ mixin ILoggingInfo {

Future<void> error(String message);

Future<void> logRequest(String method, String string, String correlationId);

void logExceptionForDebug(Object e, {StackTrace? stacktrace});
}

Expand All @@ -35,7 +37,12 @@ class LoggingInfo implements ILoggingInfo {

static LoggingInfo get instance => _singleton;

Future<void> _log(String message, String methodName, Level level) async {
Future<void> _log(
String message,
String methodName,
Level level, {
String? correlationId,
}) async {
dev.log(message);
final info = await PackageInfo.fromPlatform();
final isDebug = info.packageName.contains('test');
Expand All @@ -50,6 +57,7 @@ class LoggingInfo implements ILoggingInfo {
lang: Platform.localeName,
method: methodName,
appVersion: '${info.version}.${info.buildNumber}',
correlationId: correlationId,
);

if (Platform.isAndroid) {
Expand Down Expand Up @@ -175,4 +183,18 @@ class LoggingInfo implements ILoggingInfo {
void logExceptionForDebug(Object e, {StackTrace? stacktrace}) {
unawaited(debug(e.toString(), methodName: stacktrace.toString()));
}

@override
Future<void> logRequest(
String method,
String url,
String correlationId,
) async {
await _log(
'$method: $url',
'Request',
Level.INFO,
correlationId: correlationId,
);
}
}
12 changes: 10 additions & 2 deletions lib/core/network/token_interceptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ import 'package:givt_app/features/auth/models/session.dart';
import 'package:givt_app/features/auth/repositories/auth_repository.dart';
import 'package:http_interceptor/http_interceptor.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:uuid/uuid.dart';

class TokenInterceptor implements InterceptorContract {
@override
Future<BaseRequest> interceptRequest({required BaseRequest request}) async {
final correlationId = const Uuid().v4();

try {
final prefs = await SharedPreferences.getInstance();
final sessionString = prefs.getString(Session.tag);

if (!request.headers.containsKey('Content-Type')) {
request.headers['Content-Type'] = 'application/json';
}

request.headers['Accept'] = 'application/json';
request.headers['Correlation-Id'] = correlationId;

if (sessionString == null) {
return request;
Expand All @@ -37,8 +42,11 @@ class TokenInterceptor implements InterceptorContract {
methodName: stackTrace.toString(),
);
}
await LoggingInfo.instance.info(
'${request.method}: ${request.url}',

await LoggingInfo.instance.logRequest(
request.method,
request.url.toString(),
correlationId,
);
return request;
}
Expand Down
40 changes: 24 additions & 16 deletions lib/features/give/pages/bt_scan_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import 'package:go_router/go_router.dart';
import 'package:sprintf/sprintf.dart';

class BTScanPage extends StatefulWidget {
const BTScanPage({super.key});
const BTScanPage({
super.key,
});

@override
State<BTScanPage> createState() => _BTScanPageState();
Expand Down Expand Up @@ -94,31 +96,24 @@ class _BTScanPageState extends State<BTScanPage> {
},
),
);
case BluetoothAdapterState.unavailable:
case BluetoothAdapterState.off:
await LoggingInfo.instance.info('Bluetooth adapter is off');
if (Platform.isAndroid) {
await LoggingInfo.instance.info('Trying to turn it on...');
await FlutterBluePlus.turnOn();
try {
await FlutterBluePlus.turnOn(timeout: 10);
} catch (_) {
// We can't turn on the bluetooth automatically, so show a dialog
await showTurnOnBluetoothDialog();
}
}
if (Platform.isIOS) {
await LoggingInfo.instance.info('iOS User has Bluetooth off...');
if (!context.mounted) {
return;
}
await showDialog<void>(
context: context,
builder: (_) => WarningDialog(
title: context.l10n.turnOnBluetooth,
content: context.l10n.bluetoothErrorMessage,
onConfirm: () async {
await startBluetoothScan();
if (!context.mounted) {
return;
}
Navigator.of(context).pop();
},
),
);
await showTurnOnBluetoothDialog();
}
// We don't want to handle other cases at the moment, so:
// ignore: no_default_cases
Expand All @@ -137,6 +132,19 @@ class _BTScanPageState extends State<BTScanPage> {
});
}

Future<void> showTurnOnBluetoothDialog() {
return showDialog<void>(
context: context,
builder: (_) => WarningDialog(
title: context.l10n.turnOnBluetooth,
content: context.l10n.bluetoothErrorMessage,
onConfirm: () async {
Navigator.of(context).pop();
},
),
);
}

void _onPeripheralsDetectedData(List<ScanResult> results) {
for (final scanResult in results) {
if (scanResult.advertisementData.advName.isEmpty) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: givt_app
description: Givt App
version: 4.2.21
version: 4.2.22
publish_to: none

environment:
Expand Down

0 comments on commit 70e643a

Please sign in to comment.