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 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)
} }

View File

@ -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

View File

@ -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
}
} }

View File

@ -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)
}
} }

View File

@ -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) {

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>