|
1 | 1 | # Android Document Scanner Library |
2 | 2 |
|
3 | | -image::https://img.shields.io/badge/version-1.4-green.svg[] |
| 3 | +image::https://img.shields.io/badge/version-1.5-green.svg[] |
4 | 4 | image::https://img.shields.io/badge/minSDK-19-blue.svg[] |
5 | 5 | image::https://img.shields.io/badge/license-MIT-yellowgreen.svg[] |
6 | 6 |
|
@@ -37,8 +37,8 @@ Add lines below to your *app* level build.gradle |
37 | 37 |
|
38 | 38 | [source,bourne] |
39 | 39 | ---- |
40 | | - implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' |
41 | | - implementation 'com.github.mayuce:AndroidDocumentScanner:1.4' |
| 40 | + implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' |
| 41 | + implementation 'com.github.mayuce:AndroidDocumentScanner:1.5' |
42 | 42 | ---- |
43 | 43 |
|
44 | 44 | And Sync the gradle |
@@ -85,9 +85,112 @@ You can customize something in layout via ScannerConstants. |
85 | 85 | public static String cropColor="#6666ff",backColor="#ff0000",progressColor="#331199"; // Default Colors |
86 | 86 | public static boolean saveStorage=false; // Make it true if you need image in your storage. |
87 | 87 | ---- |
| 88 | + |
| 89 | +### (NEW) Version 1.5 Feature - Custom Scanner Activity! |
| 90 | + |
| 91 | +With 1.5 version you have a feature to create your own Document Scanner Activity. |
| 92 | +You still can use old customization via ScannerConstants or you can create a new scanner activity for your layout. |
| 93 | + |
| 94 | +#### HOW |
| 95 | + |
| 96 | +* Place Scanner layout to your layout |
| 97 | +
|
| 98 | +[source,bourne] |
| 99 | +---- |
| 100 | + <FrameLayout |
| 101 | + android:id="@+id/frameLayout" |
| 102 | + android:layout_width="match_parent" |
| 103 | + android:layout_height="0dp" --- * Set HERE * |
| 104 | + android:layout_weight="8" --- * Set HERE * |
| 105 | + android:layout_gravity="center" |
| 106 | + android:layout_margin="10dp"> |
| 107 | +
|
| 108 | + <FrameLayout |
| 109 | + android:id="@+id/holderImageCrop" |
| 110 | + android:layout_width="match_parent" |
| 111 | + android:layout_height="match_parent" |
| 112 | + android:layout_gravity="center" |
| 113 | + android:layout_margin="10dp"> |
| 114 | +
|
| 115 | + <ImageView |
| 116 | + android:id="@+id/imageView" |
| 117 | + android:layout_width="wrap_content" |
| 118 | + android:layout_height="wrap_content" |
| 119 | + android:layout_gravity="center" |
| 120 | + android:adjustViewBounds="true"/> |
| 121 | + </FrameLayout> |
| 122 | +
|
| 123 | + <com.labters.documentscanner.libraries.PolygonView |
| 124 | + android:id="@+id/polygonView" |
| 125 | + android:layout_width="match_parent" |
| 126 | + android:layout_height="match_parent" |
| 127 | + android:layout_gravity="center" |
| 128 | + android:visibility="gone"/> |
| 129 | + </FrameLayout> |
| 130 | +
|
| 131 | +---- |
| 132 | + |
| 133 | +* Extend your activity from DocumentScannerActivity |
| 134 | +* Provide values |
| 135 | +
|
| 136 | +[source,java] |
| 137 | +---- |
| 138 | + @Override |
| 139 | + protected FrameLayout getHolderImageCrop() { |
| 140 | + return holderImageCrop; |
| 141 | + } |
| 142 | +
|
| 143 | + @Override |
| 144 | + protected ImageView getImageView() { |
| 145 | + return imageView; |
| 146 | + } |
| 147 | +
|
| 148 | + @Override |
| 149 | + protected PolygonView getPolygonView() { |
| 150 | + return polygonView; |
| 151 | + } |
| 152 | +
|
| 153 | + @Override |
| 154 | + protected Bitmap getBitmapImage() { |
| 155 | + return cropImage; |
| 156 | + } |
| 157 | +---- |
| 158 | + |
| 159 | +* Override methods |
| 160 | +
|
| 161 | +[source,java] |
| 162 | +---- |
| 163 | + @Override |
| 164 | + protected void showProgressBar() { |
| 165 | + RelativeLayout rlContainer = findViewById(R.id.rlContainer); |
| 166 | + setViewInteract(rlContainer, false); |
| 167 | + progressBar.setVisibility(View.VISIBLE); |
| 168 | + } |
| 169 | +
|
| 170 | + @Override |
| 171 | + protected void hideProgressBar() { |
| 172 | + RelativeLayout rlContainer = findViewById(R.id.rlContainer); |
| 173 | + setViewInteract(rlContainer, true); |
| 174 | + progressBar.setVisibility(View.GONE); |
| 175 | + } |
| 176 | +
|
| 177 | + @Override |
| 178 | + protected void showError(CropperErrorType errorType) { |
| 179 | + switch (errorType) { |
| 180 | + case CROP_ERROR: |
| 181 | + Toast.makeText(this, ScannerConstants.cropError, Toast.LENGTH_LONG).show(); |
| 182 | + break; |
| 183 | + } |
| 184 | + } |
| 185 | +---- |
| 186 | + |
| 187 | +And *after* setting your view call *startCropping()* method |
| 188 | + |
| 189 | +If you have a trouble you can follow follow com.labters.documentscanner.ImageCropActivity for how to do that. |
| 190 | + |
88 | 191 | ## TO-DO |
89 | 192 |
|
90 | | -Nothing |
| 193 | +I already tried it but I’ve lost myself in code and added many features. To make module simple I reverted them. When I have time I need to do some code clean-up. |
91 | 194 |
|
92 | 195 | ## Thanks |
93 | 196 |
|
|
100 | 203 | ---- |
101 | 204 | MIT License |
102 | 205 |
|
103 | | -Copyright (c) 2019 Muhammet Ali YUCE |
| 206 | +Copyright (c) 2020 Muhammet Ali YUCE |
104 | 207 |
|
105 | 208 | Permission is hereby granted, free of charge, to any person obtaining a copy |
106 | 209 | of this software and associated documentation files (the "Software"), to deal |
|
0 commit comments