Added camera preview on Dialer if device is a tablet (like on iPad)
This commit is contained in:
parent
11f292f835
commit
0cfb7e9503
9 changed files with 115 additions and 20 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -47,6 +47,7 @@ public class DeviceOrientationEventListener extends OrientationEventListener {
|
|||
if (mAlwaysChangingPhoneAngle == degrees) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAlwaysChangingPhoneAngle = degrees;
|
||||
Log.i(
|
||||
"[Orientation Helper] Device orientation changed to "
|
||||
|
|
|
@ -10,6 +10,20 @@
|
|||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/dialer_background" />
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/video_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_preview_change_camera"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_margin="5dp"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/switch_camera"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/dialer"
|
||||
android:layout_width="300dp"
|
||||
|
|
|
@ -10,6 +10,20 @@
|
|||
android:layout_centerHorizontal="true"
|
||||
android:src="@drawable/dialer_background" />
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/video_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/video_preview_change_camera"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_margin="5dp"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/switch_camera"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/dialer"
|
||||
android:layout_width="300dp"
|
||||
|
|
|
@ -16,9 +16,22 @@
|
|||
android:id="@+id/top_bar"
|
||||
layout="@layout/assistant_topbar" />
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/qr_code_capture_texture"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextureView
|
||||
android:id="@+id/qr_code_capture_texture"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/qr_code_capture_change_camera"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_margin="5dp"
|
||||
android:src="@drawable/switch_camera"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
|
||||
<!-- UI config -->
|
||||
<bool name="orientation_portrait_only">false</bool>
|
||||
<bool name="show_statusbar_only_on_dialer">false</bool>
|
||||
<bool name="force_use_of_linphone_friends">false</bool>
|
||||
<bool name="use_linphone_tag">true</bool>
|
||||
<bool name="hide_bottom_bar_on_second_level_views">true</bool>
|
||||
<bool name="use_full_screen_image_splashscreen">false</bool>
|
||||
<bool name="show_camera_preview_on_dialer_on_tablets">true</bool>
|
||||
|
||||
<!-- Time -->
|
||||
<string name="history_date_format" translatable="false">EEE d MMM</string>
|
||||
|
|
Loading…
Reference in a new issue