private void initStep(boolean isCameraPreviewStarted) { clearScanIndicatorViews(); mCameraOverlayRoot.removeAllViews(); mCameraOverlayRoot.addView(createCombinedStepCameraOverlay()); //RecognitionSettings settings = buildRecognizerBundle(); reportStepStart(isCameraPreviewStarted); }
@Override public void run() { clearSplashScreen(true); } }, SPLASH_DURATION_NEXT_SIDE);
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar ab = getSupportActionBar(); if (ab != null) { setContentView(R.layout.activity_custom_verification_flow); } catch (InflateException ie) { Throwable cause = ie.getCause(); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); return; } else { Bundle extras = getIntent().getExtras(); if (extras == null) { throw new NullPointerException("CustomVerificationFlowActivity requires recognizer bundle"); initRecognizerView(useLegacyCamera); ViewGroup vgRoot = findViewById(R.id.rootRecognizerView); mSoundPool = new SoundPool.Builder().setMaxStreams(1).setAudioAttributes(audioAttrs).build(); } else { mSoundPool = createOldSoundPool(); if (soundResourceId > 0) { mSoundId = mSoundPool.load(this, soundResourceId, 1); setVolumeControlStream(AudioManager.STREAM_MUSIC);
@Override protected void onResume() { super.onResume(); mActivityState = ActivityState.RESUMED; onGlareStatus(false); clearScanIndicatorViews(); if (mCurrentCombinedSide == CombinedSide.SECOND_SIDE) { // when resume() on recognizer view is called, hard reset is called which resets the combined recognizer to scan first // side again and appropriate UI changes should be performed if the combined recognizer is not // in the initial state mCurrentCombinedSide = CombinedSide.FIRST_SIDE; initStep(false); } else { reportStepStart(false); } if (mRecognizerView != null) { // all activity lifecycle events must be passed on to RecognizerView mRecognizerView.resume(); } }
private void initRecognizerView(boolean forceUseLegacyCamera) { mRecognizerView = findViewById(R.id.recognizerView); mRecognizerBundle.loadFromIntent(getIntent()); mRecognizerView.setRecognizerBundle(mRecognizerBundle); mCameraOverlayRoot.setLayoutParams( new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mCameraOverlayRoot.addView(createCombinedStepCameraOverlay()); setupMetadataCallbacks();
@Override public void onError(Throwable ex) { String defaultDialogTitle = getString(R.string.mb_warning_title); if (ex instanceof CameraResolutionTooSmallException) { Log.e(this, ex, "Camera resolution too low!"); handleError(defaultDialogTitle, getString(R.string.mb_feature_unsupported_device)); } else if (ex instanceof RecognizerError) { Log.e(this, ex, "There was an error starting a native recognizer. Reason: {}", ex.getMessage()); handleError(defaultDialogTitle, getString(R.string.mb_error_initializing)); } else if (ex instanceof UnsatisfiedLinkError) { Log.e(this, ex, "Native library not loaded!"); handleError(defaultDialogTitle, getString(R.string.mb_error_initializing)); } else if (ex instanceof AutoFocusRequiredButNotSupportedException) { Log.e(this, ex, "Autofocus required, but not supported!"); handleError(defaultDialogTitle, getNotSupportedReasonDescription(NotSupportedReason.NO_AUTOFOCUS_CAMERA)); } else if (ex instanceof FeatureNotSupportedException) { handleError(defaultDialogTitle, getNotSupportedReasonDescription(((FeatureNotSupportedException) ex).getReason())); } else if (ex instanceof SecurityException) { Log.e(this, ex, "Camera permission not given!"); handleError(defaultDialogTitle, getString(R.string.mb_camera_not_allowed)); } else { handleError(defaultDialogTitle, getString(R.string.mb_camera_not_ready)); } }
View documentOverlay = getLayoutInflater().inflate(R.layout.id_card_camera_overlay, mRecognizerView, false); if (getSupportActionBar() != null) { setTorchButtonIcon(mTorchOn); mIbTorch.setOnClickListener(new View.OnClickListener() { @Override
private void onScanDoneWithSuccess() { Recognizer recognizer = mRecognizerBundle.getRecognizers()[0]; if (recognizer instanceof CombinedRecognizer) { CombinedRecognizer combinedRecognizer = (CombinedRecognizer) recognizer; if (combinedRecognizer.getCombinedResult().isDocumentDataMatch()) { finishWithResults(); } else { // handle case when scanned sides were from different documents onDocumentSidesNotMatching(); } } }
@Override public void onAutofocusFailed() { clearScanIndicatorViews(); }
@Override public void run() { // clear splash screen and resume scanning (true) clearSplashScreen(true); } }, SPLASH_DURATION_CAMERA_STARTING);
@Override public void run() { clearSplashScreen(true); } }, SPLASH_DURATION_NEXT_SIDE);