mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-06-27 09:02:59 +02:00
fix #56, add a toggle for enabling front camera photo flipping
This commit is contained in:
@ -42,6 +42,10 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
get() = prefs.getBoolean(TURN_FLASH_OFF_AT_STARTUP, false)
|
||||
set(turnFlashOffAtStartup) = prefs.edit().putBoolean(TURN_FLASH_OFF_AT_STARTUP, turnFlashOffAtStartup).apply()
|
||||
|
||||
var flipPhotos: Boolean
|
||||
get() = prefs.getBoolean(FLIP_PHOTOS, false)
|
||||
set(flipPhotos) = prefs.edit().putBoolean(FLIP_PHOTOS, flipPhotos).apply()
|
||||
|
||||
var lastUsedCamera: Int
|
||||
get() = prefs.getInt(LAST_USED_CAMERA, Camera.CameraInfo.CAMERA_FACING_BACK)
|
||||
set(cameraId) = prefs.edit().putInt(LAST_USED_CAMERA, cameraId).apply()
|
||||
|
@ -11,6 +11,7 @@ val SOUND = "sound"
|
||||
val FOCUS_BEFORE_CAPTURE = "focus_before_capture"
|
||||
val VOLUME_BUTTONS_AS_SHUTTER = "volume_buttons_as_shutter"
|
||||
val TURN_FLASH_OFF_AT_STARTUP = "turn_flash_off_at_startup"
|
||||
val FLIP_PHOTOS = "flip_photos"
|
||||
val LAST_USED_CAMERA = "last_used_camera"
|
||||
val FLASHLIGHT_STATE = "flashlight_state"
|
||||
val BACK_PHOTO_RESOLUTION_INDEX = "back_photo_resolution_index"
|
||||
|
@ -3,6 +3,7 @@ package com.simplemobiletools.camera
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Matrix
|
||||
import android.hardware.Camera
|
||||
import android.media.ExifInterface
|
||||
import android.net.Uri
|
||||
import android.os.AsyncTask
|
||||
@ -73,6 +74,16 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
|
||||
image = rotate(image, totalRotation)
|
||||
}
|
||||
|
||||
if (currCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT && !activity.config.flipPhotos) {
|
||||
val matrix = Matrix()
|
||||
if (path.startsWith(activity.internalStoragePath)) {
|
||||
matrix.preScale(1f, -1f)
|
||||
} else {
|
||||
matrix.preScale(-1f, 1f)
|
||||
}
|
||||
image = Bitmap.createBitmap(image, 0, 0, image.width, image.height, matrix, false)
|
||||
}
|
||||
|
||||
if (image != null) {
|
||||
image.compress(Bitmap.CompressFormat.JPEG, 80, fos)
|
||||
fos?.close()
|
||||
|
@ -30,6 +30,7 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupFocusBeforeCapture()
|
||||
setupVolumeButtonsAsShutter()
|
||||
setupTurnFlashOffAtStartup()
|
||||
setupFlipPhotos()
|
||||
updateTextColors(settings_holder)
|
||||
}
|
||||
|
||||
@ -108,4 +109,12 @@ class SettingsActivity : SimpleActivity() {
|
||||
config.turnFlashOffAtStartup = settings_turn_flash_off_at_startup.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupFlipPhotos() {
|
||||
settings_flip_photos.isChecked = config.flipPhotos
|
||||
settings_flip_photos_holder.setOnClickListener {
|
||||
settings_flip_photos.toggle()
|
||||
config.flipPhotos = settings_flip_photos.isChecked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user