updating target SDK to 31 and some small things

This commit is contained in:
tibbi 2022-04-20 21:13:57 +02:00
parent 2da12d4165
commit d717fe299c
11 changed files with 140 additions and 108 deletions

View File

@ -9,13 +9,12 @@ if (keystorePropertiesFile.exists()) {
} }
android { android {
compileSdkVersion 29 compileSdkVersion 31
buildToolsVersion "29.0.3"
defaultConfig { defaultConfig {
applicationId "com.simplemobiletools.camera" applicationId "com.simplemobiletools.camera"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 29 targetSdkVersion 31
versionCode 77 versionCode 77
versionName "5.3.1" versionName "5.3.1"
setProperty("archivesBaseName", "camera") setProperty("archivesBaseName", "camera")
@ -59,5 +58,5 @@ android {
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:99a97f2e16' implementation 'com.github.SimpleMobileTools:Simple-Commons:99a97f2e16'
implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'androidx.documentfile:documentfile:1.0.1'
implementation "androidx.exifinterface:exifinterface:1.3.2" implementation "androidx.exifinterface:exifinterface:1.3.3"
} }

View File

@ -1,32 +1,33 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.simplemobiletools.camera" package="com.simplemobiletools.camera"
android:installLocation="auto"> android:installLocation="auto">
<uses-feature <uses-feature
android:name="android.hardware.camera" android:name="android.hardware.camera"
android:required="true"/> android:required="true" />
<uses-feature <uses-feature
android:name="android.hardware.microphone" android:name="android.hardware.microphone"
android:required="false"/> android:required="false" />
<uses-feature <uses-feature
android:name="android.hardware.camera.autofocus" android:name="android.hardware.camera.autofocus"
android:required="false"/> android:required="false" />
<uses-permission android:name="android.permission.RECORD_AUDIO"/> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/> <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission <uses-permission
android:name="android.permission.USE_FINGERPRINT" android:name="android.permission.USE_FINGERPRINT"
tools:node="remove"/> tools:node="remove" />
<application <application
android:name=".App" android:name=".App"
android:allowBackup="true" android:allowBackup="true"
android:appCategory="image"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_launcher_name" android:label="@string/app_launcher_name"
android:requestLegacyExternalStorage="true" android:requestLegacyExternalStorage="true"
@ -35,74 +36,77 @@
<activity <activity
android:name=".activities.SplashActivity" android:name=".activities.SplashActivity"
android:theme="@style/SplashTheme"/> android:exported="false"
android:theme="@style/SplashTheme" />
<activity <activity
android:name=".activities.MainActivity" android:name=".activities.MainActivity"
android:exported="true"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:showOnLockScreen="true" android:showOnLockScreen="true"
android:theme="@style/FullScreenTheme"> android:theme="@style/FullScreenTheme">
<intent-filter> <intent-filter>
<action android:name="android.media.action.IMAGE_CAPTURE"/> <action android:name="android.media.action.IMAGE_CAPTURE" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.media.action.IMAGE_CAPTURE_SECURE"/> <action android:name="android.media.action.IMAGE_CAPTURE_SECURE" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.media.action.STILL_IMAGE_CAMERA"/> <action android:name="android.media.action.STILL_IMAGE_CAMERA" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.media.action.STILL_IMAGE_CAMERA_SECURE"/> <action android:name="android.media.action.STILL_IMAGE_CAMERA_SECURE" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.media.action.VIDEO_CAMERA"/> <action android:name="android.media.action.VIDEO_CAMERA" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
<intent-filter> <intent-filter>
<action android:name="android.media.action.VIDEO_CAPTURE"/> <action android:name="android.media.action.VIDEO_CAPTURE" />
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name="com.simplemobiletools.commons.activities.AboutActivity" android:name="com.simplemobiletools.commons.activities.AboutActivity"
android:exported="false"
android:label="@string/about" android:label="@string/about"
android:parentActivityName=".activities.SettingsActivity"/> android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name="com.simplemobiletools.commons.activities.LicenseActivity"
android:label="@string/third_party_licences"
android:parentActivityName="com.simplemobiletools.commons.activities.AboutActivity"/>
<activity <activity
android:name="com.simplemobiletools.commons.activities.CustomizationActivity" android:name="com.simplemobiletools.commons.activities.CustomizationActivity"
android:exported="false"
android:label="@string/customize_colors" android:label="@string/customize_colors"
android:parentActivityName=".activities.SettingsActivity"/> android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name="com.simplemobiletools.commons.activities.FAQActivity"
android:label="@string/frequently_asked_questions"
android:parentActivityName="com.simplemobiletools.commons.activities.AboutActivity"/>
<activity <activity
android:name=".activities.SettingsActivity" android:name=".activities.SettingsActivity"
android:exported="true"
android:label="@string/settings" android:label="@string/settings"
android:parentActivityName=".activities.MainActivity"/> android:parentActivityName=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver <receiver
android:name=".receivers.HardwareShutterReceiver"> android:name=".receivers.HardwareShutterReceiver"
android:exported="false">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.CAMERA_BUTTON"/> <action android:name="android.intent.action.CAMERA_BUTTON" />
</intent-filter> </intent-filter>
</receiver> </receiver>
@ -113,252 +117,271 @@
android:grantUriPermissions="true"> android:grantUriPermissions="true">
<meta-data <meta-data
android:name="android.support.FILE_PROVIDER_PATHS" android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/> android:resource="@xml/provider_paths" />
</provider> </provider>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Red" android:name=".activities.SplashActivity.Red"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_red" android:icon="@mipmap/ic_launcher_red"
android:roundIcon="@mipmap/ic_launcher_red" android:roundIcon="@mipmap/ic_launcher_red"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Pink" android:name=".activities.SplashActivity.Pink"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_pink" android:icon="@mipmap/ic_launcher_pink"
android:roundIcon="@mipmap/ic_launcher_pink" android:roundIcon="@mipmap/ic_launcher_pink"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Purple" android:name=".activities.SplashActivity.Purple"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_purple" android:icon="@mipmap/ic_launcher_purple"
android:roundIcon="@mipmap/ic_launcher_purple" android:roundIcon="@mipmap/ic_launcher_purple"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Deep_purple" android:name=".activities.SplashActivity.Deep_purple"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_deep_purple" android:icon="@mipmap/ic_launcher_deep_purple"
android:roundIcon="@mipmap/ic_launcher_deep_purple" android:roundIcon="@mipmap/ic_launcher_deep_purple"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Indigo" android:name=".activities.SplashActivity.Indigo"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_indigo" android:icon="@mipmap/ic_launcher_indigo"
android:roundIcon="@mipmap/ic_launcher_indigo" android:roundIcon="@mipmap/ic_launcher_indigo"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Blue" android:name=".activities.SplashActivity.Blue"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_blue" android:icon="@mipmap/ic_launcher_blue"
android:roundIcon="@mipmap/ic_launcher_blue" android:roundIcon="@mipmap/ic_launcher_blue"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Light_blue" android:name=".activities.SplashActivity.Light_blue"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_light_blue" android:icon="@mipmap/ic_launcher_light_blue"
android:roundIcon="@mipmap/ic_launcher_light_blue" android:roundIcon="@mipmap/ic_launcher_light_blue"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Cyan" android:name=".activities.SplashActivity.Cyan"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_cyan" android:icon="@mipmap/ic_launcher_cyan"
android:roundIcon="@mipmap/ic_launcher_cyan" android:roundIcon="@mipmap/ic_launcher_cyan"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Teal" android:name=".activities.SplashActivity.Teal"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_teal" android:icon="@mipmap/ic_launcher_teal"
android:roundIcon="@mipmap/ic_launcher_teal" android:roundIcon="@mipmap/ic_launcher_teal"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Green" android:name=".activities.SplashActivity.Green"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_green" android:icon="@mipmap/ic_launcher_green"
android:roundIcon="@mipmap/ic_launcher_green" android:roundIcon="@mipmap/ic_launcher_green"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Light_green" android:name=".activities.SplashActivity.Light_green"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_light_green" android:icon="@mipmap/ic_launcher_light_green"
android:roundIcon="@mipmap/ic_launcher_light_green" android:roundIcon="@mipmap/ic_launcher_light_green"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Lime" android:name=".activities.SplashActivity.Lime"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_lime" android:icon="@mipmap/ic_launcher_lime"
android:roundIcon="@mipmap/ic_launcher_lime" android:roundIcon="@mipmap/ic_launcher_lime"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Yellow" android:name=".activities.SplashActivity.Yellow"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_yellow" android:icon="@mipmap/ic_launcher_yellow"
android:roundIcon="@mipmap/ic_launcher_yellow" android:roundIcon="@mipmap/ic_launcher_yellow"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Amber" android:name=".activities.SplashActivity.Amber"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_amber" android:icon="@mipmap/ic_launcher_amber"
android:roundIcon="@mipmap/ic_launcher_amber" android:roundIcon="@mipmap/ic_launcher_amber"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Orange" android:name=".activities.SplashActivity.Orange"
android:enabled="true" android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Deep_orange" android:name=".activities.SplashActivity.Deep_orange"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_deep_orange" android:icon="@mipmap/ic_launcher_deep_orange"
android:roundIcon="@mipmap/ic_launcher_deep_orange" android:roundIcon="@mipmap/ic_launcher_deep_orange"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Brown" android:name=".activities.SplashActivity.Brown"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_brown" android:icon="@mipmap/ic_launcher_brown"
android:roundIcon="@mipmap/ic_launcher_brown" android:roundIcon="@mipmap/ic_launcher_brown"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Blue_grey" android:name=".activities.SplashActivity.Blue_grey"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_blue_grey" android:icon="@mipmap/ic_launcher_blue_grey"
android:roundIcon="@mipmap/ic_launcher_blue_grey" android:roundIcon="@mipmap/ic_launcher_blue_grey"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
<activity-alias <activity-alias
android:name=".activities.SplashActivity.Grey_black" android:name=".activities.SplashActivity.Grey_black"
android:enabled="false" android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_grey_black" android:icon="@mipmap/ic_launcher_grey_black"
android:roundIcon="@mipmap/ic_launcher_grey_black" android:roundIcon="@mipmap/ic_launcher_grey_black"
android:targetActivity=".activities.SplashActivity"> android:targetActivity=".activities.SplashActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity-alias> </activity-alias>
</application> </application>

View File

@ -155,12 +155,12 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
stopBackgroundThread() stopBackgroundThread()
} }
override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture?, width: Int, height: Int) { override fun onSurfaceTextureSizeChanged(surface: SurfaceTexture, width: Int, height: Int) {
closeCamera() closeCamera()
openCamera(width, height) openCamera(width, height)
} }
override fun onSurfaceTextureUpdated(surface: SurfaceTexture?) {} override fun onSurfaceTextureUpdated(surface: SurfaceTexture) {}
override fun onSurfaceTextureDestroyed(surface: SurfaceTexture) = true override fun onSurfaceTextureDestroyed(surface: SurfaceTexture) = true
@ -359,7 +359,8 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
configMap.getOutputSizes(SurfaceTexture::class.java) configMap.getOutputSizes(SurfaceTexture::class.java)
} }
mPreviewSize = chooseOptimalPreviewSize(outputSizes, rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, currentResolution) mPreviewSize =
chooseOptimalPreviewSize(outputSizes, rotatedPreviewWidth, rotatedPreviewHeight, maxPreviewWidth, maxPreviewHeight, currentResolution)
mActivity.runOnUiThread { mActivity.runOnUiThread {
mTextureView.setAspectRatio(mPreviewSize!!.height, mPreviewSize!!.width) mTextureView.setAspectRatio(mPreviewSize!!.height, mPreviewSize!!.width)
@ -378,7 +379,14 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
} }
} }
private fun chooseOptimalPreviewSize(choices: Array<Size>, textureViewWidth: Int, textureViewHeight: Int, maxWidth: Int, maxHeight: Int, selectedResolution: MySize): Size { private fun chooseOptimalPreviewSize(
choices: Array<Size>,
textureViewWidth: Int,
textureViewHeight: Int,
maxWidth: Int,
maxHeight: Int,
selectedResolution: MySize
): Size {
val bigEnough = ArrayList<Size>() val bigEnough = ArrayList<Size>()
val notBigEnough = ArrayList<Size>() val notBigEnough = ArrayList<Size>()
val bigEnoughIncorrectAR = ArrayList<Size>() val bigEnoughIncorrectAR = ArrayList<Size>()
@ -404,10 +412,10 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
} }
return when { return when {
bigEnough.isNotEmpty() -> bigEnough.minBy { it.width * it.height }!! bigEnough.isNotEmpty() -> bigEnough.minByOrNull { it.width * it.height }!!
notBigEnough.isNotEmpty() -> notBigEnough.maxBy { it.width * it.height }!! notBigEnough.isNotEmpty() -> notBigEnough.maxByOrNull { it.width * it.height }!!
bigEnoughIncorrectAR.isNotEmpty() -> bigEnoughIncorrectAR.minBy { it.width * it.height }!! bigEnoughIncorrectAR.isNotEmpty() -> bigEnoughIncorrectAR.minByOrNull { it.width * it.height }!!
notBigEnoughIncorrectAR.isNotEmpty() -> notBigEnoughIncorrectAR.maxBy { it.width * it.height }!! notBigEnoughIncorrectAR.isNotEmpty() -> notBigEnoughIncorrectAR.maxByOrNull { it.width * it.height }!!
else -> selectedResolution.toSize() else -> selectedResolution.toSize()
} }
} }
@ -822,7 +830,7 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
} }
try { try {
val texture = mTextureView.surfaceTexture val texture = mTextureView.surfaceTexture!!
texture.setDefaultBufferSize(mPreviewSize!!.width, mPreviewSize!!.height) texture.setDefaultBufferSize(mPreviewSize!!.width, mPreviewSize!!.height)
mPreviewRequestBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_RECORD).apply { mPreviewRequestBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_RECORD).apply {
set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD) set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_VIDEO_RECORD)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 843 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/view_holder" android:id="@+id/view_holder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -9,14 +8,14 @@
<com.simplemobiletools.camera.views.AutoFitTextureView <com.simplemobiletools.camera.views.AutoFitTextureView
android:id="@+id/camera_texture_view" android:id="@+id/camera_texture_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content" />
<ImageView <ImageView
android:id="@+id/capture_black_screen" android:id="@+id/capture_black_screen"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:alpha="0" android:alpha="0"
android:background="#000000" /> android:background="@color/md_grey_black" />
<ImageView <ImageView
android:id="@+id/settings" android:id="@+id/settings"
@ -24,7 +23,7 @@
android:layout_height="@dimen/icon_size" android:layout_height="@dimen/icon_size"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:padding="@dimen/normal_margin" android:padding="@dimen/normal_margin"
android:src="@drawable/ic_settings_cog"/> android:src="@drawable/ic_settings_cog_vector" />
<ImageView <ImageView
android:id="@+id/toggle_photo_video" android:id="@+id/toggle_photo_video"
@ -33,7 +32,7 @@
android:layout_below="@+id/settings" android:layout_below="@+id/settings"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:padding="@dimen/normal_margin" android:padding="@dimen/normal_margin"
android:src="@drawable/ic_video_vector"/> android:src="@drawable/ic_video_vector" />
<ImageView <ImageView
android:id="@+id/change_resolution" android:id="@+id/change_resolution"
@ -42,7 +41,7 @@
android:layout_below="@+id/toggle_photo_video" android:layout_below="@+id/toggle_photo_video"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:padding="@dimen/normal_margin" android:padding="@dimen/normal_margin"
android:src="@drawable/ic_resolution_vector"/> android:src="@drawable/ic_resolution_vector" />
<ImageView <ImageView
android:id="@+id/last_photo_video_preview" android:id="@+id/last_photo_video_preview"
@ -50,7 +49,7 @@
android:layout_height="@dimen/icon_size" android:layout_height="@dimen/icon_size"
android:layout_below="@+id/change_resolution" android:layout_below="@+id/change_resolution"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:padding="@dimen/medium_margin"/> android:padding="@dimen/medium_margin" />
<LinearLayout <LinearLayout
android:id="@+id/btn_holder" android:id="@+id/btn_holder"
@ -65,14 +64,14 @@
android:layout_height="@dimen/icon_size" android:layout_height="@dimen/icon_size"
android:layout_weight="1" android:layout_weight="1"
android:padding="@dimen/normal_margin" android:padding="@dimen/normal_margin"
android:src="@drawable/ic_camera_front_vector"/> android:src="@drawable/ic_camera_front_vector" />
<ImageView <ImageView
android:id="@+id/shutter" android:id="@+id/shutter"
android:layout_width="@dimen/icon_size" android:layout_width="@dimen/icon_size"
android:layout_height="@dimen/icon_size" android:layout_height="@dimen/icon_size"
android:layout_weight="1" android:layout_weight="1"
android:src="@drawable/ic_shutter_vector"/> android:src="@drawable/ic_shutter_vector" />
<ImageView <ImageView
android:id="@+id/toggle_flash" android:id="@+id/toggle_flash"
@ -80,7 +79,7 @@
android:layout_height="@dimen/icon_size" android:layout_height="@dimen/icon_size"
android:layout_weight="1" android:layout_weight="1"
android:padding="@dimen/normal_margin" android:padding="@dimen/normal_margin"
android:src="@drawable/ic_flash_off_vector"/> android:src="@drawable/ic_flash_off_vector" />
</LinearLayout> </LinearLayout>
@ -92,6 +91,6 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:text="00:00" android:text="00:00"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:visibility="gone"/> android:visibility="gone" />
</RelativeLayout> </RelativeLayout>

View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="AppCompatResource">
<item <item
android:id="@+id/about" android:id="@+id/about"
android:showAsAction="never"
android:title="@string/about" android:title="@string/about"
app:showAsAction="never"/> app:showAsAction="never" />
</menu> </menu>

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.4.32' ext.kotlin_version = '1.6.20'
repositories { repositories {
google() google()
@ -9,7 +9,7 @@ buildscript {
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.3' classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip