Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
e72b4a25
Commit
e72b4a25
authored
Dec 14, 2018
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simugu Bug修复 第二版
parent
7e37190c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
343 additions
and
106 deletions
+343
-106
build.gradle
+0
-9
src/main/AndroidManifest.xml
+0
-1
src/main/assets/litepal.xml
+9
-0
src/main/java/tech/starwin/LibConfig.java
+2
-4
src/main/java/tech/starwin/broadcast/ActionEnum.java
+2
-1
src/main/java/tech/starwin/database/Collector.java
+3
-3
src/main/java/tech/starwin/impl/OnNoShakeClickListener.java
+2
-1
src/main/java/tech/starwin/mvp/presenter/UploadPresenter.java
+5
-1
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
+2
-8
src/main/java/tech/starwin/mvp/ui/activity/TakePhotoActivity.java
+40
-34
src/main/java/tech/starwin/utils/LoginManager.java
+3
-0
src/main/java/tech/starwin/utils/collection/UploadManager.java
+2
-1
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
+2
-1
src/main/java/tech/starwin/utils/ui_utils/QMUIHelper.java
+4
-0
src/main/java/tech/starwin/widget/CameraView.java
+241
-0
src/main/res/layout/activity_take_photo.xml
+26
-42
src/main/res/values-zh-rCN/strings.xml
+0
-0
src/main/res/values/strings.xml
+0
-0
No files found.
build.gradle
View file @
e72b4a25
...
...
@@ -82,10 +82,6 @@ dependencies {
//Gson
api
'com.google.code.gson:gson:2.8.2'
//bugly
// api 'com.tencent.bugly:crashreport:2.6.6.1'
// api 'com.tencent.bugly:nativecrashreport:3.3.1'
//rxjava
api
'com.jakewharton.rxbinding2:rxbinding:2.2.0'
api
'io.reactivex.rxjava2:rxandroid:2.1.0'
...
...
@@ -109,11 +105,6 @@ dependencies {
//firebase remoteConfig
api
'com.google.firebase:firebase-config:16.0.0'
//camerakit
// api 'com.wonderkiln:camerakit:0.13.1'
api
'com.camerakit:camerakit:1.0.0-beta3.10'
api
'com.camerakit:jpegkit:0.1.0'
api
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0'
//facebook accountKit SDK
api
'com.facebook.android:account-kit-sdk:4.37.0'
...
...
src/main/AndroidManifest.xml
View file @
e72b4a25
...
...
@@ -63,7 +63,6 @@
<permission
android:name=
"android.permission.ACCESS_COARSE_LOCATION"
/>
<!-- GPS定位-->
<permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name=
"android.permission.RECORD_VIDEO"
/>
<uses-permission
android:name=
"android.permission.RECORD_AUDIO"
/>
...
...
src/main/assets/litepal.xml
0 → 100644
View file @
e72b4a25
<?xml version="1.0" encoding="utf-8"?>
<litepal>
<dbname
value=
"collect_info"
/>
<version
value=
"1"
/>
<list>
<mapping
class=
"tech.starwin.database.entity.CollectInfoEntity"
/>
</list>
</litepal>
\ No newline at end of file
src/main/java/tech/starwin/LibConfig.java
View file @
e72b4a25
...
...
@@ -2,6 +2,7 @@ package tech.starwin;
import
android.app.Application
;
import
android.content.Context
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.text.TextUtils
;
import
android.view.View
;
...
...
@@ -100,6 +101,7 @@ public class LibConfig {
ScreenAutoSize
.
resizeDensity
(
CONTEXT
,
360
f
);
LitePal
.
initialize
(
CONTEXT
);
SQLiteDatabase
db
=
LitePal
.
getDatabase
();
//上传工具
UploadManager
.
init
(
CONTEXT
);
...
...
@@ -116,10 +118,6 @@ public class LibConfig {
//init gateway
Gateway
.
init
(
PreferencesManager
.
get
().
getGatewayInfo
());
//init Bugly
// if (!TextUtils.isEmpty(BUGLY_APP_ID)) {
// CrashReport.initCrashReport(CONTEXT, BUGLY_APP_ID, DEBUG);
// }
//init AppsFlyer
if
(!
TextUtils
.
isEmpty
(
APPSFLYER_DEV_KEY
))
{
...
...
src/main/java/tech/starwin/broadcast/ActionEnum.java
View file @
e72b4a25
...
...
@@ -5,7 +5,8 @@ package tech.starwin.broadcast;
*/
public
enum
ActionEnum
{
LOGIN_INVALID
(
"action.login.invalid"
),
LOGIN_SUCCESS
(
"action.login.success"
);
LOGIN_SUCCESS
(
"action.login.success"
),
GATEWAY_UPDATED
(
"action.gateway.update"
);
private
String
action
;
...
...
src/main/java/tech/starwin/database/Collector.java
View file @
e72b4a25
...
...
@@ -105,9 +105,9 @@ public class Collector {
infos1
.
addAll
(
infos2
);
CollectInfoEntity
location
=
Collector
.
getStoreEntity
(
InfoType
.
LOCATION
,
context
,
null
);
if
(
location
==
null
)
{
location
=
LitePal
.
where
(
"type='LOCATION'"
).
findFirst
(
CollectInfoEntity
.
class
);
}
//
if (location == null) {
//
location = LitePal.where("type='LOCATION'").findFirst(CollectInfoEntity.class);
//
}
if
(
location
!=
null
)
{
infos1
.
add
(
location
);
...
...
src/main/java/tech/starwin/impl/OnNoShakeClickListener.java
View file @
e72b4a25
...
...
@@ -8,7 +8,7 @@ import android.view.View;
*/
public
abstract
class
OnNoShakeClickListener
extends
OnEventClickListener
{
public
int
lockTime
=
15
00
;
public
int
lockTime
=
20
00
;
public
OnNoShakeClickListener
(
int
milliSencons
)
{
lockTime
=
milliSencons
;
...
...
@@ -21,6 +21,7 @@ public abstract class OnNoShakeClickListener extends OnEventClickListener {
public
final
void
onClick
(
final
View
v
)
{
super
.
onClick
(
v
);
v
.
setClickable
(
false
);
v
.
setLongClickable
(
false
);
v
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
src/main/java/tech/starwin/mvp/presenter/UploadPresenter.java
View file @
e72b4a25
...
...
@@ -45,11 +45,15 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
public
void
onSuccess
(
OcrResultBean
data
)
{
TrackEventHelper
.
logEvent
(
TrackEvent
.
IDENTITY_INFO_SUBMIT
);
OcrResultBean
.
KTP
ktp
=
new
Gson
().
fromJson
(
data
.
getData
(),
OcrResultBean
.
KTP
.
class
);
if
(
ktp
!=
null
&&
ktp
.
getResult
()
!=
null
&&
ktp
.
getResult
().
equals
(
"PASS"
))
{
if
(
ktp
!=
null
&&
ktp
.
getResult
()
!=
null
)
{
if
(
ktp
.
getResult
().
equals
(
"PASS"
))
{
view
.
onHttpSuccess
(
action
,
ktp
);
}
else
{
view
.
onHttpError
(
action
,
ktp
.
getMessage
());
}
}
else
{
view
.
onHttpError
(
action
,
data
.
getMessage
());
}
}
@Override
...
...
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
View file @
e72b4a25
...
...
@@ -79,6 +79,7 @@ public class UserPresenter extends BasePresenter<UserApi> {
@Override
public
void
accept
(
GatewayInfoBean
gatewayInfoBean
)
throws
Exception
{
Gateway
.
setGatewayInfoBean
(
gatewayInfoBean
);
EventBus
.
getDefault
().
post
(
ActionEnum
.
GATEWAY_UPDATED
);
}
});
}
...
...
@@ -212,7 +213,7 @@ public class UserPresenter extends BasePresenter<UserApi> {
/**
* 获取贷款状态、贷款详情、绑定银行卡、银行卡列表
*
*
/
*/
public
void
getBankAndLoanAmout
(
String
action
,
LatestLoanAppBean
loanBean
)
{
Observable
<
LoanInfo
>
observable
=
Observable
.
zip
(
getService
(
LoanApi
.
class
).
getLatestLoanApp
(
LoginManager
.
get
().
getToken
()),
...
...
@@ -475,9 +476,6 @@ public class UserPresenter extends BasePresenter<UserApi> {
* 客户服务热线、公司介绍
*/
public
void
getCustomerMsg
(
String
action
)
{
DisplayBean
displayBean
=
PreferencesManager
.
get
().
getCustomerInfo
();
//一小时之内 不重复获取
if
(
displayBean
==
null
||
System
.
currentTimeMillis
()
-
displayBean
.
getUpdateTime
()
>
(
1000
*
60
*
60
))
{
handleRequest
(
apiService
.
display
(),
new
HttpObserver
<
DisplayBean
>()
{
@Override
public
void
onStart
()
{
...
...
@@ -501,10 +499,6 @@ public class UserPresenter extends BasePresenter<UserApi> {
view
.
onHttpFinish
(
action
);
}
});
}
else
{
view
.
onHttpSuccess
(
action
,
displayBean
);
}
}
...
...
src/main/java/tech/starwin/mvp/ui/activity/TakePhotoActivity.java
View file @
e72b4a25
...
...
@@ -2,30 +2,34 @@ package tech.starwin.mvp.ui.activity;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.hardware.Camera
;
import
android.support.annotation.DrawableRes
;
import
android.support.v4.app.FragmentActivity
;
import
android.text.TextUtils
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.Button
;
import
android.widget.FrameLayout
;
import
android.widget.ImageView
;
import
com.
camerakit.CameraKitView
;
import
com.
qmuiteam.qmui.util.QMUIStatusBarHelper
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
tech.starwin.LibConfig
;
import
tech.starwin.R
;
import
tech.starwin.base.BaseActivity
;
import
tech.starwin.impl.OnEventClickListener
;
import
tech.starwin.impl.OnNoShakeClickListener
;
import
tech.starwin.utils.BitmapUtils
;
import
tech.starwin.utils.FileUtils
;
import
tech.starwin.utils.collection.UploadManager
;
import
tech.starwin.utils.context_utils.ActivityJumper
;
import
tech.starwin.utils.context_utils.EasyActivityResult
;
import
tech.starwin.utils.ui_utils.QMUIHelper
;
import
tech.starwin.utils.ui_utils.UIHelper
;
import
tech.starwin.widget.CameraView
;
import
tech.starwin.widget.TopBar
;
/**
* Created by SiKang on 2018/9/25.
...
...
@@ -49,12 +53,14 @@ public class TakePhotoActivity extends BaseActivity {
ImageView
btnCapture
;
ImageView
maskImv
;
Button
mbtnCancel
;
Camera
Kit
View
cameraView
;
CameraView
cameraView
;
public
static
String
KTP_IMAGE
=
"ktp_img.jpg"
;
private
static
final
int
PHOTO_FILE_SIZE_MAX
=
2
*
1024
*
1024
;
final
int
BITMAP_MAX_SQUARE_SIZE
=
3920
;
@Override
public
boolean
useTopBar
()
{
return
false
;
}
@Override
public
int
bindLayout
()
{
...
...
@@ -64,11 +70,20 @@ public class TakePhotoActivity extends BaseActivity {
@Override
public
void
initView
()
{
QMUIStatusBarHelper
.
translucent
(
this
);
TopBar
topBar
=
findViewById
(
R
.
id
.
activity_take_photo_topbar
);
topBar
.
setStatusBarHeight
(
QMUIStatusBarHelper
.
getStatusbarHeight
(
this
));
topBar
.
toolBar
().
addLeftBackImageButton
().
setOnClickListener
(
v
->
finish
());
QMUIHelper
.
madeTopBar
(
topBar
);
btnCapture
=
findViewById
(
R
.
id
.
button_shoot
);
mbtnCancel
=
findViewById
(
R
.
id
.
button_cancel
);
cameraView
=
findViewById
(
R
.
id
.
cameraView
);
maskImv
=
findViewById
(
R
.
id
.
activity_takephoto_mask_imv
);
cameraView
.
setTargetPreviewSize
(
1920
,
1080
);
int
mask
=
getIntent
().
getIntExtra
(
"preview_mask"
,
0
);
int
btnImg
=
getIntent
().
getIntExtra
(
"shoot_btn_img"
,
0
);
if
(
mask
!=
0
)
{
...
...
@@ -82,32 +97,29 @@ public class TakePhotoActivity extends BaseActivity {
findViewById
(
R
.
id
.
imageview_id_frame
).
setVisibility
(
View
.
VISIBLE
);
}
UIHelper
.
bindClickListener
(
new
On
Event
ClickListener
()
{
UIHelper
.
bindClickListener
(
new
On
NoShake
ClickListener
()
{
@Override
public
void
onEventClick
(
View
v
)
{
if
(
v
.
getId
()
==
R
.
id
.
button_shoot
)
{
cameraView
.
captureImage
(
new
CameraKitView
.
ImageCallback
()
{
@Override
public
void
onImage
(
CameraKitView
cameraKitView
,
byte
[]
bytes
)
{
cameraView
.
captureImage
(
bitmap
->
{
File
image
=
FileUtils
.
getImageFile
(
getApplicationContext
(),
KTP_IMAGE
);
if
(!
image
.
exists
())
{
image
.
mkdir
();
}
try
{
FileOutputStream
outputStream
=
new
FileOutputStream
(
image
.
getPath
());
outputStream
.
write
(
bytes
);
outputStream
.
close
();
BitmapUtils
.
saveBitmapToSDCard
(
bitmap
,
image
,
100
);
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"image_path"
,
image
.
getAbsolutePath
());
setResult
(
RESULT_OK
,
intent
);
finish
();
}
catch
(
java
.
io
.
IOException
e
)
{
e
.
printStackTrace
();
}
}
// try {
// FileOutputStream outputStream = new FileOutputStream(image.getPath());
// outputStream.write(data);
// outputStream.close();
//
// } catch (java.io.IOException e) {
// e.printStackTrace();
// }
});
}
else
if
(
v
.
getId
()
==
R
.
id
.
button_cancel
)
{
setResult
(
RESULT_CANCELED
);
...
...
@@ -120,30 +132,24 @@ public class TakePhotoActivity extends BaseActivity {
@Override
protected
void
onStart
()
{
cameraView
.
onStart
();
super
.
onStart
();
}
@Override
protected
void
onPause
()
{
cameraView
.
onPause
();
super
.
onPause
();
}
@Override
protected
void
onResume
()
{
cameraView
.
onResume
();
cameraView
.
startPreview
();
super
.
onResume
();
}
@Override
protected
void
onStop
()
{
cameraView
.
onStop
();
cameraView
.
stopPreview
();
super
.
onStop
();
}
@Override
protected
void
onDestroy
()
{
cameraView
.
release
();
super
.
onDestroy
();
}
@Override
public
void
onHttpSuccess
(
String
action
,
Object
result
)
{
}
...
...
src/main/java/tech/starwin/utils/LoginManager.java
View file @
e72b4a25
...
...
@@ -159,6 +159,9 @@ public class LoginManager {
}
public
TokenInfoBean
getTokenInfo
()
{
if
(!
TextUtils
.
isEmpty
(
LibConfig
.
TEST_TOKEN
))
{
return
new
TokenInfoBean
();
}
if
(
tokenInfo
==
null
)
{
tokenInfo
=
PreferencesManager
.
get
().
getTokenInfo
();
}
...
...
src/main/java/tech/starwin/utils/collection/UploadManager.java
View file @
e72b4a25
...
...
@@ -38,6 +38,7 @@ import tech.starwin.utils.GeneralUtils;
import
tech.starwin.utils.LogUtils
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.RetryWithDelay
;
import
tech.starwin.utils.context_utils.AppInfoUtils
;
import
tech.starwin.utils.context_utils.PermissionsHelper
;
...
...
@@ -79,7 +80,7 @@ public class UploadManager {
return
true
;
}
})
//
.retryWhen(new RetryWithDelay(5, 20 * 1000))
.
retryWhen
(
new
RetryWithDelay
(
5
,
20
*
1000
))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
();
}
...
...
src/main/java/tech/starwin/utils/context_utils/PermissionsHelper.java
View file @
e72b4a25
...
...
@@ -56,7 +56,8 @@ public class PermissionsHelper {
checkPermission
(
activity
,
new
String
[]{
Manifest
.
permission
.
CAMERA
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
RECORD_AUDIO
},
listener
);
Manifest
.
permission
.
RECORD_AUDIO
,
Manifest
.
permission
.
ACCESS_FINE_LOCATION
},
listener
);
}
/**
...
...
src/main/java/tech/starwin/utils/ui_utils/QMUIHelper.java
View file @
e72b4a25
...
...
@@ -174,6 +174,10 @@ public class QMUIHelper {
topbarCustomizer
=
customizer
;
}
public
static
void
madeTopBar
(
TopBar
topBar
){
topbarCustomizer
.
madeTopBar
(
topBar
);
}
/**
* TopBar默认样式定制
*/
...
...
src/main/java/tech/starwin/widget/CameraView.java
0 → 100644
View file @
e72b4a25
package
tech
.
starwin
.
widget
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
android.graphics.ImageFormat
;
import
android.graphics.Rect
;
import
android.graphics.YuvImage
;
import
android.hardware.Camera
;
import
android.util.AttributeSet
;
import
android.view.SurfaceHolder
;
import
android.view.SurfaceView
;
import
android.widget.ImageView
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.util.List
;
/**
* Created by SiKang on 2018/12/14.
*/
public
class
CameraView
extends
SurfaceView
implements
SurfaceHolder
.
Callback
,
Camera
.
PreviewCallback
{
private
final
String
TAG
=
"CameraView"
;
private
SurfaceHolder
mHolder
;
private
Camera
mCamera
;
//默认预览尺寸
private
int
imageWidth
=
1920
;
private
int
imageHeight
=
1080
;
//帧率
private
int
frameRate
=
30
;
private
boolean
isCaptureImage
=
false
;
private
OnSurfaceChangedListener
surfaceChangedListener
;
public
CameraView
(
Context
context
)
{
super
(
context
);
init
();
}
public
CameraView
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
init
();
}
public
CameraView
(
Context
context
,
AttributeSet
attrs
,
int
defStyleAttr
)
{
super
(
context
,
attrs
,
defStyleAttr
);
init
();
}
private
void
init
()
{
mHolder
=
getHolder
();
//设置SurfaceView 的SurfaceHolder的回调函数
mHolder
.
addCallback
(
this
);
mHolder
.
setType
(
SurfaceHolder
.
SURFACE_TYPE_PUSH_BUFFERS
);
}
@Override
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
//Surface创建时开启Camera
openCamera
();
}
@Override
public
void
surfaceChanged
(
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
//设置Camera基本参数
if
(
mCamera
!=
null
)
initCameraParams
();
}
@Override
public
void
surfaceDestroyed
(
SurfaceHolder
holder
)
{
try
{
release
();
}
catch
(
Exception
e
)
{
}
}
private
PreviewPictureCallback
previewPictureCallback
;
public
void
captureImage
(
Camera
.
PictureCallback
pictureCallback
)
{
mCamera
.
takePicture
(
null
,
null
,
pictureCallback
);
}
public
void
captureImage
(
PreviewPictureCallback
pictureCallback
)
{
this
.
previewPictureCallback
=
pictureCallback
;
isCaptureImage
=
true
;
}
public
interface
PreviewPictureCallback
{
void
onImage
(
Bitmap
bitmap
);
}
public
void
setTargetPreviewSize
(
int
width
,
int
height
)
{
this
.
imageWidth
=
width
;
this
.
imageHeight
=
height
;
}
public
interface
OnSurfaceChangedListener
{
void
onSurfaceChanged
(
int
finalWidth
,
int
finalHeight
);
}
@Override
public
void
onPreviewFrame
(
byte
[]
data
,
Camera
camera
)
{
if
(
previewPictureCallback
!=
null
&&
isCaptureImage
)
{
isCaptureImage
=
false
;
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Camera
.
Size
size
=
camera
.
getParameters
().
getPreviewSize
();
final
YuvImage
image
=
new
YuvImage
(
data
,
ImageFormat
.
NV21
,
size
.
width
,
size
.
height
,
null
);
ByteArrayOutputStream
stream
=
new
ByteArrayOutputStream
();
image
.
compressToJpeg
(
new
Rect
(
0
,
0
,
size
.
width
,
size
.
height
),
100
,
stream
);
Bitmap
bmp
=
BitmapFactory
.
decodeByteArray
(
stream
.
toByteArray
(),
0
,
stream
.
size
());
if
(
bmp
!=
null
)
{
previewPictureCallback
.
onImage
(
bmp
);
}
}
}).
start
();
}
}
@Override
protected
void
onMeasure
(
int
widthMeasureSpec
,
int
heightMeasureSpec
)
{
super
.
onMeasure
(
widthMeasureSpec
,
heightMeasureSpec
);
}
/**
* 摄像头配置
*/
public
void
initCameraParams
()
{
stopPreview
();
Camera
.
Parameters
camParams
=
mCamera
.
getParameters
();
List
<
Camera
.
Size
>
sizes
=
camParams
.
getSupportedPreviewSizes
();
for
(
int
i
=
0
;
i
<
sizes
.
size
();
i
++)
{
if
((
sizes
.
get
(
i
).
width
>=
imageWidth
&&
sizes
.
get
(
i
).
height
>=
imageHeight
)
||
i
==
sizes
.
size
()
-
1
)
{
imageWidth
=
sizes
.
get
(
i
).
width
;
imageHeight
=
sizes
.
get
(
i
).
height
;
// Log.v(TAG, "Changed to supported resolution: " + imageWidth + "x" + imageHeight);
break
;
}
}
camParams
.
setPreviewSize
(
imageWidth
,
imageHeight
);
camParams
.
setPictureSize
(
imageWidth
,
imageHeight
);
// Log.v(TAG, "Setting imageWidth: " + imageWidth + " imageHeight: " + imageHeight + " frameRate: " + frameRate);
camParams
.
setPreviewFrameRate
(
frameRate
);
// Log.v(TAG, "Preview Framerate: " + camParams.getPreviewFrameRate());
mCamera
.
setParameters
(
camParams
);
//取到的图像默认是横向的,这里旋转90度,保持和预览画面相同
mCamera
.
setDisplayOrientation
(
90
);
}
/**
* 开始预览
*/
public
void
startPreview
()
{
try
{
if
(
mCamera
!=
null
)
{
mCamera
.
setPreviewCallback
(
this
);
mCamera
.
setPreviewDisplay
(
mHolder
);
//set the surface to be used for live preview
mCamera
.
startPreview
();
mCamera
.
autoFocus
(
autoFocusCB
);
}
}
catch
(
IOException
e
)
{
mCamera
.
release
();
mCamera
=
null
;
}
}
/**
* 停止预览
*/
public
void
stopPreview
()
{
if
(
mCamera
!=
null
)
{
mCamera
.
stopPreview
();
mCamera
.
setPreviewCallback
(
null
);
}
}
/**
* 打开指定摄像头
*/
public
void
openCamera
()
{
Camera
.
CameraInfo
cameraInfo
=
new
Camera
.
CameraInfo
();
for
(
int
cameraId
=
0
;
cameraId
<
Camera
.
getNumberOfCameras
();
cameraId
++)
{
Camera
.
getCameraInfo
(
cameraId
,
cameraInfo
);
if
(
cameraInfo
.
facing
==
Camera
.
CameraInfo
.
CAMERA_FACING_BACK
)
{
try
{
mCamera
=
Camera
.
open
(
cameraId
);
}
catch
(
Exception
e
)
{
if
(
mCamera
!=
null
)
{
mCamera
.
release
();
mCamera
=
null
;
}
}
break
;
}
}
}
/**
* 摄像头自动聚焦
*/
Camera
.
AutoFocusCallback
autoFocusCB
=
new
Camera
.
AutoFocusCallback
()
{
public
void
onAutoFocus
(
boolean
success
,
Camera
camera
)
{
postDelayed
(
doAutoFocus
,
2000
);
}
};
private
Runnable
doAutoFocus
=
new
Runnable
()
{
public
void
run
()
{
if
(
mCamera
!=
null
)
{
try
{
mCamera
.
autoFocus
(
autoFocusCB
);
}
catch
(
Exception
e
)
{
}
}
}
};
/**
* 释放
*/
public
void
release
()
{
if
(
mCamera
!=
null
)
{
mCamera
.
setPreviewCallback
(
null
);
mCamera
.
stopPreview
();
mCamera
.
release
();
mCamera
=
null
;
}
}
}
src/main/res/layout/activity_take_photo.xml
View file @
e72b4a25
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
Relative
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<RelativeLayout
android:id=
"@+id/containerImg"
android:layout_width=
"match_parent"
android:layout_height=
"0dip"
android:layout_weight=
"1"
>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/gray_bg"
>
android:layout_height=
"match_parent"
>
<com.camerakit.CameraKit
View
<tech.starwin.widget.Camera
View
android:id=
"@+id/cameraView"
app:camera_facing=
"back"
app:camera_flash=
"auto"
app:camera_focus=
"continuous"
app:camera_permissions=
"camera"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:adjustViewBounds=
"true"
android:keepScreenOn=
"true"
/>
android:layout_centerInParent=
"true"
/>
<LinearLayout
android:id=
"@+id/imageview_id_frame"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical
"
android:visibility=
"gone
"
>
android:layout_centerInParent=
"true
"
android:orientation=
"vertical
"
>
<View
<tech.starwin.widget.TopBar
android:id=
"@+id/activity_take_photo_topbar"
android:layout_width=
"match_parent"
android:layout_height=
"0dip"
android:layout_weight=
"1"
android:background=
"#e0000000"
/>
android:layout_height=
"50dp"
/>
<LinearLayout
android:id=
"@+id/imageview_id_frame"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
>
android:layout_height=
"0dp"
android:layout_margin=
"10dp"
android:layout_weight=
"1"
android:gravity=
"center_vertical"
android:orientation=
"horizontal"
android:visibility=
"invisible"
>
<com.qmuiteam.qmui.widget.QMUIVerticalTextView
android:id=
"@+id/verticalTextView"
android:layout_width=
"wrap_content"
android:layout_height=
"match_par
ent"
android:layout_height=
"wrap_cont
ent"
android:layout_alignParentRight=
"true"
android:layout_margin=
"6dp"
android:gravity=
"center_vertical"
android:paddingBottom=
"16dp"
android:paddingTop=
"16dp"
android:text=
"@string/take_ktp_tip_footer"
...
...
@@ -66,8 +54,9 @@
<com.qmuiteam.qmui.widget.QMUIVerticalTextView
android:layout_width=
"wrap_content"
android:layout_height=
"match_par
ent"
android:layout_height=
"wrap_cont
ent"
android:layout_margin=
"6dp"
android:gravity=
"center_vertical"
android:paddingBottom=
"16dp"
android:paddingTop=
"16dp"
android:text=
"@string/take_ktp_tip_header"
...
...
@@ -75,18 +64,11 @@
</LinearLayout>
<View
android:layout_width=
"match_parent"
android:layout_height=
"0dip"
android:layout_weight=
"1"
android:background=
"#e0000000"
/>
</LinearLayout>
</FrameLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"110dp"
android:layout_height=
"100dp"
android:layout_alignParentBottom=
"true"
android:background=
"@color/gray_bg"
>
<ImageView
...
...
@@ -107,5 +89,7 @@
android:rotation=
"90.0"
android:text=
"@string/text_cancel"
/>
</RelativeLayout>
</LinearLayout>
</
Linear
Layout>
</
Relative
Layout>
src/main/res/values-zh-rCN/strings.xml
deleted
100644 → 0
View file @
7e37190c
This diff is collapsed.
Click to expand it.
src/main/res/values/strings.xml
View file @
e72b4a25
This diff is collapsed.
Click to expand it.
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