From 827495f2016179f6198e9a99fb056b32ccc64d02 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 27 Jan 2025 07:32:53 +0300 Subject: [PATCH] Removed Google Barcode. --- .../ui/Stories/recorder/QRScanner.java | 69 ++++++++++--------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/QRScanner.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/QRScanner.java index b7e31f46cc..41448ef4e1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/QRScanner.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/QRScanner.java @@ -17,9 +17,9 @@ import androidx.annotation.NonNull; -import com.google.android.gms.vision.Frame; -import com.google.android.gms.vision.barcode.Barcode; -import com.google.android.gms.vision.barcode.BarcodeDetector; +// import com.google.android.gms.vision.Frame; +// import com.google.android.gms.vision.barcode.Barcode; +// import com.google.android.gms.vision.barcode.BarcodeDetector; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.MessagesController; @@ -35,7 +35,7 @@ public class QRScanner { - private final AtomicReference detector = new AtomicReference<>(); + // private final AtomicReference detector = new AtomicReference<>(); private final AtomicBoolean paused = new AtomicBoolean(false); private final Utilities.Callback listener; @@ -46,7 +46,7 @@ public QRScanner(Context context, Utilities.Callback whenScanned) { this.listener = whenScanned; this.prefix = MessagesController.getInstance(UserConfig.selectedAccount).linkPrefix; Utilities.globalQueue.postRunnable(() -> { - detector.set(new BarcodeDetector.Builder(context).setBarcodeFormats(Barcode.QR_CODE).build()); + // detector.set(new BarcodeDetector.Builder(context).setBarcodeFormats(Barcode.QR_CODE).build()); attach(cameraView); }); } @@ -64,12 +64,13 @@ public void destroy() { public void attach(CameraView cameraView) { this.cameraView = cameraView; - if (detector.get() == null) return; + if (true) return; + // if (detector.get() == null) return; - if (!paused.get()) { - Utilities.globalQueue.cancelRunnable(this.process); - Utilities.globalQueue.postRunnable(this.process, getTimeout()); - } + // if (!paused.get()) { + // Utilities.globalQueue.cancelRunnable(this.process); + // Utilities.globalQueue.postRunnable(this.process, getTimeout()); + // } } public void setPaused(boolean pause) { @@ -93,7 +94,8 @@ public boolean isPaused() { private Bitmap cacheBitmap; private final Runnable process = () -> { - if (detector.get() == null || cameraView == null || paused.get()) { + if (true) { + // if (detector.get() == null || cameraView == null || paused.get()) { return; } @@ -131,30 +133,31 @@ private Detected detect(Bitmap bitmap) { return null; } - final BarcodeDetector detector = this.detector.get(); - if (detector == null || !detector.isOperational()) { + // final BarcodeDetector detector = this.detector.get(); + // if (detector == null || !detector.isOperational()) { + if (true) { return null; } final int w = bitmap.getWidth(); final int h = bitmap.getHeight(); - final Frame frame = new Frame.Builder().setBitmap(bitmap).build(); - final SparseArray codes = detector.detect(frame); - - for (int i = 0; i < codes.size(); ++i) { - final Barcode code = codes.valueAt(i); - String link = code.rawValue; - if (link == null) continue; - link = link.trim(); - if (!link.startsWith(prefix) && !link.startsWith("https://" + prefix) && !link.startsWith("http://" + prefix)) continue; - - final PointF[] cornerPoints = new PointF[code.cornerPoints.length]; - for (int j = 0; j < code.cornerPoints.length; ++j) { - cornerPoints[j] = new PointF((float) code.cornerPoints[j].x / w, (float) code.cornerPoints[j].y / h); - } +// final Frame frame = new Frame.Builder().setBitmap(bitmap).build(); + // final SparseArray codes = detector.detect(frame); - return new Detected(link, cornerPoints); - } + // for (int i = 0; i < codes.size(); ++i) { + // final Barcode code = codes.valueAt(i); + // String link = code.rawValue; + // if (link == null) continue; + // link = link.trim(); + // if (!link.startsWith(prefix) && !link.startsWith("https://" + prefix) && !link.startsWith("http://" + prefix)) continue; + + // final PointF[] cornerPoints = new PointF[code.cornerPoints.length]; + // for (int j = 0; j < code.cornerPoints.length; ++j) { + // cornerPoints[j] = new PointF((float) code.cornerPoints[j].x / w, (float) code.cornerPoints[j].y / h); + // } + + // return new Detected(link, cornerPoints); + // } return null; } @@ -179,10 +182,10 @@ public long getTimeout() { } public void detach() { - BarcodeDetector detector = this.detector.getAndSet(null); - if (detector != null) { - detector.release(); - } + // BarcodeDetector detector = this.detector.getAndSet(null); + // if (detector != null) { + // detector.release(); + // } } public static final class Detected {