Skip to content

Commit cb0fc12

Browse files
authored
Update readme.adoc
1 parent 998eb7f commit cb0fc12

File tree

1 file changed

+38
-131
lines changed

1 file changed

+38
-131
lines changed

readme.adoc

Lines changed: 38 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Android Document Scanner Library
22

3-
image::https://img.shields.io/badge/version-1.6.0-green.svg[]
3+
image::https://img.shields.io/badge/version-1.6.1-green.svg[]
44
image::https://img.shields.io/badge/minSDK-21-blue.svg[]
55
image::https://img.shields.io/badge/license-MIT-yellowgreen.svg[]
66

7+
If you liked the work you can think about https://www.paypal.com/donate/?hosted_button_id=MCMYPAN46SKFA[Donate via Paypal].
8+
79
This library helps you to scan any document like CamScanner.
810

911
image::documentscannerMockup.png[]
@@ -26,168 +28,73 @@ Add lines below to your *app* level build.gradle
2628

2729
[source,bourne]
2830
----
29-
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
30-
implementation 'com.quickbirdstudios:opencv:4.5.2'
31-
implementation 'io.github.mayuce:AndroidDocumentScanner:1.6.0'
31+
implementation 'io.github.mayuce:AndroidDocumentScanner:1.6.1'
3232
----
3333

3434
And Sync the gradle
3535

3636
## Usage
3737

38-
To start ImageCrop process
39-
40-
[source,java]
41-
----
42-
ScannerConstants.selectedImageBitmap=btimap
43-
startActivityForResult(Intent(MainActivity@this, ImageCropActivity::class.java),Constants.REQUEST_CROP)
44-
----
45-
46-
Catch the cropped image
47-
48-
[source,java]
49-
----
50-
if (requestCode==Constants.REQUEST_CROP && resultCode== Activity.RESULT_OK )
51-
{
52-
if (ScannerConstants.selectedImageBitmap!=null)
53-
imgBitmap.setImageBitmap(ScannerConstants.selectedImageBitmap)
54-
else
55-
Toast.makeText(MainActivity@this,"Something wen't wrong.",Toast.LENGTH_LONG).show()
56-
}
57-
----
58-
59-
### Additional Features
60-
61-
On above Android 9.0 there is magnifier to help user to see zoomed image to crop.
38+
New version of this library provides you the gear instead of ready to go car. So you need to build your own implementation with it, before you upgrade your project make sure that you know it's gonna be a braking change in your project.
6239

63-
#### Customizing ImageCropActivity
40+
* Add DocumentScannerView to your layout
6441
65-
You can customize something in layout via ScannerConstants.
66-
67-
[source,java]
42+
[source,xml]
6843
----
69-
// ScannerConstants.java
70-
public static String cropText="CROP",
71-
backText="CLOSE",
72-
imageError="Can't picked image,
73-
please try again.",
74-
cropError="You have not selected a valid field. Please make corrections until the lines are blue.";
75-
public static String cropColor="#6666ff",backColor="#ff0000",progressColor="#331199"; // Default Colors
76-
public static boolean saveStorage=false; // Make it true if you need image in your storage.
44+
...
45+
<com.labters.documentscanner.DocumentScannerView
46+
android:id="@+id/document_scanner"
47+
android:layout_width="match_parent"
48+
android:layout_height="match_parent" />
49+
...
7750
----
7851

79-
### Custom Scanner Activity
52+
* Set loading listener
8053
81-
With 1.5 version you have a feature to create your own Document Scanner Activity.
82-
You still can use old customization via ScannerConstants or you can create a new scanner activity for your layout.
83-
84-
#### HOW
85-
86-
* Place Scanner layout to your layout
87-
88-
[source,bourne]
54+
[source,kotlin]
8955
----
90-
<FrameLayout
91-
android:id="@+id/frameLayout"
92-
android:layout_width="match_parent"
93-
android:layout_height="0dp" --- * Set HERE *
94-
android:layout_weight="8" --- * Set HERE *
95-
android:layout_gravity="center"
96-
android:layout_margin="10dp">
97-
98-
<FrameLayout
99-
android:id="@+id/holderImageCrop"
100-
android:layout_width="match_parent"
101-
android:layout_height="match_parent"
102-
android:layout_gravity="center"
103-
android:layout_margin="10dp">
104-
105-
<ImageView
106-
android:id="@+id/imageView"
107-
android:layout_width="wrap_content"
108-
android:layout_height="wrap_content"
109-
android:layout_gravity="center"
110-
android:adjustViewBounds="true"/>
111-
</FrameLayout>
112-
113-
<com.labters.documentscanner.libraries.PolygonView
114-
android:id="@+id/polygonView"
115-
android:layout_width="match_parent"
116-
android:layout_height="match_parent"
117-
android:layout_gravity="center"
118-
android:visibility="gone"/>
119-
</FrameLayout>
120-
56+
binding.documentScanner.setOnLoadListener { loading ->
57+
binding.progressBar.isVisible = loading
58+
}
12159
----
12260

123-
* Extend your activity from DocumentScannerActivity
124-
* Provide values
61+
* Set selected Bitmap into the view
12562
126-
[source,java]
63+
[source,kotlin]
12764
----
128-
@Override
129-
protected FrameLayout getHolderImageCrop() {
130-
return holderImageCrop;
131-
}
132-
133-
@Override
134-
protected ImageView getImageView() {
135-
return imageView;
136-
}
137-
138-
@Override
139-
protected PolygonView getPolygonView() {
140-
return polygonView;
141-
}
142-
143-
@Override
144-
protected Bitmap getBitmapImage() {
145-
return cropImage;
146-
}
65+
binding.documentScanner.setImage(bitmap)
14766
----
14867

149-
* Override methods
68+
* After selecting the edge points get cropped image
15069
151-
[source,java]
70+
[source,kotlin]
15271
----
153-
@Override
154-
protected void showProgressBar() {
155-
RelativeLayout rlContainer = findViewById(R.id.rlContainer);
156-
setViewInteract(rlContainer, false);
157-
progressBar.setVisibility(View.VISIBLE);
158-
}
159-
160-
@Override
161-
protected void hideProgressBar() {
162-
RelativeLayout rlContainer = findViewById(R.id.rlContainer);
163-
setViewInteract(rlContainer, true);
164-
progressBar.setVisibility(View.GONE);
165-
}
166-
167-
@Override
168-
protected void showError(CropperErrorType errorType) {
169-
switch (errorType) {
170-
case CROP_ERROR:
171-
Toast.makeText(this, ScannerConstants.cropError, Toast.LENGTH_LONG).show();
172-
break;
72+
binding.btnImageCrop.setOnClickListener {
73+
lifecycleScope.launch {
74+
binding.progressBar.isVisible = true
75+
val image = binding.documentScanner.getCroppedImage()
76+
binding.progressBar.isVisible = false
77+
binding.resultImage.isVisible = true
78+
binding.resultImage.setImageBitmap(image)
79+
}
17380
}
174-
}
17581
----
17682

177-
And *after* setting your view call *startCropping()* method
83+
### Additional Features
84+
85+
On above Android 9.0 there is magnifier to help user to see zoomed image to crop.
17886

179-
If you have a trouble you can follow follow com.labters.documentscannerandroid.ImageCropActivity for how to do that.
87+
If you face with any issues you can take a look at com.labters.documentscannerandroid.ImageCropActivity to see how does it works.
18088

18189
## TO-DO
18290

183-
- Remove RxJava dependency.
91+
- Nothing so far, you may tell me?..
18492
18593
## Thanks
18694

187-
* Thanks RX library to improve this project.
18895
* Thanks OpenCV for this awesome library. - https://opencv.org/
189-
and
190-
* Inspiration from *aashari* . Thanks him for his source codes. - https://github.com/aashari/android-opencv-camera-scanner
96+
97+
* Inspiration from *aashari* . Thanks to him for his https://github.com/aashari/android-opencv-camera-scanner[source codes].
19198
19299
[source,bourne]
193100
----

0 commit comments

Comments
 (0)