remove logs

This commit is contained in:
darthpaul 2022-07-13 17:08:20 +01:00
parent d020e42635
commit 776e842af5
7 changed files with 9 additions and 72 deletions

View File

@ -9,7 +9,6 @@ import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.provider.MediaStore
import android.util.Log
import android.view.*
import android.widget.RelativeLayout
import com.bumptech.glide.Glide
@ -33,7 +32,6 @@ import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, CameraXPreviewListener {
companion object {
private const val TAG = "MainActivity"
private const val FADE_DELAY = 5000L
private const val CAPTURE_ANIMATION_DURATION = 100L
}
@ -122,15 +120,12 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
private fun initVariables() {
mIsInPhotoMode = if (isVideoCaptureIntent()) {
Log.w(TAG, "initializeCamera: video capture")
false
} else if (isImageCaptureIntent()) {
Log.w(TAG, "initializeCamera: image capture mode")
true
} else {
config.initPhotoMode
}
Log.w(TAG, "initInPhotoMode = $mIsInPhotoMode")
mIsCameraAvailable = false
mIsHardwareShutterHandled = false
mCurrVideoRecTimer = 0
@ -202,7 +197,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
private fun checkImageCaptureIntent() {
if (isImageCaptureIntent()) {
Log.i(TAG, "isImageCaptureIntent: ")
hideIntentButtons()
val output = intent.extras?.get(MediaStore.EXTRA_OUTPUT)
if (output != null && output is Uri) {
@ -213,7 +207,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
private fun checkVideoCaptureIntent() {
if (intent?.action == MediaStore.ACTION_VIDEO_CAPTURE) {
Log.i(TAG, "checkVideoCaptureIntent: ")
mIsInPhotoMode = false
hideIntentButtons()
shutter.setImageResource(R.drawable.ic_video_rec)
@ -402,7 +395,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
mPreviewUri = Uri.withAppendedPath(uri, lastMediaId.toString())
Log.e(TAG, "mPreviewUri= $mPreviewUri")
loadLastTakenMedia(mPreviewUri)
}
@ -585,7 +577,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
setResult(Activity.RESULT_OK, this)
}
Log.w(TAG, "onMediaCaptured: exiting uri=$uri")
finish()
} else if (isVideoCaptureIntent()) {
Intent().apply {
@ -593,7 +584,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
setResult(Activity.RESULT_OK, this)
}
Log.w(TAG, "onMediaCaptured: video exiting uri=$uri")
finish()
}
}
@ -604,7 +594,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
putExtra("data", bitmap)
setResult(Activity.RESULT_OK, this)
}
Log.w(TAG, "onImageCaptured: exiting bitmap size=${bitmap.byteCount}")
finish()
}
}
@ -663,7 +652,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
fun drawFocusCircle(x: Float, y: Float) = mFocusCircleView.drawFocusCircle(x, y)
override fun mediaSaved(path: String) {
Log.e(TAG, "mediaSaved: $path")
rescanPaths(arrayListOf(path)) {
setupPreviewImage(true)
Intent(BROADCAST_REFRESH_MEDIA).apply {

View File

@ -1,7 +1,6 @@
package com.simplemobiletools.camera.dialogs
import android.app.Activity
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.app.AlertDialog
@ -28,7 +27,6 @@ class ChangeResolutionDialogX(
private var dialog: AlertDialog? = null
private val config = activity.config
private val TAG = "ChangeResolutionDialogX"
init {
val view = LayoutInflater.from(activity).inflate(R.layout.dialog_change_resolution, null).apply {
setupPhotoResolutionPicker(this)
@ -57,7 +55,6 @@ class ChangeResolutionDialogX(
view.change_resolution_photo_holder.setOnClickListener {
RadioGroupDialog(activity, ArrayList(items), selectionIndex) {
selectionIndex = it as Int
Log.w(TAG, "setupPhotoResolutionPicker: selectionIndex=$it")
view.change_resolution_photo.text = items[selectionIndex].title
if (isFrontCamera) {
config.frontPhotoResIndex = it
@ -80,8 +77,6 @@ class ChangeResolutionDialogX(
var selectionIndex = if (isFrontCamera) config.frontVideoResIndex else config.backVideoResIndex
selectionIndex = selectionIndex.coerceAtLeast(0)
Log.i(TAG, "videoResolutions=$videoResolutions")
Log.i(TAG, "setupVideoResolutionPicker: selectionIndex=$selectionIndex")
view.change_resolution_video_holder.setOnClickListener {
RadioGroupDialog(activity, ArrayList(items), selectionIndex) {
@ -99,6 +94,5 @@ class ChangeResolutionDialogX(
}
val selectedItem = items.getOrNull(selectionIndex)
view.change_resolution_video.text = selectedItem?.title
Log.i(TAG, "setupVideoResolutionPicker: selectedItem=$selectedItem")
}
}

View File

@ -2,14 +2,12 @@ package com.simplemobiletools.camera.helpers
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.Log
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.sqrt
//inspired by https://android.googlesource.com/platform/packages/apps/Camera2/+/refs/heads/master/src/com/android/camera/util/CameraUtil.java#244
object BitmapUtils {
private const val TAG = "BitmapUtils"
private const val INLINE_BITMAP_MAX_PIXEL_NUM = 50 * 1024
fun makeBitmap(jpegData: ByteArray, maxNumOfPixels: Int = INLINE_BITMAP_MAX_PIXEL_NUM): Bitmap? {
@ -31,7 +29,6 @@ object BitmapUtils {
options
)
} catch (ex: OutOfMemoryError) {
Log.e(TAG, "Got oom exception ", ex)
null
}
}

View File

@ -6,20 +6,19 @@ import android.hardware.camera2.CameraCharacteristics
import android.hardware.camera2.CameraManager
import android.hardware.camera2.params.StreamConfigurationMap
import android.media.MediaRecorder
import android.util.Log
import android.util.Size
import androidx.appcompat.app.AppCompatActivity
import androidx.camera.core.CameraSelector
import com.simplemobiletools.camera.extensions.config
import com.simplemobiletools.camera.models.CameraSelectorImageQualities
import com.simplemobiletools.camera.models.MySize
import com.simplemobiletools.commons.extensions.showErrorToast
class ImageQualityManager(
activity: AppCompatActivity,
private val activity: AppCompatActivity,
) {
companion object {
private const val TAG = "ImageQualityManager"
private const val MAX_VIDEO_WIDTH = 4096
private const val MAX_VIDEO_HEIGHT = 2160
private val CAMERA_LENS = arrayOf(CameraCharacteristics.LENS_FACING_FRONT, CameraCharacteristics.LENS_FACING_BACK)
@ -39,11 +38,10 @@ class ImageQualityManager(
val imageSizes = configMap.getOutputSizes(ImageFormat.JPEG).map { MySize(it.width, it.height) }
val cameraSelector = lens.toCameraSelector()
imageQualities.add(CameraSelectorImageQualities(cameraSelector, imageSizes))
Log.i(TAG, "initQualities: imageSizes=$imageSizes")
}
}
} catch (e: Exception) {
Log.e(TAG, "Camera ID=$cameraId is not supported", e)
activity.showErrorToast(e)
}
}
}
@ -69,12 +67,7 @@ class ImageQualityManager(
.sortedByDescending { it.pixels }
.distinctBy { it.pixels }
.map { Size(it.width, it.height) }
.also {
Log.i(TAG, "Resolutions: $it, index=$index")
}
.getOrNull(index).also {
Log.i(TAG, "getUserSelectedResolution: $it, index=$index")
}
.getOrNull(index)
}
fun getSupportedResolutions(cameraSelector: CameraSelector): List<MySize> {

View File

@ -5,7 +5,6 @@ import android.net.Uri
import android.os.Environment
import android.os.ParcelFileDescriptor
import android.provider.MediaStore
import android.util.Log
import com.simplemobiletools.camera.extensions.config
import com.simplemobiletools.camera.extensions.getOutputMediaFile
import com.simplemobiletools.camera.extensions.getRandomMediaName
@ -25,7 +24,6 @@ class MediaOutputHelper(
) {
companion object {
private const val TAG = "MediaOutputHelper"
private const val MODE = "rw"
private const val EXTERNAL_VOLUME = "external"
private const val IMAGE_MIME_TYPE = "image/jpeg"
@ -112,7 +110,6 @@ class MediaOutputHelper(
private fun getOutputStreamMediaOutput(): MediaOutput.OutputStreamMediaOutput? {
var mediaOutput: MediaOutput.OutputStreamMediaOutput? = null
val canWrite = canWriteToFilePath(mediaStorageDir)
Log.i(TAG, "getMediaOutput: canWrite=${canWrite}")
if (canWrite) {
val path = activity.getOutputMediaFile(true)
val uri = getUriForFilePath(path)
@ -121,16 +118,14 @@ class MediaOutputHelper(
mediaOutput = MediaOutput.OutputStreamMediaOutput(outputStream, uri)
}
}
Log.i(TAG, "OutputStreamMediaOutput: $mediaOutput")
return mediaOutput
}
private fun openOutputStream(uri: Uri): OutputStream? {
return try {
Log.i(TAG, "uri: $uri")
contentResolver.openOutputStream(uri)
} catch (e: Exception) {
e.printStackTrace()
activity.showErrorToast(e)
null
}
}
@ -138,7 +133,6 @@ class MediaOutputHelper(
private fun getFileDescriptorMediaOutput(): MediaOutput.FileDescriptorMediaOutput? {
var mediaOutput: MediaOutput.FileDescriptorMediaOutput? = null
val canWrite = canWriteToFilePath(mediaStorageDir)
Log.i(TAG, "getMediaOutput: canWrite=${canWrite}")
if (canWrite) {
val path = activity.getOutputMediaFile(false)
val uri = getUriForFilePath(path)
@ -149,14 +143,12 @@ class MediaOutputHelper(
}
}
}
Log.i(TAG, "FileDescriptorMediaOutput: $mediaOutput")
return mediaOutput
}
private fun getFileMediaOutput(): MediaOutput.FileMediaOutput? {
var mediaOutput: MediaOutput.FileMediaOutput? = null
val canWrite = canWriteToFilePath(mediaStorageDir)
Log.i(TAG, "getMediaOutput: canWrite=${canWrite}")
if (canWrite) {
val path = activity.getOutputMediaFile(false)
val uri = getUriForFilePath(path)
@ -164,16 +156,14 @@ class MediaOutputHelper(
mediaOutput = MediaOutput.FileMediaOutput(File(path), uri)
}
}
Log.i(TAG, "FileDescriptorMediaOutput: $mediaOutput")
return mediaOutput
}
private fun openFileDescriptor(uri: Uri): ParcelFileDescriptor? {
return try {
Log.i(TAG, "uri: $uri")
contentResolver.openFileDescriptor(uri, MODE)
} catch (e: Exception) {
e.printStackTrace()
activity.showErrorToast(e)
null
}
}
@ -215,7 +205,6 @@ class MediaOutputHelper(
documentFile.createFile(path.getMimeType(), path.getFilenameFromPath())?.uri
}
} catch (e: Exception) {
e.printStackTrace()
null
}
}
@ -224,7 +213,6 @@ class MediaOutputHelper(
try {
activity.createDocumentUriUsingFirstParentTreeUri(path)
} catch (e: Exception) {
e.printStackTrace()
null
} ?: Uri.fromFile(targetFile)
}

View File

@ -1,6 +1,5 @@
package com.simplemobiletools.camera.helpers
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.camera.core.CameraSelector
import androidx.camera.lifecycle.ProcessCameraProvider
@ -11,13 +10,13 @@ import com.simplemobiletools.camera.extensions.toCameraXQuality
import com.simplemobiletools.camera.extensions.toVideoQuality
import com.simplemobiletools.camera.models.CameraSelectorVideoQualities
import com.simplemobiletools.camera.models.VideoQuality
import com.simplemobiletools.commons.extensions.showErrorToast
class VideoQualityManager(
private val activity: AppCompatActivity,
) {
companion object {
private const val TAG = "VideoQualityHelper"
private val QUALITIES = listOf(Quality.UHD, Quality.FHD, Quality.HD, Quality.SD)
private val CAMERA_SELECTORS = arrayOf(CameraSelector.DEFAULT_BACK_CAMERA, CameraSelector.DEFAULT_FRONT_CAMERA)
}
@ -37,12 +36,10 @@ class VideoQualityManager(
.also { allQualities ->
val qualities = allQualities.map { it.toVideoQuality() }
videoQualities.add(CameraSelectorVideoQualities(camSelector, qualities))
}
Log.i(TAG, "bindCameraUseCases: videoQualities=$videoQualities")
}
} catch (e: Exception) {
Log.e(TAG, "Camera Face $camSelector is not supported", e)
activity.showErrorToast(e)
}
}
}

View File

@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.content.Context
import android.hardware.SensorManager
import android.hardware.display.DisplayManager
import android.util.Log
import android.util.Size
import android.view.*
import android.view.GestureDetector.SimpleOnGestureListener
@ -43,7 +42,6 @@ class CameraXPreview(
) : MyPreview, DefaultLifecycleObserver {
companion object {
private const val TAG = "CameraXPreview"
private const val RATIO_4_3_VALUE = 4.0 / 3.0
private const val RATIO_16_9_VALUE = 16.0 / 9.0
@ -75,7 +73,6 @@ class CameraXPreview(
in 225 until 315 -> Surface.ROTATION_90
else -> Surface.ROTATION_0
}
Log.i(TAG, "onOrientationChanged: rotation=$rotation")
preview?.targetRotation = rotation
imageCapture?.targetRotation = rotation
videoCapture?.targetRotation = rotation
@ -91,9 +88,7 @@ class CameraXPreview(
private var recordingState: VideoRecordEvent? = null
private var cameraSelector = config.lastUsedCameraLens.toCameraSelector()
private var flashMode = FLASH_MODE_OFF
private var isPhotoCapture = initInPhotoMode.also {
Log.i(TAG, "initInPhotoMode= $it")
}
private var isPhotoCapture = initInPhotoMode
init {
bindToLifeCycle()
@ -108,7 +103,6 @@ class CameraXPreview(
}
private fun startCamera(switching: Boolean = false) {
Log.i(TAG, "startCamera: ")
imageQualityManager.initSupportedQualities()
val cameraProviderFuture = ProcessCameraProvider.getInstance(activity)
@ -120,7 +114,6 @@ class CameraXPreview(
bindCameraUseCases()
setupCameraObservers()
} catch (e: Exception) {
Log.e(TAG, "startCamera: ", e)
val errorMessage = if (switching) R.string.camera_switch_error else R.string.camera_open_error
activity.toast(errorMessage)
}
@ -197,9 +190,6 @@ class CameraXPreview(
.apply {
imageQualityManager.getUserSelectedResolution(cameraSelector)?.let { resolution ->
val rotatedResolution = getRotatedResolution(rotation, resolution)
Log.i(TAG, "buildImageCapture: rotation=$rotation")
Log.i(TAG, "buildImageCapture: resolution=$resolution")
Log.i(TAG, "buildImageCapture: rotatedResolution=$rotatedResolution")
setTargetResolution(rotatedResolution)
} ?: setTargetAspectRatio(aspectRatio)
}
@ -255,7 +245,6 @@ class CameraXPreview(
@SuppressLint("ClickableViewAccessibility")
// source: https://stackoverflow.com/a/60095886/10552591
private fun setupZoomAndFocus() {
Log.i(TAG, "camera controller: ${previewView.controller}")
val scaleGesture = camera?.let { ScaleGestureDetector(activity, PinchToZoomOnScaleGestureListener(it.cameraInfo, it.cameraControl)) }
val gestureDetector = GestureDetector(activity, object : SimpleOnGestureListener() {
override fun onSingleTapConfirmed(event: MotionEvent): Boolean {
@ -263,7 +252,6 @@ class CameraXPreview(
val display = displayManager.getDisplay(Display.DEFAULT_DISPLAY)
val width = previewView.width.toFloat()
val height = previewView.height.toFloat()
Log.i(TAG, "onSingleTapConfirmed: width=$width,height=$height")
val factory = DisplayOrientedMeteringPointFactory(display, it, width, height)
val xPos = event.x
val yPos = event.y
@ -275,13 +263,11 @@ class CameraXPreview(
.build()
camera?.cameraControl?.startFocusAndMetering(focusMeteringAction)
listener.onFocusCamera(xPos, yPos)
Log.i(TAG, "start focus")
true
} ?: false
}
})
previewView.setOnTouchListener { _, event ->
Log.i(TAG, "setOnTouchListener: x=${event.x}, y=${event.y}")
gestureDetector.onTouchEvent(event)
scaleGesture?.onTouchEvent(event)
true
@ -405,7 +391,6 @@ class CameraXPreview(
}
private fun handleImageCaptureError(exception: ImageCaptureException) {
Log.e(TAG, "Error", exception)
listener.toggleBottomButtons(false)
cameraErrorHandler.handleImageCaptureError(exception.imageCaptureError)
}
@ -421,13 +406,11 @@ class CameraXPreview(
}
override fun toggleRecording() {
Log.d(TAG, "toggleRecording: currentRecording=$currentRecording, recordingState=$recordingState")
if (currentRecording == null || recordingState is VideoRecordEvent.Finalize) {
startRecording()
} else {
currentRecording?.stop()
currentRecording = null
Log.d(TAG, "Recording stopped")
}
}
@ -454,7 +437,6 @@ class CameraXPreview(
currentRecording = recording.withAudioEnabled()
.start(mainExecutor) { recordEvent ->
Log.d(TAG, "recordEvent=$recordEvent ")
recordingState = recordEvent
when (recordEvent) {
is VideoRecordEvent.Start -> {
@ -470,7 +452,6 @@ class CameraXPreview(
playStopVideoRecordingSoundIfEnabled()
listener.onVideoRecordingStopped()
if (recordEvent.hasError()) {
Log.e(TAG, "recording failed:", recordEvent.cause)
cameraErrorHandler.handleVideoRecordingError(recordEvent.error)
} else {
listener.onMediaSaved(mediaOutput.uri ?: recordEvent.outputResults.outputUri)
@ -478,7 +459,6 @@ class CameraXPreview(
}
}
}
Log.d(TAG, "Recording started")
}
private fun playShutterSoundIfEnabled() {