mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-21 13:50:48 +01:00
fix #56, add a toggle for enabling front camera photo flipping
This commit is contained in:
parent
02978b8375
commit
c9537ec2c4
@ -42,6 +42,10 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
get() = prefs.getBoolean(TURN_FLASH_OFF_AT_STARTUP, false)
|
get() = prefs.getBoolean(TURN_FLASH_OFF_AT_STARTUP, false)
|
||||||
set(turnFlashOffAtStartup) = prefs.edit().putBoolean(TURN_FLASH_OFF_AT_STARTUP, turnFlashOffAtStartup).apply()
|
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
|
var lastUsedCamera: Int
|
||||||
get() = prefs.getInt(LAST_USED_CAMERA, Camera.CameraInfo.CAMERA_FACING_BACK)
|
get() = prefs.getInt(LAST_USED_CAMERA, Camera.CameraInfo.CAMERA_FACING_BACK)
|
||||||
set(cameraId) = prefs.edit().putInt(LAST_USED_CAMERA, cameraId).apply()
|
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 FOCUS_BEFORE_CAPTURE = "focus_before_capture"
|
||||||
val VOLUME_BUTTONS_AS_SHUTTER = "volume_buttons_as_shutter"
|
val VOLUME_BUTTONS_AS_SHUTTER = "volume_buttons_as_shutter"
|
||||||
val TURN_FLASH_OFF_AT_STARTUP = "turn_flash_off_at_startup"
|
val TURN_FLASH_OFF_AT_STARTUP = "turn_flash_off_at_startup"
|
||||||
|
val FLIP_PHOTOS = "flip_photos"
|
||||||
val LAST_USED_CAMERA = "last_used_camera"
|
val LAST_USED_CAMERA = "last_used_camera"
|
||||||
val FLASHLIGHT_STATE = "flashlight_state"
|
val FLASHLIGHT_STATE = "flashlight_state"
|
||||||
val BACK_PHOTO_RESOLUTION_INDEX = "back_photo_resolution_index"
|
val BACK_PHOTO_RESOLUTION_INDEX = "back_photo_resolution_index"
|
||||||
|
@ -3,6 +3,7 @@ package com.simplemobiletools.camera
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.graphics.Matrix
|
import android.graphics.Matrix
|
||||||
|
import android.hardware.Camera
|
||||||
import android.media.ExifInterface
|
import android.media.ExifInterface
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.AsyncTask
|
import android.os.AsyncTask
|
||||||
@ -73,6 +74,16 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
|
|||||||
image = rotate(image, totalRotation)
|
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) {
|
if (image != null) {
|
||||||
image.compress(Bitmap.CompressFormat.JPEG, 80, fos)
|
image.compress(Bitmap.CompressFormat.JPEG, 80, fos)
|
||||||
fos?.close()
|
fos?.close()
|
||||||
|
@ -30,6 +30,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupFocusBeforeCapture()
|
setupFocusBeforeCapture()
|
||||||
setupVolumeButtonsAsShutter()
|
setupVolumeButtonsAsShutter()
|
||||||
setupTurnFlashOffAtStartup()
|
setupTurnFlashOffAtStartup()
|
||||||
|
setupFlipPhotos()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(settings_holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,4 +109,12 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
config.turnFlashOffAtStartup = settings_turn_flash_off_at_startup.isChecked
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,5 +164,25 @@
|
|||||||
android:text="@string/turn_flash_off_at_startup"/>
|
android:text="@string/turn_flash_off_at_startup"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_flip_photos_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:padding="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||||
|
android:id="@+id/settings_flip_photos"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:clickable="false"
|
||||||
|
android:paddingLeft="@dimen/medium_margin"
|
||||||
|
android:paddingStart="@dimen/medium_margin"
|
||||||
|
android:text="@string/flip_front_camera_photos_horizontally"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Vor der Aufnahme fokussieren</string>
|
<string name="focus_before_capture">Vor der Aufnahme fokussieren</string>
|
||||||
<string name="volume_buttons_as_shutter">Benutze Lautstärkeregler als Shutter</string>
|
<string name="volume_buttons_as_shutter">Benutze Lautstärkeregler als Shutter</string>
|
||||||
<string name="turn_flash_off_at_startup">Schalte Blitzlicht bei Start aus</string>
|
<string name="turn_flash_off_at_startup">Schalte Blitzlicht bei Start aus</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Enfocar antes de la captura</string>
|
<string name="focus_before_capture">Enfocar antes de la captura</string>
|
||||||
<string name="volume_buttons_as_shutter">Utilizar los botones de volumen como obturador</string>
|
<string name="volume_buttons_as_shutter">Utilizar los botones de volumen como obturador</string>
|
||||||
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Focus before capture</string>
|
<string name="focus_before_capture">Focus before capture</string>
|
||||||
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
||||||
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Messa a fuoco prima della cattura</string>
|
<string name="focus_before_capture">Messa a fuoco prima della cattura</string>
|
||||||
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
||||||
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">キャプチャ前に再度焦点を合わせる</string>
|
<string name="focus_before_capture">キャプチャ前に再度焦点を合わせる</string>
|
||||||
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
||||||
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Focus before capture</string>
|
<string name="focus_before_capture">Focus before capture</string>
|
||||||
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
||||||
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
<string name="focus_before_capture">Focus before capture</string>
|
<string name="focus_before_capture">Focus before capture</string>
|
||||||
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
||||||
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Złap ostrość przed zrobieniem zdjęcia</string>
|
<string name="focus_before_capture">Złap ostrość przed zrobieniem zdjęcia</string>
|
||||||
<string name="volume_buttons_as_shutter">Używaj przycisków głośności jako spustu migawki</string>
|
<string name="volume_buttons_as_shutter">Używaj przycisków głośności jako spustu migawki</string>
|
||||||
<string name="turn_flash_off_at_startup">Wyłącz lampę błyskową podczas uruchamiania</string>
|
<string name="turn_flash_off_at_startup">Wyłącz lampę błyskową podczas uruchamiania</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Focus before capture</string>
|
<string name="focus_before_capture">Focus before capture</string>
|
||||||
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
||||||
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Focar antes de capturar</string>
|
<string name="focus_before_capture">Focar antes de capturar</string>
|
||||||
<string name="volume_buttons_as_shutter">Usar botões de volume como obturador</string>
|
<string name="volume_buttons_as_shutter">Usar botões de volume como obturador</string>
|
||||||
<string name="turn_flash_off_at_startup">Desligar flash ao iniciar</string>
|
<string name="turn_flash_off_at_startup">Desligar flash ao iniciar</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Перефокусировка перед захватом</string>
|
<string name="focus_before_capture">Перефокусировка перед захватом</string>
|
||||||
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
||||||
<string name="turn_flash_off_at_startup">Выключать вспышку при запуске</string>
|
<string name="turn_flash_off_at_startup">Выключать вспышку при запуске</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Zaostriť pred fotením</string>
|
<string name="focus_before_capture">Zaostriť pred fotením</string>
|
||||||
<string name="volume_buttons_as_shutter">Použiť tlačidlá na ovládanie hlasitosti ako spúšťač</string>
|
<string name="volume_buttons_as_shutter">Použiť tlačidlá na ovládanie hlasitosti ako spúšťač</string>
|
||||||
<string name="turn_flash_off_at_startup">Vypnúť blesk pri spustení</string>
|
<string name="turn_flash_off_at_startup">Vypnúť blesk pri spustení</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Preklopiť fotky z prednej kamera vodorovne</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Fokusera om innan bildtagning</string>
|
<string name="focus_before_capture">Fokusera om innan bildtagning</string>
|
||||||
<string name="volume_buttons_as_shutter">Använd volymknapparna som slutare</string>
|
<string name="volume_buttons_as_shutter">Använd volymknapparna som slutare</string>
|
||||||
<string name="turn_flash_off_at_startup">Stäng av blixten vid start</string>
|
<string name="turn_flash_off_at_startup">Stäng av blixten vid start</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<string name="focus_before_capture">Focus before capture</string>
|
<string name="focus_before_capture">Focus before capture</string>
|
||||||
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
|
||||||
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
|
||||||
|
<string name="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>
|
||||||
|
|
||||||
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
|
||||||
<!-- Short description has to have less than 80 chars -->
|
<!-- Short description has to have less than 80 chars -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user