Skip to content

Commit

Permalink
fix #56, add a toggle for enabling front camera photo flipping
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbi committed Sep 21, 2017
1 parent 02978b8 commit c9537ec
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/kotlin/com/simplemobiletools/camera/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/kotlin/com/simplemobiletools/camera/PhotoProcessor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SettingsActivity : SimpleActivity() {
setupFocusBeforeCapture()
setupVolumeButtonsAsShutter()
setupTurnFlashOffAtStartup()
setupFlipPhotos()
updateTextColors(settings_holder)
}

Expand Down Expand Up @@ -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
}
}
}
20 changes: 20 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,25 @@
android:text="@string/turn_flash_off_at_startup"/>

</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>
</ScrollView>
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="focus_before_capture">Vor der Aufnahme fokussieren</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="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>

<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<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="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 -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="focus_before_capture">Focus before capture</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="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>

<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<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="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 -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="focus_before_capture">キャプチャ前に再度焦点を合わせる</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="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>

<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-lt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="focus_before_capture">Focus before capture</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="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>

<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<string name="focus_before_capture">Focus before capture</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="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>

<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<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="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 -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="focus_before_capture">Focus before capture</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="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>

<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<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="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 -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="focus_before_capture">Перефокусировка перед захватом</string>
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</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 -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<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="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 -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="focus_before_capture">Fokusera om innan bildtagning</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="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>

<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<string name="focus_before_capture">Focus before capture</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="flip_front_camera_photos_horizontally">Flip front camera photos horizontally</string>

<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
Expand Down

0 comments on commit c9537ec

Please sign in to comment.