Added setting for video preview
This commit is contained in:
parent
2cb8994b98
commit
b28b604bb7
9 changed files with 71 additions and 30 deletions
|
@ -39,6 +39,7 @@ import org.linphone.core.Call;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.CoreListenerStub;
|
import org.linphone.core.CoreListenerStub;
|
||||||
import org.linphone.core.tools.Log;
|
import org.linphone.core.tools.Log;
|
||||||
|
import org.linphone.settings.LinphonePreferences;
|
||||||
import org.linphone.views.AddressAware;
|
import org.linphone.views.AddressAware;
|
||||||
import org.linphone.views.AddressText;
|
import org.linphone.views.AddressText;
|
||||||
import org.linphone.views.CallButton;
|
import org.linphone.views.CallButton;
|
||||||
|
@ -188,28 +189,27 @@ public class DialerActivity extends MainActivity implements AddressText.AddressC
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableVideoPreviewIfTablet(boolean enable) {
|
private void enableVideoPreviewIfTablet(boolean enable) {
|
||||||
if (isTablet()
|
Core core = LinphoneManager.getCore();
|
||||||
&& getResources().getBoolean(R.bool.show_camera_preview_on_dialer_on_tablets)) {
|
TextureView preview = findViewById(R.id.video_preview);
|
||||||
Core core = LinphoneManager.getCore();
|
if (preview != null && core != null) {
|
||||||
if (enable) {
|
if (enable && isTablet() && LinphonePreferences.instance().isVideoPreviewEnabled()) {
|
||||||
TextureView preview = findViewById(R.id.video_preview);
|
preview.setVisibility(View.VISIBLE);
|
||||||
if (preview != null && core != null) {
|
core.setNativePreviewWindowId(preview);
|
||||||
preview.setVisibility(View.VISIBLE);
|
core.enableVideoPreview(true);
|
||||||
core.setNativePreviewWindowId(preview);
|
|
||||||
core.enableVideoPreview(true);
|
ImageView changeCamera = findViewById(R.id.video_preview_change_camera);
|
||||||
ImageView changeCamera = findViewById(R.id.video_preview_change_camera);
|
if (changeCamera != null && core.getVideoDevicesList().length > 1) {
|
||||||
if (changeCamera != null && core.getVideoDevicesList().length > 1) {
|
changeCamera.setVisibility(View.VISIBLE);
|
||||||
changeCamera.setVisibility(View.VISIBLE);
|
changeCamera.setOnClickListener(
|
||||||
changeCamera.setOnClickListener(
|
new View.OnClickListener() {
|
||||||
new View.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(View v) {
|
||||||
public void onClick(View v) {
|
LinphoneManager.getCallManager().switchCamera();
|
||||||
LinphoneManager.getCallManager().switchCamera();
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
preview.setVisibility(View.GONE);
|
||||||
core.setNativePreviewWindowId(null);
|
core.setNativePreviewWindowId(null);
|
||||||
core.enableVideoPreview(false);
|
core.enableVideoPreview(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,19 +71,22 @@ public class QrCodeConfigurationAssistantActivity extends AssistantActivity {
|
||||||
if (core != null && core.getVideoDevicesList().length > 1) {
|
if (core != null && core.getVideoDevicesList().length > 1) {
|
||||||
changeCamera.setVisibility(View.VISIBLE);
|
changeCamera.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setBackCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onResume() {
|
||||||
super.onStart();
|
super.onResume();
|
||||||
setBackCamera();
|
|
||||||
launchQrcodeReader();
|
launchQrcodeReader();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onPause() {
|
||||||
super.onDestroy();
|
|
||||||
enableQrcodeReader(false);
|
enableQrcodeReader(false);
|
||||||
|
|
||||||
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableQrcodeReader(boolean enable) {
|
private void enableQrcodeReader(boolean enable) {
|
||||||
|
|
|
@ -1135,4 +1135,12 @@ public class LinphonePreferences {
|
||||||
public void setOpenH264CodecDownloadEnabled(boolean enable) {
|
public void setOpenH264CodecDownloadEnabled(boolean enable) {
|
||||||
getConfig().setBool("app", "open_h264_download_enabled", enable);
|
getConfig().setBool("app", "open_h264_download_enabled", enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isVideoPreviewEnabled() {
|
||||||
|
return isVideoEnabled() && getConfig().getBool("app", "video_preview", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoPreviewEnabled(boolean enabled) {
|
||||||
|
getConfig().setBool("app", "video_preview", enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
private View mRootView;
|
private View mRootView;
|
||||||
private LinphonePreferences mPrefs;
|
private LinphonePreferences mPrefs;
|
||||||
|
|
||||||
private SwitchSetting mEnable, mAutoInitiate, mAutoAccept, mOverlay;
|
private SwitchSetting mEnable, mAutoInitiate, mAutoAccept, mOverlay, mVideoPreview;
|
||||||
private ListSetting mPreset, mSize, mFps;
|
private ListSetting mPreset, mSize, mFps;
|
||||||
private TextSetting mBandwidth;
|
private TextSetting mBandwidth;
|
||||||
private LinearLayout mVideoCodecs;
|
private LinearLayout mVideoCodecs;
|
||||||
|
@ -75,6 +75,8 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
private void loadSettings() {
|
private void loadSettings() {
|
||||||
mEnable = mRootView.findViewById(R.id.pref_video_enable);
|
mEnable = mRootView.findViewById(R.id.pref_video_enable);
|
||||||
|
|
||||||
|
mVideoPreview = mRootView.findViewById(R.id.pref_video_preview);
|
||||||
|
|
||||||
mAutoInitiate = mRootView.findViewById(R.id.pref_video_initiate_call_with_video);
|
mAutoInitiate = mRootView.findViewById(R.id.pref_video_initiate_call_with_video);
|
||||||
|
|
||||||
mAutoAccept = mRootView.findViewById(R.id.pref_video_automatically_accept_video);
|
mAutoAccept = mRootView.findViewById(R.id.pref_video_automatically_accept_video);
|
||||||
|
@ -103,6 +105,7 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
public void onBoolValueChanged(boolean newValue) {
|
public void onBoolValueChanged(boolean newValue) {
|
||||||
mPrefs.enableVideo(newValue);
|
mPrefs.enableVideo(newValue);
|
||||||
if (!newValue) {
|
if (!newValue) {
|
||||||
|
mVideoPreview.setChecked(false);
|
||||||
mAutoAccept.setChecked(false);
|
mAutoAccept.setChecked(false);
|
||||||
mAutoInitiate.setChecked(false);
|
mAutoInitiate.setChecked(false);
|
||||||
}
|
}
|
||||||
|
@ -110,6 +113,14 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mVideoPreview.setListener(
|
||||||
|
new SettingListenerBase() {
|
||||||
|
@Override
|
||||||
|
public void onBoolValueChanged(boolean newValue) {
|
||||||
|
mPrefs.setVideoPreviewEnabled(newValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mAutoInitiate.setListener(
|
mAutoInitiate.setListener(
|
||||||
new SettingListenerBase() {
|
new SettingListenerBase() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -185,6 +196,8 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
mEnable.setChecked(mPrefs.isVideoEnabled());
|
mEnable.setChecked(mPrefs.isVideoEnabled());
|
||||||
updateVideoSettingsVisibility(mPrefs.isVideoEnabled());
|
updateVideoSettingsVisibility(mPrefs.isVideoEnabled());
|
||||||
|
|
||||||
|
mVideoPreview.setChecked(mPrefs.isVideoPreviewEnabled());
|
||||||
|
|
||||||
mAutoInitiate.setChecked(mPrefs.shouldInitiateVideoCall());
|
mAutoInitiate.setChecked(mPrefs.shouldInitiateVideoCall());
|
||||||
|
|
||||||
mAutoAccept.setChecked(mPrefs.shouldAutomaticallyAcceptVideoRequests());
|
mAutoAccept.setChecked(mPrefs.shouldAutomaticallyAcceptVideoRequests());
|
||||||
|
@ -265,6 +278,13 @@ public class VideoSettingsFragment extends SettingsFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVideoSettingsVisibility(boolean show) {
|
private void updateVideoSettingsVisibility(boolean show) {
|
||||||
|
mVideoPreview.setVisibility(
|
||||||
|
show
|
||||||
|
&& getResources().getBoolean(R.bool.isTablet)
|
||||||
|
&& getResources()
|
||||||
|
.getBoolean(R.bool.show_camera_preview_on_dialer_on_tablets)
|
||||||
|
? View.VISIBLE
|
||||||
|
: View.GONE);
|
||||||
mAutoInitiate.setVisibility(show ? View.VISIBLE : View.GONE);
|
mAutoInitiate.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||||
mAutoAccept.setVisibility(show ? View.VISIBLE : View.GONE);
|
mAutoAccept.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||||
mOverlay.setVisibility(show ? View.VISIBLE : View.GONE);
|
mOverlay.setVisibility(show ? View.VISIBLE : View.GONE);
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
android:id="@+id/video_preview"
|
android:id="@+id/video_preview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
android:id="@+id/video_preview"
|
android:id="@+id/video_preview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|
|
@ -18,12 +18,14 @@
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/black_color">
|
||||||
|
|
||||||
<TextureView
|
<TextureView
|
||||||
android:id="@+id/qr_code_capture_texture"
|
android:id="@+id/qr_code_capture_texture"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent"
|
||||||
|
android:layout_centerInParent="true"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/qr_code_capture_change_camera"
|
android:id="@+id/qr_code_capture_change_camera"
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
linphone:title="@string/pref_video_enable_title" />
|
linphone:title="@string/pref_video_enable_title" />
|
||||||
|
|
||||||
|
<org.linphone.settings.widget.SwitchSetting
|
||||||
|
android:id="@+id/pref_video_preview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
linphone:title="@string/pref_preview_video" />
|
||||||
|
|
||||||
<org.linphone.settings.widget.SwitchSetting
|
<org.linphone.settings.widget.SwitchSetting
|
||||||
android:id="@+id/pref_video_initiate_call_with_video"
|
android:id="@+id/pref_video_initiate_call_with_video"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -395,7 +395,7 @@
|
||||||
</string-array>
|
</string-array>
|
||||||
<string name="pref_none">None</string>
|
<string name="pref_none">None</string>
|
||||||
<string name="pref_preferences_title">Preferences</string>
|
<string name="pref_preferences_title">Preferences</string>
|
||||||
<string name="pref_video_enable_title">Enable Video</string>
|
<string name="pref_video_enable_title">Enable video</string>
|
||||||
|
|
||||||
<!-- Audio settings -->
|
<!-- Audio settings -->
|
||||||
<string name="pref_audio_title">Audio</string>
|
<string name="pref_audio_title">Audio</string>
|
||||||
|
@ -425,7 +425,7 @@
|
||||||
<string name="pref_video_preset">Video preset</string>
|
<string name="pref_video_preset">Video preset</string>
|
||||||
<string name="pref_preferred_video_size">Preferred video size</string>
|
<string name="pref_preferred_video_size">Preferred video size</string>
|
||||||
<string name="pref_preferred_fps">Preferred FPS</string>
|
<string name="pref_preferred_fps">Preferred FPS</string>
|
||||||
|
<string name="pref_preview_video">Display camera preview on dialer</string>
|
||||||
<string name="pref_bandwidth_limit">Bandwidth limit in kbits/s</string>
|
<string name="pref_bandwidth_limit">Bandwidth limit in kbits/s</string>
|
||||||
<string name="pref_video_codecs_title">Codecs</string>
|
<string name="pref_video_codecs_title">Codecs</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue