Merge branch 'dev_qrcode' into feature/qrcode_integration
# Conflicts: # app/src/main/AndroidManifest.xml # app/src/main/java/org/linphone/assistant/AssistantFragmentsEnum.java # res/layout/video.xml # src/android/org/linphone/LinphoneManager.java # src/android/org/linphone/assistant/AssistantActivity.java # src/android/org/linphone/assistant/RemoteProvisioningActivity.java # src/android/org/linphone/assistant/RemoteProvisioningFragment.java # src/android/org/linphone/assistant/WelcomeFragment.java # submodules/bcmatroska2 # submodules/belcard # submodules/cmake-builder # submodules/externals/openh264 # submodules/externals/zxing-cpp # submodules/linphone # submodules/mediastreamer2 # submodules/oRTP
This commit is contained in:
commit
04207ebcef
13 changed files with 246 additions and 22 deletions
|
@ -47,6 +47,7 @@
|
|||
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
android:largeScreens="true"
|
||||
|
|
|
@ -1450,6 +1450,9 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
@Override
|
||||
public void onChatRoomStateChanged(Core lc, ChatRoom cr, ChatRoom.State state) {}
|
||||
|
||||
@Override
|
||||
public void onQrcodeFound(Core lc, String result) {}
|
||||
|
||||
public void onCallEncryptionChanged(
|
||||
Core lc, Call call, boolean encrypted, String authenticationToken) {}
|
||||
|
||||
|
@ -2017,8 +2020,6 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
}
|
||||
}
|
||||
|
||||
public void onQrcodeFound(Core lc, String something) {}
|
||||
|
||||
public interface AddressType {
|
||||
CharSequence getText();
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
@ -85,6 +86,8 @@ public class AssistantActivity extends Activity
|
|||
ActivityCompat.OnRequestPermissionsResultCallback,
|
||||
AccountCreatorListener {
|
||||
private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 201;
|
||||
private static final int PERMISSIONS_REQUEST_CAMERA = 202;
|
||||
private static final int PERMISSIONS_ENABLED_CAMERA = 203;
|
||||
private static AssistantActivity instance;
|
||||
public DialPlan country;
|
||||
public String phone_number;
|
||||
|
@ -334,6 +337,8 @@ public class AssistantActivity extends Activity
|
|||
} else {
|
||||
displayCreateAccount();
|
||||
}
|
||||
} else if (currentFragment == AssistantFragmentsEnum.QRCODE_READER) {
|
||||
displayRemoteProvisioning("");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,7 +352,12 @@ public class AssistantActivity extends Activity
|
|||
}
|
||||
|
||||
public void checkAndRequestAudioPermission() {
|
||||
checkAndRequestPermission(Manifest.permission.RECORD_AUDIO, 0);
|
||||
checkAndRequestPermission(
|
||||
Manifest.permission.RECORD_AUDIO, PERMISSIONS_REQUEST_RECORD_AUDIO);
|
||||
}
|
||||
|
||||
public void checkAndRequestVideoPermission() {
|
||||
checkAndRequestPermission(Manifest.permission.CAMERA, PERMISSIONS_REQUEST_CAMERA);
|
||||
}
|
||||
|
||||
public void checkAndRequestPermission(String permission, int result) {
|
||||
|
@ -371,7 +381,7 @@ public class AssistantActivity extends Activity
|
|||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(
|
||||
int requestCode, String[] permissions, int[] grantResults) {
|
||||
int requestCode, String[] permissions, final int[] grantResults) {
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
Log.i(
|
||||
"[Permission] "
|
||||
|
@ -382,12 +392,25 @@ public class AssistantActivity extends Activity
|
|||
: "denied"));
|
||||
}
|
||||
|
||||
if (requestCode == PERMISSIONS_REQUEST_RECORD_AUDIO) {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
launchEchoCancellerCalibration(true);
|
||||
} else {
|
||||
isEchoCalibrationFinished();
|
||||
}
|
||||
switch (requestCode) {
|
||||
case PERMISSIONS_REQUEST_CAMERA:
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
displayQRCodeReader();
|
||||
}
|
||||
break;
|
||||
case PERMISSIONS_REQUEST_RECORD_AUDIO:
|
||||
LinphoneUtils.dispatchOnUIThread(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
launchEchoCancellerCalibration(true);
|
||||
} else {
|
||||
isEchoCalibrationFinished();
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -543,13 +566,28 @@ public class AssistantActivity extends Activity
|
|||
back.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void displayRemoteProvisioning() {
|
||||
public void displayRemoteProvisioning(String url) {
|
||||
fragment = new RemoteProvisioningFragment();
|
||||
Bundle extra = new Bundle();
|
||||
extra.putString("RemoteUrl", url);
|
||||
fragment.setArguments(extra);
|
||||
changeFragment(fragment);
|
||||
currentFragment = AssistantFragmentsEnum.REMOTE_PROVISIONING;
|
||||
back.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void displayQRCodeReader() {
|
||||
if (getPackageManager().checkPermission(Manifest.permission.CAMERA, getPackageName())
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
checkAndRequestVideoPermission();
|
||||
} else {
|
||||
fragment = new QrcodeFragment();
|
||||
changeFragment(fragment);
|
||||
currentFragment = AssistantFragmentsEnum.QRCODE_READER;
|
||||
back.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
public void displayCountryChooser() {
|
||||
fragment = new CountryListFragment();
|
||||
changeFragment(fragment);
|
||||
|
@ -849,6 +887,14 @@ public class AssistantActivity extends Activity
|
|||
return countryListAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
if (currentFragment == AssistantFragmentsEnum.QRCODE_READER) {
|
||||
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class reads a JSON file containing Country-specific phone number description, and allows
|
||||
* to present them into a ListView
|
||||
|
|
|
@ -28,5 +28,6 @@ public enum AssistantFragmentsEnum {
|
|||
LOGIN,
|
||||
REMOTE_PROVISIONING,
|
||||
ECHO_CANCELLER_CALIBRATION,
|
||||
DOWNLOAD_CODEC;
|
||||
DOWNLOAD_CODEC,
|
||||
QRCODE_READER
|
||||
}
|
||||
|
|
143
app/src/main/java/org/linphone/assistant/QrcodeFragment.java
Normal file
143
app/src/main/java/org/linphone/assistant/QrcodeFragment.java
Normal file
|
@ -0,0 +1,143 @@
|
|||
package org.linphone.assistant;
|
||||
|
||||
/*
|
||||
QrcodeFragment.java
|
||||
Copyright (C) 2018 Belledonne Communications, Grenoble, France
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.CoreListenerStub;
|
||||
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
|
||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||
|
||||
public class QrcodeFragment extends Fragment {
|
||||
private SurfaceView mQrcodeView;
|
||||
private CoreListenerStub mListener;
|
||||
private AndroidVideoWindowImpl androidVideoWindowImpl;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.qrcode, container, false);
|
||||
|
||||
mQrcodeView = (SurfaceView) view.findViewById(R.id.qrcodeCaptureSurface);
|
||||
|
||||
mListener =
|
||||
new CoreListenerStub() {
|
||||
@Override
|
||||
public void onQrcodeFound(Core lc, String result) {
|
||||
enableQrcodeReader(false);
|
||||
AssistantActivity.instance().displayRemoteProvisioning(result);
|
||||
}
|
||||
};
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void enableQrcodeReader(boolean enable) {
|
||||
LinphoneManager.getLc().enableQrcodeVideoPreview(enable);
|
||||
LinphoneManager.getLc().enableVideoPreview(enable);
|
||||
if (enable) {
|
||||
LinphoneManager.getLc().addListener(mListener);
|
||||
} else {
|
||||
LinphoneManager.getLc().removeListener(mListener);
|
||||
}
|
||||
}
|
||||
|
||||
private void setBackCamera(boolean useBackCamera) {
|
||||
int camId = 0;
|
||||
AndroidCameraConfiguration.AndroidCamera[] cameras =
|
||||
AndroidCameraConfiguration.retrieveCameras();
|
||||
for (AndroidCameraConfiguration.AndroidCamera androidCamera : cameras) {
|
||||
if (androidCamera.frontFacing == !useBackCamera) camId = androidCamera.id;
|
||||
}
|
||||
String[] devices = LinphoneManager.getLc().getVideoDevicesList();
|
||||
String newDevice = devices[camId];
|
||||
LinphoneManager.getLc().setVideoDevice(newDevice);
|
||||
}
|
||||
|
||||
private void launchQrcodeReader() {
|
||||
setBackCamera(true);
|
||||
|
||||
androidVideoWindowImpl =
|
||||
new AndroidVideoWindowImpl(
|
||||
null,
|
||||
mQrcodeView,
|
||||
new AndroidVideoWindowImpl.VideoWindowListener() {
|
||||
public void onVideoRenderingSurfaceReady(
|
||||
AndroidVideoWindowImpl vw, SurfaceView surface) {}
|
||||
|
||||
public void onVideoRenderingSurfaceDestroyed(
|
||||
AndroidVideoWindowImpl vw) {}
|
||||
|
||||
public void onVideoPreviewSurfaceReady(
|
||||
AndroidVideoWindowImpl vw, SurfaceView surface) {
|
||||
LinphoneManager.getLc()
|
||||
.setNativePreviewWindowId(androidVideoWindowImpl);
|
||||
}
|
||||
|
||||
public void onVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl vw) {}
|
||||
});
|
||||
|
||||
enableQrcodeReader(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
launchQrcodeReader();
|
||||
if (androidVideoWindowImpl != null) {
|
||||
synchronized (androidVideoWindowImpl) {
|
||||
// LinphoneManager.getLc().setNativePreviewWindowId(androidVideoWindowImpl);
|
||||
}
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (androidVideoWindowImpl != null) {
|
||||
synchronized (androidVideoWindowImpl) {
|
||||
// LinphoneManager.getLc().setNativePreviewWindowId(null);
|
||||
}
|
||||
}
|
||||
enableQrcodeReader(false);
|
||||
// setBackCamera(false);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (androidVideoWindowImpl != null) {
|
||||
androidVideoWindowImpl.release();
|
||||
androidVideoWindowImpl = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
|
@ -204,14 +204,8 @@ public class RemoteProvisioningActivity extends Activity {
|
|||
LinphonePreferences.instance().setContext(this); // Needed, else the next call will crash
|
||||
LinphonePreferences.instance().setRemoteProvisioningUrl(configUri);
|
||||
|
||||
mHandler.postDelayed(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LinphoneManager.getInstance().restartCore();
|
||||
}
|
||||
},
|
||||
1000);
|
||||
LinphoneManager.getLc().getConfig().sync();
|
||||
LinphoneManager.getInstance().restartCore();
|
||||
}
|
||||
|
||||
private void goToLinphoneActivity() {
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.linphone.settings.LinphonePreferences;
|
|||
|
||||
public class RemoteProvisioningFragment extends Fragment implements OnClickListener, TextWatcher {
|
||||
private EditText remoteProvisioningUrl;
|
||||
private Button apply;
|
||||
private Button apply, qrcode;
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
|
@ -43,10 +43,16 @@ public class RemoteProvisioningFragment extends Fragment implements OnClickListe
|
|||
|
||||
remoteProvisioningUrl = view.findViewById(R.id.assistant_remote_provisioning_url);
|
||||
remoteProvisioningUrl.addTextChangedListener(this);
|
||||
qrcode = view.findViewById(R.id.assistant_qrcode);
|
||||
qrcode.setOnClickListener(this);
|
||||
apply = view.findViewById(R.id.assistant_apply);
|
||||
apply.setEnabled(false);
|
||||
apply.setOnClickListener(this);
|
||||
|
||||
if (!getArguments().getString("RemoteUrl").isEmpty()) {
|
||||
remoteProvisioningUrl.setText(getArguments().getString("RemoteUrl"));
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -61,6 +67,8 @@ public class RemoteProvisioningFragment extends Fragment implements OnClickListe
|
|||
LinphoneManager.getLc().getConfig().sync();
|
||||
LinphoneManager.getInstance().restartCore();
|
||||
AssistantActivity.instance().setCoreListener();
|
||||
} else if (id == R.id.assistant_qrcode) {
|
||||
AssistantActivity.instance().displayQRCodeReader();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ public class WelcomeFragment extends Fragment implements OnClickListener {
|
|||
} else if (id == R.id.create_account) {
|
||||
AssistantActivity.instance().displayCreateAccount();
|
||||
} else if (id == R.id.remote_provisioning) {
|
||||
AssistantActivity.instance().displayRemoteProvisioning();
|
||||
AssistantActivity.instance().displayRemoteProvisioning("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,5 +59,18 @@
|
|||
android:paddingRight="10dp"
|
||||
android:layout_marginTop="20dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/assistant_qrcode"
|
||||
android:text="@string/assistant_launch_qrcode"
|
||||
android:background="@drawable/assistant_button"
|
||||
android:textColor="@drawable/assistant_button_text_color"
|
||||
style="@style/font8"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingRight="10dp"
|
||||
android:layout_marginTop="20dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
16
app/src/main/res/layout/qrcode.xml
Normal file
16
app/src/main/res/layout/qrcode.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/qrcode_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:screenOrientation="portrait" >
|
||||
|
||||
|
||||
<SurfaceView
|
||||
android:id="@+id/qrcodeCaptureSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -92,6 +92,7 @@
|
|||
<string name="assistant_generic_account">Use SIP account</string>
|
||||
<string name="assistant_remote_provisioning_title">Fetch remote configuration</string>
|
||||
<string name="assistant_fetch_apply">Fetch and apply</string>
|
||||
<string name="assistant_launch_qrcode">QRCode</string>
|
||||
<string name="assistant_login">Login</string>
|
||||
<string name="assistant_ec_calibration">Echo canceler calibration in progress</string>
|
||||
<string name="assistant_remote_provisioning_login">Enter your login</string>
|
||||
|
|
BIN
liblinphone_tester/res/raw/cpim_grammar
Normal file
BIN
liblinphone_tester/res/raw/cpim_grammar
Normal file
Binary file not shown.
BIN
liblinphone_tester/res/raw/vcard_grammar
Normal file
BIN
liblinphone_tester/res/raw/vcard_grammar
Normal file
Binary file not shown.
Loading…
Reference in a new issue