Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d7ab9bd authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊 Committed by Nishith Khanna
Browse files

Camera: add qr scanner activity

parent fc77f583
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -99,6 +99,18 @@
            android:exported="false"
            >
        </activity>

        <activity
            android:name="net.sourceforge.opencamera.qr.QrScannerActivity"
            android:configChanges="orientation|screenLayout|screenSize|smallestScreenSize|keyboardHidden"
            android:exported="true"
            android:excludeFromRecents="true"
            android:launchMode="singleInstance"
            android:screenOrientation="nosensor"
            android:visibleToInstantApps="true"
            android:windowSoftInputMode="stateAlwaysHidden|adjustPan">
        </activity>

        <!-- should not change the android:name, including moving to a subpackage - see http://android-developers.blogspot.co.uk/2011/06/things-that-cannot-change.html -->
        <receiver
            android:icon="@mipmap/ic_launcher"
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import android.view.View;

import androidx.core.content.ContextCompat;

import foundation.e.camera.R;
import net.sourceforge.opencamera.R;

public class OverlayQRCodeView extends View {
    private Drawable qrcode;
+17 −15
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
@@ -4856,22 +4855,10 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
            if( video_recorder != null ) {
                stopVideo(false);
            }
            this.functionalMode = FunctionalMode.QRCODE;
            final Activity activity = (Activity) Preview.this.getContext();
            final FrameLayout rootLayout = activity.findViewById(android.R.id.content);
            rootLayout.addView(overlayQRCodeView);
            int qrcodeCamId = ((MainActivity)getContext()).getBetterQRCodeCameraID();
            if (qrcodeCamId >= 0) {
                applicationInterface.setCameraIdPref(qrcodeCamId);
                //userSwitchToCamera(qrcodeCamId, true);
            }
            setQRCode(true);
        } else if (this.is_qrcode()) {
            this.functionalMode = FunctionalMode.PHOTO;
            final Activity activity = (Activity) Preview.this.getContext();
            final FrameLayout rootLayout = activity.findViewById(android.R.id.content);
            if (overlayQRCodeView.getParent() != null) {
                rootLayout.removeView(overlayQRCodeView);
            }
            setQRCode(false);
        } else if (this.is_photo()) {
            if( this.isOnTimer() ) {
                cancelTimer();
@@ -8883,6 +8870,21 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
        }
    }

    public void setQRCode(boolean enabled) {
        final Activity activity = (Activity) Preview.this.getContext();
        final FrameLayout rootLayout = activity.findViewById(android.R.id.content);
        if (enabled) {
            this.functionalMode = FunctionalMode.QRCODE;
            rootLayout.addView(overlayQRCodeView);
            int qrcodeCamId = ((MainActivity)getContext()).getBetterQRCodeCameraID();
            if (qrcodeCamId >= 0) {
                applicationInterface.setCameraIdPref(qrcodeCamId);
            }
        } else if (overlayQRCodeView.getParent() != null) {
            rootLayout.removeView(overlayQRCodeView);
        }
    }

    public boolean isQRCode() {
        return functionalMode == FunctionalMode.QRCODE;
    }
+11 −0
Original line number Diff line number Diff line
package net.sourceforge.opencamera.qr

import android.os.Bundle
import net.sourceforge.opencamera.MainActivity

class QrScannerActivity : MainActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        preview.setQRCode(true)
    }
}