Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
ocr-oa
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈赛康
ocr-oa
Commits
b76f8dad
Commit
b76f8dad
authored
May 13, 2018
by
陈赛康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上线版本代码;
parent
da7093bf
Changes
35
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
669 additions
and
247 deletions
+669
-247
build.gradle
app/build.gradle
+2
-2
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+5
-8
GetUserid.aidl
...src/main/aidl/com/bril/baoding/studio/aidl/GetUserid.aidl
+1
-0
Configs.java
...n/java/cn/com/bril/androidocr/studio/configs/Configs.java
+8
-7
RequestConfig.java
.../cn/com/bril/androidocr/studio/configs/RequestConfig.java
+5
-1
HttpHolder.java
...n/java/cn/com/bril/androidocr/studio/http/HttpHolder.java
+7
-3
MainActivity.java
.../com/bril/androidocr/studio/ui/activity/MainActivity.java
+34
-20
OcrRecordActivity.java
...bril/androidocr/studio/ui/activity/OcrRecordActivity.java
+2
-1
ProofreadActivity.java
...bril/androidocr/studio/ui/activity/ProofreadActivity.java
+4
-3
RecognizeActivity.java
...bril/androidocr/studio/ui/activity/RecognizeActivity.java
+74
-20
VertifyActivity.java
...m/bril/androidocr/studio/ui/activity/VertifyActivity.java
+123
-74
FragmentListAdapter.java
...ril/androidocr/studio/ui/adapter/FragmentListAdapter.java
+29
-1
ExportFragment.java
...om/bril/androidocr/studio/ui/fragment/ExportFragment.java
+76
-39
ShareFragment.java
...com/bril/androidocr/studio/ui/fragment/ShareFragment.java
+50
-28
FileUtil.java
...in/java/cn/com/bril/androidocr/studio/utils/FileUtil.java
+12
-1
ShareUtil.java
...n/java/cn/com/bril/androidocr/studio/utils/ShareUtil.java
+4
-2
activity_proofread.xml
app/src/main/res/layout/activity_proofread.xml
+6
-3
export_layout.xml
app/src/main/res/layout/export_layout.xml
+4
-2
listview_item_layout.xml
app/src/main/res/layout/listview_item_layout.xml
+8
-2
recognize_layout.xml
app/src/main/res/layout/recognize_layout.xml
+5
-2
top_title_layout.xml
app/src/main/res/layout/top_title_layout.xml
+15
-6
styles.xml
app/src/main/res/values/styles.xml
+1
-0
AndroidManifest.xml
scanlibrary/src/main/AndroidManifest.xml
+1
-1
IScanner.java
scanlibrary/src/main/java/com/scanlibrary/IScanner.java
+5
-0
PickImageFragment.java
...rary/src/main/java/com/scanlibrary/PickImageFragment.java
+52
-14
ResultFragment.java
...library/src/main/java/com/scanlibrary/ResultFragment.java
+1
-1
ScanActivity.java
scanlibrary/src/main/java/com/scanlibrary/ScanActivity.java
+33
-2
ScanConstants.java
scanlibrary/src/main/java/com/scanlibrary/ScanConstants.java
+5
-1
ScanFragment.java
scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java
+18
-0
Utils.java
scanlibrary/src/main/java/com/scanlibrary/Utils.java
+32
-0
result_layout2.xml
scanlibrary/src/main/res/layout/result_layout2.xml
+1
-0
scan_fragment_layout.xml
scanlibrary/src/main/res/layout/scan_fragment_layout.xml
+37
-2
colors.xml
scanlibrary/src/main/res/values/colors.xml
+2
-0
dimens.xml
scanlibrary/src/main/res/values/dimens.xml
+5
-0
provider_paths.xml
scanlibrary/src/main/res/xml/provider_paths.xml
+2
-1
No files found.
app/build.gradle
View file @
b76f8dad
...
@@ -10,8 +10,8 @@ android {
...
@@ -10,8 +10,8 @@ android {
applicationId
"cn.com.bril.androidocr.studio"
applicationId
"cn.com.bril.androidocr.studio"
minSdkVersion
21
minSdkVersion
21
targetSdkVersion
25
targetSdkVersion
25
versionCode
14
versionCode
31
versionName
"
3.4
.0"
versionName
"
5.1
.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
}
buildTypes
{
buildTypes
{
...
...
app/src/main/AndroidManifest.xml
View file @
b76f8dad
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"cn.com.bril.androidocr.studio"
>
package=
"cn.com.bril.androidocr.studio"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.CAMERA"
/>
<uses-permission
android:name=
"android.permission.CAMERA"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
...
@@ -20,8 +20,7 @@
...
@@ -20,8 +20,7 @@
android:name=
".ui.activity.MainActivity"
android:name=
".ui.activity.MainActivity"
android:label=
"@string/app_name"
>
android:label=
"@string/app_name"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
...
@@ -38,10 +37,8 @@
...
@@ -38,10 +37,8 @@
<activity
<activity
android:name=
".ui.activity.OcrRecordActivity"
android:name=
".ui.activity.OcrRecordActivity"
android:launchMode=
"singleTask"
/>
android:launchMode=
"singleTask"
/>
<activity
android:name=
".ui.activity.SearchActivity"
></activity>
<activity
android:name=
".ui.activity.SearchActivity"
/>
<activity
android:name=
".ui.activity.OcrDetailActivity"
></activity>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
app/src/main/aidl/com/bril/baoding/studio/aidl/GetUserid.aidl
View file @
b76f8dad
...
@@ -3,4 +3,5 @@ package com.bril.baoding.studio.aidl;
...
@@ -3,4 +3,5 @@ package com.bril.baoding.studio.aidl;
interface
GetUserid
{
interface
GetUserid
{
int
getUserid
();
int
getUserid
();
String
getUsername
();
String
getUsername
();
String
getLoginName
();
}
}
\ No newline at end of file
app/src/main/java/cn/com/bril/androidocr/studio/configs/Configs.java
View file @
b76f8dad
...
@@ -8,16 +8,17 @@ import android.os.Environment;
...
@@ -8,16 +8,17 @@ import android.os.Environment;
public
class
Configs
{
public
class
Configs
{
public
static
String
USER_NAME
=
"
科员
"
;
public
static
String
USER_NAME
=
""
;
public
static
String
USER_ID
=
"
11
"
;
public
static
String
USER_ID
=
""
;
public
final
static
String
IMAGE_BASE
=
Environment
public
final
static
String
IMAGE_BASE
=
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/
documentocr
/images"
;
.
getExternalStorageDirectory
().
getPath
()
+
"/
wuzhihuaOA
/images"
;
public
final
static
String
PDF_BASE
=
Environment
public
final
static
String
PDF_BASE
=
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/
documentocr
/pdfs"
;
.
getExternalStorageDirectory
().
getPath
()
+
"/
wuzhihuaOA
/pdfs"
;
public
final
static
String
TXT_BASE
=
Environment
public
final
static
String
TXT_BASE
=
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/
documentocr
/txts"
;
.
getExternalStorageDirectory
().
getPath
()
+
"/
wuzhihuaOA
/txts"
;
// public final static String TXT_BASE= "sdcard/
documentocr
/txts";
// public final static String TXT_BASE= "sdcard/
wuzhihuaOA
/txts";
public
final
static
String
WORD_BASE
=
Environment
public
final
static
String
WORD_BASE
=
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/documentocr/docs"
;
.
getExternalStorageDirectory
().
getPath
()
+
"/wuzhihuaOA/docs"
;
}
}
app/src/main/java/cn/com/bril/androidocr/studio/configs/RequestConfig.java
View file @
b76f8dad
...
@@ -8,11 +8,13 @@ public class RequestConfig {
...
@@ -8,11 +8,13 @@ public class RequestConfig {
public
static
int
TAKE_PHOTO_REQUEST
=
1
;
public
static
int
TAKE_PHOTO_REQUEST
=
1
;
public
static
int
PERMISSION_REQUEST_CODE
=
99
;
public
static
int
PERMISSION_REQUEST_CODE
=
99
;
public
static
String
BASE_URL
=
"http://zjk.haomo-studio.com/zhangjiakouOA/"
;
public
static
String
BASE_URL
=
"http://zjk.haomo-studio.com/zhangjiakouOA/"
;
//
public static String BASE_URL="http://192.168.1.72:8050/zhangjiakouOA
/";
//
public static String BASE_URL="http://143.19.128.79:19195/api
/";
//添加
//添加
public
static
String
ADD_URL
=
BASE_URL
+
"cc_files/new"
;
public
static
String
ADD_URL
=
BASE_URL
+
"cc_files/new"
;
//上传文件
//上传文件
public
static
String
UP_FILE
=
BASE_URL
+
"upload_ocr_file"
;
public
static
String
UP_FILE
=
BASE_URL
+
"upload_ocr_file"
;
public
static
String
UP_SOURCE_URL
=
BASE_URL
+
"upload_ocrfile_generate_thumb"
;
//编辑文件
//编辑文件
public
static
String
EDIT_FILE_URL
=
BASE_URL
+
"cc_files/"
;
public
static
String
EDIT_FILE_URL
=
BASE_URL
+
"cc_files/"
;
//创建导出记录
//创建导出记录
...
@@ -39,5 +41,7 @@ public class RequestConfig {
...
@@ -39,5 +41,7 @@ public class RequestConfig {
public
final
static
String
BATCH_CREATE_FILE_URL
=
BASE_URL
+
"cc_files/create/batch"
;
public
final
static
String
BATCH_CREATE_FILE_URL
=
BASE_URL
+
"cc_files/create/batch"
;
//创建文件
//创建文件
public
final
static
String
CREATE_FILE_URL
=
BASE_URL
+
"cc_files/new"
;
public
final
static
String
CREATE_FILE_URL
=
BASE_URL
+
"cc_files/new"
;
//获取文件
public
final
static
String
GET_FILE_FROM_NET
=
BASE_URL
+
"return_file?filePath="
;
}
}
app/src/main/java/cn/com/bril/androidocr/studio/http/HttpHolder.java
View file @
b76f8dad
...
@@ -45,8 +45,9 @@ public class HttpHolder {
...
@@ -45,8 +45,9 @@ public class HttpHolder {
x
.
http
().
post
(
params
,
callBack
);
x
.
http
().
post
(
params
,
callBack
);
}
}
//上传文件
//上传文件
public
static
void
upLoadFile
(
String
path
,
VertifyActivity
.
HttpCallBack
callBack
){
public
static
void
upLoadFile
(
String
url
,
String
path
,
Callback
.
CommonCallback
callBack
){
RequestParams
params
=
new
RequestParams
(
RequestConfig
.
UP_FILE
);
// RequestParams params=new RequestParams(RequestConfig.UP_FILE);
RequestParams
params
=
new
RequestParams
(
url
);
List
<
KeyValue
>
list
=
new
ArrayList
<>();
List
<
KeyValue
>
list
=
new
ArrayList
<>();
list
.
add
(
new
KeyValue
(
"file"
,
new
File
(
path
)));
//文件流数据
list
.
add
(
new
KeyValue
(
"file"
,
new
File
(
path
)));
//文件流数据
// list.add(new KeyValue("parameters", json.toString()));
// list.add(new KeyValue("parameters", json.toString()));
...
@@ -54,7 +55,7 @@ public class HttpHolder {
...
@@ -54,7 +55,7 @@ public class HttpHolder {
//添加请求参数
//添加请求参数
params
.
setRequestBody
(
body
);
params
.
setRequestBody
(
body
);
x
.
http
().
post
(
params
,
callBack
);
x
.
http
().
post
(
params
,
callBack
);
}
;
}
//创建记录
//创建记录
public
static
void
createFileRecord
(
String
url
,
Map
<
String
,
Object
>
map
,
Callback
.
CommonCallback
<
String
>
listener
){
public
static
void
createFileRecord
(
String
url
,
Map
<
String
,
Object
>
map
,
Callback
.
CommonCallback
<
String
>
listener
){
RequestParams
params
=
new
RequestParams
(
url
);
RequestParams
params
=
new
RequestParams
(
url
);
...
@@ -126,6 +127,8 @@ public class HttpHolder {
...
@@ -126,6 +127,8 @@ public class HttpHolder {
if
(
entry
.
getKey
().
equals
(
"downloadName"
)){
if
(
entry
.
getKey
().
equals
(
"downloadName"
)){
if
(
entry
.
getValue
().
contains
(
"doc"
))
if
(
entry
.
getValue
().
contains
(
"doc"
))
params
.
setSaveFilePath
(
Configs
.
WORD_BASE
+
"/"
+
entry
.
getValue
().
substring
(
entry
.
getValue
().
lastIndexOf
(
"/"
)+
1
));
params
.
setSaveFilePath
(
Configs
.
WORD_BASE
+
"/"
+
entry
.
getValue
().
substring
(
entry
.
getValue
().
lastIndexOf
(
"/"
)+
1
));
else
if
(
entry
.
getValue
().
contains
(
"jpg"
)
||
entry
.
getValue
().
contains
(
"png"
))
params
.
setSaveFilePath
(
Configs
.
IMAGE_BASE
+
"/"
+
entry
.
getValue
().
substring
(
entry
.
getValue
().
lastIndexOf
(
"/"
)+
1
));
}
}
params
.
addBodyParameter
(
entry
.
getKey
(),
String
.
valueOf
(
entry
.
getValue
()));
params
.
addBodyParameter
(
entry
.
getKey
(),
String
.
valueOf
(
entry
.
getValue
()));
}
}
...
@@ -192,4 +195,5 @@ public class HttpHolder {
...
@@ -192,4 +195,5 @@ public class HttpHolder {
params
.
addBodyParameter
(
"fileName"
,
name
);
params
.
addBodyParameter
(
"fileName"
,
name
);
x
.
http
().
post
(
params
,
callBack
);
x
.
http
().
post
(
params
,
callBack
);
}
}
}
}
app/src/main/java/cn/com/bril/androidocr/studio/ui/activity/MainActivity.java
View file @
b76f8dad
...
@@ -49,6 +49,7 @@ import cn.com.bril.androidocr.studio.ui.adapter.TabFragmentPagerAdapter;
...
@@ -49,6 +49,7 @@ import cn.com.bril.androidocr.studio.ui.adapter.TabFragmentPagerAdapter;
import
cn.com.bril.androidocr.studio.ui.fragment.ExportFragment
;
import
cn.com.bril.androidocr.studio.ui.fragment.ExportFragment
;
import
cn.com.bril.androidocr.studio.ui.fragment.ShareFragment
;
import
cn.com.bril.androidocr.studio.ui.fragment.ShareFragment
;
import
cn.com.bril.androidocr.studio.ui.widget.NoScrollViewPager
;
import
cn.com.bril.androidocr.studio.ui.widget.NoScrollViewPager
;
import
cn.com.bril.androidocr.studio.utils.FileUtil
;
import
cn.com.bril.androidocr.studio.utils.ScreenUtil
;
import
cn.com.bril.androidocr.studio.utils.ScreenUtil
;
import
cn.com.bril.androidocr.studio.utils.ViewUtil
;
import
cn.com.bril.androidocr.studio.utils.ViewUtil
;
...
@@ -80,7 +81,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -80,7 +81,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
@BindView
(
R
.
id
.
bottom_menu
)
@BindView
(
R
.
id
.
bottom_menu
)
RelativeLayout
bottomMenu
;
RelativeLayout
bottomMenu
;
@BindView
(
R
.
id
.
left_iv
)
@BindView
(
R
.
id
.
left_iv
)
ImageView
leftIv
;
LinearLayout
leftIv
;
@BindView
(
R
.
id
.
tab_back
)
@BindView
(
R
.
id
.
tab_back
)
ImageView
tabBack
;
ImageView
tabBack
;
// @BindView(R.id.tab_head)
// @BindView(R.id.tab_head)
...
@@ -141,12 +142,14 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -141,12 +142,14 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
setContentView
(
R
.
layout
.
activity_main
);
ButterKnife
.
bind
(
this
);
ButterKnife
.
bind
(
this
);
OcrApplication
.
getInstance
().
addActivity
(
this
);
OcrApplication
.
getInstance
().
addActivity
(
this
);
//
bindService();
bindService
();
initViews
();
initViews
();
...
@@ -154,9 +157,13 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -154,9 +157,13 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
initEvents
();
initEvents
();
check
Permission
();
init
Permission
();
dialog
=
new
ProgressDialog
(
this
);
dialog
=
new
ProgressDialog
(
this
);
FileUtil
.
creatDir
(
Configs
.
WORD_BASE
);
FileUtil
.
creatDir
(
Configs
.
TXT_BASE
);
FileUtil
.
creatDir
(
Configs
.
IMAGE_BASE
);
}
}
private
void
bindService
()
{
private
void
bindService
()
{
...
@@ -164,20 +171,27 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -164,20 +171,27 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
intent
.
setPackage
(
"com.bril.baoding.studio"
);
intent
.
setPackage
(
"com.bril.baoding.studio"
);
bindService
(
intent
,
mServiceConnection
,
Context
.
BIND_AUTO_CREATE
);
bindService
(
intent
,
mServiceConnection
,
Context
.
BIND_AUTO_CREATE
);
}
}
public
void
checkPermission
()
{
if
(
ContextCompat
.
checkSelfPermission
(
this
,
private
void
initPermission
()
{
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
)
String
permissions
[]
=
{
!=
PackageManager
.
PERMISSION_GRANTED
)
{
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
//权限还没有授予,需要在这里写申请权限的代码
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
ActivityCompat
.
requestPermissions
(
this
,
Manifest
.
permission
.
CAMERA
new
String
[]{
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
},
};
PERMISSION_REQUEST_CODE
);
ArrayList
<
String
>
toApplyList
=
new
ArrayList
<
String
>();
}
else
{
for
(
String
perm
:
permissions
)
{
//权限已经被授予,在这里直接写要执行的相应方法即可
if
(
PackageManager
.
PERMISSION_GRANTED
!=
ContextCompat
.
checkSelfPermission
(
this
,
perm
))
{
// creatDir(Configs.IMAGE_CACHE);
toApplyList
.
add
(
perm
);
// getIntentData();
//进入到这里代表没有权限.
}
}
String
tmpList
[]
=
new
String
[
toApplyList
.
size
()];
if
(!
toApplyList
.
isEmpty
())
{
ActivityCompat
.
requestPermissions
(
this
,
toApplyList
.
toArray
(
tmpList
),
PERMISSION_REQUEST_CODE
);
}
}
}
}
private
void
initViews
()
{
private
void
initViews
()
{
rightIv
.
setVisibility
(
View
.
VISIBLE
);
rightIv
.
setVisibility
(
View
.
VISIBLE
);
rightTv
.
setVisibility
(
View
.
GONE
);
rightTv
.
setVisibility
(
View
.
GONE
);
...
@@ -201,7 +215,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -201,7 +215,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
ViewUtil
.
setNavImageSize
(
this
,
share
,
R
.
drawable
.
share_focused
,
40
,
45
);
//40
ViewUtil
.
setNavImageSize
(
this
,
share
,
R
.
drawable
.
share_focused
,
40
,
45
);
//40
// ViewUtil.setNavImageSize(this, rename, R.drawable.rename, 50, 50);//40
// ViewUtil.setNavImageSize(this, rename, R.drawable.rename, 50, 50);//40
ViewUtil
.
setNavImageSize
(
this
,
delete
,
R
.
drawable
.
delete_normal
,
35
,
45
);
//32
ViewUtil
.
setNavImageSize
(
this
,
delete
,
R
.
drawable
.
delete_normal
,
35
,
45
);
//32
}
}
private
void
setImageGone
()
{
private
void
setImageGone
()
{
...
@@ -215,7 +228,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -215,7 +228,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
group
.
setOnCheckedChangeListener
(
new
RadioGroup
.
OnCheckedChangeListener
()
{
group
.
setOnCheckedChangeListener
(
new
RadioGroup
.
OnCheckedChangeListener
()
{
@Override
@Override
public
void
onCheckedChanged
(
RadioGroup
group
,
@IdRes
int
checkedId
)
{
public
void
onCheckedChanged
(
RadioGroup
group
,
@IdRes
int
checkedId
)
{
String
tag
=
null
;
String
tag
=
null
;
switch
(
checkedId
)
{
switch
(
checkedId
)
{
case
R
.
id
.
radio_1
:
case
R
.
id
.
radio_1
:
...
@@ -260,7 +272,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -260,7 +272,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
if
(
requestCode
==
PERMISSION_REQUEST_CODE
){
if
(
requestCode
==
PERMISSION_REQUEST_CODE
){
for
(
int
grant:
grantResults
){
for
(
int
grant:
grantResults
){
if
(
grant
!=
PackageManager
.
PERMISSION_GRANTED
)
if
(
grant
!=
PackageManager
.
PERMISSION_GRANTED
)
Toast
.
makeText
(
this
,
"
请开启读取与写入权限
"
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
this
,
"
文件或拍照权限未开启
"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
}
}
}
}
...
@@ -283,7 +295,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -283,7 +295,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
viewPager
.
setCurrentItem
(
position
);
viewPager
.
setCurrentItem
(
position
);
}
}
@OnClick
({
R
.
id
.
right_iv
,
R
.
id
.
fabbtn
,
R
.
id
.
tab_select
,
R
.
id
.
tab_back
})
@OnClick
({
R
.
id
.
right_iv
,
R
.
id
.
fabbtn
,
R
.
id
.
tab_select
,
R
.
id
.
tab_back
,
R
.
id
.
left_iv
})
public
void
onViewClicked
(
View
view
)
{
public
void
onViewClicked
(
View
view
)
{
switch
(
view
.
getId
())
{
switch
(
view
.
getId
())
{
case
R
.
id
.
rightTv
:
case
R
.
id
.
rightTv
:
...
@@ -319,6 +331,9 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -319,6 +331,9 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
else
else
shareFragment
.
setAllItemChecked
(
isAllSelected
);
shareFragment
.
setAllItemChecked
(
isAllSelected
);
break
;
break
;
case
R
.
id
.
left_iv
:
finish
();
break
;
}
}
}
}
//展示工具栏
//展示工具栏
...
@@ -351,7 +366,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
...
@@ -351,7 +366,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
}
}
}
}
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
switch
(
v
.
getId
())
{
switch
(
v
.
getId
())
{
...
...
app/src/main/java/cn/com/bril/androidocr/studio/ui/activity/OcrRecordActivity.java
View file @
b76f8dad
...
@@ -3,6 +3,7 @@ package cn.com.bril.androidocr.studio.ui.activity;
...
@@ -3,6 +3,7 @@ package cn.com.bril.androidocr.studio.ui.activity;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.ListView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.TextView
;
...
@@ -18,7 +19,7 @@ public class OcrRecordActivity extends BaseActivity implements View.OnClickListe
...
@@ -18,7 +19,7 @@ public class OcrRecordActivity extends BaseActivity implements View.OnClickListe
@BindView
(
R
.
id
.
left_tv
)
@BindView
(
R
.
id
.
left_tv
)
TextView
title
;
TextView
title
;
@BindView
(
R
.
id
.
left_iv
)
@BindView
(
R
.
id
.
left_iv
)
ImageView
back
;
LinearLayout
back
;
@BindView
(
R
.
id
.
right_iv
)
@BindView
(
R
.
id
.
right_iv
)
ImageView
rightIv
;
ImageView
rightIv
;
...
...
app/src/main/java/cn/com/bril/androidocr/studio/ui/activity/ProofreadActivity.java
View file @
b76f8dad
...
@@ -6,7 +6,7 @@ import android.os.Bundle;
...
@@ -6,7 +6,7 @@ import android.os.Bundle;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.app.AppCompatActivity
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.EditText
;
import
android.widget.
ImageView
;
import
android.widget.
LinearLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Glide
;
...
@@ -17,17 +17,18 @@ import butterknife.OnClick;
...
@@ -17,17 +17,18 @@ import butterknife.OnClick;
import
cn.com.bril.androidocr.studio.OcrApplication
;
import
cn.com.bril.androidocr.studio.OcrApplication
;
import
cn.com.bril.androidocr.studio.R
;
import
cn.com.bril.androidocr.studio.R
;
import
cn.com.bril.androidocr.studio.beans.Image
;
import
cn.com.bril.androidocr.studio.beans.Image
;
import
cn.com.bril.androidocr.studio.ui.widget.MatrixImageView
;
public
class
ProofreadActivity
extends
AppCompatActivity
{
public
class
ProofreadActivity
extends
AppCompatActivity
{
@BindView
(
R
.
id
.
left_iv
)
@BindView
(
R
.
id
.
left_iv
)
ImageView
lefIv
;
LinearLayout
lefIv
;
@BindView
(
R
.
id
.
topTitle
)
@BindView
(
R
.
id
.
topTitle
)
TextView
topTitle
;
TextView
topTitle
;
@BindView
(
R
.
id
.
rightTv
)
@BindView
(
R
.
id
.
rightTv
)
TextView
rightTv
;
TextView
rightTv
;
@BindView
(
R
.
id
.
photo
)
@BindView
(
R
.
id
.
photo
)
ImageView
photo
;
Matrix
ImageView
photo
;
@BindView
(
R
.
id
.
content
)
@BindView
(
R
.
id
.
content
)
EditText
content
;
EditText
content
;
@BindView
(
R
.
id
.
left_tv
)
@BindView
(
R
.
id
.
left_tv
)
...
...
app/src/main/java/cn/com/bril/androidocr/studio/ui/activity/RecognizeActivity.java
View file @
b76f8dad
...
@@ -16,6 +16,7 @@ import android.support.annotation.NonNull;
...
@@ -16,6 +16,7 @@ import android.support.annotation.NonNull;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.app.AppCompatActivity
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
...
@@ -28,6 +29,11 @@ import com.abbyy.mobile.ocr4.layout.MocrPrebuiltLayoutInfo;
...
@@ -28,6 +29,11 @@ import com.abbyy.mobile.ocr4.layout.MocrPrebuiltLayoutInfo;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Glide
;
import
com.scanlibrary.ScanActivity
;
import
com.scanlibrary.ScanActivity
;
import
com.scanlibrary.ScanConstants
;
import
com.scanlibrary.ScanConstants
;
import
com.scanlibrary.Utils
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.xutils.common.Callback
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -44,6 +50,8 @@ import cn.com.bril.androidocr.studio.beans.Image;
...
@@ -44,6 +50,8 @@ import cn.com.bril.androidocr.studio.beans.Image;
import
cn.com.bril.androidocr.studio.configs.RequestConfig
;
import
cn.com.bril.androidocr.studio.configs.RequestConfig
;
import
cn.com.bril.androidocr.studio.engine.RecognitionContext
;
import
cn.com.bril.androidocr.studio.engine.RecognitionContext
;
import
cn.com.bril.androidocr.studio.engine.RecognitionService
;
import
cn.com.bril.androidocr.studio.engine.RecognitionService
;
import
cn.com.bril.androidocr.studio.http.HttpHolder
;
import
cn.com.bril.androidocr.studio.utils.PhotoBitmapUtils
;
import
static
cn
.
com
.
bril
.
androidocr
.
studio
.
utils
.
FileUtil
.
saveBitmap
;
import
static
cn
.
com
.
bril
.
androidocr
.
studio
.
utils
.
FileUtil
.
saveBitmap
;
...
@@ -63,6 +71,8 @@ public class RecognizeActivity extends AppCompatActivity {
...
@@ -63,6 +71,8 @@ public class RecognizeActivity extends AppCompatActivity {
TextView
progress
;
TextView
progress
;
@BindView
(
R
.
id
.
bottom_progress
)
@BindView
(
R
.
id
.
bottom_progress
)
RelativeLayout
bottomProgress
;
RelativeLayout
bottomProgress
;
@BindView
(
R
.
id
.
rotate
)
LinearLayout
rotate
;
private
BroadcastReceiver
_progressReceiver
;
private
BroadcastReceiver
_progressReceiver
;
private
BroadcastReceiver
_prebuiltWordsInfoReceiver
;
private
BroadcastReceiver
_prebuiltWordsInfoReceiver
;
private
BroadcastReceiver
_rotationTypeDetectionReceiver
;
private
BroadcastReceiver
_rotationTypeDetectionReceiver
;
...
@@ -74,7 +84,7 @@ public class RecognizeActivity extends AppCompatActivity {
...
@@ -74,7 +84,7 @@ public class RecognizeActivity extends AppCompatActivity {
@BindView
(
R
.
id
.
bottom
)
@BindView
(
R
.
id
.
bottom
)
LinearLayout
bottom
;
LinearLayout
bottom
;
@BindView
(
R
.
id
.
left_iv
)
@BindView
(
R
.
id
.
left_iv
)
ImageView
lefIv
;
LinearLayout
lefIv
;
@BindView
(
R
.
id
.
contentIv
)
@BindView
(
R
.
id
.
contentIv
)
ImageView
contentIv
;
ImageView
contentIv
;
@BindView
(
R
.
id
.
left_tv
)
@BindView
(
R
.
id
.
left_tv
)
...
@@ -83,24 +93,23 @@ public class RecognizeActivity extends AppCompatActivity {
...
@@ -83,24 +93,23 @@ public class RecognizeActivity extends AppCompatActivity {
int
image_type
;
int
image_type
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
recognize_layout
);
setContentView
(
R
.
layout
.
recognize_layout
);
OcrApplication
.
getInstance
().
addActivity
(
this
);
OcrApplication
.
getInstance
().
addActivity
(
this
);
ButterKnife
.
bind
(
this
);
ButterKnife
.
bind
(
this
);
leftTv
.
setText
(
"识别"
);
leftTv
.
setText
(
"识别"
);
rightTv
.
setVisibility
(
View
.
GONE
);
rightTv
.
setVisibility
(
View
.
GONE
);
image_type
=
getIntentData
();
image_type
=
getIntentData
();
checkPermission
();
checkPermission
();
}
}
public
int
getIntentData
()
{
public
int
getIntentData
()
{
return
getIntent
().
getIntExtra
(
"type"
,
4
);
return
getIntent
().
getIntExtra
(
"type"
,
4
);
}
}
public
void
setButtonEnable
(
boolean
flg
)
{
public
void
setButtonEnable
(
boolean
flg
)
{
...
@@ -145,8 +154,6 @@ public class RecognizeActivity extends AppCompatActivity {
...
@@ -145,8 +154,6 @@ public class RecognizeActivity extends AppCompatActivity {
}
}
}
}
@Override
@Override
protected
void
onStart
()
{
protected
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
...
@@ -209,7 +216,7 @@ public class RecognizeActivity extends AppCompatActivity {
...
@@ -209,7 +216,7 @@ public class RecognizeActivity extends AppCompatActivity {
}
}
}
}
@OnClick
({
R
.
id
.
left_iv
,
R
.
id
.
bottom
})
@OnClick
({
R
.
id
.
left_iv
,
R
.
id
.
bottom
,
R
.
id
.
rotate
})
public
void
onViewClicked
(
View
view
)
{
public
void
onViewClicked
(
View
view
)
{
switch
(
view
.
getId
())
{
switch
(
view
.
getId
())
{
case
R
.
id
.
left_iv
:
case
R
.
id
.
left_iv
:
...
@@ -218,9 +225,13 @@ public class RecognizeActivity extends AppCompatActivity {
...
@@ -218,9 +225,13 @@ public class RecognizeActivity extends AppCompatActivity {
case
R
.
id
.
bottom
:
//识别触发
case
R
.
id
.
bottom
:
//识别触发
setRecogniztionView
(
View
.
VISIBLE
);
setRecogniztionView
(
View
.
VISIBLE
);
Uri
uri
=
Uri
.
fromFile
(
new
File
(
image
.
getPath
()));
Uri
uri
=
Uri
.
fromFile
(
new
File
(
image
.
getPath
()));
// String path= Configs.IMAGE_BASE+"/1525487086902.jpg";
// uri= FileUtil.getFileUri(this,new File(path));
startRecogniziton
(
uri
);
startRecogniziton
(
uri
);
setButtonEnable
(
false
);
setButtonEnable
(
false
);
break
;
break
;
case
R
.
id
.
rotate
:
break
;
}
}
}
}
...
@@ -274,16 +285,17 @@ public class RecognizeActivity extends AppCompatActivity {
...
@@ -274,16 +285,17 @@ public class RecognizeActivity extends AppCompatActivity {
}
}
break
;
break
;
case
99
:
case
99
:
if
(
null
==
data
)
if
(
null
==
data
)
finish
();
finish
();
else
{
else
{
Uri
uri
=
data
.
getExtras
().
getParcelable
(
ScanConstants
.
SCANNED_RESULT
);
Uri
uri
=
data
.
getExtras
().
getParcelable
(
ScanConstants
.
SCANNED_RESULT
);
Bitmap
bitmap
=
null
;
Bitmap
bitmap
=
null
;
try
{
try
{
bitmap
=
MediaStore
.
Images
.
Media
.
getBitmap
(
getContentResolver
(),
uri
);
bitmap
=
MediaStore
.
Images
.
Media
.
getBitmap
(
getContentResolver
(),
uri
);
getContentResolver
().
delete
(
uri
,
null
,
null
);
getContentResolver
().
delete
(
uri
,
null
,
null
);
// iv.setImageBitmap(bitmap);
// iv.setImageBitmap(bitmap);
String
path
=
saveBitmap
(
this
,
bitmap
);
String
path
=
PhotoBitmapUtils
.
amendRotatePhoto
(
saveBitmap
(
this
,
bitmap
),
this
);
path
=
Utils
.
saveBitmap
(
bitmap
,
System
.
currentTimeMillis
()
+
".jpg"
).
getPath
();
String
name
=
path
.
substring
(
path
.
lastIndexOf
(
"/"
)
+
1
);
String
name
=
path
.
substring
(
path
.
lastIndexOf
(
"/"
)
+
1
);
image
=
new
Image
(
path
,
name
);
image
=
new
Image
(
path
,
name
);
...
@@ -312,16 +324,57 @@ public class RecognizeActivity extends AppCompatActivity {
...
@@ -312,16 +324,57 @@ public class RecognizeActivity extends AppCompatActivity {
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
RecognitionContext
.
setRecognitionResult
(
result
);
RecognitionContext
.
setRecognitionResult
(
result
);
Intent
intent
=
new
Intent
(
this
,
VertifyActivity
.
class
);
// image.setRecogniztion(getResources().getString(R.string.vertify_content));
image
.
setRecogniztion
(
result
.
toString
());
image
.
setRecogniztion
(
result
.
toString
());
intent
.
putExtra
(
"image"
,
image
);
/**
startActivity
(
intent
);
* {
"sourcePicturePath": "/home/haomo/zhangjiakou/upload/ocr/1525684712085.jpg",
"thumbPath": "/home/haomo/zhangjiakou/upload/ocr/thum/1525684712085.jpg"
}
{"code":0,"message":"ocr/1525684863204.jpg","fields":null}
*/
HttpHolder
.
upLoadFile
(
RequestConfig
.
UP_SOURCE_URL
,
image
.
getPath
(),
new
Callback
.
CommonCallback
<
String
>()
{
@Override
public
void
onSuccess
(
String
result
)
{
if
(
result
!=
null
)
{
JSONObject
object
=
null
;
try
{
object
=
new
JSONObject
(
result
);
// String filePath = object.getString("message");
String
filePath
=
object
.
getString
(
"sourcePicturePath"
);
String
thumPath
=
object
.
getString
(
"thumbPath"
);
Intent
intent
=
new
Intent
(
RecognizeActivity
.
this
,
VertifyActivity
.
class
);
intent
.
putExtra
(
"image"
,
image
);
intent
.
putExtra
(
"sourceFile"
,
filePath
);
intent
.
putExtra
(
"sourceThumFile"
,
thumPath
);
startActivity
(
intent
);
RecognizeActivity
.
this
.
finish
();
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
}
@Override
public
void
onError
(
Throwable
ex
,
boolean
isOnCallback
)
{
Toast
.
makeText
(
RecognizeActivity
.
this
,
"网络异常,请重新操作"
,
Toast
.
LENGTH_SHORT
).
show
();
Log
.
e
(
"TAG"
,
ex
.
getMessage
());
}
@Override
public
void
onCancelled
(
CancelledException
cex
)
{
}
@Override
public
void
onFinished
()
{
}
});
}
else
{
}
else
{
Toast
.
makeText
(
this
,
"No result."
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
this
,
"No result."
,
Toast
.
LENGTH_LONG
).
show
();
}
}
finish
();
}
}
//识别结果 -失败
//识别结果 -失败
...
@@ -347,14 +400,15 @@ public class RecognizeActivity extends AppCompatActivity {
...
@@ -347,14 +400,15 @@ public class RecognizeActivity extends AppCompatActivity {
private
void
dispatchRecognitionProgress
(
int
progress
)
{
private
void
dispatchRecognitionProgress
(
int
progress
)
{
bar
.
setProgress
(
progress
);
bar
.
setProgress
(
progress
);
this
.
progress
.
setText
(
"已识别:"
+
progress
+
"%"
);
this
.
progress
.
setText
(
"已识别:"
+
progress
+
"%"
);
}
}
private
void
setRecogniztionView
(
int
type
){
if
(
type
==
View
.
GONE
){
private
void
setRecogniztionView
(
int
type
)
{
if
(
type
==
View
.
GONE
)
{
bottomProgress
.
setVisibility
(
type
);
bottomProgress
.
setVisibility
(
type
);
bottomBtn
.
setVisibility
(
View
.
VISIBLE
);
bottomBtn
.
setVisibility
(
View
.
VISIBLE
);
bar
.
setProgress
(
0
);
bar
.
setProgress
(
0
);
}
else
{
}
else
{
bottomBtn
.
setVisibility
(
View
.
GONE
);
bottomBtn
.
setVisibility
(
View
.
GONE
);
bottomProgress
.
setVisibility
(
type
);
bottomProgress
.
setVisibility
(
type
);
}
}
...
...
app/src/main/java/cn/com/bril/androidocr/studio/ui/activity/VertifyActivity.java
View file @
b76f8dad
This diff is collapsed.
Click to expand it.
app/src/main/java/cn/com/bril/androidocr/studio/ui/adapter/FragmentListAdapter.java
View file @
b76f8dad
...
@@ -27,6 +27,7 @@ public class FragmentListAdapter extends BaseAdapter {
...
@@ -27,6 +27,7 @@ public class FragmentListAdapter extends BaseAdapter {
private
ListTextClickListener
listTextClickListener
;
private
ListTextClickListener
listTextClickListener
;
private
int
show
=
View
.
GONE
;
private
int
show
=
View
.
GONE
;
AdapterRadioSelectedListener
radioSelectedListener
;
AdapterRadioSelectedListener
radioSelectedListener
;
ListFileClickListener
fileOnClickListener
;
public
FragmentListAdapter
(
Context
context
,
List
<
OcrRootBean
>
list
,
ListTextClickListener
listTextClickListener
,
AdapterRadioSelectedListener
radioSelectedListener
)
{
public
FragmentListAdapter
(
Context
context
,
List
<
OcrRootBean
>
list
,
ListTextClickListener
listTextClickListener
,
AdapterRadioSelectedListener
radioSelectedListener
)
{
this
.
context
=
context
;
this
.
context
=
context
;
this
.
infos
=
list
;
this
.
infos
=
list
;
...
@@ -34,6 +35,15 @@ public class FragmentListAdapter extends BaseAdapter {
...
@@ -34,6 +35,15 @@ public class FragmentListAdapter extends BaseAdapter {
this
.
radioSelectedListener
=
radioSelectedListener
;
this
.
radioSelectedListener
=
radioSelectedListener
;
}
}
public
void
setFileOnClickListener
(
ListFileClickListener
fileOnClickListener
){
this
.
fileOnClickListener
=
fileOnClickListener
;
}
public
void
setAdapterData
(
List
<
OcrRootBean
>
list
){
this
.
infos
=
list
;
notifyDataSetChanged
();
}
public
void
setRadioShow
(
int
show
){
public
void
setRadioShow
(
int
show
){
this
.
show
=
show
;
this
.
show
=
show
;
notifyDataSetChanged
();
notifyDataSetChanged
();
...
@@ -87,7 +97,7 @@ public class FragmentListAdapter extends BaseAdapter {
...
@@ -87,7 +97,7 @@ public class FragmentListAdapter extends BaseAdapter {
String
s
=
info
.
getIncludes
().
getCc_file
().
getFileName
();
String
s
=
info
.
getIncludes
().
getCc_file
().
getFileName
();
String
fileName
;
String
fileName
;
if
(
s
.
contains
(
"."
))
if
(
s
.
contains
(
"."
))
fileName
=
s
.
substring
(
0
,
s
.
i
ndexOf
(
"."
));
fileName
=
s
.
substring
(
0
,
s
.
lastI
ndexOf
(
"."
));
else
else
fileName
=
s
;
fileName
=
s
;
holder
.
title
.
setText
(
fileName
);
holder
.
title
.
setText
(
fileName
);
...
@@ -102,6 +112,7 @@ public class FragmentListAdapter extends BaseAdapter {
...
@@ -102,6 +112,7 @@ public class FragmentListAdapter extends BaseAdapter {
}
else
}
else
holder
.
iv
.
setImageDrawable
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
word
));
holder
.
iv
.
setImageDrawable
(
context
.
getResources
().
getDrawable
(
R
.
drawable
.
word
));
holder
.
iv
.
setOnClickListener
(
new
ListFileOnClickListener
(
position
));
holder
.
title
.
setOnClickListener
(
new
ListTextOnClickListener
(
position
));
holder
.
title
.
setOnClickListener
(
new
ListTextOnClickListener
(
position
));
holder
.
radioButton
.
setVisibility
(
show
);
holder
.
radioButton
.
setVisibility
(
show
);
holder
.
radioButton
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
holder
.
radioButton
.
setOnCheckedChangeListener
(
new
CompoundButton
.
OnCheckedChangeListener
()
{
...
@@ -127,6 +138,19 @@ public class FragmentListAdapter extends BaseAdapter {
...
@@ -127,6 +138,19 @@ public class FragmentListAdapter extends BaseAdapter {
}
}
}
}
class
ListFileOnClickListener
implements
View
.
OnClickListener
{
int
position
;
public
ListFileOnClickListener
(
int
position
)
{
this
.
position
=
position
;
}
@Override
public
void
onClick
(
View
v
)
{
fileOnClickListener
.
onListFileCallBack
(
position
);
}
}
public
interface
AdapterRadioSelectedListener
{
public
interface
AdapterRadioSelectedListener
{
void
adapterRadioSelectedCallBack
();
void
adapterRadioSelectedCallBack
();
}
}
...
@@ -134,6 +158,10 @@ public class FragmentListAdapter extends BaseAdapter {
...
@@ -134,6 +158,10 @@ public class FragmentListAdapter extends BaseAdapter {
public
interface
ListTextClickListener
{
public
interface
ListTextClickListener
{
void
onListTextCallBack
(
int
postion
);
void
onListTextCallBack
(
int
postion
);
}
}
public
interface
ListFileClickListener
{
void
onListFileCallBack
(
int
position
);
}
class
ViewHolder
{
class
ViewHolder
{
TextView
title
,
time
;
TextView
title
,
time
;
ImageView
iv
;
ImageView
iv
;
...
...
app/src/main/java/cn/com/bril/androidocr/studio/ui/fragment/ExportFragment.java
View file @
b76f8dad
This diff is collapsed.
Click to expand it.
app/src/main/java/cn/com/bril/androidocr/studio/ui/fragment/ShareFragment.java
View file @
b76f8dad
...
@@ -4,6 +4,7 @@ import android.app.Activity;
...
@@ -4,6 +4,7 @@ import android.app.Activity;
import
android.app.AlertDialog
;
import
android.app.AlertDialog
;
import
android.app.ProgressDialog
;
import
android.app.ProgressDialog
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
...
@@ -41,6 +42,7 @@ import cn.com.bril.androidocr.studio.http.HttpHolder;
...
@@ -41,6 +42,7 @@ import cn.com.bril.androidocr.studio.http.HttpHolder;
import
cn.com.bril.androidocr.studio.http.MainHttpCallBack
;
import
cn.com.bril.androidocr.studio.http.MainHttpCallBack
;
import
cn.com.bril.androidocr.studio.interf.HandleMenuListener
;
import
cn.com.bril.androidocr.studio.interf.HandleMenuListener
;
import
cn.com.bril.androidocr.studio.interf.OnHttpListener
;
import
cn.com.bril.androidocr.studio.interf.OnHttpListener
;
import
cn.com.bril.androidocr.studio.ui.activity.OcrDetailActivity
;
import
cn.com.bril.androidocr.studio.ui.adapter.FragmentListAdapter
;
import
cn.com.bril.androidocr.studio.ui.adapter.FragmentListAdapter
;
import
cn.com.bril.androidocr.studio.ui.adapter.ShareFragmentAdapter
;
import
cn.com.bril.androidocr.studio.ui.adapter.ShareFragmentAdapter
;
import
cn.com.bril.androidocr.studio.ui.pulltorefresh.PullToRefreshBase
;
import
cn.com.bril.androidocr.studio.ui.pulltorefresh.PullToRefreshBase
;
...
@@ -56,9 +58,7 @@ import cn.com.bril.androidocr.studio.utils.ShareUtil;
...
@@ -56,9 +58,7 @@ import cn.com.bril.androidocr.studio.utils.ShareUtil;
* Created by sunny on 2018-3-12.
* Created by sunny on 2018-3-12.
*/
*/
public
class
ShareFragment
extends
Fragment
implements
OnHttpListener
,
FragmentListAdapter
.
ListTextClickListener
,
View
.
OnClickListener
{
public
class
ShareFragment
extends
Fragment
implements
OnHttpListener
,
FragmentListAdapter
.
ListTextClickListener
,
View
.
OnClickListener
,
ShareFragmentAdapter
.
ListFileClickListener
{
private
PullToRefreshListView
pullToRefreshListView
;
private
PullToRefreshListView
pullToRefreshListView
;
private
ListView
listView
;
private
ListView
listView
;
private
Context
context
;
private
Context
context
;
...
@@ -96,6 +96,7 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
...
@@ -96,6 +96,7 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
}
}
}
}
};
};
private
ArrayList
<
Uri
>
shareFileUris
;
private
ArrayList
<
Uri
>
shareFileUris
;
private
EditText
reNameEdit
;
private
EditText
reNameEdit
;
private
AlertDialog
reNameDialog
;
private
AlertDialog
reNameDialog
;
...
@@ -153,16 +154,18 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
...
@@ -153,16 +154,18 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
pullToRefreshListView
.
setPullRefreshEnabled
(
true
);
pullToRefreshListView
.
setPullRefreshEnabled
(
true
);
listView
=
pullToRefreshListView
.
getRefreshableView
();
listView
=
pullToRefreshListView
.
getRefreshableView
();
pullToRefreshListView
.
doPullRefreshing
(
true
,
500
);
adaper
=
new
ShareFragmentAdapter
(
context
,
beanList
,
this
,
new
ShareFragmentAdapter
.
AdapterRadioSelectedListener
()
{
adaper
=
new
ShareFragmentAdapter
(
context
,
beanList
,
this
,
new
ShareFragmentAdapter
.
AdapterRadioSelectedListener
()
{
@Override
@Override
public
void
adapterRadioSelectedCallBack
()
{
public
void
adapterRadioSelectedCallBack
()
{
setSelectedInfos
(
adaper
.
getSelectedInfo
());
setSelectedInfos
(
adaper
.
getSelectedInfo
());
messageToMain
.
noticeMessage
(
adaper
.
getSelectedInfo
().
size
());
messageToMain
.
noticeMessage
(
adaper
.
getSelectedInfo
().
size
());
}
}
});
});
adaper
.
setFileOnClickListener
(
this
);
listView
.
setAdapter
(
adaper
);
listView
.
setAdapter
(
adaper
);
}
}
public
void
initEvents
(){
public
void
initEvents
(){
pullToRefreshListView
.
setOnRefreshListener
(
new
PullToRefreshBase
.
OnRefreshListener
<
ListView
>()
{
pullToRefreshListView
.
setOnRefreshListener
(
new
PullToRefreshBase
.
OnRefreshListener
<
ListView
>()
{
...
@@ -202,32 +205,24 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
...
@@ -202,32 +205,24 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
listView
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
listView
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
@Override
@Override
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
public
void
onItemClick
(
AdapterView
<?>
parent
,
View
view
,
int
position
,
long
id
)
{
String
path
=
beanList
.
get
(
position
).
getIncludes
().
getCc_file
().
getFilePath
();
String
filePath
=
beanList
.
get
(
position
).
getIncludes
().
getCc_file
().
getFileSource
();
String
fileName
=
beanList
.
get
(
position
).
getIncludes
().
getCc_file
().
getFileName
();
String
content
=
beanList
.
get
(
position
).
getIncludes
().
getCc_file
().
getContent
();
if
(
fileName
.
contains
(
".pdf"
)){
Intent
intent
=
new
Intent
(
context
,
OcrDetailActivity
.
class
);
if
(
FileUtil
.
isFileExist
(
Configs
.
PDF_BASE
+
"/"
+
fileName
)){
intent
.
putExtra
(
"image"
,
filePath
);
FileType
.
openFile
(
context
,
new
File
(
Configs
.
PDF_BASE
+
"/"
+
fileName
));
intent
.
putExtra
(
"content"
,
content
);
}
context
.
startActivity
(
intent
);
else
{
downLoadFile
(
path
,
fileName
,
"single"
);
}
}
else
if
(
fileName
.
contains
(
".doc"
)||
fileName
.
contains
(
".docs"
)){
if
(
FileUtil
.
isFileExist
(
Configs
.
WORD_BASE
+
"/"
+
fileName
)){
FileType
.
openFile
(
context
,
new
File
(
Configs
.
WORD_BASE
+
"/"
+
fileName
));
}
else
downLoadFile
(
path
,
fileName
,
"single"
);
}
else
if
(
fileName
.
contains
(
".txt"
)){
if
(
FileUtil
.
isFileExist
(
Configs
.
TXT_BASE
+
"/"
+
fileName
)){
FileType
.
openFile
(
context
,
new
File
(
Configs
.
TXT_BASE
+
"/"
+
fileName
));
}
else
downLoadFile
(
path
,
fileName
,
"single"
);
}
}
}
});
});
}
}
@Override
public
void
onResume
()
{
super
.
onResume
();
pullToRefreshListView
.
doPullRefreshing
(
true
,
500
);
if
(
adaper
!=
null
)
adaper
.
setRadioShow
(
View
.
GONE
);
}
public
void
setAllItemChecked
(
boolean
flg
){
public
void
setAllItemChecked
(
boolean
flg
){
adaper
.
setRadioAllSelected
(
flg
);
adaper
.
setRadioAllSelected
(
flg
);
}
}
...
@@ -246,7 +241,7 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
...
@@ -246,7 +241,7 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
params
.
addBodyParameter
(
"filters"
,
json
);
params
.
addBodyParameter
(
"filters"
,
json
);
String
json2
=
"{\"cc_file\":{\"includes\":[\"file_id\"]}}"
;
String
json2
=
"{\"cc_file\":{\"includes\":[\"file_id\"]}}"
;
params
.
addBodyParameter
(
"includes"
,
json2
);
params
.
addBodyParameter
(
"includes"
,
json2
);
x
.
http
().
pos
t
(
params
,
new
MainHttpCallBack
(
"list"
,
this
));
x
.
http
().
ge
t
(
params
,
new
MainHttpCallBack
(
"list"
,
this
));
}
}
//下载文件
//下载文件
private
void
downLoadFile
(
String
path
,
String
fileName
,
final
String
type
)
{
private
void
downLoadFile
(
String
path
,
String
fileName
,
final
String
type
)
{
...
@@ -300,7 +295,7 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
...
@@ -300,7 +295,7 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
shareFileUris
=
new
ArrayList
<>();
shareFileUris
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
OcrRootBean
.
Cc_file
cc_file
=
list
.
get
(
i
).
getIncludes
().
getCc_file
();
OcrRootBean
.
Cc_file
cc_file
=
list
.
get
(
i
).
getIncludes
().
getCc_file
();
String
type
=
cc_file
.
getFileName
().
substring
(
cc_file
.
getFileName
().
i
ndexOf
(
"."
)
+
1
);
String
type
=
cc_file
.
getFileName
().
substring
(
cc_file
.
getFileName
().
lastI
ndexOf
(
"."
)
+
1
);
String
filePath
=
""
;
String
filePath
=
""
;
if
(
"doc"
.
equals
(
type
)
||
"docs"
.
equals
(
type
))
if
(
"doc"
.
equals
(
type
)
||
"docs"
.
equals
(
type
))
filePath
=
Configs
.
WORD_BASE
+
"/"
+
cc_file
.
getFileName
();
filePath
=
Configs
.
WORD_BASE
+
"/"
+
cc_file
.
getFileName
();
...
@@ -398,6 +393,7 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
...
@@ -398,6 +393,7 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
pullToRefreshListView
.
onPullUpRefreshComplete
();
pullToRefreshListView
.
onPullUpRefreshComplete
();
pullToRefreshListView
.
onPullDownRefreshComplete
();
pullToRefreshListView
.
onPullDownRefreshComplete
();
}
}
Toast
.
makeText
(
context
,
"网络异常,请检查"
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
@Override
@Override
...
@@ -427,4 +423,30 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
...
@@ -427,4 +423,30 @@ public class ShareFragment extends Fragment implements OnHttpListener, FragmentL
break
;
break
;
}
}
}
}
@Override
public
void
onListFileCallBack
(
int
position
)
{
String
path
=
beanList
.
get
(
position
).
getIncludes
().
getCc_file
().
getFilePath
();
String
fileName
=
beanList
.
get
(
position
).
getIncludes
().
getCc_file
().
getFileName
();
if
(
fileName
.
contains
(
".pdf"
)){
if
(
FileUtil
.
isFileExist
(
Configs
.
PDF_BASE
+
"/"
+
fileName
)){
FileType
.
openFile
(
context
,
new
File
(
Configs
.
PDF_BASE
+
"/"
+
fileName
));
}
else
{
downLoadFile
(
path
,
fileName
,
"single"
);
}
}
else
if
(
fileName
.
contains
(
".doc"
)||
fileName
.
contains
(
".docs"
)){
if
(
FileUtil
.
isFileExist
(
Configs
.
WORD_BASE
+
"/"
+
fileName
)){
FileType
.
openFile
(
context
,
new
File
(
Configs
.
WORD_BASE
+
"/"
+
fileName
));
}
else
downLoadFile
(
path
,
fileName
,
"single"
);
}
else
if
(
fileName
.
contains
(
".txt"
)){
if
(
FileUtil
.
isFileExist
(
Configs
.
TXT_BASE
+
"/"
+
fileName
)){
FileType
.
openFile
(
context
,
new
File
(
Configs
.
TXT_BASE
+
"/"
+
fileName
));
}
else
downLoadFile
(
path
,
fileName
,
"single"
);
}
}
}
}
app/src/main/java/cn/com/bril/androidocr/studio/utils/FileUtil.java
View file @
b76f8dad
...
@@ -23,7 +23,7 @@ public class FileUtil {
...
@@ -23,7 +23,7 @@ public class FileUtil {
public
static
String
saveBitmap
(
Context
context
,
Bitmap
mBitmap
)
{
public
static
String
saveBitmap
(
Context
context
,
Bitmap
mBitmap
)
{
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
).
format
(
new
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
).
format
(
new
Date
());
Date
());
String
savePath
=
ScanConstants
.
IMAGE_PATH
+
"/"
+
"IMG_"
+
timeStamp
+
String
savePath
=
ScanConstants
.
IMAGE_PATH
+
"/"
+
timeStamp
+
".jpg"
;
".jpg"
;
File
filePic
;
File
filePic
;
...
@@ -45,6 +45,16 @@ public class FileUtil {
...
@@ -45,6 +45,16 @@ public class FileUtil {
return
filePic
.
getAbsolutePath
();
return
filePic
.
getAbsolutePath
();
}
}
//文件夹创建
public
static
void
creatDir
(
String
path
){
if
(!
isFileExist
(
path
)){
File
file
=
new
File
(
path
);
if
(!
file
.
exists
())
file
.
mkdirs
();
}
}
//判断文件是否存在
//判断文件是否存在
public
static
boolean
isFileExist
(
String
path
){
public
static
boolean
isFileExist
(
String
path
){
try
try
...
@@ -75,4 +85,5 @@ public class FileUtil {
...
@@ -75,4 +85,5 @@ public class FileUtil {
}
}
return
tempFileUri
;
return
tempFileUri
;
}
}
}
}
app/src/main/java/cn/com/bril/androidocr/studio/utils/ShareUtil.java
View file @
b76f8dad
...
@@ -18,9 +18,10 @@ public class ShareUtil {
...
@@ -18,9 +18,10 @@ public class ShareUtil {
// 調用系統方法分享文件
// 調用系統方法分享文件
public
static
void
shareFile
(
Activity
activity
,
File
file
)
{
public
static
void
shareFile
(
Activity
activity
,
File
file
)
{
if
(
null
!=
file
&&
file
.
exists
())
{
if
(
null
!=
file
&&
file
.
exists
())
{
Intent
share
=
new
Intent
(
Intent
.
ACTION_SEND
);
Intent
share
=
new
Intent
(
Intent
.
ACTION_SEND
);
share
.
putExtra
(
Intent
.
EXTRA_STREAM
,
FileUtil
.
getFileUri
(
activity
,
file
)
);
share
.
putExtra
(
Intent
.
EXTRA_STREAM
,
FileUtil
.
getFileUri
(
activity
,
file
)
);
share
.
setType
(
getMimeType
(
file
.
getAbsolutePath
()));
//此处可发送多种文件
share
.
setType
(
getMimeType
(
file
.
getAbsolutePath
()));
//此处可发送多种文件
share
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
share
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
share
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
share
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
...
@@ -55,6 +56,7 @@ public class ShareUtil {
...
@@ -55,6 +56,7 @@ public class ShareUtil {
Intent
intent
=
new
Intent
(
Intent
.
ACTION_SEND_MULTIPLE
);
//发送多个文件
Intent
intent
=
new
Intent
(
Intent
.
ACTION_SEND_MULTIPLE
);
//发送多个文件
intent
.
setType
(
"*/*"
);
//多个文件格式
intent
.
setType
(
"*/*"
);
//多个文件格式
intent
.
putParcelableArrayListExtra
(
Intent
.
EXTRA_STREAM
,
uris
);
//Intent.EXTRA_STREAM同于传输文件流
intent
.
putParcelableArrayListExtra
(
Intent
.
EXTRA_STREAM
,
uris
);
//Intent.EXTRA_STREAM同于传输文件流
activity
.
startActivity
(
Intent
.
createChooser
(
intent
,
"多文件分享"
));
activity
.
startActivity
(
intent
);
//Intent.createChooser(intent, "多文件分享")
}
}
}
}
app/src/main/res/layout/activity_proofread.xml
View file @
b76f8dad
...
@@ -11,11 +11,12 @@
...
@@ -11,11 +11,12 @@
android:id=
"@+id/head"
android:id=
"@+id/head"
layout=
"@layout/top_title_layout"
/>
layout=
"@layout/top_title_layout"
/>
<ImageView
<
cn.com.bril.androidocr.studio.ui.widget.Matrix
ImageView
android:id=
"@+id/photo"
android:id=
"@+id/photo"
android:layout_width=
"
5
00dp"
android:layout_width=
"
3
00dp"
android:layout_height=
"
30
0dp"
android:layout_height=
"
25
0dp"
android:layout_centerHorizontal=
"true"
android:layout_centerHorizontal=
"true"
android:scaleType=
"matrix"
android:layout_below=
"@+id/head"
/>
android:layout_below=
"@+id/head"
/>
<ScrollView
<ScrollView
...
@@ -30,6 +31,8 @@
...
@@ -30,6 +31,8 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:minHeight=
"300dp"
android:minHeight=
"300dp"
android:gravity=
"start"
android:padding=
"8dp"
android:textColorHighlight=
"@color/yellow"
android:textColorHighlight=
"@color/yellow"
android:background=
"@color/white"
/>
android:background=
"@color/white"
/>
</ScrollView>
</ScrollView>
...
...
app/src/main/res/layout/export_layout.xml
View file @
b76f8dad
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
>
>
<TextView
<TextView
android:id=
"@+id/tilte"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@string/export"
android:text=
"@string/export"
...
@@ -18,19 +19,20 @@
...
@@ -18,19 +19,20 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_height=
"1dp"
android:background=
"@color/bg_normal"
/>
android:background=
"@color/bg_normal"
/>
<LinearLayout
<LinearLayout
android:id=
"@+id/pdfLayout"
android:id=
"@+id/pdfLayout"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:padding=
"10dp"
android:padding=
"10dp"
android:visibility=
"gone"
>
>
<TextView
<TextView
android:id=
"@+id/pdf"
android:id=
"@+id/pdf"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:text=
"
Pdf
导出"
android:text=
"
WPS
导出"
android:textColor=
"@color/txtcolor"
android:textColor=
"@color/txtcolor"
android:textSize=
"@dimen/txt16sp"
/>
android:textSize=
"@dimen/txt16sp"
/>
...
...
app/src/main/res/layout/listview_item_layout.xml
View file @
b76f8dad
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
android:id=
"@+id/icon"
android:id=
"@+id/icon"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:src=
"@drawable/word"
android:padding=
"5dp"
android:padding=
"5dp"
/>
/>
...
@@ -18,13 +19,18 @@
...
@@ -18,13 +19,18 @@
android:orientation=
"vertical"
android:orientation=
"vertical"
android:gravity=
"center_vertical"
android:gravity=
"center_vertical"
android:layout_marginLeft=
"15dp"
android:layout_marginLeft=
"15dp"
android:padding=
"10dp"
android:layout_toRightOf=
"@+id/icon"
android:layout_toRightOf=
"@+id/icon"
>
android:padding=
"5dp"
android:layout_centerVertical=
"true"
android:layout_alignParentTop=
"true"
android:layout_alignParentEnd=
"true"
>
<TextView
<TextView
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"0dp"
android:layout_height=
"0dp"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:minWidth=
"100dp"
android:singleLine=
"true"
android:id=
"@+id/title"
android:id=
"@+id/title"
android:textSize=
"@dimen/txt16sp"
android:textSize=
"@dimen/txt16sp"
android:focusable=
"false"
android:focusable=
"false"
...
...
app/src/main/res/layout/recognize_layout.xml
View file @
b76f8dad
...
@@ -10,8 +10,10 @@
...
@@ -10,8 +10,10 @@
<ImageView
<ImageView
android:id=
"@+id/contentIv"
android:id=
"@+id/contentIv"
android:layout_width=
"wrap_content"
android:layout_width=
"280dp"
android:layout_height=
"wrap_content"
android:layout_height=
"350dp"
android:scaleType=
"centerInside"
android:layout_margin=
"12dp"
android:layout_below=
"@+id/head"
android:layout_below=
"@+id/head"
android:layout_above=
"@+id/bottom"
android:layout_above=
"@+id/bottom"
android:layout_centerInParent=
"true"
android:layout_centerInParent=
"true"
...
@@ -74,6 +76,7 @@
...
@@ -74,6 +76,7 @@
<LinearLayout
<LinearLayout
android:id=
"@+id/rotate"
android:layout_width=
"90dp"
android:layout_width=
"90dp"
android:layout_height=
"35dp"
android:layout_height=
"35dp"
android:background=
"@drawable/gary_round_bg"
android:background=
"@drawable/gary_round_bg"
...
...
app/src/main/res/layout/top_title_layout.xml
View file @
b76f8dad
...
@@ -6,14 +6,23 @@
...
@@ -6,14 +6,23 @@
android:id=
"@+id/topBarLayout"
android:id=
"@+id/topBarLayout"
>
>
<
ImageView
<
LinearLayout
android:id=
"@+id/left_iv"
android:id=
"@+id/left_iv"
android:layout_width=
"12dp"
android:layout_width=
"100dp"
android:layout_height=
"15dp"
android:layout_height=
"wrap_content"
android:src=
"@drawable/back_icon"
android:layout_centerVertical=
"true"
android:layout_centerVertical=
"true"
android:layout_marginLeft=
"20dp"
android:gravity=
"center_vertical"
>
/>
<ImageView
android:layout_width=
"15dp"
android:layout_height=
"18dp"
android:src=
"@drawable/back_icon"
android:layout_marginLeft=
"15dp"
/>
</LinearLayout>
<TextView
<TextView
android:id=
"@+id/left_tv"
android:id=
"@+id/left_tv"
...
...
app/src/main/res/values/styles.xml
View file @
b76f8dad
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<!--Button按钮正常状态颜色-->
<!--Button按钮正常状态颜色-->
<item
name=
"colorButtonNormal"
>
@color/normal
</item>
<item
name=
"colorButtonNormal"
>
@color/normal
</item>
<!--//colorAccent-->
<!--//colorAccent-->
<!--<item name="android:colorControlNormal">@color/normal</item>-->
</style>
</style>
<style
name=
"AppTheme.AppBarOverlay"
parent=
"ThemeOverlay.AppCompat.Dark.ActionBar"
>
<style
name=
"AppTheme.AppBarOverlay"
parent=
"ThemeOverlay.AppCompat.Dark.ActionBar"
>
...
...
scanlibrary/src/main/AndroidManifest.xml
View file @
b76f8dad
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
<activity
<activity
android:name=
".ScanActivity"
android:name=
".ScanActivity"
android:configChanges=
"orientation|screenSize"
android:configChanges=
"orientation|screenSize"
android:label=
"@string/app_name"
>
android:label=
"@string/app_name"
>
</activity>
</activity>
<provider
<provider
...
...
scanlibrary/src/main/java/com/scanlibrary/IScanner.java
View file @
b76f8dad
package
com
.
scanlibrary
;
package
com
.
scanlibrary
;
import
android.graphics.Bitmap
;
import
android.net.Uri
;
import
android.net.Uri
;
/**
/**
...
@@ -9,5 +10,9 @@ public interface IScanner {
...
@@ -9,5 +10,9 @@ public interface IScanner {
void
onBitmapSelect
(
Uri
uri
);
void
onBitmapSelect
(
Uri
uri
);
void
onBitmapScan
(
Bitmap
bitmap
);
void
onScanFinish
(
Uri
uri
);
void
onScanFinish
(
Uri
uri
);
void
onRotate
(
Bitmap
bitmap
);
}
}
scanlibrary/src/main/java/com/scanlibrary/PickImageFragment.java
View file @
b76f8dad
...
@@ -19,6 +19,7 @@ import android.view.ViewGroup;
...
@@ -19,6 +19,7 @@ import android.view.ViewGroup;
import
android.widget.ImageButton
;
import
android.widget.ImageButton
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -63,9 +64,11 @@ public class PickImageFragment extends Fragment {
...
@@ -63,9 +64,11 @@ public class PickImageFragment extends Fragment {
}
}
}
}
private
void
clearTempImages
()
{
private
void
clearTempImages
()
{
try
{
try
{
File
tempFolder
=
new
File
(
ScanConstants
.
IMAGE_
PATH
);
File
tempFolder
=
new
File
(
ScanConstants
.
IMAGE_
CACHE
);
for
(
File
f
:
tempFolder
.
listFiles
())
for
(
File
f
:
tempFolder
.
listFiles
())
f
.
delete
();
f
.
delete
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -118,16 +121,17 @@ public class PickImageFragment extends Fragment {
...
@@ -118,16 +121,17 @@ public class PickImageFragment extends Fragment {
Intent
cameraIntent
=
new
Intent
(
android
.
provider
.
MediaStore
.
ACTION_IMAGE_CAPTURE
);
Intent
cameraIntent
=
new
Intent
(
android
.
provider
.
MediaStore
.
ACTION_IMAGE_CAPTURE
);
File
file
=
createImageFile
();
File
file
=
createImageFile
();
boolean
isDirectoryCreated
=
file
.
getParentFile
().
mkdirs
();
boolean
isDirectoryCreated
=
file
.
getParentFile
().
mkdirs
();
Uri
tempFileUri
;
Log
.
d
(
""
,
"openCamera: isDirectoryCreated: "
+
isDirectoryCreated
);
Log
.
d
(
""
,
"openCamera: isDirectoryCreated: "
+
isDirectoryCreated
);
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
N
)
{
Uri
tempFileUri
=
FileProvider
.
getUriForFile
(
getActivity
().
getApplicationContext
(),
tempFileUri
=
FileProvider
.
getUriForFile
(
getActivity
().
getApplicationContext
(),
"com.scanlibrary.provider"
,
// As defined in Manifest
"com.scanlibrary.provider"
,
// As defined in Manifest
file
);
file
);
cameraIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
tempFileUri
);
cameraIntent
.
addFlags
(
Intent
.
FLAG_GRANT_READ_URI_PERMISSION
);
}
else
{
}
else
{
Uri
tempFileUri
=
Uri
.
fromFile
(
file
);
tempFileUri
=
Uri
.
fromFile
(
file
);
cameraIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
tempFileUri
);
}
}
cameraIntent
.
putExtra
(
MediaStore
.
EXTRA_OUTPUT
,
tempFileUri
);
startActivityForResult
(
cameraIntent
,
ScanConstants
.
START_CAMERA_REQUEST_CODE
);
startActivityForResult
(
cameraIntent
,
ScanConstants
.
START_CAMERA_REQUEST_CODE
);
}
}
...
@@ -135,7 +139,7 @@ public class PickImageFragment extends Fragment {
...
@@ -135,7 +139,7 @@ public class PickImageFragment extends Fragment {
clearTempImages
();
clearTempImages
();
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
).
format
(
new
String
timeStamp
=
new
SimpleDateFormat
(
"yyyyMMdd_HHmmss"
).
format
(
new
Date
());
Date
());
File
file
=
new
File
(
ScanConstants
.
IMAGE_
PATH
,
"IMG_"
+
timeStamp
+
File
file
=
new
File
(
ScanConstants
.
IMAGE_
CACHE
,
timeStamp
+
".jpg"
);
".jpg"
);
fileUri
=
Uri
.
fromFile
(
file
);
fileUri
=
Uri
.
fromFile
(
file
);
return
file
;
return
file
;
...
@@ -150,12 +154,13 @@ public class PickImageFragment extends Fragment {
...
@@ -150,12 +154,13 @@ public class PickImageFragment extends Fragment {
switch
(
requestCode
)
{
switch
(
requestCode
)
{
case
ScanConstants
.
START_CAMERA_REQUEST_CODE
:
case
ScanConstants
.
START_CAMERA_REQUEST_CODE
:
bitmap
=
getBitmap
(
fileUri
);
bitmap
=
getBitmap
(
fileUri
);
// Bundle bundle = data.getExtras();
// bitmap=decodeUriAsBitmap(fileUri);
// bitmap = (Bitmap) bundle.get("data");
break
;
break
;
case
ScanConstants
.
PICKFILE_REQUEST_CODE
:
case
ScanConstants
.
PICKFILE_REQUEST_CODE
:
bitmap
=
getBitmap
(
data
.
getData
());
// Uri originalUri = data.getData(); //获得图片的uri
bitmap
=
getBitmap
(
data
.
getData
());
break
;
break
;
default
:
default
:
break
;
break
;
...
@@ -163,14 +168,24 @@ public class PickImageFragment extends Fragment {
...
@@ -163,14 +168,24 @@ public class PickImageFragment extends Fragment {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
if
(
bitmap
!=
null
)
{
// sendToRoatate(bitmap);
postImagePick
(
bitmap
);
}
}
else
{
}
else
{
getActivity
().
finish
();
if
(
isIntentPreferenceSet
())
{
}
handleIntentPreference
();
if
(
bitmap
!=
null
)
{
}
else
{
postImagePick
(
bitmap
);
getActivity
().
finish
();
}
// getActivity().finish();
}
}
}
}
protected
void
sendToRoatate
(
Bitmap
bitmap
){
scanner
.
onRotate
(
bitmap
);
}
protected
void
postImagePick
(
Bitmap
bitmap
)
{
protected
void
postImagePick
(
Bitmap
bitmap
)
{
Uri
uri
=
Utils
.
getUri
(
getActivity
(),
bitmap
);
Uri
uri
=
Utils
.
getUri
(
getActivity
(),
bitmap
);
// Uri uri = Uri.parse(MediaStore.Images.Media.insertImage(context.getContentResolver(), bitmap, null,null));
// Uri uri = Uri.parse(MediaStore.Images.Media.insertImage(context.getContentResolver(), bitmap, null,null));
...
@@ -180,7 +195,16 @@ public class PickImageFragment extends Fragment {
...
@@ -180,7 +195,16 @@ public class PickImageFragment extends Fragment {
private
Bitmap
getBitmap
(
Uri
selectedimg
)
throws
IOException
{
private
Bitmap
getBitmap
(
Uri
selectedimg
)
throws
IOException
{
BitmapFactory
.
Options
options
=
new
BitmapFactory
.
Options
();
BitmapFactory
.
Options
options
=
new
BitmapFactory
.
Options
();
options
.
inSampleSize
=
3
;
int
height
=
options
.
outHeight
;
int
width
=
options
.
outWidth
;
int
minLen
=
Math
.
min
(
height
,
width
);
// 原图的最小边长
int
inSampleSize
=
2
;
// 默认像素压缩比例,压缩为原图的1/2
if
(
minLen
>
100
)
{
// 如果原始图像的最小边长大于100dp(此处单位我认为是dp,而非px)
float
ratio
=
(
float
)
minLen
/
100.0f
;
// 计算像素压缩比例
inSampleSize
=
(
int
)
ratio
;
}
options
.
inJustDecodeBounds
=
false
;
// 计算好压缩比例后,这次可以去加载原图了
options
.
inSampleSize
=
inSampleSize
;
AssetFileDescriptor
fileDescriptor
=
null
;
AssetFileDescriptor
fileDescriptor
=
null
;
fileDescriptor
=
fileDescriptor
=
getActivity
().
getContentResolver
().
openAssetFileDescriptor
(
selectedimg
,
"r"
);
getActivity
().
getContentResolver
().
openAssetFileDescriptor
(
selectedimg
,
"r"
);
...
@@ -189,4 +213,18 @@ public class PickImageFragment extends Fragment {
...
@@ -189,4 +213,18 @@ public class PickImageFragment extends Fragment {
fileDescriptor
.
getFileDescriptor
(),
null
,
options
);
fileDescriptor
.
getFileDescriptor
(),
null
,
options
);
return
original
;
return
original
;
}
}
/**
* @param uri:图片的本地url地址
* @return Bitmap;
*/
private
Bitmap
decodeUriAsBitmap
(
Uri
uri
)
{
Bitmap
bitmap
=
null
;
try
{
bitmap
=
BitmapFactory
.
decodeStream
(
getActivity
().
getContentResolver
().
openInputStream
(
uri
));
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
return
null
;
}
return
bitmap
;
}
}
}
\ No newline at end of file
scanlibrary/src/main/java/com/scanlibrary/ResultFragment.java
View file @
b76f8dad
...
@@ -95,13 +95,13 @@ public class ResultFragment extends Fragment {
...
@@ -95,13 +95,13 @@ public class ResultFragment extends Fragment {
Uri
uri
=
Utils
.
getUri
(
getActivity
(),
bitmap
);
Uri
uri
=
Utils
.
getUri
(
getActivity
(),
bitmap
);
data
.
putExtra
(
ScanConstants
.
SCANNED_RESULT
,
uri
);
data
.
putExtra
(
ScanConstants
.
SCANNED_RESULT
,
uri
);
getActivity
().
setResult
(
Activity
.
RESULT_OK
,
data
);
getActivity
().
setResult
(
Activity
.
RESULT_OK
,
data
);
getActivity
().
finish
();
original
.
recycle
();
original
.
recycle
();
System
.
gc
();
System
.
gc
();
getActivity
().
runOnUiThread
(
new
Runnable
()
{
getActivity
().
runOnUiThread
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
dismissDialog
();
dismissDialog
();
getActivity
().
finish
();
}
}
});
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
scanlibrary/src/main/java/com/scanlibrary/ScanActivity.java
View file @
b76f8dad
...
@@ -8,6 +8,8 @@ import android.graphics.Bitmap;
...
@@ -8,6 +8,8 @@ import android.graphics.Bitmap;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
static
com
.
scanlibrary
.
ScanConstants
.
ROTATE_BITMAP
;
/**
/**
* Created by jhansi on 28/03/15.
* Created by jhansi on 28/03/15.
*/
*/
...
@@ -31,6 +33,7 @@ public class ScanActivity extends Activity implements IScanner, ComponentCallbac
...
@@ -31,6 +33,7 @@ public class ScanActivity extends Activity implements IScanner, ComponentCallbac
fragmentTransaction
.
commit
();
fragmentTransaction
.
commit
();
}
}
protected
int
getPreferenceContent
()
{
protected
int
getPreferenceContent
()
{
return
getIntent
().
getIntExtra
(
ScanConstants
.
OPEN_INTENT_PREFERENCE
,
0
);
return
getIntent
().
getIntExtra
(
ScanConstants
.
OPEN_INTENT_PREFERENCE
,
0
);
}
}
...
@@ -48,6 +51,19 @@ public class ScanActivity extends Activity implements IScanner, ComponentCallbac
...
@@ -48,6 +51,19 @@ public class ScanActivity extends Activity implements IScanner, ComponentCallbac
fragmentTransaction
.
commit
();
fragmentTransaction
.
commit
();
}
}
@Override
public
void
onBitmapScan
(
Bitmap
bitmap
)
{
ScanFragment
fragment
=
new
ScanFragment
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putParcelable
(
ScanConstants
.
SELECTED_BITMAP
,
bitmap
);
fragment
.
setArguments
(
bundle
);
android
.
app
.
FragmentManager
fragmentManager
=
getFragmentManager
();
FragmentTransaction
fragmentTransaction
=
fragmentManager
.
beginTransaction
();
fragmentTransaction
.
add
(
R
.
id
.
content
,
fragment
);
fragmentTransaction
.
addToBackStack
(
ScanFragment
.
class
.
toString
());
fragmentTransaction
.
commit
();
}
@Override
@Override
public
void
onScanFinish
(
Uri
uri
)
{
public
void
onScanFinish
(
Uri
uri
)
{
ResultFragment
fragment
=
new
ResultFragment
();
ResultFragment
fragment
=
new
ResultFragment
();
...
@@ -61,6 +77,20 @@ public class ScanActivity extends Activity implements IScanner, ComponentCallbac
...
@@ -61,6 +77,20 @@ public class ScanActivity extends Activity implements IScanner, ComponentCallbac
fragmentTransaction
.
commit
();
fragmentTransaction
.
commit
();
}
}
@Override
public
void
onRotate
(
Bitmap
bitmap
)
{
RotateFragment
fragment
=
new
RotateFragment
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putParcelable
(
ScanConstants
.
ROTATE_BITMAP
,
bitmap
);
fragment
.
setArguments
(
bundle
);
android
.
app
.
FragmentManager
fragmentManager
=
getFragmentManager
();
FragmentTransaction
fragmentTransaction
=
fragmentManager
.
beginTransaction
();
fragmentTransaction
.
add
(
R
.
id
.
content
,
fragment
);
fragmentTransaction
.
addToBackStack
(
RotateFragment
.
class
.
toString
());
fragmentTransaction
.
commit
();
}
@Override
@Override
public
void
onTrimMemory
(
int
level
)
{
public
void
onTrimMemory
(
int
level
)
{
switch
(
level
)
{
switch
(
level
)
{
...
@@ -97,9 +127,10 @@ public class ScanActivity extends Activity implements IScanner, ComponentCallbac
...
@@ -97,9 +127,10 @@ public class ScanActivity extends Activity implements IScanner, ComponentCallbac
new
AlertDialog
.
Builder
(
this
)
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
R
.
string
.
low_memory
)
.
setTitle
(
R
.
string
.
low_memory
)
.
setMessage
(
R
.
string
.
low_memory_message
)
.
setMessage
(
R
.
string
.
low_memory_message
)
.
create
()
.
create
()
;
.
show
();
//
.show();
break
;
break
;
default
:
default
:
/*
/*
Release any non-critical data structures.
Release any non-critical data structures.
...
...
scanlibrary/src/main/java/com/scanlibrary/ScanConstants.java
View file @
b76f8dad
...
@@ -15,7 +15,11 @@ public class ScanConstants {
...
@@ -15,7 +15,11 @@ public class ScanConstants {
public
final
static
int
OPEN_MEDIA
=
5
;
public
final
static
int
OPEN_MEDIA
=
5
;
public
final
static
String
SCANNED_RESULT
=
"scannedResult"
;
public
final
static
String
SCANNED_RESULT
=
"scannedResult"
;
public
final
static
String
IMAGE_PATH
=
Environment
public
final
static
String
IMAGE_PATH
=
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/documentocr/images"
;
.
getExternalStorageDirectory
().
getPath
()
+
"/wuzhihuaOA/images"
;
public
final
static
String
IMAGE_CACHE
=
Environment
.
getExternalStorageDirectory
().
getPath
()
+
"/wuzhihuaOA/cache"
;
public
final
static
String
SELECTED_BITMAP
=
"selectedBitmap"
;
public
final
static
String
SELECTED_BITMAP
=
"selectedBitmap"
;
public
final
static
String
ROTATE_BITMAP
=
"rotateBitmap"
;
}
}
scanlibrary/src/main/java/com/scanlibrary/ScanFragment.java
View file @
b76f8dad
...
@@ -19,6 +19,7 @@ import android.view.ViewGroup;
...
@@ -19,6 +19,7 @@ import android.view.ViewGroup;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.FrameLayout
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -39,6 +40,8 @@ public class ScanFragment extends Fragment {
...
@@ -39,6 +40,8 @@ public class ScanFragment extends Fragment {
private
ProgressDialogFragment
progressDialogFragment
;
private
ProgressDialogFragment
progressDialogFragment
;
private
IScanner
scanner
;
private
IScanner
scanner
;
private
Bitmap
original
;
private
Bitmap
original
;
private
TextView
rotateTv
;
private
boolean
isRotate
=
false
;
@Override
@Override
public
void
onAttach
(
Activity
activity
)
{
public
void
onAttach
(
Activity
activity
)
{
...
@@ -66,10 +69,12 @@ public class ScanFragment extends Fragment {
...
@@ -66,10 +69,12 @@ public class ScanFragment extends Fragment {
scanButton
.
setOnClickListener
(
new
ScanButtonClickListener
());
scanButton
.
setOnClickListener
(
new
ScanButtonClickListener
());
sourceFrame
=
(
FrameLayout
)
view
.
findViewById
(
R
.
id
.
sourceFrame
);
sourceFrame
=
(
FrameLayout
)
view
.
findViewById
(
R
.
id
.
sourceFrame
);
polygonView
=
(
PolygonView
)
view
.
findViewById
(
R
.
id
.
polygonView
);
polygonView
=
(
PolygonView
)
view
.
findViewById
(
R
.
id
.
polygonView
);
rotateTv
=
(
TextView
)
view
.
findViewById
(
R
.
id
.
rotate
);
sourceFrame
.
post
(
new
Runnable
()
{
sourceFrame
.
post
(
new
Runnable
()
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
original
=
getBitmap
();
original
=
getBitmap
();
// original=getRotateBitmap();
if
(
original
!=
null
)
{
if
(
original
!=
null
)
{
setBitmap
(
original
);
setBitmap
(
original
);
}
}
...
@@ -77,6 +82,11 @@ public class ScanFragment extends Fragment {
...
@@ -77,6 +82,11 @@ public class ScanFragment extends Fragment {
});
});
}
}
private
Bitmap
getRotateBitmap
(){
Bitmap
bitmap
=
getArguments
().
getParcelable
(
ScanConstants
.
SELECTED_BITMAP
);
return
bitmap
;
}
private
Bitmap
getBitmap
()
{
private
Bitmap
getBitmap
()
{
Uri
uri
=
getUri
();
Uri
uri
=
getUri
();
try
{
try
{
...
@@ -97,6 +107,11 @@ public class ScanFragment extends Fragment {
...
@@ -97,6 +107,11 @@ public class ScanFragment extends Fragment {
private
void
setBitmap
(
Bitmap
original
)
{
private
void
setBitmap
(
Bitmap
original
)
{
Bitmap
scaledBitmap
=
scaledBitmap
(
original
,
sourceFrame
.
getWidth
(),
sourceFrame
.
getHeight
());
Bitmap
scaledBitmap
=
scaledBitmap
(
original
,
sourceFrame
.
getWidth
(),
sourceFrame
.
getHeight
());
sourceImageView
.
setImageBitmap
(
scaledBitmap
);
sourceImageView
.
setImageBitmap
(
scaledBitmap
);
initPolygonView
();
}
private
void
initPolygonView
()
{
Bitmap
tempBitmap
=
((
BitmapDrawable
)
sourceImageView
.
getDrawable
()).
getBitmap
();
Bitmap
tempBitmap
=
((
BitmapDrawable
)
sourceImageView
.
getDrawable
()).
getBitmap
();
Map
<
Integer
,
PointF
>
pointFs
=
getEdgePoints
(
tempBitmap
);
Map
<
Integer
,
PointF
>
pointFs
=
getEdgePoints
(
tempBitmap
);
polygonView
.
setPoints
(
pointFs
);
polygonView
.
setPoints
(
pointFs
);
...
@@ -153,6 +168,8 @@ public class ScanFragment extends Fragment {
...
@@ -153,6 +168,8 @@ public class ScanFragment extends Fragment {
private
class
ScanButtonClickListener
implements
View
.
OnClickListener
{
private
class
ScanButtonClickListener
implements
View
.
OnClickListener
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
Map
<
Integer
,
PointF
>
points
=
polygonView
.
getPoints
();
Map
<
Integer
,
PointF
>
points
=
polygonView
.
getPoints
();
if
(
isScanPointsValid
(
points
))
{
if
(
isScanPointsValid
(
points
))
{
new
ScanAsyncTask
(
points
).
execute
();
new
ScanAsyncTask
(
points
).
execute
();
...
@@ -215,6 +232,7 @@ public class ScanFragment extends Fragment {
...
@@ -215,6 +232,7 @@ public class ScanFragment extends Fragment {
protected
Bitmap
doInBackground
(
Void
...
params
)
{
protected
Bitmap
doInBackground
(
Void
...
params
)
{
Bitmap
bitmap
=
getScannedBitmap
(
original
,
points
);
Bitmap
bitmap
=
getScannedBitmap
(
original
,
points
);
Uri
uri
=
Utils
.
getUri
(
getActivity
(),
bitmap
);
Uri
uri
=
Utils
.
getUri
(
getActivity
(),
bitmap
);
// uri=Utils.saveBitmap(bitmap,System.currentTimeMillis() + ".jpg");
scanner
.
onScanFinish
(
uri
);
scanner
.
onScanFinish
(
uri
);
return
bitmap
;
return
bitmap
;
}
}
...
...
scanlibrary/src/main/java/com/scanlibrary/Utils.java
View file @
b76f8dad
...
@@ -6,6 +6,9 @@ import android.net.Uri;
...
@@ -6,6 +6,9 @@ import android.net.Uri;
import
android.provider.MediaStore
;
import
android.provider.MediaStore
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
/**
/**
...
@@ -28,4 +31,33 @@ public class Utils {
...
@@ -28,4 +31,33 @@ public class Utils {
Bitmap
bitmap
=
MediaStore
.
Images
.
Media
.
getBitmap
(
context
.
getContentResolver
(),
uri
);
Bitmap
bitmap
=
MediaStore
.
Images
.
Media
.
getBitmap
(
context
.
getContentResolver
(),
uri
);
return
bitmap
;
return
bitmap
;
}
}
/**
* 将得到的一个Bitmap保存到SD卡上,得到一个URI地址
*/
public
static
Uri
saveBitmap
(
Bitmap
bm
,
String
name
)
{
//在SD卡上创建目录
File
tmpDir
=
new
File
(
ScanConstants
.
IMAGE_PATH
);
if
(!
tmpDir
.
exists
())
{
tmpDir
.
mkdir
();
}
File
img
=
new
File
(
tmpDir
.
getAbsolutePath
()
,
name
);
if
(
img
.
exists
())
img
.
delete
();
try
{
img
.
createNewFile
();
FileOutputStream
fos
=
new
FileOutputStream
(
img
);
bm
.
compress
(
Bitmap
.
CompressFormat
.
PNG
,
85
,
fos
);
fos
.
flush
();
fos
.
close
();
return
Uri
.
fromFile
(
img
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
return
null
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
}
}
\ No newline at end of file
scanlibrary/src/main/res/layout/result_layout2.xml
View file @
b76f8dad
...
@@ -110,6 +110,7 @@
...
@@ -110,6 +110,7 @@
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:scaleType=
"centerInside"
android:layout_margin=
"@dimen/scanPadding"
/>
android:layout_margin=
"@dimen/scanPadding"
/>
</FrameLayout>
</FrameLayout>
...
...
scanlibrary/src/main/res/layout/scan_fragment_layout.xml
View file @
b76f8dad
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
android:background=
"@android:color/black"
android:background=
"@android:color/black"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<Button
<Button
android:id=
"@+id/scanButton"
android:id=
"@+id/scanButton"
android:layout_width=
"fill_parent"
android:layout_width=
"fill_parent"
...
@@ -13,7 +15,7 @@
...
@@ -13,7 +15,7 @@
android:background=
"@color/normal"
android:background=
"@color/normal"
android:orientation=
"horizontal"
android:orientation=
"horizontal"
android:padding=
"@dimen/bottom_bar_padding"
android:padding=
"@dimen/bottom_bar_padding"
android:textSize=
"16sp"
android:textColor=
"@android:color/white"
android:textColor=
"@android:color/white"
android:text=
"@string/scan"
/>
android:text=
"@string/scan"
/>
...
@@ -44,8 +46,41 @@
...
@@ -44,8 +46,41 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:visibility=
"gone"
></com.scanlibrary.PolygonView
>
android:visibility=
"gone"
/
>
</FrameLayout>
</FrameLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"49dp"
android:background=
"@color/normal"
android:gravity=
"center_vertical"
android:layout_alignParentTop=
"true"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center_vertical"
android:paddingLeft=
"15dp"
android:textSize=
"18sp"
android:textColor=
"@color/white"
android:text=
"裁剪页"
/>
<TextView
android:id=
"@+id/rotate"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/white"
android:layout_alignParentRight=
"true"
android:textSize=
"16sp"
android:layout_marginRight=
"15dp"
android:text=
"旋转"
android:visibility=
"gone"
/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
scanlibrary/src/main/res/values/colors.xml
View file @
b76f8dad
...
@@ -11,4 +11,6 @@
...
@@ -11,4 +11,6 @@
<color
name=
"status_bar"
>
#FF034D71
</color>
<color
name=
"status_bar"
>
#FF034D71
</color>
<color
name=
"normal"
>
#00BF8B
</color>
<color
name=
"normal"
>
#00BF8B
</color>
<color
name=
"white"
>
#fff
</color>
</resources>
</resources>
\ No newline at end of file
scanlibrary/src/main/res/values/dimens.xml
View file @
b76f8dad
...
@@ -10,5 +10,10 @@
...
@@ -10,5 +10,10 @@
<dimen
name=
"bottom_bar_padding"
>
15dp
</dimen>
<dimen
name=
"bottom_bar_padding"
>
15dp
</dimen>
<dimen
name=
"txt18"
>
18sp
</dimen>
<dimen
name=
"txt16"
>
16sp
</dimen>
<dimen
name=
"txt14"
>
14sp
</dimen>
</resources>
</resources>
scanlibrary/src/main/res/xml/provider_paths.xml
View file @
b76f8dad
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<paths
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<paths
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<external-path
name=
"external_files"
path=
"."
/>
<external-path
name=
"external_files"
path=
"wuzhihuaOA/"
/>
<!--external_files-->
</paths>
</paths>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment