Skip to content

Commit 5fc51c1

Browse files
DooMMasteRSteffen Arntz
andauthored
Fix issues with the call screen were hanging up while ringing and declining a call were impossible. (#280)
* fix permission issues and hangup/decline while ringing * Bump versions to meet current minimal requirements Co-authored-by: Steffen Arntz <steffen.arntz@ucware.com>
1 parent fc434a3 commit 5fc51c1

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
lines changed

example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
44
import 'package:flutter_webrtc/flutter_webrtc.dart';
55
import 'package:sip_ua/sip_ua.dart';
66

7+
78
import 'src/about.dart';
89
import 'src/callscreen.dart';
910
import 'src/dialpad.dart';

example/lib/src/callscreen.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
154154
void registrationStateChanged(RegistrationState state) {}
155155

156156
void _cleanUp() {
157+
if(_localStream == null) return;
157158
_localStream?.getTracks().forEach((track) {
158159
track.stop();
159160
});
@@ -205,7 +206,7 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
205206
}
206207

207208
void _handleHangup() {
208-
call!.hangup();
209+
call!.hangup({'status_code': 603});
209210
_timer.cancel();
210211
}
211212

example/lib/src/dialpad.dart

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
import 'dart:io';
2+
13
import 'package:flutter/foundation.dart';
24
import 'package:flutter/material.dart';
35
import 'package:flutter_webrtc/flutter_webrtc.dart';
6+
import 'package:permission_handler/permission_handler.dart';
47
import 'package:shared_preferences/shared_preferences.dart';
58
import 'package:sip_ua/sip_ua.dart';
9+
import 'package:flutter/foundation.dart';
10+
611

712
import 'widgets/action_button.dart';
813

@@ -36,7 +41,7 @@ class _MyDialPadWidget extends State<DialPadWidget>
3641
_textController = TextEditingController(text: _dest);
3742
_textController!.text = _dest!;
3843

39-
this.setState(() {});
44+
setState(() {});
4045
}
4146

4247
void _bindEventListeners() {
@@ -46,8 +51,12 @@ class _MyDialPadWidget extends State<DialPadWidget>
4651
Future<Widget?> _handleCall(BuildContext context,
4752
[bool voiceonly = false]) async {
4853
var dest = _textController?.text;
54+
if(defaultTargetPlatform == TargetPlatform.android || defaultTargetPlatform == TargetPlatform.iOS) {
55+
await Permission.microphone.request();
56+
await Permission.camera.request();
57+
}
4958
if (dest == null || dest.isEmpty) {
50-
showDialog<Null>(
59+
showDialog<void>(
5160
context: context,
5261
barrierDismissible: false,
5362
builder: (BuildContext context) {
@@ -92,15 +101,15 @@ class _MyDialPadWidget extends State<DialPadWidget>
92101
void _handleBackSpace([bool deleteAll = false]) {
93102
var text = _textController!.text;
94103
if (text.isNotEmpty) {
95-
this.setState(() {
104+
setState(() {
96105
text = deleteAll ? '' : text.substring(0, text.length - 1);
97106
_textController!.text = text;
98107
});
99108
}
100109
}
101110

102111
void _handleNum(String number) {
103-
this.setState(() {
112+
setState(() {
104113
_textController!.text += number;
105114
});
106115
}
@@ -136,8 +145,8 @@ class _MyDialPadWidget extends State<DialPadWidget>
136145
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
137146
children: row
138147
.map((label) => ActionButton(
139-
title: '${label.keys.first}',
140-
subTitle: '${label.values.first}',
148+
title: label.keys.first,
149+
subTitle: label.values.first,
141150
onPressed: () => _handleNum(label.keys.first),
142151
number: true,
143152
))
@@ -275,7 +284,7 @@ class _MyDialPadWidget extends State<DialPadWidget>
275284
padding: const EdgeInsets.all(6.0),
276285
child: Center(
277286
child: Text(
278-
'Received Message: ${receivedMsg}',
287+
'Received Message: $receivedMsg',
279288
style: TextStyle(fontSize: 14, color: Colors.black54),
280289
)),
281290
),
@@ -290,7 +299,7 @@ class _MyDialPadWidget extends State<DialPadWidget>
290299

291300
@override
292301
void registrationStateChanged(RegistrationState state) {
293-
this.setState(() {});
302+
setState(() {});
294303
}
295304

296305
@override
@@ -314,6 +323,5 @@ class _MyDialPadWidget extends State<DialPadWidget>
314323

315324
@override
316325
void onNewNotify(Notify ntf) {
317-
// TODO: implement onNewNotify
318326
}
319327
}

example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies:
2828
sip_ua:
2929
path: ../
3030
shared_preferences: ^2.0.5
31+
permission_handler: ^9.2.0
3132

3233
dev_dependencies:
3334
flutter_test:

example/scripts/project_tools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function add_permission_label() {
3737
echo ""
3838
echo "Add permission labels to AndroidManifest.xml."
3939
echo ""
40-
python add-line.py -i ../android/app/build.gradle -s 'minSdkVersion 16' -t 'minSdkVersion 21' -r
40+
python add-line.py -i ../android/app/build.gradle -s 'minSdkVersion 21' -t 'minSdkVersion 32' -r
4141
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.CAMERA" />'
4242
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.RECORD_AUDIO" />'
4343
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.WAKE_LOCK" />'

0 commit comments

Comments
 (0)