Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/connection_node'
Browse files Browse the repository at this point in the history
  • Loading branch information
YuliaGrigorieva committed May 29, 2024
2 parents 05a159d + 1dd2cf6 commit 01bcbf8
Show file tree
Hide file tree
Showing 24 changed files with 447 additions and 206 deletions.
2 changes: 1 addition & 1 deletion audio_call/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.voximplant.flutter.audiocall"
// set minSdk to 21 since multidex is enabled by default since this version
minSdkVersion flutter.minSdkVersion
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
76 changes: 41 additions & 35 deletions audio_call/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ PODS:
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Logger (~> 7.8)
- FirebaseCoreInternal (10.8.0):
- FirebaseCoreInternal (10.25.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseInstallations (10.8.0):
- FirebaseInstallations (10.25.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
Expand All @@ -36,46 +36,52 @@ PODS:
- Flutter
- flutter_local_notifications (0.0.1):
- Flutter
- flutter_voximplant (3.8.0):
- flutter_voximplant (3.11.1):
- Flutter
- VoxImplantSDK (= 2.46.12)
- GoogleDataTransport (9.2.2):
- VoxImplantSDK (= 2.52.0)
- GoogleDataTransport (9.4.1):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- nanopb (< 2.30911.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/AppDelegateSwizzler (7.11.1):
- GoogleUtilities/AppDelegateSwizzler (7.13.3):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.11.1):
- GoogleUtilities/Privacy
- GoogleUtilities/Environment (7.13.3):
- GoogleUtilities/Privacy
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.11.1):
- GoogleUtilities/Logger (7.13.3):
- GoogleUtilities/Environment
- GoogleUtilities/Network (7.11.1):
- GoogleUtilities/Privacy
- GoogleUtilities/Network (7.13.3):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Privacy
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.11.1)"
- GoogleUtilities/Reachability (7.11.1):
- "GoogleUtilities/NSData+zlib (7.13.3)":
- GoogleUtilities/Privacy
- GoogleUtilities/Privacy (7.13.3)
- GoogleUtilities/Reachability (7.13.3):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (7.11.1):
- GoogleUtilities/Privacy
- GoogleUtilities/UserDefaults (7.13.3):
- GoogleUtilities/Logger
- nanopb (2.30909.0):
- nanopb/decode (= 2.30909.0)
- nanopb/encode (= 2.30909.0)
- nanopb/decode (2.30909.0)
- nanopb/encode (2.30909.0)
- GoogleUtilities/Privacy
- nanopb (2.30909.1):
- nanopb/decode (= 2.30909.1)
- nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1)
- permission_handler_apple (9.0.4):
- Flutter
- PromisesObjC (2.2.0)
- PromisesObjC (2.4.0)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- VoxImplantSDK (2.46.12):
- VoxImplantSDK/Core (= 2.46.12)
- VoxImplantSDK/Core (2.46.12):
- VoxImplantWebRTC (= 93.0.0)
- VoxImplantWebRTC (93.0.0)
- VoxImplantSDK (2.52.0):
- VoxImplantWebRTC (= 112.0.0)
- VoxImplantWebRTC (112.0.0)

DEPENDENCIES:
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
Expand Down Expand Up @@ -124,22 +130,22 @@ SPEC CHECKSUMS:
firebase_core: 58542d7399889ebdbb034baa72d081e54c5c814d
firebase_messaging: 01a8db2962f81ea190d08db767aba2e7e805e647
FirebaseCore: fa80ad16a62d52f67274b5b88304c3a318bbf9a4
FirebaseCoreInternal: fa2899eb1f340054858d289e5a0fb935a0a74e52
FirebaseInstallations: b2a05a3fe707df764345d68685534d07d0664af3
FirebaseCoreInternal: 910a81992c33715fec9263ca7381d59ab3a750b7
FirebaseInstallations: 91950fe859846fff0fbd296180909dd273103b09
FirebaseMessaging: fd93783258c53ae5cdb9b41bf0c51606a677f2d5
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_callkit_voximplant: 9e1128135757ea8a21ae7bbc06ff4a37e906ccc5
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
flutter_voximplant: 40c3110cc9943047f36fb9847f8803350237480a
GoogleDataTransport: 8378d1fa8ac49753ea6ce70d65a7cb70ce5f66e6
GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
flutter_voximplant: f8a0e7ce1af495fe6ecd53233640df972952f43d
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472
VoxImplantSDK: 577259786bc3da6ed3cf3d4ee1a8e08245c19ce6
VoxImplantWebRTC: 8ddd8a63d0c20afa604fec22a2552c32b0371974
VoxImplantSDK: fbc3bfc64cedc98545758717c8395a64edc091bf
VoxImplantWebRTC: 2256a8b9157cc46e1a4c8e0ed5816c5c672d7d5d

PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011
PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048

COCOAPODS: 1.15.0
COCOAPODS: 1.15.2
37 changes: 15 additions & 22 deletions audio_call/lib/screens/active_call/bloc/active_call_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,18 @@ class ActiveCallBloc extends Bloc<ActiveCallEvent, ActiveCallState> {
}

Future<void> _readyToStartCall(
ReadyToStartCallEvent event,
Emitter<ActiveCallState> emit) async {
ReadyToStartCallEvent event, Emitter<ActiveCallState> emit) async {
_callStateSubscription = _callService.subscribeToCallEvents().listen(
(event) {
(event) {
add(CallChangedEvent(event));
},
);
_audioDeviceSubscription =
_callService.subscribeToAudioDeviceEvents().listen(
(event) {
add(AudioDevicesChanged(event));
},
);
(event) {
add(AudioDevicesChanged(event));
},
);
try {
if (_isIncoming) {
if (Platform.isAndroid) {
Expand Down Expand Up @@ -96,8 +95,7 @@ class ActiveCallBloc extends Bloc<ActiveCallEvent, ActiveCallState> {
}

Future<void> _handleCallChanged(
CallChangedEvent event,
Emitter<ActiveCallState> emit) async {
CallChangedEvent event, Emitter<ActiveCallState> emit) async {
CallEvent callEvent = event.event;

if (callEvent is OnFailedCallEvent) {
Expand Down Expand Up @@ -145,38 +143,33 @@ class ActiveCallBloc extends Bloc<ActiveCallEvent, ActiveCallState> {
}

Future<void> _holdCall(
HoldPressedEvent event,
Emitter<ActiveCallState> emit) async {
Platform.isIOS
HoldPressedEvent event, Emitter<ActiveCallState> emit) async {
Platform.isIOS
? await _callKitService?.holdCall(event.hold)
: await _callService.holdCall(hold: event.hold);
}

Future<void> _muteAudio(
MutePressedEvent event,
Emitter<ActiveCallState> emit) async {
Platform.isIOS
MutePressedEvent event, Emitter<ActiveCallState> emit) async {
Platform.isIOS
? await _callKitService?.muteCall(event.mute)
: await _callService.muteCall(mute: event.mute);
}

Future<void> _hangupCall(
HangupPressedEvent event,
Emitter<ActiveCallState> emit) async {
Platform.isIOS
HangupPressedEvent event, Emitter<ActiveCallState> emit) async {
Platform.isIOS
? await _callKitService?.endCall()
: await _callService.hangup();
}

Future<void> _selectAudioDevice(
SelectAudioDevicePressedEvent event,
Future<void> _selectAudioDevice(SelectAudioDevicePressedEvent event,
Emitter<ActiveCallState> emit) async {
await _callService.selectAudioDevice(device: event.device);
}

Future<void> _handleAudioDevicesChanged(
AudioDevicesChanged event,
Emitter<ActiveCallState> emit) async {
AudioDevicesChanged event, Emitter<ActiveCallState> emit) async {
AudioDeviceEvent audioEvent = event.event;
if (audioEvent is OnActiveAudioDeviceChanged) {
emit(state.copyWith(activeAudioDevice: audioEvent.device));
Expand Down
14 changes: 8 additions & 6 deletions audio_call/lib/screens/login/bloc/login_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
}

Future<void> _loadLastUser(
LoadLastUser event,
Emitter<LoginState> emit) async {
LoadLastUser event, Emitter<LoginState> emit) async {
// TODO(yulia)
// if (Platform.isAndroid &&
// await NotificationHelper().didNotificationLaunchApp()) {
Expand All @@ -35,23 +34,26 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> {
await _authService.loginWithAccessToken();
emit(LoginSuccess());
} on VIException catch (e) {
emit(LoginFailure(errorCode: e.code, errorDescription: e.message ?? 'Unknown error'));
emit(LoginFailure(
errorCode: e.code, errorDescription: e.message ?? 'Unknown error'));
}
}
}

Future<void> _loginWithPassword(
LoginWithPassword event,
Emitter<LoginState> emit) async {
LoginWithPassword event, Emitter<LoginState> emit) async {
emit(LoginInProgress());
VINode node = VINode.values.byName(event.node);
try {
await _authService.loginWithPassword(
node,
'${event.username}.voximplant.com',
event.password,
);
emit(LoginSuccess());
} on VIException catch (e) {
emit(LoginFailure(errorCode: e.code, errorDescription: e.message ?? 'Unknown error'));
emit(LoginFailure(
errorCode: e.code, errorDescription: e.message ?? 'Unknown error'));
}
}
}
10 changes: 6 additions & 4 deletions audio_call/lib/screens/login/bloc/login_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ abstract class LoginEvent extends Equatable {
List<Object> get props => [];
}

class LoadLastUser extends LoginEvent { }
class LoadLastUser extends LoginEvent {}

class LoginWithPassword extends LoginEvent {
final String username;
final String password;
final String node;

const LoginWithPassword({required this.username, required this.password});
const LoginWithPassword(
{required this.username, required this.password, required this.node});

@override
List<Object> get props => [username, password];
List<Object> get props => [username, password, node];

@override
String toString() => 'LoginWithPassword: '
'username: $username, password: *****';
}

class Dispose extends LoginEvent { }
class Dispose extends LoginEvent {}
42 changes: 41 additions & 1 deletion audio_call/lib/screens/login/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ import 'package:audio_call/widgets/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

const List<String> nodes = <String>[
'Node1',
'Node2',
'Node3',
'Node4',
'Node5',
'Node6',
'Node7',
'Node8',
'Node9',
'Node10'
];

class LoginPage extends StatefulWidget {
static const routeName = '/login';

Expand All @@ -22,6 +35,8 @@ class _LoginPageState extends State<LoginPage> {

bool _isUsernameValid = true;
bool _isPasswordValid = true;
bool _isNodeSelected = false;
String? _node;

@override
void initState() {
Expand All @@ -39,12 +54,18 @@ class _LoginPageState extends State<LoginPage> {

@override
Widget build(BuildContext context) {
void login() => _bloc.add(
void login() {
final node = _node;
if (node != null) {
_bloc.add(
LoginWithPassword(
username: _usernameController.text,
password: _passwordController.text,
node: node,
),
);
}
}

void handleLoginFailed(String errorCode, String errorDescription) {
if (errorCode == 'ERROR_INVALID_USERNAME') {
Expand Down Expand Up @@ -92,6 +113,25 @@ class _LoginPageState extends State<LoginPage> {
validator: (_) =>
_isPasswordValid ? null : 'Invalid password',
),
_isNodeSelected
? Container()
: const Padding(
padding: EdgeInsets.only(top: 5, left: 20),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"Connection Node is required",
style: TextStyle(color: VoximplantColors.red),
))),
Widgets.dropdown(
items: nodes,
onChange: (String? node) {
setState(() {
_isNodeSelected = true;
_node = node;
});
},
value: _node),
Widgets.maxWidthRaisedButton(
text: 'Log in',
onPressed: login,
Expand Down
Loading

0 comments on commit 01bcbf8

Please sign in to comment.