Skip to content

Commit 612a691

Browse files
committed
couple minor code style and string updates
1 parent 36c0d35 commit 612a691

18 files changed

Lines changed: 34 additions & 45 deletions

File tree

app/src/main/kotlin/com/simplemobiletools/camera/PhotoProcessor.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
3636
var fos: OutputStream? = null
3737
val path: String
3838
try {
39-
if (uri != null) {
40-
path = uri.path
39+
path = if (uri != null) {
40+
uri.path
4141
} else {
42-
path = activity.getOutputMediaFile(true)
42+
activity.getOutputMediaFile(true)
4343
}
4444

4545
if (path.isEmpty()) {
@@ -114,7 +114,6 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
114114

115115
override fun onPostExecute(path: String) {
116116
super.onPostExecute(path)
117-
118117
mActivity?.get()?.mediaSaved(path)
119118
}
120119

app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
201201
return
202202
}
203203

204-
if (mCurrCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
205-
mCurrCameraId = Camera.CameraInfo.CAMERA_FACING_FRONT
204+
mCurrCameraId = if (mCurrCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
205+
Camera.CameraInfo.CAMERA_FACING_FRONT
206206
} else {
207-
mCurrCameraId = Camera.CameraInfo.CAMERA_FACING_BACK
207+
Camera.CameraInfo.CAMERA_FACING_BACK
208208
}
209209

210210
config.lastUsedCamera = mCurrCameraId

app/src/main/kotlin/com/simplemobiletools/camera/extensions/int.kt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@ import android.hardware.Camera
44
import com.simplemobiletools.camera.ORIENT_LANDSCAPE_LEFT
55
import com.simplemobiletools.camera.ORIENT_LANDSCAPE_RIGHT
66

7-
fun Int.compensateDeviceRotation(currCameraId: Int): Int {
8-
val isFrontCamera = currCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT
9-
return if (this == ORIENT_LANDSCAPE_LEFT) {
10-
270
11-
} else if (this == ORIENT_LANDSCAPE_RIGHT) {
12-
90
13-
} else if (isFrontCamera) {
14-
180
15-
} else {
16-
0
17-
}
7+
fun Int.compensateDeviceRotation(currCameraId: Int) = when {
8+
this == ORIENT_LANDSCAPE_LEFT -> 270
9+
this == ORIENT_LANDSCAPE_RIGHT -> 90
10+
currCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT -> 180
11+
else -> 0
1812
}

app/src/main/kotlin/com/simplemobiletools/camera/extensions/size.kt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,10 @@ fun Camera.Size.isSixToFive(): Boolean {
3434
return diff < RATIO_TOLERANCE
3535
}
3636

37-
fun Camera.Size.getAspectRatio(context: Context): String {
38-
return if (isSixteenToNine()) {
39-
"16:9"
40-
} else if (isFourToThree()) {
41-
"4:3"
42-
} else if (isThreeToTwo()) {
43-
"3:2"
44-
} else if (isSixToFive()) {
45-
"6:5"
46-
} else {
47-
context.resources.getString(R.string.other)
48-
}
37+
fun Camera.Size.getAspectRatio(context: Context) = when {
38+
isSixteenToNine() -> "16:9"
39+
isFourToThree() -> "4:3"
40+
isThreeToTwo() -> "3:2"
41+
isSixToFive() -> "6:5"
42+
else -> context.resources.getString(R.string.other)
4943
}

app/src/main/kotlin/com/simplemobiletools/camera/views/FocusRectView.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class FocusRectView(context: Context) : ViewGroup(context) {
4343
toggleRect(true)
4444

4545
mHandler.removeCallbacksAndMessages(null)
46-
mHandler.postDelayed({ toggleRect(false) }, RECT_DURATION.toLong())
46+
mHandler.postDelayed({
47+
toggleRect(false)
48+
}, RECT_DURATION.toLong())
4749
}
4850

4951
private fun toggleRect(show: Boolean) {

app/src/main/res/values-de/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@
4646

4747
<!--
4848
Haven't found some strings? There's more at
49-
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
49+
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
5050
-->
5151
</resources>

app/src/main/res/values-es/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@
4646

4747
<!--
4848
Haven't found some strings? There's more at
49-
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
49+
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
5050
-->
5151
</resources>

app/src/main/res/values-fr/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@
4646

4747
<!--
4848
Haven't found some strings? There's more at
49-
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
49+
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
5050
-->
5151
</resources>

app/src/main/res/values-it/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@
4646

4747
<!--
4848
Haven't found some strings? There's more at
49-
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
49+
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
5050
-->
5151
</resources>

app/src/main/res/values-ja/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@
4646

4747
<!--
4848
Haven't found some strings? There's more at
49-
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/library/src/main/res
49+
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
5050
-->
5151
</resources>

0 commit comments

Comments
 (0)