正在查看: Biko v2.0.23 应用的 FrontCameraView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Biko v2.0.23 应用的 FrontCameraView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package app.callpe.ui.misc;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.LifecycleOwner;
import app.callpe.common.utils.extensions.ActivityExtKt;
import app.callpe.databinding.ActivityFrontCameraBinding;
import com.otaliastudios.cameraview.CameraException;
import com.otaliastudios.cameraview.CameraListener;
import com.otaliastudios.cameraview.CameraView;
import com.otaliastudios.cameraview.VideoResult;
import com.otaliastudios.cameraview.controls.Mode;
import com.otaliastudios.cameraview.controls.Preview;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.collections.ArraysKt;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Ref;
import timber.log.Timber;
@Metadata(d1 = {"\u0000D\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\b\u0018\u0000 \u001e2\u00020\u0001:\u0001\u001eB\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0011\u001a\u00020\u0012H\u0002J\b\u0010\u0013\u001a\u00020\u0012H\u0002J\b\u0010\u0014\u001a\u00020\u0010H\u0002J\u0012\u0010\u0015\u001a\u00020\u00122\b\u0010\u0016\u001a\u0004\u0018\u00010\u0017H\u0015J\b\u0010\u0018\u001a\u00020\u0012H\u0014J\u0010\u0010\u0019\u001a\u00020\u00122\u0006\u0010\u0016\u001a\u00020\u0017H\u0014J\u0010\u0010\u001a\u001a\u00020\u00122\u0006\u0010\u001b\u001a\u00020\u0017H\u0014J\b\u0010\u001c\u001a\u00020\u0012H\u0002J\b\u0010\u001d\u001a\u00020\u0012H\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082.¢\u0006\u0002\n\u0000R\u0010\u0010\u0005\u001a\u0004\u0018\u00010\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0082D¢\u0006\u0002\n\u0000R\u0010\u0010\t\u001a\u0004\u0018\u00010\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000b\u001a\u00020\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000e\u001a\u00020\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u000f\u001a\u00020\u0010X\u0082.¢\u0006\u0002\n\u0000¨\u0006\u001f"}, d2 = {"Lapp/callpe/ui/misc/FrontCameraView;", "Landroidx/appcompat/app/AppCompatActivity;", "()V", "binding", "Lapp/callpe/databinding/ActivityFrontCameraBinding;", "camera", "Lcom/otaliastudios/cameraview/CameraView;", "defaultMaxDuration", "", "mVideoCounterHandler", "Landroid/os/Handler;", "mVideoCounterProgress", "mVideoCounterRunnable", "Ljava/lang/Runnable;", "maxDuration", "outputDirectory", "Ljava/io/File;", "captureVideoSnapshot", "", "destroyVideo", "getOutputDirectory", "onCreate", "savedInstanceState", "Landroid/os/Bundle;", "onDestroy", "onRestoreInstanceState", "onSaveInstanceState", "outState", "recordingEnded", "startRecording", "Companion", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public final class FrontCameraView extends AppCompatActivity {
public static final String FILENAME_FORMAT = "yyyy-MM-dd-HH-mm-ss-SSS";
private static final String MAX_DURATION_KEY = "max_duration";
private static final String VIDEO_EXTENSION = ".mp4";
private ActivityFrontCameraBinding binding;
private CameraView camera;
private int mVideoCounterProgress;
private File outputDirectory;
private Handler mVideoCounterHandler = new Handler(Looper.getMainLooper());
private Runnable mVideoCounterRunnable = new Runnable() {
@Override
public final void run() {
FrontCameraView.mVideoCounterRunnable$lambda$0();
}
};
private final int defaultMaxDuration = 6;
private int maxDuration = 6;
public static final void mVideoCounterRunnable$lambda$0() {
}
protected void onCreate(Bundle savedInstanceState) {
Unit unit;
super.onCreate(savedInstanceState);
ActivityFrontCameraBinding inflate = ActivityFrontCameraBinding.inflate(getLayoutInflater());
Intrinsics.checkNotNullExpressionValue(inflate, "inflate(layoutInflater)");
this.binding = inflate;
ActivityFrontCameraBinding activityFrontCameraBinding = null;
if (inflate == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
inflate = null;
}
setContentView((View) inflate.getRoot());
if (savedInstanceState != null) {
this.maxDuration = savedInstanceState.getInt(MAX_DURATION_KEY, this.defaultMaxDuration);
unit = Unit.INSTANCE;
} else {
unit = null;
}
if (unit == null) {
this.maxDuration = getIntent().getIntExtra(MAX_DURATION_KEY, this.defaultMaxDuration);
}
ActivityFrontCameraBinding activityFrontCameraBinding2 = this.binding;
if (activityFrontCameraBinding2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding2 = null;
}
CameraView cameraView = activityFrontCameraBinding2.camera;
this.camera = cameraView;
if (cameraView != null) {
cameraView.setLifecycleOwner((LifecycleOwner) this);
}
CameraView cameraView2 = this.camera;
if (cameraView2 != null) {
cameraView2.setMode(Mode.VIDEO);
}
this.outputDirectory = getOutputDirectory();
CameraView cameraView3 = this.camera;
if (cameraView3 != null) {
cameraView3.addCameraListener(new CameraListener() {
public void onCameraError(CameraException exception) {
Intrinsics.checkNotNullParameter(exception, "exception");
super.onCameraError(exception);
ActivityExtKt.toast((Activity) FrontCameraView.this, "Error Code " + exception.getReason());
FrontCameraView.this.setResult(0);
FrontCameraView.this.finish();
}
public void onVideoRecordingEnd() {
super.onVideoRecordingEnd();
FrontCameraView.this.recordingEnded();
}
public void onVideoRecordingStart() {
super.onVideoRecordingStart();
FrontCameraView.this.startRecording();
}
public void onVideoTaken(VideoResult result) {
Intrinsics.checkNotNullParameter(result, "result");
super.onVideoTaken(result);
Timber.e("result " + result.getFile().getAbsoluteFile() + " exist " + result.getFile().exists() + " end reason " + result.getTerminationReason(), new Object[0]);
Intent intent = new Intent();
intent.putExtra("path", result.getFile().getAbsolutePath());
FrontCameraView.this.setResult(-1, intent);
FrontCameraView.this.finish();
}
});
}
ActivityFrontCameraBinding activityFrontCameraBinding3 = this.binding;
if (activityFrontCameraBinding3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
} else {
activityFrontCameraBinding = activityFrontCameraBinding3;
}
activityFrontCameraBinding.imageViewClick.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
FrontCameraView.onCreate$lambda$3(FrontCameraView.this, view);
}
});
}
public static final void onCreate$lambda$3(FrontCameraView frontCameraView, View view) {
Intrinsics.checkNotNullParameter(frontCameraView, "this$0");
frontCameraView.captureVideoSnapshot();
}
public final void startRecording() {
ActivityFrontCameraBinding activityFrontCameraBinding = this.binding;
ActivityFrontCameraBinding activityFrontCameraBinding2 = null;
if (activityFrontCameraBinding == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding = null;
}
ImageButton imageButton = activityFrontCameraBinding.imageViewClick;
Intrinsics.checkNotNullExpressionValue(imageButton, "binding.imageViewClick");
imageButton.setVisibility(8);
ActivityFrontCameraBinding activityFrontCameraBinding3 = this.binding;
if (activityFrontCameraBinding3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding3 = null;
}
TextView textView = activityFrontCameraBinding3.textViewMessageBottom;
Intrinsics.checkNotNullExpressionValue(textView, "binding.textViewMessageBottom");
textView.setVisibility(8);
ActivityFrontCameraBinding activityFrontCameraBinding4 = this.binding;
if (activityFrontCameraBinding4 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding4 = null;
}
activityFrontCameraBinding4.constraintTimer.setVisibility(0);
ActivityFrontCameraBinding activityFrontCameraBinding5 = this.binding;
if (activityFrontCameraBinding5 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding5 = null;
}
activityFrontCameraBinding5.progressbarVideoCounter.setProgress(0);
ActivityFrontCameraBinding activityFrontCameraBinding6 = this.binding;
if (activityFrontCameraBinding6 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding6 = null;
}
activityFrontCameraBinding6.progressbarVideoCounter.setMax(this.maxDuration);
ActivityFrontCameraBinding activityFrontCameraBinding7 = this.binding;
if (activityFrontCameraBinding7 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding7 = null;
}
activityFrontCameraBinding7.progressbarVideoCounter.invalidate();
final Ref.ObjectRef objectRef = new Ref.ObjectRef();
objectRef.element = "00:" + this.maxDuration;
ActivityFrontCameraBinding activityFrontCameraBinding8 = this.binding;
if (activityFrontCameraBinding8 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
} else {
activityFrontCameraBinding2 = activityFrontCameraBinding8;
}
activityFrontCameraBinding2.textViewVideoTimer.setText((CharSequence) objectRef.element);
Runnable runnable = new Runnable() {
@Override
public final void run() {
FrontCameraView.startRecording$lambda$4(FrontCameraView.this, objectRef);
}
};
this.mVideoCounterRunnable = runnable;
Handler handler = this.mVideoCounterHandler;
if (handler != null) {
handler.postDelayed(runnable, 1000L);
}
}
public static final void startRecording$lambda$4(FrontCameraView frontCameraView, Ref.ObjectRef objectRef) {
int i;
Intrinsics.checkNotNullParameter(frontCameraView, "this$0");
Intrinsics.checkNotNullParameter(objectRef, "$time");
frontCameraView.mVideoCounterProgress++;
ActivityFrontCameraBinding activityFrontCameraBinding = frontCameraView.binding;
ActivityFrontCameraBinding activityFrontCameraBinding2 = null;
if (activityFrontCameraBinding == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding = null;
}
activityFrontCameraBinding.progressbarVideoCounter.setProgress(frontCameraView.mVideoCounterProgress);
String valueOf = String.valueOf(frontCameraView.mVideoCounterProgress);
int i2 = frontCameraView.mVideoCounterProgress;
if (i2 > 59) {
int i3 = i2 / 60;
String valueOf2 = String.valueOf(i2 - (i3 * 60));
i = i3;
valueOf = valueOf2;
} else {
i = 0;
}
if (valueOf.length() == 1) {
int i4 = frontCameraView.mVideoCounterProgress;
}
Timber.e("takeVideo: mVideoCounterProgress " + frontCameraView.mVideoCounterProgress, new Object[0]);
int i5 = frontCameraView.maxDuration - frontCameraView.mVideoCounterProgress;
Timber.e("takeVideo: seconds " + i5, new Object[0]);
StringBuilder sb = new StringBuilder();
sb.append('0');
sb.append(i);
sb.append(':');
sb.append(i5);
objectRef.element = sb.toString();
ActivityFrontCameraBinding activityFrontCameraBinding3 = frontCameraView.binding;
if (activityFrontCameraBinding3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding3 = null;
}
ImageButton imageButton = activityFrontCameraBinding3.imageViewClick;
Intrinsics.checkNotNullExpressionValue(imageButton, "binding.imageViewClick");
imageButton.setVisibility(8);
ActivityFrontCameraBinding activityFrontCameraBinding4 = frontCameraView.binding;
if (activityFrontCameraBinding4 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
} else {
activityFrontCameraBinding2 = activityFrontCameraBinding4;
}
activityFrontCameraBinding2.textViewVideoTimer.setText((CharSequence) objectRef.element);
Handler handler = frontCameraView.mVideoCounterHandler;
if (handler != null) {
handler.postDelayed(frontCameraView.mVideoCounterRunnable, 1000L);
}
}
public final void recordingEnded() {
ActivityFrontCameraBinding activityFrontCameraBinding = this.binding;
if (activityFrontCameraBinding == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding = null;
}
ImageButton imageButton = activityFrontCameraBinding.imageViewClick;
Intrinsics.checkNotNullExpressionValue(imageButton, "binding.imageViewClick");
imageButton.setVisibility(0);
ActivityFrontCameraBinding activityFrontCameraBinding2 = this.binding;
if (activityFrontCameraBinding2 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding2 = null;
}
TextView textView = activityFrontCameraBinding2.textViewMessageBottom;
Intrinsics.checkNotNullExpressionValue(textView, "binding.textViewMessageBottom");
textView.setVisibility(0);
ActivityFrontCameraBinding activityFrontCameraBinding3 = this.binding;
if (activityFrontCameraBinding3 == null) {
Intrinsics.throwUninitializedPropertyAccessException("binding");
activityFrontCameraBinding3 = null;
}
activityFrontCameraBinding3.constraintTimer.setVisibility(8);
Handler handler = this.mVideoCounterHandler;
if (handler != null) {
handler.removeCallbacks(this.mVideoCounterRunnable);
}
this.mVideoCounterHandler = null;
}
private final void captureVideoSnapshot() {
CameraView cameraView = this.camera;
if (cameraView == null) {
return;
}
if (cameraView.isTakingVideo()) {
ActivityExtKt.toast((Activity) this, "Already taking video.");
return;
}
File file = this.outputDirectory;
if (file == null) {
Intrinsics.throwUninitializedPropertyAccessException("outputDirectory");
file = null;
}
File file2 = new File(file, new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS", Locale.ENGLISH).format(Long.valueOf(System.currentTimeMillis())) + VIDEO_EXTENSION);
if (cameraView.getPreview() != Preview.GL_SURFACE) {
ActivityExtKt.toast((Activity) this, "Camera not supported");
} else {
cameraView.takeVideoSnapshot(file2, this.maxDuration * 1000);
}
}
private final File getOutputDirectory() {
File[] externalMediaDirs = getExternalMediaDirs();
Intrinsics.checkNotNullExpressionValue(externalMediaDirs, "externalMediaDirs");
File file = (File) ArraysKt.firstOrNull(externalMediaDirs);
if (file != null) {
new File(file, getResources().getString(2131951675)).mkdirs();
}
new File(getCacheDir(), getResources().getString(2131951675)).mkdir();
File file2 = new File(getExternalFilesDir(null), "Camera");
if (!file2.exists()) {
if (!file2.mkdir()) {
Log.e("ERROR", "Cannot create a directory!");
} else {
file2.mkdirs();
}
}
return file2;
}
protected void onSaveInstanceState(Bundle outState) {
Intrinsics.checkNotNullParameter(outState, "outState");
super.onSaveInstanceState(outState);
outState.putInt(MAX_DURATION_KEY, this.maxDuration);
}
protected void onRestoreInstanceState(Bundle savedInstanceState) {
Intrinsics.checkNotNullParameter(savedInstanceState, "savedInstanceState");
super.onRestoreInstanceState(savedInstanceState);
this.maxDuration = savedInstanceState.getInt(MAX_DURATION_KEY, this.defaultMaxDuration);
}
protected void onDestroy() {
super.onDestroy();
destroyVideo();
}
private final void destroyVideo() {
CameraView cameraView;
try {
CameraView cameraView2 = this.camera;
boolean z = true;
if (cameraView2 == null || !cameraView2.isTakingVideo()) {
z = false;
}
if (!z || (cameraView = this.camera) == null) {
return;
}
cameraView.stopVideo();
} catch (Exception unused) {
}
}
}