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

Commit 796ac880 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge branch '7567-master-qr' into 'master'

Camera: add qr scanner activity

See merge request !75
parents 3f3d5ff9 14413b1c
Loading
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,18 @@
            android:exported="false"
            android:exported="false"
            >
            >
        </activity>
        </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 -->
        <!-- 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
        <receiver
            android:icon="@mipmap/ic_launcher"
            android:icon="@mipmap/ic_launcher"
+25 −23
Original line number Original line Diff line number Diff line
@@ -14,7 +14,6 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.RectF;
@@ -61,6 +60,14 @@ import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import androidx.core.content.ContextCompat;


import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Reader;
import com.google.zxing.Result;
import com.google.zxing.common.HybridBinarizer;

import net.sourceforge.opencamera.MainActivity;
import net.sourceforge.opencamera.MainActivity;
import net.sourceforge.opencamera.MyDebug;
import net.sourceforge.opencamera.MyDebug;
import net.sourceforge.opencamera.ScriptC_histogram_compute;
import net.sourceforge.opencamera.ScriptC_histogram_compute;
@@ -94,14 +101,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.TimeoutException;


import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.Reader;
import com.google.zxing.Result;
import com.google.zxing.common.HybridBinarizer;
import com.google.zxing.RGBLuminanceSource;

import foundation.e.camera.R;
import foundation.e.camera.R;


/** This class was originally named due to encapsulating the camera preview,
/** This class was originally named due to encapsulating the camera preview,
@@ -4775,22 +4774,10 @@ public class Preview implements SurfaceHolder.Callback, TextureView.SurfaceTextu
            if (video_recorder != null) {
            if (video_recorder != null) {
                stopVideo(false);
                stopVideo(false);
            }
            }
            this.functionalMode = FunctionalMode.QRCODE;
            setQRCode(true);
            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);
            }
        } else if (this.is_qrcode()) {
        } else if (this.is_qrcode()) {
            this.functionalMode = FunctionalMode.PHOTO;
            this.functionalMode = FunctionalMode.PHOTO;
            final Activity activity = (Activity) Preview.this.getContext();
            setQRCode(false);
            final FrameLayout rootLayout = activity.findViewById(android.R.id.content);
            if (overlayQRCodeView.getParent() != null) {
                rootLayout.removeView(overlayQRCodeView);
            }
        } else if (this.is_photo()) {
        } else if (this.is_photo()) {
            if (this.isOnTimer()) {
            if (this.isOnTimer()) {
                cancelTimer();
                cancelTimer();
@@ -8654,6 +8641,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() {
    public boolean isQRCode() {
        return functionalMode == FunctionalMode.QRCODE;
        return functionalMode == FunctionalMode.QRCODE;
    }
    }
+11 −0
Original line number Original line 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)
    }
}