Merge pull request #453 from TheSunCat/fix-calls
Fix call dialog on Android 11 + screen sharing
This commit is contained in:
commit
573f76ac89
4 changed files with 21 additions and 13 deletions
|
|
@ -19,7 +19,11 @@
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"/>
|
<uses-permission android:name="android.permission.BIND_TELECOM_CONNECTION_SERVICE"/>
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_STATE"
|
||||||
|
android:maxSdkVersion="29" />
|
||||||
|
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||||
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
|
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ class MyCallingPage extends State<Calling> {
|
||||||
Room? get room => call.room;
|
Room? get room => call.room;
|
||||||
|
|
||||||
String get displayName => call.room.getLocalizedDisplayname(
|
String get displayName => call.room.getLocalizedDisplayname(
|
||||||
MatrixLocals(L10n.of(context)!),
|
MatrixLocals(L10n.of(widget.context)!),
|
||||||
);
|
);
|
||||||
|
|
||||||
String get callId => widget.callId;
|
String get callId => widget.callId;
|
||||||
|
|
@ -248,18 +248,18 @@ class MyCallingPage extends State<Calling> {
|
||||||
|
|
||||||
void _resizeLocalVideo(Orientation orientation) {
|
void _resizeLocalVideo(Orientation orientation) {
|
||||||
final shortSide = min(
|
final shortSide = min(
|
||||||
MediaQuery.of(context).size.width,
|
MediaQuery.of(widget.context).size.width,
|
||||||
MediaQuery.of(context).size.height,
|
MediaQuery.of(widget.context).size.height,
|
||||||
);
|
);
|
||||||
_localVideoMargin = remoteStream != null
|
_localVideoMargin = remoteStream != null
|
||||||
? const EdgeInsets.only(top: 20.0, right: 20.0)
|
? const EdgeInsets.only(top: 20.0, right: 20.0)
|
||||||
: EdgeInsets.zero;
|
: EdgeInsets.zero;
|
||||||
_localVideoWidth = remoteStream != null
|
_localVideoWidth = remoteStream != null
|
||||||
? shortSide / 3
|
? shortSide / 3
|
||||||
: MediaQuery.of(context).size.width;
|
: MediaQuery.of(widget.context).size.width;
|
||||||
_localVideoHeight = remoteStream != null
|
_localVideoHeight = remoteStream != null
|
||||||
? shortSide / 4
|
? shortSide / 4
|
||||||
: MediaQuery.of(context).size.height;
|
: MediaQuery.of(widget.context).size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleCallState(CallState state) {
|
void _handleCallState(CallState state) {
|
||||||
|
|
@ -309,14 +309,15 @@ class MyCallingPage extends State<Calling> {
|
||||||
androidNotificationOptions: AndroidNotificationOptions(
|
androidNotificationOptions: AndroidNotificationOptions(
|
||||||
channelId: 'notification_channel_id',
|
channelId: 'notification_channel_id',
|
||||||
channelName: 'Foreground Notification',
|
channelName: 'Foreground Notification',
|
||||||
channelDescription: L10n.of(context)!.foregroundServiceRunning,
|
channelDescription:
|
||||||
|
L10n.of(widget.context)!.foregroundServiceRunning,
|
||||||
),
|
),
|
||||||
iosNotificationOptions: const IOSNotificationOptions(),
|
iosNotificationOptions: const IOSNotificationOptions(),
|
||||||
foregroundTaskOptions: const ForegroundTaskOptions(),
|
foregroundTaskOptions: const ForegroundTaskOptions(),
|
||||||
);
|
);
|
||||||
FlutterForegroundTask.startService(
|
FlutterForegroundTask.startService(
|
||||||
notificationTitle: L10n.of(context)!.screenSharingTitle,
|
notificationTitle: L10n.of(widget.context)!.screenSharingTitle,
|
||||||
notificationText: L10n.of(context)!.screenSharingDetail,
|
notificationText: L10n.of(widget.context)!.screenSharingDetail,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
FlutterForegroundTask.stopService();
|
FlutterForegroundTask.stopService();
|
||||||
|
|
@ -379,7 +380,7 @@ class MyCallingPage extends State<Calling> {
|
||||||
child: Icon(_speakerOn ? Icons.volume_up : Icons.volume_off),
|
child: Icon(_speakerOn ? Icons.volume_up : Icons.volume_off),
|
||||||
onPressed: _switchSpeaker,
|
onPressed: _switchSpeaker,
|
||||||
foregroundColor: Colors.black54,
|
foregroundColor: Colors.black54,
|
||||||
backgroundColor: Theme.of(context).backgroundColor,
|
backgroundColor: Theme.of(widget.context).backgroundColor,
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
final hangupButton = FloatingActionButton(
|
final hangupButton = FloatingActionButton(
|
||||||
|
|
@ -481,7 +482,7 @@ class MyCallingPage extends State<Calling> {
|
||||||
var title = '';
|
var title = '';
|
||||||
if (call.localHold) {
|
if (call.localHold) {
|
||||||
title = '${call.room.getLocalizedDisplayname(
|
title = '${call.room.getLocalizedDisplayname(
|
||||||
MatrixLocals(L10n.of(context)!),
|
MatrixLocals(L10n.of(widget.context)!),
|
||||||
)} held the call.';
|
)} held the call.';
|
||||||
} else if (call.remoteOnHold) {
|
} else if (call.remoteOnHold) {
|
||||||
title = 'You held the call.';
|
title = 'You held the call.';
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate {
|
||||||
void addCallingOverlay(String callId, CallSession call) {
|
void addCallingOverlay(String callId, CallSession call) {
|
||||||
final context = kIsWeb
|
final context = kIsWeb
|
||||||
? ChatList.contextForVoip!
|
? ChatList.contextForVoip!
|
||||||
: FluffyChatApp.routerKey.currentContext!; // web is weird
|
: FluffyChatApp.matrixKey.currentContext!; // web is weird
|
||||||
|
|
||||||
if (overlayEntry != null) {
|
if (overlayEntry != null) {
|
||||||
Logs().e('[VOIP] addCallingOverlay: The call session already exists?');
|
Logs().e('[VOIP] addCallingOverlay: The call session already exists?');
|
||||||
overlayEntry!.remove();
|
overlayEntry!.remove();
|
||||||
|
|
@ -165,7 +166,7 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate {
|
||||||
addCallingOverlay(call.callId, call);
|
addCallingOverlay(call.callId, call);
|
||||||
try {
|
try {
|
||||||
if (!hasCallingAccount) {
|
if (!hasCallingAccount) {
|
||||||
ScaffoldMessenger.of(FluffyChatApp.routerKey.currentContext!)
|
ScaffoldMessenger.of(FluffyChatApp.matrixKey.currentContext!)
|
||||||
.showSnackBar(
|
.showSnackBar(
|
||||||
const SnackBar(
|
const SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ class FluffyChatApp extends StatefulWidget {
|
||||||
final List<Client> clients;
|
final List<Client> clients;
|
||||||
final Map<String, String>? queryParameters;
|
final Map<String, String>? queryParameters;
|
||||||
static GlobalKey<VRouterState> routerKey = GlobalKey<VRouterState>();
|
static GlobalKey<VRouterState> routerKey = GlobalKey<VRouterState>();
|
||||||
|
static GlobalKey<MatrixState> matrixKey = GlobalKey<MatrixState>();
|
||||||
const FluffyChatApp({
|
const FluffyChatApp({
|
||||||
Key? key,
|
Key? key,
|
||||||
this.testWidget,
|
this.testWidget,
|
||||||
|
|
@ -75,6 +76,7 @@ class FluffyChatAppState extends State<FluffyChatApp> {
|
||||||
initialUrl: _initialUrl ?? '/',
|
initialUrl: _initialUrl ?? '/',
|
||||||
routes: AppRoutes(columnMode ?? false).routes,
|
routes: AppRoutes(columnMode ?? false).routes,
|
||||||
builder: (context, child) => Matrix(
|
builder: (context, child) => Matrix(
|
||||||
|
key: FluffyChatApp.matrixKey,
|
||||||
context: context,
|
context: context,
|
||||||
router: FluffyChatApp.routerKey,
|
router: FluffyChatApp.routerKey,
|
||||||
clients: widget.clients,
|
clients: widget.clients,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue