Skip to content

Commit

Permalink
TW-1926: upgrade flutter to 3.24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sherlockvn authored and nqhhdev committed Sep 11, 2024
1 parent 7661c07 commit e3e043d
Show file tree
Hide file tree
Showing 20 changed files with 348 additions and 173 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
name: Build

env:
FLUTTER_VERSION: 3.22.2
FLUTTER_VERSION: 3.24.0
XCODE_VERSION: ^15.0.1

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ on:
pull_request:

env:
FLUTTER_VERSION: 3.22.2
FLUTTER_VERSION: 3.24.0
LIBOLM_VERSION: 3.2.16

name: Deploying on GitHub Pages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
- "v*.*.*"

env:
FLUTTER_VERSION: 3.22.2
FLUTTER_VERSION: 3.24.0
XCODE_VERSION: ^15.0.1

name: Release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
name: Tests

env:
FLUTTER_VERSION: 3.22.2
FLUTTER_VERSION: 3.24.0

jobs:
code_analyze:
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
FLUTTER_VERSION: 3.22.2
FLUTTER_VERSION: 3.24.0

image:
name: cirrusci/flutter:${FLUTTER_VERSION}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Specify versions
ARG FLUTTER_VERSION=3.22.2
ARG FLUTTER_VERSION=3.24.0
ARG OLM_VERSION=3.2.16
ARG NIX_VERSION=2.22.1

Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Flutter

let apnTokenKey = "apnToken"

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
var twakeApnChannel: FlutterMethodChannel?
var initialNotiInfo: Any?
Expand Down
37 changes: 27 additions & 10 deletions lib/pages/chat_list/receive_sharing_intent_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:app_links/app_links.dart';
import 'package:fluffychat/event/twake_event_types.dart';
import 'package:fluffychat/pages/share/share.dart';
import 'package:fluffychat/presentation/extensions/shared_media_file_extension.dart';
Expand All @@ -11,7 +12,6 @@ import 'dart:async';
import 'package:fluffychat/config/app_config.dart';
import 'package:matrix/matrix.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
import 'package:uni_links/uni_links.dart';

mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {
MatrixState get matrixState;
Expand Down Expand Up @@ -96,24 +96,41 @@ mixin ReceiveSharingIntentMixin<T extends StatefulWidget> on State<T> {
if (!PlatformInfos.isMobile) return;

// For sharing images coming from outside the app while the app is in the memory
intentFileStreamSubscription = ReceiveSharingIntent.getMediaStream()
intentFileStreamSubscription = ReceiveSharingIntent.instance
.getMediaStream()
.listen(_processIncomingSharedFiles, onError: print);

// For sharing images coming from outside the app while the app is closed
ReceiveSharingIntent.getInitialMedia().then(_processIncomingSharedFiles);

// For sharing or opening urls/text coming from outside the app while the app is in the memory
intentDataStreamSubscription = ReceiveSharingIntent.getTextStream()
.listen(_processIncomingSharedText, onError: print);
ReceiveSharingIntent.instance
.getInitialMedia()
.then(_processIncomingSharedFiles);

ReceiveSharingIntent.instance.getMediaStream().listen((value) {
// TODO: Handle mutliple text sharing
if (value.isNotEmpty) {
if (value.first is String) {
_processIncomingSharedText(value.first as String);
}
}
});

// For sharing or opening urls/text coming from outside the app while the app is closed
ReceiveSharingIntent.getInitialText().then(_processIncomingSharedText);
ReceiveSharingIntent.instance.getInitialMedia().then((value) {
// TODO: Handle mutliple text sharing
if (value.isNotEmpty) {
if (value.first is String) {
_processIncomingSharedText(value.first as String);
}
}
});

// For receiving shared Uris
intentUriStreamSubscription = linkStream.listen(_processIncomingUris);
final appLinks = AppLinks();
intentUriStreamSubscription =
appLinks.stringLinkStream.listen(_processIncomingUris);
if (TwakeApp.gotInitialLink == false) {
TwakeApp.gotInitialLink = true;
getInitialLink().then(_processIncomingUris);
appLinks.getInitialLinkString().then(_processIncomingUris);
}
}
}
4 changes: 2 additions & 2 deletions lib/presentation/extensions/shared_media_file_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import 'package:receive_sharing_intent/receive_sharing_intent.dart';

extension SharedMediaFileExtension on SharedMediaFile {
MatrixFile toMatrixFile() {
if (type == SharedMediaType.IMAGE) {
if (type == SharedMediaType.image) {
return MatrixImageFile(
bytes: null,
name: path.split("/").last,
filePath: path,
);
}
if (type == SharedMediaType.VIDEO) {
if (type == SharedMediaType.video) {
Uint8List? thumbnailBytes;
if (thumbnail != null) {
thumbnailBytes = File(thumbnail!).readAsBytesSync();
Expand Down
49 changes: 25 additions & 24 deletions lib/utils/voip/callkeep_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class CallKeepManager {
}

void didDisplayIncomingCall(CallKeepDidDisplayIncomingCall event) {
final callUUID = event.callUUID;
final number = event.handle;
final callUUID = event.callData.callUUID;
final number = event.callData.handle;
Logs().v('[displayIncomingCall] $callUUID number: $number');
// addCall(callUUID, CallKeeper(this null));
}
Expand All @@ -168,20 +168,18 @@ class CallKeepManager {
}

Future<void> initialize() async {
_callKeep.on(CallKeepPerformAnswerCallAction(), answerCall);
_callKeep.on(CallKeepDidPerformDTMFAction(), didPerformDTMFAction);
_callKeep.on(
CallKeepDidReceiveStartCallAction(),
_callKeep.on<CallKeepPerformAnswerCallAction>(answerCall);
_callKeep.on<CallKeepDidPerformDTMFAction>(didPerformDTMFAction);
_callKeep.on<CallKeepDidReceiveStartCallAction>(
didReceiveStartCallAction,
);
_callKeep.on(CallKeepDidToggleHoldAction(), didToggleHoldCallAction);
_callKeep.on(
CallKeepDidPerformSetMutedCallAction(),
_callKeep.on<CallKeepDidToggleHoldAction>(didToggleHoldCallAction);
_callKeep.on<CallKeepDidPerformSetMutedCallAction>(
didPerformSetMutedCallAction,
);
_callKeep.on(CallKeepPerformEndCallAction(), endCall);
_callKeep.on(CallKeepPushKitToken(), onPushKitToken);
_callKeep.on(CallKeepDidDisplayIncomingCall(), didDisplayIncomingCall);
_callKeep.on<CallKeepPerformEndCallAction>(endCall);
_callKeep.on<CallKeepPushKitToken>(onPushKitToken);
_callKeep.on<CallKeepDidDisplayIncomingCall>(didDisplayIncomingCall);
Logs().i('[VOIP] Initialized');
}

Expand Down Expand Up @@ -217,13 +215,13 @@ class CallKeepManager {
if (isIOS) {
await _callKeep.updateDisplay(
callUUID,
displayName: 'New Name',
callerName: 'New Name',
handle: callUUID,
);
} else {
await _callKeep.updateDisplay(
callUUID,
displayName: callUUID,
callerName: callUUID,
handle: 'New Name',
);
}
Expand All @@ -235,8 +233,7 @@ class CallKeepManager {
await _callKeep.displayIncomingCall(
call.callId,
'${call.room.getLocalizedDisplayname()} (Twake Chat)',
localizedCallerName:
'${call.room.getLocalizedDisplayname()} (Twake Chat)',
callerName: '${call.room.getLocalizedDisplayname()} (Twake Chat)',
handleType: 'number',
hasVideo: call.type == CallType.kVideo,
);
Expand Down Expand Up @@ -298,8 +295,8 @@ class CallKeepManager {

/// CallActions.
Future<void> answerCall(CallKeepPerformAnswerCallAction event) async {
final callUUID = event.callUUID;
final keeper = calls[event.callUUID]!;
final callUUID = event.callData.callUUID;
final keeper = calls[event.callData.callUUID]!;
if (!keeper.connected) {
Logs().e('answered');
// Answer Call
Expand All @@ -325,17 +322,21 @@ class CallKeepManager {
Future<void> didReceiveStartCallAction(
CallKeepDidReceiveStartCallAction event,
) async {
if (event.handle == null) {
if (event.callData.handle == null) {
// @TODO: sometime we receive `didReceiveStartCallAction` with handle` undefined`
return;
}
final callUUID = event.callUUID!;
if (event.callUUID == null) {
final call =
await _voipPlugin!.voip.inviteToCall(event.handle!, CallType.kVideo);
final callUUID = event.callData.callUUID!;
if (event.callData.callUUID == null) {
final call = await _voipPlugin!.voip
.inviteToCall(event.callData.handle!, CallType.kVideo);
addCall(callUUID, CallKeeper(this, call));
}
await _callKeep.startCall(callUUID, event.handle!, event.handle!);
await _callKeep.startCall(
callUUID,
event.callData.handle!,
event.callData.handle!,
);
Timer(const Duration(seconds: 1), () {
_callKeep.setCurrentCallActive(callUUID);
});
Expand Down
6 changes: 4 additions & 2 deletions lib/utils/voip/user_media_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ class UserMediaManager {

AudioPlayer? _assetsAudioPlayer;

static final _flutterRingtonePlayer = FlutterRingtonePlayer();

Future<void> startRingingTone() async {
if (PlatformInfos.isMobile) {
await FlutterRingtonePlayer.playRingtone(volume: 80);
await _flutterRingtonePlayer.playRingtone(volume: 80);
} else if ((kIsWeb || PlatformInfos.isMacOS) &&
_assetsAudioPlayer != null) {
const path = 'assets/sounds/phone.ogg';
Expand All @@ -31,7 +33,7 @@ class UserMediaManager {

Future<void> stopRingingTone() async {
if (PlatformInfos.isMobile) {
await FlutterRingtonePlayer.stop();
await _flutterRingtonePlayer.stop();
}
await _assetsAudioPlayer?.stop();
_assetsAudioPlayer = null;
Expand Down
4 changes: 4 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <flutter_avif_linux/flutter_avif_linux_plugin.h>
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
#include <gtk/gtk_plugin.h>
#include <handy_window/handy_window_plugin.h>
#include <irondash_engine_context/irondash_engine_context_plugin.h>
#include <media_kit_libs_linux/media_kit_libs_linux_plugin.h>
Expand Down Expand Up @@ -52,6 +53,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) flutter_webrtc_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWebRTCPlugin");
flutter_web_r_t_c_plugin_register_with_registrar(flutter_webrtc_registrar);
g_autoptr(FlPluginRegistrar) gtk_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
gtk_plugin_register_with_registrar(gtk_registrar);
g_autoptr(FlPluginRegistrar) handy_window_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "HandyWindowPlugin");
handy_window_plugin_register_with_registrar(handy_window_registrar);
Expand Down
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
flutter_avif_linux
flutter_secure_storage_linux
flutter_webrtc
gtk
handy_window
irondash_engine_context
media_kit_libs_linux
Expand Down
4 changes: 4 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import FlutterMacOS
import Foundation

import app_links
import appkit_ui_element_colors
import audio_session
import connectivity_plus
Expand All @@ -16,6 +17,7 @@ import emoji_picker_flutter
import file_saver
import file_selector_macos
import firebase_core
import firebase_messaging
import flutter_app_badger
import flutter_avif_macos
import flutter_image_compress_macos
Expand Down Expand Up @@ -48,6 +50,7 @@ import wakelock_plus
import window_to_front

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
AppkitUiElementColorsPlugin.register(with: registry.registrar(forPlugin: "AppkitUiElementColorsPlugin"))
AudioSessionPlugin.register(with: registry.registrar(forPlugin: "AudioSessionPlugin"))
ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin"))
Expand All @@ -59,6 +62,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin"))
FlutterAppBadgerPlugin.register(with: registry.registrar(forPlugin: "FlutterAppBadgerPlugin"))
FlutterAvifPlugin.register(with: registry.registrar(forPlugin: "FlutterAvifPlugin"))
FlutterImageCompressMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterImageCompressMacosPlugin"))
Expand Down
Loading

0 comments on commit e3e043d

Please sign in to comment.