Skip to content

Commit d338d57

Browse files
committed
Allow auto-detect the perspective on open
1 parent 13f433b commit d338d57

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

app/src/main/java/com/dan/perspective/MainFragment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ class MainFragment(activity: MainActivity) : AppFragment(activity) {
186186

187187
clearOutputImage()
188188
updateButtons()
189+
190+
if (settings.autoDetectOnOpen) {
191+
autoDetectPerspective()
192+
}
189193
}
190194
}
191195
}

app/src/main/java/com/dan/perspective/Settings.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Settings( private val activity: Activity) {
3232
var prevLeftBottomY = -1f
3333
var prevWidth = 0
3434
var prevHeight = 0
35+
var autoDetectOnOpen = false
3536

3637
init {
3738
loadProperties()

app/src/main/java/com/dan/perspective/SettingsFragment.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ class SettingsFragment(activity: MainActivity) : AppFragment(activity) {
2323
override fun onBack(homeButton: Boolean) {
2424
settings.jpegQuality = JPEG_QUALITY_BASE + (100 - JPEG_QUALITY_BASE) * binding.seekBarJpegQuality.progress / binding.seekBarJpegQuality.max
2525
settings.hapticFeedback = binding.switchHapticFeedback.isChecked
26+
settings.autoDetectOnOpen = binding.switchAutoPerspectiveOnOpen.isChecked
2627

2728
settings.saveProperties()
2829
}
2930

3031
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
3132
binding = SettingsFragmentBinding.inflate( inflater )
3233

34+
binding.switchAutoPerspectiveOnOpen.isChecked = settings.autoDetectOnOpen
35+
3336
val jpegQualityProgress = when {
3437
settings.jpegQuality >= 100 -> binding.seekBarJpegQuality.max
3538
settings.jpegQuality < JPEG_QUALITY_BASE -> 0

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

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,29 @@
1717
android:layout_height="wrap_content"
1818
android:orientation="vertical">
1919

20+
<TextView
21+
android:id="@+id/textView9"
22+
android:layout_width="match_parent"
23+
android:layout_height="wrap_content"
24+
android:layout_marginBottom="5dp"
25+
android:paddingTop="16dp"
26+
android:text="Open"
27+
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
28+
android:textStyle="bold" />
29+
30+
<Switch
31+
android:id="@+id/switchAutoPerspectiveOnOpen"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
android:paddingTop="16dp"
35+
android:paddingBottom="16dp"
36+
android:text="Auto perspective on open" />
37+
2038
<TextView
2139
android:id="@+id/textView4"
2240
android:layout_width="wrap_content"
2341
android:layout_height="wrap_content"
42+
android:paddingTop="16dp"
2443
android:text="Save"
2544
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
2645
android:textStyle="bold" />
@@ -29,7 +48,9 @@
2948
android:layout_width="match_parent"
3049
android:layout_height="wrap_content"
3150
android:layout_gravity="center_vertical"
32-
android:orientation="horizontal">
51+
android:orientation="horizontal"
52+
android:paddingTop="16dp"
53+
android:paddingBottom="16dp">
3354

3455
<TextView
3556
android:id="@+id/textView10"
@@ -56,21 +77,12 @@
5677
android:textAlignment="center" />
5778
</LinearLayout>
5879

59-
<View
60-
android:id="@+id/divider4"
61-
android:layout_width="match_parent"
62-
android:layout_height="1dp"
63-
android:layout_marginStart="5dp"
64-
android:layout_marginTop="16dp"
65-
android:layout_marginEnd="5dp"
66-
android:layout_marginBottom="16dp"
67-
android:background="@android:drawable/divider_horizontal_textfield" />
68-
6980
<TextView
7081
android:id="@+id/textView8"
7182
android:layout_width="match_parent"
7283
android:layout_height="wrap_content"
7384
android:layout_marginBottom="5dp"
85+
android:paddingTop="16dp"
7486
android:text="Interface"
7587
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
7688
android:textStyle="bold" />
@@ -79,6 +91,8 @@
7991
android:id="@+id/switchHapticFeedback"
8092
android:layout_width="match_parent"
8193
android:layout_height="wrap_content"
94+
android:paddingTop="16dp"
95+
android:paddingBottom="16dp"
8296
android:text="Haptic feedback" />
8397

8498
</LinearLayout>

0 commit comments

Comments
 (0)