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

Added new app/notification icon & fixed notification disconnecting #158

Merged
merged 3 commits into from
Jul 6, 2024
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="79"
android:viewportHeight="72"
android:tint="#FFFFFF">
<group android:scaleX="0.92"
android:scaleY="0.838481"
android:translateX="3.16"
android:translateY="5.8146834">
<path
android:pathData="M15,2L4,68.5H27L31,45.5H45L41.5,68.5H64L75,2H51.5L48,25.5H33.5L36.5,2H15Z"
android:strokeWidth="6"
android:fillColor="#181825"
android:strokeColor="#CDD6F5"/>
</group>
</vector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
<item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/splash"/>
</item>
<item>
<bitmap android:gravity="bottom" android:src="@drawable/branding"/>
</item>
</layer-list>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file modified packages/app/android/app/src/main/res/drawable/background.png
15 changes: 0 additions & 15 deletions packages/app/android/app/src/main/res/drawable/hollybike_logo.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="79"
android:viewportHeight="72">
<group android:scaleX="0.33"
android:scaleY="0.3007595"
android:translateX="26.465"
android:translateY="25.172659">
<path
android:pathData="M15,2L4,68.5H27L31,45.5H45L41.5,68.5H64L75,2H51.5L48,25.5H33.5L36.5,2H15Z"
android:strokeWidth="6"
android:fillColor="#181825"
android:strokeColor="#CDD6F5"/>
</group>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@
<item>
<bitmap android:gravity="fill" android:src="@drawable/background"/>
</item>
<item>
<bitmap android:gravity="center" android:src="@drawable/splash"/>
</item>
<item>
<bitmap android:gravity="bottom" android:src="@drawable/branding"/>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
Diff not rendered.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBackground">#181825</item>
<item name="android:windowSplashScreenBrandingImage">@drawable/android12branding</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Expand Down
3 changes: 3 additions & 0 deletions packages/app/android/app/src/main/res/values-v31/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
<item name="android:windowSplashScreenBackground">#181825</item>
<item name="android:windowSplashScreenBrandingImage">@drawable/android12branding</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/android12splash</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#1E1E2E</color>
<color name="ic_launcher_background">#181825</color>
</resources>
Binary file added packages/app/assets/icon.svg/deltsv.png
Binary file added packages/app/assets/icon.svg/icon.png
Binary file added packages/app/assets/icon/brand.png
Binary file modified packages/app/assets/icon/icon.png
Binary file removed packages/app/assets/icon/icon_foreground.png
Diff not rendered.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "BrandingImage.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "BrandingImage@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "BrandingImage@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 5 additions & 1 deletion packages/app/ios/Runner/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="LaunchBackground" translatesAutoresizingMaskIntoConstraints="NO" id="tWc-Dq-wcI"/>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" image="LaunchImage" translatesAutoresizingMaskIntoConstraints="NO" id="YRO-k0-Ey4"></imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" image="BrandingImage" translatesAutoresizingMaskIntoConstraints="NO" id="Uyq-Kz-ftE"/>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="Uyq-Kz-ftE" secondAttribute="bottom" id="8Yb-q4-8bl"/>
<constraint firstItem="Uyq-Kz-ftE" firstAttribute="centerX" secondItem="YRO-k0-Ey4" secondAttribute="centerX" id="3kg-TC-cPP"/>
<constraint firstItem="YRO-k0-Ey4" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="3T2-ad-Qdv"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="bottom" secondItem="Ze5-6b-2t3" secondAttribute="bottom" id="RPx-PI-7Xg"/>
<constraint firstItem="tWc-Dq-wcI" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="SdS-ul-q2q"/>
Expand All @@ -38,7 +41,8 @@
</scene>
</scenes>
<resources>
<image name="LaunchImage" width="168" height="185"/>
<image name="LaunchImage" width="1152" height="1152"/>
<image name="LaunchBackground" width="1" height="1"/>
<image name="BrandingImage" width="1" height="1"/>
</resources>
</document>
47 changes: 43 additions & 4 deletions packages/app/lib/notification/bloc/notification_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ class NotificationBloc extends Bloc<NotificationEvent, NotificationState> {
androidConfiguration: AndroidConfiguration(
onStart: onStart,
autoStart: true,
isForegroundMode: false,
autoStartOnBoot: true,
isForegroundMode: true,
initialNotificationTitle: 'Service de notifications HollyBike',
initialNotificationContent: 'Ce service permet de recevoir des notifications en temps réel.',
),
iosConfiguration: IosConfiguration(
autoStart: true,
Expand Down Expand Up @@ -122,7 +125,7 @@ class NotificationBloc extends Bloc<NotificationEvent, NotificationState> {
'hollybike-event-status-notifications',
'Status des événements',
channelDescription:
'Canal de notifications de Hollybike pour le status des événements',
'Canal de notifications de Hollybike pour le status des événements',
importance: Importance.max,
priority: Priority.high,
showWhen: false,
Expand Down Expand Up @@ -228,13 +231,17 @@ class NotificationBloc extends Bloc<NotificationEvent, NotificationState> {

@pragma('vm:entry-point')
static void onStart(ServiceInstance service) async {
bool initializing = true;

DartPluginRegistrant.ensureInitialized();

final authPersistence = AuthPersistence();

final flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
flutterLocalNotificationsPlugin.initialize(
const InitializationSettings(
android: AndroidInitializationSettings(
'background',
'ic_stat_hollybike',
),
),
);
Expand Down Expand Up @@ -269,19 +276,49 @@ class NotificationBloc extends Bloc<NotificationEvent, NotificationState> {
break;
case 'AddedToEventNotification':
onAddedToEvent(message.data, flutterLocalNotificationsPlugin);
break;
case 'RemovedFromEventNotification':
onRemovedFromEvent(message.data, flutterLocalNotificationsPlugin);
break;
case 'DeleteEventNotification':
onEventDeleted(message.data, flutterLocalNotificationsPlugin);
break;
}
});

void retryConnection() {
Future.delayed(const Duration(seconds: 10), () async {
try {
log('Retrying connection');

final currentSession = await authPersistence.currentSession;

if (currentSession == null) {
return;
}

connectWebSocket(currentSession.token, currentSession.host);
} catch (e) {
log('Error: $e', stackTrace: StackTrace.current);
retryConnection(); // Retry again if an error occurs
}
});
}

webSocket?.onDisconnect(() {
log('Notification websocket disconnected');

webSocket = null;

retryConnection();
});
}

service.on('connect').listen((event) {
if (initializing) {
return;
}

final token = event?['token'] as String;
final host = event?['host'] as String;

Expand All @@ -293,10 +330,12 @@ class NotificationBloc extends Bloc<NotificationEvent, NotificationState> {
service.stopSelf();
});

final currentSession = await AuthPersistence().currentSession;
final currentSession = await authPersistence.currentSession;

if (currentSession != null) {
connectWebSocket(currentSession.token, currentSession.host);
}

initializing = false;
}
}
18 changes: 1 addition & 17 deletions packages/app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
cli_util:
dependency: transitive
description:
name: cli_util
sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19
url: "https://pub.dev"
source: hosted
version: "0.4.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -526,14 +518,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.4+1"
flutter_launcher_icons:
dependency: "direct main"
description:
name: flutter_launcher_icons
sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea"
url: "https://pub.dev"
source: hosted
version: "0.13.1"
flutter_lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -572,7 +556,7 @@ packages:
source: sdk
version: "0.0.0"
flutter_native_splash:
dependency: "direct main"
dependency: "direct dev"
description:
name: flutter_native_splash
sha256: edf39bcf4d74aca1eb2c1e43c3e445fd9f494013df7f0da752fefe72020eedc0
Expand Down
27 changes: 12 additions & 15 deletions packages/app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ dependencies:
freezed_annotation: ^2.4.1
dio: ^5.4.3+1
rxdart: ^0.27.7
flutter_native_splash: ^2.4.0
lottie: ^3.1.2
simple_animations: ^5.0.2
flutter_launcher_icons: ^0.13.1
cached_network_image: ^3.3.1
mapbox_maps_flutter: ^2.0.0
geojson_vi: ^2.2.4
Expand Down Expand Up @@ -87,6 +85,7 @@ dev_dependencies:
auto_route_generator: ^8.0.0
json_serializable: ^6.8.0
freezed: ^2.5.2
flutter_native_splash: ^2.4.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down Expand Up @@ -120,24 +119,24 @@ flutter_native_splash:
# of your splash screen to a solid color. Use background_image to set the background of your
# splash screen to a png image. This is useful for gradients. The image will be stretch to the
# size of the app. Only one parameter can be used, color and background_image cannot both be set.
color: "#42a5f5"
#background_image: "assets/background.png"
color: "#181825"
# background_image: "assets/icon/icon.png"

# Optional parameters are listed below. To enable a parameter, uncomment the line by removing
# the leading # character.

# The image parameter allows you to specify an image used in the splash screen. It must be a
# png file and should be sized for 4x pixel density.
#image: assets/splash.png
image: assets/icon/icon.png

# The branding property allows you to specify an image used as branding in the splash screen.
# It must be a png file. It is supported for Android, iOS and the Web. For Android 12,
# see the Android 12 section below.
#branding: assets/dart.png
branding: assets/icon/brand.png

# To position the branding image at the bottom of the screen you can use bottom, bottomRight,
# and bottomLeft. The default values is bottom if not specified or specified something else.
#branding_mode: bottom
branding_mode: bottom

# The color_dark, background_image_dark, image_dark, branding_dark are parameters that set the background
# and image when the device is in dark mode. If they are not specified, the app will use the
Expand All @@ -153,6 +152,8 @@ flutter_native_splash:
# Please visit https://developer.android.com/guide/topics/ui/splash-screen
# Following are specific parameters for Android 12+.
android_12:
image: assets/icon/icon.png

# The image parameter sets the splash screen icon image. If this parameter is not specified,
# the app's launcher icon will be used instead.
# Please note that the splash screen will be clipped to a circle on the center of the screen.
Expand All @@ -163,13 +164,15 @@ flutter_native_splash:
#image: assets/android12splash.png

# Splash screen background color.
#color: "#42a5f5"
color: "#181825"

# App icon background color.
#icon_background_color: "#111111"

# The branding property allows you to specify an image used as branding in the splash screen.
#branding: assets/dart.png
branding: assets/icon/brand.png

branding_mode: bottom

# The image_dark, color_dark, icon_background_color_dark, and branding_dark set values that
# apply when the device is in dark mode. If they are not specified, the app will use the
Expand Down Expand Up @@ -248,9 +251,3 @@ flutter_native_splash:
#info_plist_files:
# - 'ios/Runner/Info-Debug.plist'
# - 'ios/Runner/Info-Release.plist'

flutter_launcher_icons:
android: true
image_path: "assets/icon/icon.png"
adaptive_icon_foreground: "assets/icon/icon_foreground.png"
adaptive_icon_background: "#1E1E2E"