zcash-android-wallet-zcon1/zcash-android-wallet-app/qrecycler/src/main/java/cash/z/android/cameraview/api23/Camera2Api23.kt

53 lines
1.9 KiB
Kotlin

/*
* Copyright (C) 2019 Electric Coin Company
*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* This file has been modified by Electric Coin Company to translate it into Kotlin and add support for Firebase vision.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.cameraview
import android.annotation.TargetApi
import android.content.Context
import android.graphics.ImageFormat
import android.hardware.camera2.params.StreamConfigurationMap
import cash.z.android.cameraview.CameraView
import cash.z.android.cameraview.api21.Camera2
import cash.z.android.cameraview.base.CameraViewImpl
import cash.z.android.cameraview.base.PreviewImpl
import cash.z.android.cameraview.base.Size
import cash.z.android.cameraview.base.SizeMap
@TargetApi(23)
internal class Camera2Api23(callback: CameraViewImpl.Callback, preview: PreviewImpl, context: Context) :
Camera2(callback, preview, context) {
protected override fun collectPictureSizes(sizes: SizeMap, map: StreamConfigurationMap) {
// Try to get hi-res output sizes
val outputSizes = map.getHighResolutionOutputSizes(ImageFormat.JPEG)
if (outputSizes != null) {
for (size in map.getHighResolutionOutputSizes(ImageFormat.JPEG)) {
sizes.add(Size(size.width, size.height))
}
}
if (sizes.isEmpty) {
super.collectPictureSizes(sizes, map)
}
}
}