diff --git a/CHANGELOG.md b/CHANGELOG.md
index d0ddaa0d1..724d6f019 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ Group changes to describe their impact on the project, as follows:
- Improved device's do not disturb policy compliance
- Added sample application to help developpers getting started with our SDK
- Added picture in picture feature if supported instead of video overlay
+- Added camera preview as dialer's background on tablets
## [4.1.0] - 2019-05-03
diff --git a/app/src/main/java/org/linphone/activities/DialerActivity.java b/app/src/main/java/org/linphone/activities/DialerActivity.java
index e121c348c..a4f4927ca 100644
--- a/app/src/main/java/org/linphone/activities/DialerActivity.java
+++ b/app/src/main/java/org/linphone/activities/DialerActivity.java
@@ -24,6 +24,7 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.LayoutInflater;
+import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -171,16 +172,47 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
}
updateLayout();
+ enableVideoPreviewIfTablet(true);
}
@Override
protected void onPause() {
- super.onPause();
-
+ enableVideoPreviewIfTablet(false);
Core core = LinphoneManager.getCore();
if (core != null) {
core.removeListener(mListener);
}
+
+ super.onPause();
+ }
+
+ private void enableVideoPreviewIfTablet(boolean enable) {
+ if (isTablet()
+ && getResources().getBoolean(R.bool.show_camera_preview_on_dialer_on_tablets)) {
+ Core core = LinphoneManager.getCore();
+ if (enable) {
+ TextureView preview = findViewById(R.id.video_preview);
+ if (preview != null && core != null) {
+ preview.setVisibility(View.VISIBLE);
+ core.setNativePreviewWindowId(preview);
+ core.enableVideoPreview(true);
+ ImageView changeCamera = findViewById(R.id.video_preview_change_camera);
+ if (changeCamera != null && core.getVideoDevicesList().length > 1) {
+ changeCamera.setVisibility(View.VISIBLE);
+ changeCamera.setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ LinphoneManager.getCallManager().switchCamera();
+ }
+ });
+ }
+ }
+ } else {
+ core.setNativePreviewWindowId(null);
+ core.enableVideoPreview(false);
+ }
+ }
}
@Override
diff --git a/app/src/main/java/org/linphone/assistant/QrCodeConfigurationAssistantActivity.java b/app/src/main/java/org/linphone/assistant/QrCodeConfigurationAssistantActivity.java
index f6cafc21b..5e9276921 100644
--- a/app/src/main/java/org/linphone/assistant/QrCodeConfigurationAssistantActivity.java
+++ b/app/src/main/java/org/linphone/assistant/QrCodeConfigurationAssistantActivity.java
@@ -23,6 +23,8 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.TextureView;
+import android.view.View;
+import android.widget.ImageView;
import androidx.annotation.Nullable;
import org.linphone.LinphoneManager;
import org.linphone.R;
@@ -56,6 +58,32 @@ public class QrCodeConfigurationAssistantActivity extends AssistantActivity {
finish();
}
};
+
+ ImageView changeCamera = findViewById(R.id.qr_code_capture_change_camera);
+ changeCamera.setOnClickListener(
+ new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ LinphoneManager.getCallManager().switchCamera();
+ }
+ });
+ Core core = LinphoneManager.getCore();
+ if (core != null && core.getVideoDevicesList().length > 1) {
+ changeCamera.setVisibility(View.VISIBLE);
+ }
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ setBackCamera();
+ launchQrcodeReader();
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ enableQrcodeReader(false);
}
private void enableQrcodeReader(boolean enable) {
@@ -84,6 +112,11 @@ public class QrCodeConfigurationAssistantActivity extends AssistantActivity {
}
String[] devices = core.getVideoDevicesList();
String newDevice = devices[camId];
+
+ String currentDevice = core.getVideoDevice();
+ if (currentDevice != null && currentDevice.equals(newDevice)) {
+ return;
+ }
core.setVideoDevice(newDevice);
}
@@ -92,19 +125,6 @@ public class QrCodeConfigurationAssistantActivity extends AssistantActivity {
if (core == null) return;
core.setNativePreviewWindowId(mQrcodeView);
- setBackCamera();
enableQrcodeReader(true);
}
-
- @Override
- public void onResume() {
- super.onResume();
- launchQrcodeReader();
- }
-
- @Override
- public void onPause() {
- enableQrcodeReader(false);
- super.onPause();
- }
}
diff --git a/app/src/main/java/org/linphone/call/CallManager.java b/app/src/main/java/org/linphone/call/CallManager.java
index 8886785d9..40528807d 100644
--- a/app/src/main/java/org/linphone/call/CallManager.java
+++ b/app/src/main/java/org/linphone/call/CallManager.java
@@ -106,7 +106,7 @@ public class CallManager {
Call call = core.getCurrentCall();
if (call == null) {
- Log.e("[Call Manager] Trying to switch camera while not in call");
+ Log.w("[Call Manager] Trying to switch camera while not in call");
return;
}
call.update(null);
diff --git a/app/src/main/java/org/linphone/utils/DeviceOrientationEventListener.java b/app/src/main/java/org/linphone/utils/DeviceOrientationEventListener.java
index 9ac5dcb66..ff065ebdf 100644
--- a/app/src/main/java/org/linphone/utils/DeviceOrientationEventListener.java
+++ b/app/src/main/java/org/linphone/utils/DeviceOrientationEventListener.java
@@ -47,6 +47,7 @@ public class DeviceOrientationEventListener extends OrientationEventListener {
if (mAlwaysChangingPhoneAngle == degrees) {
return;
}
+
mAlwaysChangingPhoneAngle = degrees;
Log.i(
"[Orientation Helper] Device orientation changed to "
diff --git a/app/src/main/res/layout-sw533dp-land/dialer.xml b/app/src/main/res/layout-sw533dp-land/dialer.xml
index 1e8b77415..5a4758f06 100644
--- a/app/src/main/res/layout-sw533dp-land/dialer.xml
+++ b/app/src/main/res/layout-sw533dp-land/dialer.xml
@@ -10,6 +10,20 @@
android:layout_centerVertical="true"
android:src="@drawable/dialer_background" />
+
+
+
+
+
+
+
+
-
+ android:layout_height="match_parent">
+
+
+
+
+
+
diff --git a/app/src/main/res/values/non_localizable_custom.xml b/app/src/main/res/values/non_localizable_custom.xml
index 8ae43a34e..5ec0535f4 100644
--- a/app/src/main/res/values/non_localizable_custom.xml
+++ b/app/src/main/res/values/non_localizable_custom.xml
@@ -29,11 +29,11 @@
false
- false
false
true
true
false
+ true
EEE d MMM