package com.journeyapps.barcodescanner;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import mc.p;
import rb.i;
import rb.j;
import rb.m;

/* JADX INFO: loaded from: classes.dex */
public class DecoratedBarcodeView extends FrameLayout {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public BarcodeView f24591a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public ViewfinderView f24592b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public TextView f24593c;

    public DecoratedBarcodeView(Context context) {
        super(context);
        a(null);
    }

    public final void a(AttributeSet attributeSet) {
        TypedArray typedArrayObtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, m.zxing_view);
        int resourceId = typedArrayObtainStyledAttributes.getResourceId(m.zxing_view_zxing_scanner_layout, j.zxing_barcode_scanner);
        typedArrayObtainStyledAttributes.recycle();
        View.inflate(getContext(), resourceId, this);
        BarcodeView barcodeView = (BarcodeView) findViewById(i.zxing_barcode_surface);
        this.f24591a = barcodeView;
        if (barcodeView == null) {
            throw new IllegalArgumentException("There is no a com.journeyapps.barcodescanner.BarcodeView on provided layout with the id \"zxing_barcode_surface\".");
        }
        barcodeView.d(attributeSet);
        ViewfinderView viewfinderView = (ViewfinderView) findViewById(i.zxing_viewfinder_view);
        this.f24592b = viewfinderView;
        if (viewfinderView == null) {
            throw new IllegalArgumentException("There is no a com.journeyapps.barcodescanner.ViewfinderView on provided layout with the id \"zxing_viewfinder_view\".");
        }
        viewfinderView.setCameraPreview(this.f24591a);
        this.f24593c = (TextView) findViewById(i.zxing_status_view);
    }

    public BarcodeView getBarcodeView() {
        return (BarcodeView) findViewById(i.zxing_barcode_surface);
    }

    public nc.i getCameraSettings() {
        return this.f24591a.getCameraSettings();
    }

    public mc.m getDecoderFactory() {
        return this.f24591a.getDecoderFactory();
    }

    public TextView getStatusView() {
        return this.f24593c;
    }

    public ViewfinderView getViewFinder() {
        return this.f24592b;
    }

    @Override // android.view.View, android.view.KeyEvent.Callback
    public final boolean onKeyDown(int i10, KeyEvent keyEvent) {
        if (i10 == 24) {
            setTorchOn();
            return true;
        }
        if (i10 == 25) {
            setTorchOff();
            return true;
        }
        if (i10 == 27 || i10 == 80) {
            return true;
        }
        return super.onKeyDown(i10, keyEvent);
    }

    public void setCameraSettings(nc.i iVar) {
        this.f24591a.setCameraSettings(iVar);
    }

    public void setDecoderFactory(mc.m mVar) {
        this.f24591a.setDecoderFactory(mVar);
    }

    public void setStatusText(String str) {
        TextView textView = this.f24593c;
        if (textView != null) {
            textView.setText(str);
        }
    }

    public void setTorchListener(p pVar) {
    }

    public void setTorchOff() {
        this.f24591a.setTorch(false);
    }

    public void setTorchOn() {
        this.f24591a.setTorch(true);
    }

    public DecoratedBarcodeView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        a(attributeSet);
    }

    public DecoratedBarcodeView(Context context, AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        a(attributeSet);
    }
}
