mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-04-14 07:22:03 +02:00
couple minor code style and string updates
This commit is contained in:
parent
36c0d351fe
commit
612a6918b7
@ -36,10 +36,10 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
|
|||||||
var fos: OutputStream? = null
|
var fos: OutputStream? = null
|
||||||
val path: String
|
val path: String
|
||||||
try {
|
try {
|
||||||
if (uri != null) {
|
path = if (uri != null) {
|
||||||
path = uri.path
|
uri.path
|
||||||
} else {
|
} else {
|
||||||
path = activity.getOutputMediaFile(true)
|
activity.getOutputMediaFile(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
@ -114,7 +114,6 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
|
|||||||
|
|
||||||
override fun onPostExecute(path: String) {
|
override fun onPostExecute(path: String) {
|
||||||
super.onPostExecute(path)
|
super.onPostExecute(path)
|
||||||
|
|
||||||
mActivity?.get()?.mediaSaved(path)
|
mActivity?.get()?.mediaSaved(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,10 +201,10 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
|
mCurrCameraId = if (mCurrCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
|
||||||
mCurrCameraId = Camera.CameraInfo.CAMERA_FACING_FRONT
|
Camera.CameraInfo.CAMERA_FACING_FRONT
|
||||||
} else {
|
} else {
|
||||||
mCurrCameraId = Camera.CameraInfo.CAMERA_FACING_BACK
|
Camera.CameraInfo.CAMERA_FACING_BACK
|
||||||
}
|
}
|
||||||
|
|
||||||
config.lastUsedCamera = mCurrCameraId
|
config.lastUsedCamera = mCurrCameraId
|
||||||
|
@ -4,15 +4,9 @@ import android.hardware.Camera
|
|||||||
import com.simplemobiletools.camera.ORIENT_LANDSCAPE_LEFT
|
import com.simplemobiletools.camera.ORIENT_LANDSCAPE_LEFT
|
||||||
import com.simplemobiletools.camera.ORIENT_LANDSCAPE_RIGHT
|
import com.simplemobiletools.camera.ORIENT_LANDSCAPE_RIGHT
|
||||||
|
|
||||||
fun Int.compensateDeviceRotation(currCameraId: Int): Int {
|
fun Int.compensateDeviceRotation(currCameraId: Int) = when {
|
||||||
val isFrontCamera = currCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT
|
this == ORIENT_LANDSCAPE_LEFT -> 270
|
||||||
return if (this == ORIENT_LANDSCAPE_LEFT) {
|
this == ORIENT_LANDSCAPE_RIGHT -> 90
|
||||||
270
|
currCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT -> 180
|
||||||
} else if (this == ORIENT_LANDSCAPE_RIGHT) {
|
else -> 0
|
||||||
90
|
|
||||||
} else if (isFrontCamera) {
|
|
||||||
180
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,16 +34,10 @@ fun Camera.Size.isSixToFive(): Boolean {
|
|||||||
return diff < RATIO_TOLERANCE
|
return diff < RATIO_TOLERANCE
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Camera.Size.getAspectRatio(context: Context): String {
|
fun Camera.Size.getAspectRatio(context: Context) = when {
|
||||||
return if (isSixteenToNine()) {
|
isSixteenToNine() -> "16:9"
|
||||||
"16:9"
|
isFourToThree() -> "4:3"
|
||||||
} else if (isFourToThree()) {
|
isThreeToTwo() -> "3:2"
|
||||||
"4:3"
|
isSixToFive() -> "6:5"
|
||||||
} else if (isThreeToTwo()) {
|
else -> context.resources.getString(R.string.other)
|
||||||
"3:2"
|
|
||||||
} else if (isSixToFive()) {
|
|
||||||
"6:5"
|
|
||||||
} else {
|
|
||||||
context.resources.getString(R.string.other)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,9 @@ class FocusRectView(context: Context) : ViewGroup(context) {
|
|||||||
toggleRect(true)
|
toggleRect(true)
|
||||||
|
|
||||||
mHandler.removeCallbacksAndMessages(null)
|
mHandler.removeCallbacksAndMessages(null)
|
||||||
mHandler.postDelayed({ toggleRect(false) }, RECT_DURATION.toLong())
|
mHandler.postDelayed({
|
||||||
|
toggleRect(false)
|
||||||
|
}, RECT_DURATION.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleRect(show: Boolean) {
|
private fun toggleRect(show: Boolean) {
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -45,6 +45,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Não encontrou todas as cadeias a traduzir? Existem mais algumas em:
|
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>
|
</resources>
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Não encontrou todas as cadeias a traduzir? Existem mais algumas em:
|
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>
|
</resources>
|
||||||
|
@ -46,6 +46,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -45,6 +45,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
@ -45,6 +45,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Haven't found some strings? There's more at
|
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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user