Skip to content

Commit 31c16df

Browse files
author
Dan Oprea
committed
Add 4x magnifier (useful for manual focus for closeups)
1 parent 862cfb5 commit 31c16df

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

app/src/main/java/com/dan/simplerawcamera/CameraActivity.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,14 @@ class CameraActivity : AppCompatActivity() {
871871
updateSliders()
872872
}
873873

874+
mBinding.switch4X.isChecked = false
875+
mBinding.switch4X.setOnCheckedChangeListener { _, isChecked ->
876+
giveHapticFeedback(mBinding.switchSequences)
877+
val scale = if (isChecked) 4.0f else 1.0f
878+
mBinding.surfaceView.scaleX = scale
879+
mBinding.surfaceView.scaleY = scale
880+
}
881+
874882
mOrientationEventListener = object: OrientationEventListener(this, SensorManager.SENSOR_DELAY_NORMAL) {
875883
override fun onOrientationChanged(orientation: Int) {
876884
val screenOrientation = (orientation + 45) / 90 * 90 //round to 90°

app/src/main/res/layout/activity_main.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
<layout xmlns:android="http://schemas.android.com/apk/res/android"
3+
<layout xmlns:tools="http://schemas.android.com/tools"
4+
xmlns:android="http://schemas.android.com/apk/res/android"
45
xmlns:app="http://schemas.android.com/apk/res-auto">
56

67
<LinearLayout
@@ -259,6 +260,20 @@
259260
android:thumbTint="@color/white"
260261
android:visibility="invisible" />
261262

263+
<Switch
264+
android:id="@+id/switch4X"
265+
android:layout_width="match_parent"
266+
android:layout_height="wrap_content"
267+
android:layout_gravity="center"
268+
android:checked="false"
269+
android:gravity="center"
270+
android:showText="false"
271+
android:text="View 4x"
272+
android:textAlignment="center"
273+
android:textColor="@color/teal_200"
274+
android:textStyle="bold"
275+
tools:checked="false" />
276+
262277
<LinearLayout
263278
android:layout_width="0dp"
264279
android:layout_height="0dp"

0 commit comments

Comments
 (0)