couple minor code style and string updates

This commit is contained in:
tibbi 2017-09-20 23:34:13 +02:00
parent 36c0d351fe
commit 612a6918b7
18 changed files with 34 additions and 45 deletions

View File

@ -36,10 +36,10 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
var fos: OutputStream? = null
val path: String
try {
if (uri != null) {
path = uri.path
path = if (uri != null) {
uri.path
} else {
path = activity.getOutputMediaFile(true)
activity.getOutputMediaFile(true)
}
if (path.isEmpty()) {
@ -114,7 +114,6 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
override fun onPostExecute(path: String) {
super.onPostExecute(path)
mActivity?.get()?.mediaSaved(path)
}

View File

@ -201,10 +201,10 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
return
}
if (mCurrCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
mCurrCameraId = Camera.CameraInfo.CAMERA_FACING_FRONT
mCurrCameraId = if (mCurrCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
Camera.CameraInfo.CAMERA_FACING_FRONT
} else {
mCurrCameraId = Camera.CameraInfo.CAMERA_FACING_BACK
Camera.CameraInfo.CAMERA_FACING_BACK
}
config.lastUsedCamera = mCurrCameraId

View File

@ -4,15 +4,9 @@ import android.hardware.Camera
import com.simplemobiletools.camera.ORIENT_LANDSCAPE_LEFT
import com.simplemobiletools.camera.ORIENT_LANDSCAPE_RIGHT
fun Int.compensateDeviceRotation(currCameraId: Int): Int {
val isFrontCamera = currCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT
return if (this == ORIENT_LANDSCAPE_LEFT) {
270
} else if (this == ORIENT_LANDSCAPE_RIGHT) {
90
} else if (isFrontCamera) {
180
} else {
0
}
fun Int.compensateDeviceRotation(currCameraId: Int) = when {
this == ORIENT_LANDSCAPE_LEFT -> 270
this == ORIENT_LANDSCAPE_RIGHT -> 90
currCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT -> 180
else -> 0
}

View File

@ -34,16 +34,10 @@ fun Camera.Size.isSixToFive(): Boolean {
return diff < RATIO_TOLERANCE
}
fun Camera.Size.getAspectRatio(context: Context): String {
return if (isSixteenToNine()) {
"16:9"
} else if (isFourToThree()) {
"4:3"
} else if (isThreeToTwo()) {
"3:2"
} else if (isSixToFive()) {
"6:5"
} else {
context.resources.getString(R.string.other)
}
fun Camera.Size.getAspectRatio(context: Context) = when {
isSixteenToNine() -> "16:9"
isFourToThree() -> "4:3"
isThreeToTwo() -> "3:2"
isSixToFive() -> "6:5"
else -> context.resources.getString(R.string.other)
}

View File

@ -43,7 +43,9 @@ class FocusRectView(context: Context) : ViewGroup(context) {
toggleRect(true)
mHandler.removeCallbacksAndMessages(null)
mHandler.postDelayed({ toggleRect(false) }, RECT_DURATION.toLong())
mHandler.postDelayed({
toggleRect(false)
}, RECT_DURATION.toLong())
}
private fun toggleRect(show: Boolean) {

View File

@ -46,6 +46,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -46,6 +46,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -46,6 +46,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -46,6 +46,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -46,6 +46,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -46,6 +46,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -46,6 +46,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>
</resources>

View File

@ -45,6 +45,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -46,6 +46,6 @@
<!--
Não encontrou todas as cadeias a traduzir? Existem mais algumas em:
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -46,6 +46,6 @@
<!--
Não encontrou todas as cadeias a traduzir? Existem mais algumas em:
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -46,6 +46,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -45,6 +45,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -45,6 +45,6 @@
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>