Skip to content

Commit da82f16

Browse files
committed
add close scanner button
1 parent c014c2c commit da82f16

File tree

11 files changed

+36
-97
lines changed

11 files changed

+36
-97
lines changed

.idea/gradle.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 0.1.1
2+
> 2020-07-21
3+
Added `onClose` abstract method to `BaseScannerActivity`
4+
5+
# 0.1
6+
> 2020-07-21
7+
First implementation

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ class ScannerActivity : BaseScannerActivity() {
3838
}
3939

4040
override fun onDocumentAccepted(path: String) {
41-
TODO("Do something with the path to the file")
41+
Toast.makeText(this, path, Toast.LENGTH_LONG).show()
42+
}
43+
44+
override fun onClose() {
45+
finish()
4246
}
4347
}
4448

app/src/main/java/net/kuama/documentscanner/presentation/BaseScannerActivity.kt

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ abstract class BaseScannerActivity : AppCompatActivity() {
9292
onDocumentAccepted(viewModel.documentPath!!)
9393
}
9494

95+
closeScanner.setOnClickListener {
96+
onClose()
97+
}
9598
this.viewModel = viewModel
9699
}
97100

@@ -112,4 +115,5 @@ abstract class BaseScannerActivity : AppCompatActivity() {
112115

113116
abstract fun onError(throwable: Throwable)
114117
abstract fun onDocumentAccepted(path: String)
118+
abstract fun onClose()
115119
}

app/src/main/java/net/kuama/documentscanner/presentation/ScannerActivity.kt

+4
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ class ScannerActivity : BaseScannerActivity() {
1919
override fun onDocumentAccepted(path: String) {
2020
Toast.makeText(this, path, Toast.LENGTH_LONG).show()
2121
}
22+
23+
override fun onClose() {
24+
finish()
25+
}
2226
}

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

-33
This file was deleted.

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

+13
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@
6363
app:layout_constraintEnd_toEndOf="parent"
6464
app:layout_constraintTop_toTopOf="@id/shutter" />
6565

66+
<ImageButton
67+
android:id="@+id/closeScanner"
68+
android:layout_width="wrap_content"
69+
android:layout_height="wrap_content"
70+
android:layout_marginTop="16dp"
71+
android:layout_marginEnd="16dp"
72+
android:background="@null"
73+
android:contentDescription="@string/close_document_preview"
74+
android:src="@drawable/ic_close_24"
75+
app:layout_constraintEnd_toEndOf="parent"
76+
app:layout_constraintTop_toTopOf="parent" />
77+
78+
6679
<androidx.constraintlayout.widget.ConstraintLayout
6780
android:id="@+id/previewWrap"
6881
android:layout_width="match_parent"

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

-6
This file was deleted.

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

-28
This file was deleted.

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

-27
This file was deleted.

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ android.useAndroidX=true
1919
android.enableJetifier=true
2020
# Kotlin code style for this project: "official" or "obsolete":
2121
kotlin.code.style=official
22-
version_code=1
23-
version_name=0.1
22+
version_code=2
23+
version_name=0.1.1

0 commit comments

Comments
 (0)