126 lines
4.6 KiB
Java
126 lines
4.6 KiB
Java
|
package c.o.a.u;
|
||
|
|
||
|
import android.annotation.SuppressLint;
|
||
|
import android.content.Context;
|
||
|
import android.content.res.TypedArray;
|
||
|
import android.graphics.Canvas;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.View;
|
||
|
import android.widget.FrameLayout;
|
||
|
import androidx.annotation.NonNull;
|
||
|
import androidx.annotation.VisibleForTesting;
|
||
|
import c.o.a.b;
|
||
|
import c.o.a.u.a;
|
||
|
import com.otaliastudios.cameraview.R;
|
||
|
/* compiled from: OverlayLayout */
|
||
|
@SuppressLint({"CustomViewStyleable"})
|
||
|
public class c extends FrameLayout implements a {
|
||
|
public static final String i;
|
||
|
public static final b j;
|
||
|
@VisibleForTesting
|
||
|
public a.EnumC0167a k = a.EnumC0167a.PREVIEW;
|
||
|
|
||
|
/* compiled from: OverlayLayout */
|
||
|
public static class a extends FrameLayout.LayoutParams {
|
||
|
public boolean a = false;
|
||
|
public boolean b = false;
|
||
|
|
||
|
/* renamed from: c reason: collision with root package name */
|
||
|
public boolean f1507c = false;
|
||
|
|
||
|
public a(@NonNull Context context, @NonNull AttributeSet attributeSet) {
|
||
|
super(context, attributeSet);
|
||
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.c.CameraView_Layout);
|
||
|
try {
|
||
|
this.a = obtainStyledAttributes.getBoolean(R.c.CameraView_Layout_layout_drawOnPreview, false);
|
||
|
this.b = obtainStyledAttributes.getBoolean(R.c.CameraView_Layout_layout_drawOnPictureSnapshot, false);
|
||
|
this.f1507c = obtainStyledAttributes.getBoolean(R.c.CameraView_Layout_layout_drawOnVideoSnapshot, false);
|
||
|
} finally {
|
||
|
obtainStyledAttributes.recycle();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@VisibleForTesting
|
||
|
public boolean a(@NonNull a.EnumC0167a aVar) {
|
||
|
return (aVar == a.EnumC0167a.PREVIEW && this.a) || (aVar == a.EnumC0167a.VIDEO_SNAPSHOT && this.f1507c) || (aVar == a.EnumC0167a.PICTURE_SNAPSHOT && this.b);
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Object
|
||
|
@NonNull
|
||
|
public String toString() {
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
c.d.b.a.a.b0(a.class, sb, "[drawOnPreview:");
|
||
|
sb.append(this.a);
|
||
|
sb.append(",drawOnPictureSnapshot:");
|
||
|
sb.append(this.b);
|
||
|
sb.append(",drawOnVideoSnapshot:");
|
||
|
return c.d.b.a.a.G(sb, this.f1507c, "]");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static {
|
||
|
String simpleName = c.class.getSimpleName();
|
||
|
i = simpleName;
|
||
|
j = new b(simpleName);
|
||
|
}
|
||
|
|
||
|
public c(@NonNull Context context) {
|
||
|
super(context);
|
||
|
setWillNotDraw(false);
|
||
|
}
|
||
|
|
||
|
public void a(@NonNull a.EnumC0167a aVar, @NonNull Canvas canvas) {
|
||
|
synchronized (this) {
|
||
|
this.k = aVar;
|
||
|
int ordinal = aVar.ordinal();
|
||
|
if (ordinal == 0) {
|
||
|
super.draw(canvas);
|
||
|
} else if (ordinal == 1 || ordinal == 2) {
|
||
|
canvas.save();
|
||
|
float width = ((float) canvas.getWidth()) / ((float) getWidth());
|
||
|
float height = ((float) canvas.getHeight()) / ((float) getHeight());
|
||
|
b bVar = j;
|
||
|
bVar.a(0, "draw", "target:", aVar, "canvas:", canvas.getWidth() + "x" + canvas.getHeight(), "view:", getWidth() + "x" + getHeight(), "widthScale:", Float.valueOf(width), "heightScale:", Float.valueOf(height));
|
||
|
canvas.scale(width, height);
|
||
|
dispatchDraw(canvas);
|
||
|
canvas.restore();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public boolean b(@NonNull a.EnumC0167a aVar) {
|
||
|
for (int i2 = 0; i2 < getChildCount(); i2++) {
|
||
|
if (((a) getChildAt(i2).getLayoutParams()).a(aVar)) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
/* renamed from: c */
|
||
|
public a generateLayoutParams(AttributeSet attributeSet) {
|
||
|
return new a(getContext(), attributeSet);
|
||
|
}
|
||
|
|
||
|
@Override // android.view.View
|
||
|
@SuppressLint({"MissingSuperCall"})
|
||
|
public void draw(Canvas canvas) {
|
||
|
j.a(1, "normal draw called.");
|
||
|
a.EnumC0167a aVar = a.EnumC0167a.PREVIEW;
|
||
|
if (b(aVar)) {
|
||
|
a(aVar, canvas);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // android.view.ViewGroup
|
||
|
public boolean drawChild(Canvas canvas, View view, long j2) {
|
||
|
a aVar = (a) view.getLayoutParams();
|
||
|
if (aVar.a(this.k)) {
|
||
|
j.a(0, "Performing drawing for view:", view.getClass().getSimpleName(), "target:", this.k, "params:", aVar);
|
||
|
return super.drawChild(canvas, view, j2);
|
||
|
}
|
||
|
j.a(0, "Skipping drawing for view:", view.getClass().getSimpleName(), "target:", this.k, "params:", aVar);
|
||
|
return false;
|
||
|
}
|
||
|
}
|