Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit b2d6bef

Browse files
committed
Merge branch 'release/2.0.11' into 'master'
Release 2.0.11 See merge request mobile/android/AndroidDocumentScanner!41
2 parents 4c73040 + 21bdb3b commit b2d6bef

4 files changed

Lines changed: 21 additions & 13 deletions

File tree

app/src/main/java/com/example/documentscanner/MainActivity.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@ package com.example.documentscanner
22

33
import android.content.Intent
44
import android.os.Bundle
5-
import android.os.Handler
6-
import android.os.PersistableBundle
5+
import android.widget.Button
76
import androidx.appcompat.app.AppCompatActivity
87
import nz.mega.documentscanner.DocumentScannerActivity
98

109
class MainActivity : AppCompatActivity() {
1110

12-
override fun onCreate(savedInstanceState: Bundle?, persistentState: PersistableBundle?) {
13-
super.onCreate(savedInstanceState, persistentState)
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
1413
setContentView(R.layout.activity_main)
15-
16-
Handler().postDelayed({
14+
findViewById<Button>(R.id.btnPick).setOnClickListener {
1715
startActivity(Intent(this, DocumentScannerActivity::class.java))
18-
}, 2000L)
16+
}
1917
}
2018
}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
buildscript {
22
ext {
3-
versionCode = 17
4-
versionName = "2.0.10"
3+
versionCode = 18
4+
versionName = "2.0.11"
55
compileSdkVersion = 29
66
minSdkVersion = 21
77
group = "com.github.meganz"

documentscanner/src/main/java/nz/mega/documentscanner/DocumentScannerViewModel.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ class DocumentScannerViewModel : ViewModel() {
157157
document.value?.pages?.add(page)
158158
} else {
159159
document.value?.pages?.add(retakePosition, page)
160-
retakePosition = NO_POSITION
161160
}
161+
// Reset retakePosition after the page is added to avoid retakePosition causes the add page is incorrect.
162+
retakePosition = NO_POSITION
162163

163164
bitmap.recycle()
164165
transformBitmap?.recycle()
@@ -242,13 +243,21 @@ class DocumentScannerViewModel : ViewModel() {
242243
}
243244

244245
/**
245-
* Retake scan page
246+
* Retake scan page, only update the retakePage, don't delete the current page.
246247
*
247248
* @param position Page position to be retaken. Default value is the current position
248249
*/
249250
fun retakePage(position: Int = currentPagePosition.value ?: 0) {
250251
retakePosition = position
251-
deletePage(position)
252+
}
253+
254+
/**
255+
* Delete the previous page if retaking the page
256+
*/
257+
fun deletePageForRetake() {
258+
if (retakePosition != NO_POSITION){
259+
deletePage(retakePosition)
260+
}
252261
}
253262

254263
/**
@@ -313,7 +322,7 @@ class DocumentScannerViewModel : ViewModel() {
313322
}
314323

315324
private fun updateDocumentFileType() {
316-
if (document.value?.pages?.size ?: 0 > 1) {
325+
if ((document.value?.pages?.size ?: 0) > 1) {
317326
document.value?.fileType = FileType.PDF
318327
}
319328
}

documentscanner/src/main/java/nz/mega/documentscanner/camera/CameraFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class CameraFragment : Fragment() {
166166
}
167167

168168
private fun takePicture() {
169+
viewModel.deletePageForRetake()
169170
showProgress(true)
170171
imageAnalyzer?.clearAnalyzer()
171172
imageCapture?.takePicture(cameraExecutor, buildImageCapturedCallback())

0 commit comments

Comments
 (0)