This commit is contained in:
parent
4a078c139a
commit
dac6b53b2a
@ -2,141 +2,31 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import '../features/call/call_page.dart';
|
import '../features/call/call_page.dart';
|
||||||
import '../features/call/incoming_call_page.dart';
|
import '../features/call/incoming_call_page.dart';
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
import '../services/contact_service.dart';
|
import '../services/contact_service.dart';
|
||||||
=======
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
import '../services/contact_service.dart'; // Import your ContactService
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
=======
|
|
||||||
import '../services/contact_service.dart';
|
|
||||||
>>>>>>> c2c646a (feat: give parameters to callPage to avoid fetching when possible)
|
|
||||||
|
|
||||||
class CallService {
|
class CallService {
|
||||||
static const MethodChannel _channel = MethodChannel('call_service');
|
static const MethodChannel _channel = MethodChannel('call_service');
|
||||||
static String? currentPhoneNumber;
|
static String? currentPhoneNumber;
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
static String? currentDisplayName;
|
static String? currentDisplayName;
|
||||||
static Uint8List? currentThumbnail;
|
static Uint8List? currentThumbnail;
|
||||||
static bool _isCallPageVisible = false;
|
static bool _isCallPageVisible = false;
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
static String? _currentCallState;
|
static String? _currentCallState;
|
||||||
=======
|
|
||||||
static String? currentDisplayName; // Store display name
|
|
||||||
static Uint8List? currentThumbnail; // Store thumbnail
|
|
||||||
=======
|
|
||||||
static String? currentDisplayName;
|
|
||||||
static Uint8List? currentThumbnail;
|
|
||||||
>>>>>>> c2c646a (feat: give parameters to callPage to avoid fetching when possible)
|
|
||||||
static bool _isCallPageVisible = false;
|
|
||||||
=======
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
<<<<<<< HEAD
|
|
||||||
final ContactService _contactService = ContactService(); // Instantiate ContactService
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
static Map<String, dynamic>? _pendingCall;
|
static Map<String, dynamic>? _pendingCall;
|
||||||
static bool wasPhoneLocked = false;
|
static bool wasPhoneLocked = false;
|
||||||
<<<<<<< HEAD
|
|
||||||
final ContactService _contactService = ContactService();
|
final ContactService _contactService = ContactService();
|
||||||
=======
|
|
||||||
static Map<String, dynamic>? _pendingCall;
|
|
||||||
static bool wasPhoneLocked = false;
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
static String? _currentCallState;
|
|
||||||
<<<<<<< HEAD
|
|
||||||
>>>>>>> f491fb6 (fix: no screen stacking when making calls)
|
|
||||||
=======
|
|
||||||
static Map<String, dynamic>? _pendingCall;
|
|
||||||
static bool wasPhoneLocked = false;
|
|
||||||
>>>>>>> 6628dd6 (feat: merge call_service with callNotifications changes)
|
|
||||||
final ContactService _contactService = ContactService();
|
|
||||||
>>>>>>> acbccaa (feat: give parameters to callPage to avoid fetching when possible)
|
|
||||||
>>>>>>> c2c646a (feat: give parameters to callPage to avoid fetching when possible)
|
|
||||||
|
|
||||||
static final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
static final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||||
|
|
||||||
CallService() {
|
CallService() {
|
||||||
_channel.setMethodCallHandler((call) async {
|
_channel.setMethodCallHandler((call) async {
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
print('CallService: Received method ${call.method} with args ${call.arguments}');
|
print('CallService: Received method ${call.method} with args ${call.arguments}');
|
||||||
=======
|
|
||||||
print('CallService: Handling method call: ${call.method}');
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
print('CallService: Received method ${call.method} with args ${call.arguments}');
|
|
||||||
>>>>>>> b3c8bf7 (feat: merge call_service with callNotifications changes)
|
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "callAdded":
|
case "callAdded":
|
||||||
final phoneNumber = call.arguments["callId"] as String;
|
final phoneNumber = call.arguments["callId"] as String;
|
||||||
final state = call.arguments["state"] as String;
|
final state = call.arguments["state"] as String;
|
||||||
currentPhoneNumber = phoneNumber.replaceFirst('tel:', '');
|
currentPhoneNumber = phoneNumber.replaceFirst('tel:', '');
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
// Fetch contact info using ContactService if not already set
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
=======
|
|
||||||
>>>>>>> c2c646a (feat: give parameters to callPage to avoid fetching when possible)
|
|
||||||
await _fetchContactInfo(currentPhoneNumber!);
|
await _fetchContactInfo(currentPhoneNumber!);
|
||||||
print('CallService: Call added, number: $currentPhoneNumber, state: $state');
|
print('CallService: Call added, number: $currentPhoneNumber, state: $state');
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
_handleCallState(state);
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
=======
|
|
||||||
>>>>>>> b3c8bf7 (feat: merge call_service with callNotifications changes)
|
|
||||||
if (state == "ringing") {
|
|
||||||
_handleIncomingCall(phoneNumber);
|
|
||||||
} else {
|
|
||||||
_navigateToCallPage();
|
|
||||||
}
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
break;
|
|
||||||
case "callStateChanged":
|
|
||||||
final state = call.arguments["state"] as String;
|
|
||||||
wasPhoneLocked = call.arguments["wasPhoneLocked"] as bool? ?? false;
|
|
||||||
print('CallService: State changed to $state, wasPhoneLocked: $wasPhoneLocked');
|
|
||||||
<<<<<<< HEAD
|
|
||||||
_handleCallState(state);
|
|
||||||
=======
|
|
||||||
if (state == "disconnected" || state == "disconnecting") {
|
|
||||||
_closeCallPage();
|
|
||||||
if (wasPhoneLocked) {
|
|
||||||
_channel.invokeMethod("callEndedFromFlutter");
|
|
||||||
}
|
|
||||||
} else if (state == "active" || state == "dialing") {
|
|
||||||
_navigateToCallPage();
|
|
||||||
} else if (state == "ringing") {
|
|
||||||
final phoneNumber = call.arguments["callId"] as String;
|
|
||||||
_handleIncomingCall(phoneNumber.replaceFirst('tel:', ''));
|
|
||||||
}
|
|
||||||
<<<<<<< HEAD
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
_handleCallState(context, state);
|
|
||||||
break;
|
|
||||||
case "callStateChanged":
|
|
||||||
final state = call.arguments["state"] as String;
|
|
||||||
print('CallService: State changed to $state');
|
|
||||||
_handleCallState(context, state);
|
|
||||||
>>>>>>> f491fb6 (fix: no screen stacking when making calls)
|
|
||||||
<<<<<<< HEAD
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
_handleCallState(state);
|
_handleCallState(state);
|
||||||
break;
|
break;
|
||||||
case "callStateChanged":
|
case "callStateChanged":
|
||||||
@ -144,8 +34,6 @@ class CallService {
|
|||||||
wasPhoneLocked = call.arguments["wasPhoneLocked"] as bool? ?? false;
|
wasPhoneLocked = call.arguments["wasPhoneLocked"] as bool? ?? false;
|
||||||
print('CallService: State changed to $state, wasPhoneLocked: $wasPhoneLocked');
|
print('CallService: State changed to $state, wasPhoneLocked: $wasPhoneLocked');
|
||||||
_handleCallState(state);
|
_handleCallState(state);
|
||||||
>>>>>>> 6628dd6 (feat: merge call_service with callNotifications changes)
|
|
||||||
>>>>>>> b3c8bf7 (feat: merge call_service with callNotifications changes)
|
|
||||||
break;
|
break;
|
||||||
case "callEnded":
|
case "callEnded":
|
||||||
case "callRemoved":
|
case "callRemoved":
|
||||||
@ -158,36 +46,13 @@ class CallService {
|
|||||||
currentPhoneNumber = null;
|
currentPhoneNumber = null;
|
||||||
currentDisplayName = null;
|
currentDisplayName = null;
|
||||||
currentThumbnail = null;
|
currentThumbnail = null;
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
_currentCallState = null;
|
_currentCallState = null;
|
||||||
=======
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
=======
|
|
||||||
_currentCallState = null;
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
break;
|
break;
|
||||||
case "incomingCallFromNotification":
|
case "incomingCallFromNotification":
|
||||||
final phoneNumber = call.arguments["phoneNumber"] as String;
|
final phoneNumber = call.arguments["phoneNumber"] as String;
|
||||||
wasPhoneLocked = call.arguments["wasPhoneLocked"] as bool? ?? false;
|
wasPhoneLocked = call.arguments["wasPhoneLocked"] as bool? ?? false;
|
||||||
currentPhoneNumber = phoneNumber;
|
currentPhoneNumber = phoneNumber;
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
await _fetchContactInfo(currentPhoneNumber!);
|
await _fetchContactInfo(currentPhoneNumber!);
|
||||||
=======
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
=======
|
|
||||||
>>>>>>> b3c8bf7 (feat: merge call_service with callNotifications changes)
|
|
||||||
print('CallService: Incoming call from notification: $phoneNumber, wasPhoneLocked: $wasPhoneLocked');
|
|
||||||
_handleIncomingCall(phoneNumber);
|
|
||||||
break;
|
|
||||||
case "incomingCallFromNotification":
|
|
||||||
final phoneNumber = call.arguments["phoneNumber"] as String;
|
|
||||||
wasPhoneLocked = call.arguments["wasPhoneLocked"] as bool? ?? false;
|
|
||||||
currentPhoneNumber = phoneNumber;
|
|
||||||
=======
|
|
||||||
await _fetchContactInfo(currentPhoneNumber!);
|
|
||||||
>>>>>>> 6628dd6 (feat: merge call_service with callNotifications changes)
|
|
||||||
print('CallService: Incoming call from notification: $phoneNumber, wasPhoneLocked: $wasPhoneLocked');
|
print('CallService: Incoming call from notification: $phoneNumber, wasPhoneLocked: $wasPhoneLocked');
|
||||||
_handleIncomingCall(phoneNumber);
|
_handleIncomingCall(phoneNumber);
|
||||||
break;
|
break;
|
||||||
@ -195,8 +60,6 @@ class CallService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
Future<void> _fetchContactInfo(String phoneNumber) async {
|
Future<void> _fetchContactInfo(String phoneNumber) async {
|
||||||
try {
|
try {
|
||||||
final contacts = await _contactService.fetchContacts();
|
final contacts = await _contactService.fetchContacts();
|
||||||
@ -204,33 +67,12 @@ class CallService {
|
|||||||
for (var contact in contacts) {
|
for (var contact in contacts) {
|
||||||
for (var phone in contact.phones) {
|
for (var phone in contact.phones) {
|
||||||
if (_normalizePhoneNumber(phone.number) == normalizedPhoneNumber) {
|
if (_normalizePhoneNumber(phone.number) == normalizedPhoneNumber) {
|
||||||
=======
|
|
||||||
Future<void> _fetchContactInfo(String phoneNumber) async {
|
|
||||||
try {
|
|
||||||
final contacts = await _contactService.fetchContacts();
|
|
||||||
final normalizedPhoneNumber = _normalizePhoneNumber(phoneNumber);
|
|
||||||
for (var contact in contacts) {
|
|
||||||
for (var phone in contact.phones) {
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if (_normalizePhoneNumber(phone.number) == _normalizePhoneNumber(phoneNumber)) {
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
=======
|
|
||||||
if (_normalizePhoneNumber(phone.number) == normalizedPhoneNumber) {
|
|
||||||
>>>>>>> c2c646a (feat: give parameters to callPage to avoid fetching when possible)
|
|
||||||
currentDisplayName = contact.displayName;
|
currentDisplayName = contact.displayName;
|
||||||
currentThumbnail = contact.thumbnail;
|
currentThumbnail = contact.thumbnail;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
currentDisplayName = phoneNumber;
|
|
||||||
currentThumbnail = null;
|
|
||||||
=======
|
|
||||||
// If no match found, use phone number as fallback
|
|
||||||
=======
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
currentDisplayName = phoneNumber;
|
currentDisplayName = phoneNumber;
|
||||||
currentThumbnail = null;
|
currentThumbnail = null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -244,46 +86,6 @@ class CallService {
|
|||||||
return number.replaceAll(RegExp(r'[\s\-\(\)]'), '');
|
return number.replaceAll(RegExp(r'[\s\-\(\)]'), '');
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
Future<void> _fetchContactInfo(String phoneNumber) async {
|
|
||||||
if (currentDisplayName != null && currentThumbnail != null) return; // Already set
|
|
||||||
try {
|
|
||||||
final contacts = await _contactService.fetchContacts(); // Use ContactService
|
|
||||||
for (var contact in contacts) {
|
|
||||||
for (var phone in contact.phones) {
|
|
||||||
if (_normalizePhoneNumber(phone.number) == _normalizePhoneNumber(phoneNumber)) {
|
|
||||||
currentDisplayName = contact.displayName;
|
|
||||||
currentThumbnail = contact.thumbnail;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If no match found, use phone number as fallback
|
|
||||||
currentDisplayName ??= phoneNumber;
|
|
||||||
currentThumbnail ??= null;
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
} catch (e) {
|
|
||||||
print('CallService: Error fetching contact info: $e');
|
|
||||||
currentDisplayName = phoneNumber;
|
|
||||||
currentThumbnail = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String _normalizePhoneNumber(String number) {
|
|
||||||
return number.replaceAll(RegExp(r'[\s\-\(\)]'), '');
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
>>>>>>> 6628dd6 (feat: merge call_service with callNotifications changes)
|
|
||||||
>>>>>>> b3c8bf7 (feat: merge call_service with callNotifications changes)
|
|
||||||
void _handleIncomingCall(String phoneNumber) {
|
void _handleIncomingCall(String phoneNumber) {
|
||||||
final context = navigatorKey.currentContext;
|
final context = navigatorKey.currentContext;
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
@ -291,10 +93,6 @@ class CallService {
|
|||||||
_pendingCall = {"phoneNumber": phoneNumber};
|
_pendingCall = {"phoneNumber": phoneNumber};
|
||||||
Future.delayed(Duration(milliseconds: 500), () => _checkPendingCall());
|
Future.delayed(Duration(milliseconds: 500), () => _checkPendingCall());
|
||||||
} else {
|
} else {
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
void _handleCallState(BuildContext context, String state) {
|
|
||||||
=======
|
|
||||||
_navigateToIncomingCallPage(context);
|
_navigateToIncomingCallPage(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -314,46 +112,6 @@ class CallService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleCallState(String state) {
|
|
||||||
final context = navigatorKey.currentContext;
|
|
||||||
if (context == null) {
|
|
||||||
print('CallService: Navigator context is null, cannot navigate');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
>>>>>>> 6628dd6 (feat: merge call_service with callNotifications changes)
|
|
||||||
if (_currentCallState == state) {
|
|
||||||
print('CallService: State $state already handled, skipping');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_currentCallState = state;
|
|
||||||
|
|
||||||
if (state == "disconnected" || state == "disconnecting") {
|
|
||||||
_closeCallPage();
|
|
||||||
} else if (state == "active" || state == "dialing") {
|
|
||||||
_navigateToCallPage(context);
|
|
||||||
} else if (state == "ringing") {
|
|
||||||
>>>>>>> f491fb6 (fix: no screen stacking when making calls)
|
|
||||||
_navigateToIncomingCallPage(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
void _checkPendingCall() {
|
|
||||||
if (_pendingCall != null) {
|
|
||||||
final context = navigatorKey.currentContext;
|
|
||||||
if (context != null) {
|
|
||||||
print('CallService: Processing queued call: ${_pendingCall!["phoneNumber"]}');
|
|
||||||
currentPhoneNumber = _pendingCall!["phoneNumber"];
|
|
||||||
_navigateToIncomingCallPage(context);
|
|
||||||
_pendingCall = null;
|
|
||||||
} else {
|
|
||||||
print('CallService: Context still null, retrying...');
|
|
||||||
Future.delayed(Duration(milliseconds: 500), () => _checkPendingCall());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
void _handleCallState(String state) {
|
void _handleCallState(String state) {
|
||||||
final context = navigatorKey.currentContext;
|
final context = navigatorKey.currentContext;
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
@ -387,37 +145,6 @@ class CallService {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
Navigator.pushReplacement(
|
Navigator.pushReplacement(
|
||||||
=======
|
|
||||||
void _navigateToCallPage() {
|
|
||||||
final context = navigatorKey.currentContext;
|
|
||||||
if (context == null) {
|
|
||||||
print('CallService: Cannot navigate to CallPage, context is null');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_isCallPageVisible) {
|
|
||||||
print('CallService: CallPage already visible, skipping navigation');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
print('CallService: Navigating to CallPage');
|
|
||||||
Navigator.push(
|
|
||||||
<<<<<<< HEAD
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
void _navigateToCallPage(BuildContext context) {
|
|
||||||
final currentRoute = ModalRoute.of(context)?.settings.name;
|
|
||||||
print('CallService: Navigating to CallPage. Visible: $_isCallPageVisible, Current Route: $currentRoute');
|
|
||||||
if (_isCallPageVisible && currentRoute == '/call') {
|
|
||||||
print('CallService: CallPage already visible, skipping navigation');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_isCallPageVisible && currentRoute == '/incoming_call') {
|
|
||||||
print('CallService: Replacing IncomingCallPage with CallPage');
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
Navigator.pushReplacement(
|
|
||||||
>>>>>>> f491fb6 (fix: no screen stacking when making calls)
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
settings: const RouteSettings(name: '/call'),
|
settings: const RouteSettings(name: '/call'),
|
||||||
@ -435,22 +162,9 @@ class CallService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _navigateToIncomingCallPage(BuildContext context) {
|
void _navigateToIncomingCallPage(BuildContext context) {
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
final currentRoute = ModalRoute.of(context)?.settings.name;
|
final currentRoute = ModalRoute.of(context)?.settings.name;
|
||||||
print('CallService: Navigating to IncomingCallPage. Visible: $_isCallPageVisible, Current Route: $currentRoute');
|
print('CallService: Navigating to IncomingCallPage. Visible: $_isCallPageVisible, Current Route: $currentRoute');
|
||||||
if (_isCallPageVisible && currentRoute == '/incoming_call') {
|
if (_isCallPageVisible && currentRoute == '/incoming_call') {
|
||||||
=======
|
|
||||||
if (_isCallPageVisible) {
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
if (_isCallPageVisible) {
|
|
||||||
=======
|
|
||||||
final currentRoute = ModalRoute.of(context)?.settings.name;
|
|
||||||
print('CallService: Navigating to IncomingCallPage. Visible: $_isCallPageVisible, Current Route: $currentRoute');
|
|
||||||
if (_isCallPageVisible && currentRoute == '/incoming_call') {
|
|
||||||
>>>>>>> f491fb6 (fix: no screen stacking when making calls)
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
print('CallService: IncomingCallPage already visible, skipping navigation');
|
print('CallService: IncomingCallPage already visible, skipping navigation');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -475,67 +189,23 @@ class CallService {
|
|||||||
_isCallPageVisible = true;
|
_isCallPageVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
>>>>>>> 6628dd6 (feat: merge call_service with callNotifications changes)
|
|
||||||
void _closeCallPage() {
|
void _closeCallPage() {
|
||||||
final context = navigatorKey.currentContext;
|
final context = navigatorKey.currentContext;
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
print('CallService: Cannot close page, context is null');
|
print('CallService: Cannot close page, context is null');
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print('CallService: Attempting to close call page. Visible: $_isCallPageVisible');
|
print('CallService: Attempting to close call page. Visible: $_isCallPageVisible');
|
||||||
if (!_isCallPageVisible) {
|
if (!_isCallPageVisible) {
|
||||||
print('CallService: CallPage not visible, skipping pop');
|
print('CallService: CallPage not visible, skipping pop');
|
||||||
=======
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
>>>>>>> b3c8bf7 (feat: merge call_service with callNotifications changes)
|
|
||||||
=======
|
|
||||||
void _closeCallPage(BuildContext context) {
|
|
||||||
=======
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
>>>>>>> 6628dd6 (feat: merge call_service with callNotifications changes)
|
|
||||||
print('CallService: Attempting to close call page. Visible: $_isCallPageVisible');
|
|
||||||
if (!_isCallPageVisible) {
|
|
||||||
print('CallService: CallPage not visible, skipping pop');
|
|
||||||
>>>>>>> f491fb6 (fix: no screen stacking when making calls)
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Navigator.canPop(context)) {
|
if (Navigator.canPop(context)) {
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
print('CallService: Popping CallPage. Current Route: ${ModalRoute.of(context)?.settings.name}');
|
print('CallService: Popping CallPage. Current Route: ${ModalRoute.of(context)?.settings.name}');
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
_isCallPageVisible = false;
|
_isCallPageVisible = false;
|
||||||
} else {
|
} else {
|
||||||
print('CallService: Cannot pop, no routes to pop');
|
print('CallService: Cannot pop, no routes to pop');
|
||||||
=======
|
|
||||||
=======
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
print('CallService: Popping call page');
|
|
||||||
Navigator.pop(context);
|
|
||||||
_isCallPageVisible = false;
|
|
||||||
} else {
|
|
||||||
print('CallService: No page to pop');
|
|
||||||
<<<<<<< HEAD
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
=======
|
|
||||||
print('CallService: Popping CallPage. Current Route: ${ModalRoute.of(context)?.settings.name}');
|
|
||||||
Navigator.pop(context);
|
|
||||||
_isCallPageVisible = false;
|
|
||||||
} else {
|
|
||||||
print('CallService: Cannot pop, no routes to pop');
|
|
||||||
>>>>>>> f491fb6 (fix: no screen stacking when making calls)
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,26 +217,11 @@ class CallService {
|
|||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
currentPhoneNumber = phoneNumber;
|
currentPhoneNumber = phoneNumber;
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
// Use provided displayName and thumbnail if available, otherwise fetch
|
|
||||||
>>>>>>> c2c646a (feat: give parameters to callPage to avoid fetching when possible)
|
|
||||||
=======
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
currentDisplayName = displayName ?? phoneNumber;
|
currentDisplayName = displayName ?? phoneNumber;
|
||||||
currentThumbnail = thumbnail;
|
currentThumbnail = thumbnail;
|
||||||
if (displayName == null || thumbnail == null) {
|
if (displayName == null || thumbnail == null) {
|
||||||
await _fetchContactInfo(phoneNumber);
|
await _fetchContactInfo(phoneNumber);
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
currentDisplayName = displayName ?? phoneNumber; // Use provided or fetch later
|
|
||||||
currentThumbnail = thumbnail; // Use provided or fetch later
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
=======
|
|
||||||
>>>>>>> c2c646a (feat: give parameters to callPage to avoid fetching when possible)
|
|
||||||
print('CallService: Making GSM call to $phoneNumber');
|
print('CallService: Making GSM call to $phoneNumber');
|
||||||
final result = await _channel.invokeMethod('makeGsmCall', {"phoneNumber": phoneNumber});
|
final result = await _channel.invokeMethod('makeGsmCall', {"phoneNumber": phoneNumber});
|
||||||
print('CallService: makeGsmCall result: $result');
|
print('CallService: makeGsmCall result: $result');
|
||||||
@ -576,29 +231,7 @@ class CallService {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
_handleCallState("dialing");
|
_handleCallState("dialing");
|
||||||
=======
|
|
||||||
return resultMap;
|
|
||||||
>>>>>>> ec1779b (callNotifications and various fix related to calls (#49))
|
|
||||||
=======
|
|
||||||
// Fetch contact info if not provided
|
|
||||||
await _fetchContactInfo(phoneNumber);
|
|
||||||
_navigateToCallPage(context); // Navigate immediately after call initiation
|
|
||||||
>>>>>>> 3e2be8a (feat: fetch contact in makeGsmCall to show it in call)
|
|
||||||
=======
|
|
||||||
_navigateToCallPage(context);
|
|
||||||
>>>>>>> c2c646a (feat: give parameters to callPage to avoid fetching when possible)
|
|
||||||
=======
|
|
||||||
_handleCallState(context, "dialing");
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
=======
|
|
||||||
_handleCallState("dialing");
|
|
||||||
>>>>>>> b3c8bf7 (feat: merge call_service with callNotifications changes)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("CallService: Error making call: $e");
|
print("CallService: Error making call: $e");
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
@ -618,15 +251,7 @@ class CallService {
|
|||||||
SnackBar(content: Text("Failed to end call")),
|
SnackBar(content: Text("Failed to end call")),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
<<<<<<< HEAD
|
|
||||||
<<<<<<< HEAD
|
|
||||||
_closeCallPage();
|
_closeCallPage();
|
||||||
=======
|
|
||||||
_closeCallPage(context);
|
|
||||||
>>>>>>> 9e76148 (fix: no screen stacking when making calls)
|
|
||||||
=======
|
|
||||||
_closeCallPage();
|
|
||||||
>>>>>>> b3c8bf7 (feat: merge call_service with callNotifications changes)
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("CallService: Error hanging up call: $e");
|
print("CallService: Error hanging up call: $e");
|
||||||
|
Loading…
Reference in New Issue
Block a user