Some fix for qrcode, but this is crash in zxing lib
This commit is contained in:
parent
93b2aec9b5
commit
1e1db71a00
6 changed files with 54 additions and 21 deletions
|
@ -2,10 +2,11 @@
|
|||
<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:layout_height="match_parent"
|
||||
android:screenOrientation="portrait" >
|
||||
|
||||
|
||||
<org.linphone.mediastream.video.display.GL2JNIView
|
||||
<SurfaceView
|
||||
android:id="@+id/qrcodeCaptureSurface"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
|
|
@ -64,6 +64,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;
|
||||
|
@ -334,11 +335,11 @@ private static AssistantActivity instance;
|
|||
}
|
||||
|
||||
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, 0);
|
||||
checkAndRequestPermission(Manifest.permission.CAMERA, PERMISSIONS_REQUEST_CAMERA);
|
||||
}
|
||||
|
||||
public void checkAndRequestPermission(String permission, int result) {
|
||||
|
@ -361,10 +362,9 @@ private static AssistantActivity instance;
|
|||
|
||||
switch (requestCode) {
|
||||
case PERMISSIONS_REQUEST_CAMERA:
|
||||
|
||||
break;
|
||||
case PERMISSIONS_ENABLED_CAMERA:
|
||||
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
displayQRCodeReader();
|
||||
}
|
||||
break;
|
||||
case PERMISSIONS_REQUEST_RECORD_AUDIO:
|
||||
LinphoneUtils.dispatchOnUIThread(new Runnable() {
|
||||
|
@ -523,10 +523,15 @@ private static AssistantActivity instance;
|
|||
}
|
||||
|
||||
public void displayQRCodeReader() {
|
||||
fragment = new QrcodeFragment();
|
||||
changeFragment(fragment);
|
||||
currentFragment = AssistantFragmentsEnum.QRCODE_READER;
|
||||
back.setVisibility(View.VISIBLE);
|
||||
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() {
|
||||
|
@ -804,6 +809,15 @@ private static AssistantActivity instance;
|
|||
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
|
||||
|
|
|
@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
*/
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.SurfaceView;
|
||||
|
@ -45,7 +46,7 @@ public class QrcodeFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void enableQrcodeReader(boolean enable) {
|
||||
//LinphoneManager.getLc().enableQrcodeVideoPreview(enable);
|
||||
LinphoneManager.getLc().enableQrcodeVideoPreview(enable);
|
||||
LinphoneManager.getLc().enableVideoPreview(enable);
|
||||
}
|
||||
|
||||
|
@ -74,8 +75,7 @@ public class QrcodeFragment extends Fragment {
|
|||
}
|
||||
|
||||
public void onVideoPreviewSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) {
|
||||
mQrcodeView = surface;
|
||||
LinphoneManager.getLc().setNativePreviewWindowId(vw);
|
||||
LinphoneManager.getLc().setNativePreviewWindowId(androidVideoWindowImpl);
|
||||
}
|
||||
|
||||
public void onVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl vw) {
|
||||
|
@ -84,27 +84,43 @@ public class QrcodeFragment extends Fragment {
|
|||
});
|
||||
|
||||
enableQrcodeReader(true);
|
||||
LinphoneManager.getLc().setQrcodeDecodeRect(500,220,280,280);
|
||||
//LinphoneManager.getLc().setQrcodeDecodeRect(500,220,280,280);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
AssistantActivity.instance().checkAndRequestVideoPermission();
|
||||
super.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
launchQrcodeReader();
|
||||
if (androidVideoWindowImpl != null) {
|
||||
synchronized (androidVideoWindowImpl) {
|
||||
LinphoneManager.getLc().setNativePreviewWindowId(androidVideoWindowImpl);
|
||||
}
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
LinphoneManager.getLc().setNativePreviewWindowId(null);
|
||||
androidVideoWindowImpl.release();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.LinphonePreferences;
|
||||
import org.linphone.Manifest;
|
||||
import org.linphone.R;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 451f75275ccb37866f4808c79c62c5f360980d17
|
||||
Subproject commit 6638137dcb941ad2ae51cf9bd36c6407075dc0d5
|
|
@ -1 +1 @@
|
|||
Subproject commit a46973154acaab7ea7aca926e382acff4445bb17
|
||||
Subproject commit bf220563fef1d18fb6a0bd3c388951dede6ecf07
|
Loading…
Reference in a new issue