From fcfb5dd37e3d5dad7425a6e2de5fcabe794952f2 Mon Sep 17 00:00:00 2001 From: Fabrizio Moscon Date: Sat, 3 Jul 2021 17:38:31 +0100 Subject: [PATCH] feat: Android 5.3.1 --- README.md | 2 +- android/build.gradle | 2 +- .../RNTwilioVoice/TwilioVoiceModule.java | 34 +++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a683e596..28dd1c8d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Tested with: The most updated branch is [feat/twilio-android-sdk-5](https://github.com/hoxfon/react-native-twilio-programmable-voice/tree/feat/twilio-android-sdk-5) which is aligned with: -- Android 5.2.0 +- Android 5.3.1 - iOS 5.2.0 It contains breaking changes from `react-native-twilio-programmable-voice` v4, and it will be released as v5. diff --git a/android/build.gradle b/android/build.gradle index bfcab4b8..0e37a582 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -57,7 +57,7 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.twilio:audioswitch:1.1.2' - implementation 'com.twilio:voice-android:5.2.0' + implementation 'com.twilio:voice-android:5.3.1' implementation "com.android.support:appcompat-v7:$supportLibVersion" implementation 'com.facebook.react:react-native:+' implementation 'com.google.firebase:firebase-messaging:19.0.+' diff --git a/android/src/main/java/com/hoxfon/react/RNTwilioVoice/TwilioVoiceModule.java b/android/src/main/java/com/hoxfon/react/RNTwilioVoice/TwilioVoiceModule.java index d965d724..bea19cae 100644 --- a/android/src/main/java/com/hoxfon/react/RNTwilioVoice/TwilioVoiceModule.java +++ b/android/src/main/java/com/hoxfon/react/RNTwilioVoice/TwilioVoiceModule.java @@ -52,6 +52,9 @@ import com.twilio.voice.RegistrationListener; import com.twilio.voice.Voice; +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; import java.util.HashMap; import java.util.Map; import java.util.List; @@ -379,6 +382,34 @@ public void onConnectFailure(@NonNull Call call, CallException error) { toName = ""; activeCallInvite = null; } + + /* + * currentWarnings: existing quality warnings that have not been cleared yet + * previousWarnings: last set of warnings prior to receiving this callback + * + * Example: + * - currentWarnings: { A, B } + * - previousWarnings: { B, C } + * + * Newly raised warnings = currentWarnings - intersection = { A } + * Newly cleared warnings = previousWarnings - intersection = { C } + */ + public void onCallQualityWarningsChanged(@NonNull Call call, + @NonNull Set currentWarnings, + @NonNull Set previousWarnings) { + if (previousWarnings.size() > 1) { + Set intersection = new HashSet<>(currentWarnings); + currentWarnings.removeAll(previousWarnings); + intersection.retainAll(previousWarnings); + previousWarnings.removeAll(intersection); + } + String message = String.format( + Locale.US, + "Newly raised warnings: " + currentWarnings + " Clear warnings " + previousWarnings); + Log.e(TAG, message); + + // TODO send event to JS + } }; } @@ -522,6 +553,9 @@ private void handleStartActivityIntent(Intent intent) { case Constants.ACTION_OPEN_CALL_IN_PROGRESS: // the notification already brings the activity to the top + if (activeCall == null) { + callNotificationManager.removeHangupNotification(getReactApplicationContext()); + } break; default: