fixe scan in OmemoActivities
This commit is contained in:
parent
9a76aff8f9
commit
89bfae14b1
|
@ -1,6 +1,7 @@
|
||||||
package eu.siacs.conversations.ui;
|
package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
import android.databinding.DataBindingUtil;
|
import android.databinding.DataBindingUtil;
|
||||||
|
import android.net.Uri;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
@ -73,7 +74,7 @@ public abstract class OmemoActivity extends XmppActivity {
|
||||||
copyOmemoFingerprint(mSelectedFingerprint);
|
copyOmemoFingerprint(mSelectedFingerprint);
|
||||||
break;
|
break;
|
||||||
case R.id.verify_scan:
|
case R.id.verify_scan:
|
||||||
//new IntentIntegrator(this).initiateScan(Arrays.asList("AZTEC","QR_CODE"));
|
ScanActivity.scan(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -81,16 +82,16 @@ public abstract class OmemoActivity extends XmppActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||||
/*IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
|
super.onActivityResult(requestCode, requestCode, intent);
|
||||||
if (scanResult != null && scanResult.getFormatName() != null) {
|
if (requestCode == ScanActivity.REQUEST_SCAN_QR_CODE && resultCode == RESULT_OK) {
|
||||||
String data = scanResult.getContents();
|
String result = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
|
||||||
XmppUri uri = new XmppUri(data);
|
XmppUri uri = new XmppUri(result == null ? "" : result);
|
||||||
if (xmppConnectionServiceBound) {
|
if (xmppConnectionServiceBound) {
|
||||||
processFingerprintVerification(uri);
|
processFingerprintVerification(uri);
|
||||||
} else {
|
} else {
|
||||||
this.mPendingFingerprintVerificationUri = uri;
|
this.mPendingFingerprintVerificationUri = uri;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void processFingerprintVerification(XmppUri uri);
|
protected abstract void processFingerprintVerification(XmppUri uri);
|
||||||
|
@ -243,4 +244,9 @@ public abstract class OmemoActivity extends XmppActivity {
|
||||||
builder.setPositiveButton(R.string.ok, null);
|
builder.setPositiveButton(R.string.ok, null);
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
||||||
|
ScanActivity.onRequestPermissionResult(this, requestCode, grantResults);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ import android.view.TextureView;
|
||||||
import android.view.TextureView.SurfaceTextureListener;
|
import android.view.TextureView.SurfaceTextureListener;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
import eu.siacs.conversations.Config;
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
@ -67,6 +68,9 @@ import eu.siacs.conversations.ui.widget.ScannerView;
|
||||||
public final class ScanActivity extends Activity implements SurfaceTextureListener, ActivityCompat.OnRequestPermissionsResultCallback {
|
public final class ScanActivity extends Activity implements SurfaceTextureListener, ActivityCompat.OnRequestPermissionsResultCallback {
|
||||||
public static final String INTENT_EXTRA_RESULT = "result";
|
public static final String INTENT_EXTRA_RESULT = "result";
|
||||||
|
|
||||||
|
public static final int REQUEST_SCAN_QR_CODE = 0x0987;
|
||||||
|
private static final int REQUEST_CAMERA_PERMISSIONS_TO_SCAN = 0x6789;
|
||||||
|
|
||||||
private static final long VIBRATE_DURATION = 50L;
|
private static final long VIBRATE_DURATION = 50L;
|
||||||
private static final long AUTO_FOCUS_INTERVAL_MS = 2500L;
|
private static final long AUTO_FOCUS_INTERVAL_MS = 2500L;
|
||||||
private static boolean DISABLE_CONTINUOUS_AUTOFOCUS = Build.MODEL.equals("GT-I9100") // Galaxy S2
|
private static boolean DISABLE_CONTINUOUS_AUTOFOCUS = Build.MODEL.equals("GT-I9100") // Galaxy S2
|
||||||
|
@ -263,7 +267,30 @@ public final class ScanActivity extends Activity implements SurfaceTextureListen
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postFinish() {
|
private void postFinish() {
|
||||||
new Handler().postDelayed(() -> finish(), 50);
|
new Handler().postDelayed(this::finish, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void scan(Activity activity) {
|
||||||
|
if (ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
Intent intent = new Intent(activity, ScanActivity.class);
|
||||||
|
activity.startActivityForResult(intent, REQUEST_SCAN_QR_CODE);
|
||||||
|
} else {
|
||||||
|
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSIONS_TO_SCAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onRequestPermissionResult(Activity activity, int requestCode, int[] grantResults) {
|
||||||
|
if (requestCode != REQUEST_CAMERA_PERMISSIONS_TO_SCAN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (grantResults.length > 0) {
|
||||||
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
scan(activity);
|
||||||
|
} else {
|
||||||
|
Toast.makeText(activity, R.string.qr_code_scanner_needs_access_to_camera, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class AutoFocusRunnable implements Runnable {
|
private final class AutoFocusRunnable implements Runnable {
|
||||||
|
|
|
@ -133,6 +133,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
|
||||||
if (hasPendingKeyFetches()) {
|
if (hasPendingKeyFetches()) {
|
||||||
Toast.makeText(this, R.string.please_wait_for_keys_to_be_fetched, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.please_wait_for_keys_to_be_fetched, Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
|
ScanActivity.scan(this);
|
||||||
//new IntentIntegrator(this).initiateScan(Arrays.asList("AZTEC","QR_CODE"));
|
//new IntentIntegrator(this).initiateScan(Arrays.asList("AZTEC","QR_CODE"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue