Skip to content

Commit 7fac1a2

Browse files
committed
remove x86 for now
1 parent 526d895 commit 7fac1a2

File tree

22 files changed

+582
-9
lines changed

22 files changed

+582
-9
lines changed

.idea/caches/build_file_checksums.ser

65 Bytes
Binary file not shown.

.idea/caches/gradle_models.ser

62.1 KB
Binary file not shown.

.idea/codeStyles/Project.xml

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

.idea/dbnavigator.xml

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

.idea/modules.xml

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

app/build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ android {
2828
}
2929

3030
dependencies {
31-
implementation fileTree(include: ['*.jar'], dir: 'libs')
31+
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
3232
implementation 'com.android.support:appcompat-v7:26.1.0'
3333
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
3434

@@ -37,8 +37,12 @@ dependencies {
3737
testImplementation 'junit:junit:4.12'
3838
androidTestImplementation 'com.android.support.test:runner:1.0.2'
3939
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
40+
41+
// implementation project(':documentscanner-release')
42+
// implementation(name:'documentscanner-release', ext:'aar')
43+
// implementation(name:'com.haotran.documentscanner', ext:'aar')
4044
implementation project(':documentscanner')
41-
// implementation 'com.github.haocse.documentscanner:documentscanner:1.0.1'
45+
// implementation 'com.haotran.documentscanner:latest@aar'
4246

4347
// implementation 'com.github.HaoCSE:documentscanner:1.0.1'
4448

app/src/main/java/com/haotran/testing/MainActivity.java

+39-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import android.content.Intent;
55
import android.graphics.Bitmap;
66
import android.os.Bundle;
7+
import android.os.Environment;
78
import android.support.v7.app.AppCompatActivity;
9+
import android.util.Log;
810
import android.view.View;
911
import android.widget.ImageView;
1012

@@ -13,25 +15,37 @@
1315
import com.haotran.documentscanner.constants.ScanConstants;
1416
import com.haotran.documentscanner.util.ScanUtils;
1517

18+
import java.io.ByteArrayOutputStream;
19+
import java.io.File;
20+
import java.io.FileOutputStream;
21+
1622
public class MainActivity extends AppCompatActivity {
1723

1824
private static final int REQUEST_CODE = 101;
25+
private static final int CAPTURE_REQUEST_CODE = 101;
1926
private ImageView scannedImageView;
2027

2128
@Override
2229
protected void onCreate(Bundle savedInstanceState) {
2330
super.onCreate(savedInstanceState);
2431
setContentView(R.layout.activity_main);
2532
scannedImageView = findViewById(R.id.scanned_image);
26-
startScan();
33+
34+
// startCapture();
2735
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
2836
@Override
2937
public void onClick(View view) {
3038
startScan();
39+
// startCapture();
3140
}
3241
});
3342
}
3443

44+
private void startCapture() {
45+
Intent intent = new Intent(this, ScanActivity.class);
46+
startActivityForResult(intent, REQUEST_CODE);
47+
}
48+
3549
private void startScan() {
3650
Intent intent = new Intent(this, ScanActivity.class);
3751
startActivityForResult(intent, REQUEST_CODE);
@@ -47,10 +61,34 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
4761
Bitmap baseBitmap = ScanUtils.decodeBitmapFromFile(filePath, ScanConstants.IMAGE_NAME);
4862
scannedImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
4963
scannedImageView.setImageBitmap(baseBitmap);
64+
65+
ByteArrayOutputStream imageByteArray = new ByteArrayOutputStream();
66+
baseBitmap.compress(Bitmap.CompressFormat.JPEG, 100, imageByteArray);
67+
byte[] imageData = imageByteArray.toByteArray();
68+
setDpi(imageData, 300);
69+
70+
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
71+
String filename = "300dpi.png";
72+
try {
73+
File file = new File(path, filename);
74+
FileOutputStream fileOutputStream = new FileOutputStream(file);
75+
fileOutputStream.write(imageData);
76+
fileOutputStream.close();
77+
} catch (Exception e) {
78+
Log.e(">>>", e.getMessage());
79+
}
5080
}
5181
} else if(resultCode == Activity.RESULT_CANCELED) {
5282
finish();
5383
}
5484
}
5585
}
86+
87+
private static void setDpi(byte[] imageData, int dpi) {
88+
imageData[13] = 1;
89+
imageData[14] = (byte) (dpi >> 8);
90+
imageData[15] = (byte) (dpi & 0xff);
91+
imageData[16] = (byte) (dpi >> 8);
92+
imageData[17] = (byte) (dpi & 0xff);
93+
}
5694
}

build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ buildscript {
88
// mavenCentral()
99
// maven { url "https://jitpack.io" }
1010

11+
1112
}
1213
dependencies {
1314
classpath 'com.android.tools.build:gradle:3.3.2'
14-
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
15+
// classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
1516

1617
// NOTE: Do not place your application dependencies here; they belong
1718
// in the individual module build.gradle files

documentscanner-release/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
configurations.maybeCreate("default")
2+
artifacts.add("default", file('documentscanner-debug.aar'))
Binary file not shown.
Binary file not shown.

documentscanner/build.gradle

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'com.github.dcendents.android-maven'
44
android {
55
compileSdkVersion 26
66

7-
packageBuildConfig false
7+
// packageBuildConfig false
88

99

1010
defaultConfig {
@@ -32,7 +32,11 @@ android {
3232

3333
dependencies {
3434
implementation fileTree(include: ['*.jar'], dir: 'libs')
35-
implementation 'com.android.support:appcompat-v7:26.1.0'
35+
// implementation 'com.android.support:appcompat-v7:26.1.0'
36+
implementation "androidx.appcompat:appcompat:1.0.2"
37+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
38+
def support_lib_version = '1.0.0'
39+
implementation "com.google.android.material:material:$support_lib_version"
3640
testImplementation 'junit:junit:4.12'
3741
androidTestImplementation 'com.android.support.test:runner:1.0.1'
3842
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

documentscanner/src/main/AndroidManifest.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
<uses-permission android:name="android.permission.CAMERA" />
66
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
77
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
8+
89
<uses-feature android:name="android.hardware.camera.autofocus" />
910
<uses-feature android:name="android.hardware.camera" />
1011

1112
<application android:supportsRtl="true">
13+
<activity android:name=".activity.CaptureActivity"></activity>
1214
<activity
13-
android:name="com.haotran.documentscanner.activity.ScanActivity"
15+
android:name=".activity.ScanActivity"
1416
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
15-
1617
</application>
1718

1819
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.haotran.documentscanner.activity;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
6+
import com.haotran.documentscanner.R;
7+
8+
public class CaptureActivity extends AppCompatActivity {
9+
10+
@Override
11+
protected void onCreate(Bundle savedInstanceState) {
12+
super.onCreate(savedInstanceState);
13+
setContentView(R.layout.activity_capture);
14+
}
15+
}

0 commit comments

Comments
 (0)