thegrizzlylabs / geniusscan-sdk-demo

Demo apps for Genius Scan SDK
30 stars 38 forks source link

Provide upgrade instructions when changing the API #51

Closed nordfalk closed 2 years ago

nordfalk commented 2 years ago

I am currently upgrading a lot of libraries in our Android app (Visma Dinero). One of them is your wonderful library, i.e. GeniusScan, which Im upgrading from version 4.1.3 til 4.4.7,

In that process it would be nice with some migration instructions, and some deeper explanations of the changes I need to do than I can find in the changelog (https://geniusscansdk.com/docs/changelog/)

Rigt now my only option is to kinda misuse the geniusscan-sdk-demo repo and look for changes. This is what I found relevant to me: https://github.com/thegrizzlylabs/geniusscan-sdk-demo/commit/4dbb2608edeacac2745509795a9c292878561197 https://github.com/thegrizzlylabs/geniusscan-sdk-demo/commit/0a241a830626e7b23cc0d3a539f1bde82a10d63b and now I'll have to do more or less the same changes in my app, and hope I get evrything right and that Im not overlooking anything, which might happen if I am using any functions that arent in the demo app.

I have also been considering to use wayback machine and go thru all changes in your documentation https://web.archive.org/web/*/https://geniusscansdk.com/docs/v4/android/custom-scanner-guide/

But that is time consuming, and really shouldnt be neccesary :-)

nordfalk commented 2 years ago

Turns out that I was anxious about nothing.

In the end the upgrade involved changing to

<fragment
    android:id="@+id/scan_fragment"
    android:name="com.geniusscansdk.camera.ScanFragmentLegacy"

and changing from override fun getCameraManagerCallback() = object : CameraManager.Callback { to override fun getCameraCallback() = object : ScanFragment.Callback {

The ScanFragmentX was not working with at 'hack' we do, to make sure the user is holding the sufficiently away to GeniusScan can detect the corners, so for now we will use ScanFragmentLegacy

        val scanFragmentZoomOutScale = 1.1f
        // zoom a little in - to make users takes the camera a little away from the voucher so that the corners can be seen
        val previewSurfaceView = view.findViewById<View>(com.geniusscansdk.R.id.preview_surface_view) as PreviewSurfaceView
        val overlayView = view.findViewById<View>(com.geniusscansdk.R.id.overlay_surface) as OverlayView
        previewSurfaceView.animate().scaleX(scanFragmentZoomOutScale).scaleY(scanFragmentZoomOutScale)
        overlayView.animate().scaleX(scanFragmentZoomOutScale).scaleY(scanFragmentZoomOutScale)