Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MiYaFastCashier
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangjiantao
MiYaFastCashier
Commits
ce4a1f78
Commit
ce4a1f78
authored
May 24, 2022
by
赵鹏翔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code format
parent
06ab4a0f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
154 deletions
+139
-154
CustomImageCenterDialog.java
...ava/com/miya/fastcashier/log/CustomImageCenterDialog.java
+0
-153
CustomImageCenterDialog.kt
.../java/com/miya/fastcashier/log/CustomImageCenterDialog.kt
+138
-0
LFilePickerActivity.java
...in/java/com/miya/fastcashier/log/LFilePickerActivity.java
+1
-1
No files found.
app/src/main/java/com/miya/fastcashier/log/CustomImageCenterDialog.java
deleted
100644 → 0
View file @
06ab4a0f
package
com
.
miya
.
fastcashier
.
log
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.graphics.Bitmap
;
import
android.os.Build
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.WindowManager
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
com.blankj.utilcode.util.SizeUtils
;
import
com.miya.fastcashier.R
;
import
com.miya.print.utils.QRCodeUtil
;
import
androidx.annotation.NonNull
;
public
class
CustomImageCenterDialog
extends
Dialog
{
private
TextView
tvOk
;
private
TextView
tvHint
;
private
ImageView
ivContent
;
boolean
isFullScreen
;
private
String
mImageContent
;
private
String
mHintContentText
;
private
String
mConfirmContent
;
private
Bitmap
mQrCodeBitmap
;
/**
* 设置是否全屏显示
*
* @param isFullScreen
* @return
*/
public
CustomImageCenterDialog
setFullScreen
(
boolean
isFullScreen
)
{
this
.
isFullScreen
=
isFullScreen
;
return
this
;
}
@Override
public
void
onWindowFocusChanged
(
boolean
hasFocus
)
{
super
.
onWindowFocusChanged
(
hasFocus
);
if
(
isFullScreen
)
{
setFullScreen
();
}
}
/**
* 隐藏虚拟按键,并且全屏
*/
protected
void
setFullScreen
()
{
//隐藏虚拟按键,并且全屏
if
(
Build
.
VERSION
.
SDK_INT
>
11
&&
Build
.
VERSION
.
SDK_INT
<
19
)
{
// lower api
View
v
=
this
.
getWindow
().
getDecorView
();
v
.
setSystemUiVisibility
(
View
.
GONE
);
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
19
)
{
//for new api versions.
View
decorView
=
getWindow
().
getDecorView
();
int
uiOptions
=
View
.
SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION//暂时不需要hideNavigation
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
|
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
View
.
SYSTEM_UI_FLAG_FULLSCREEN
// hide status bar
|
View
.
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
;
decorView
.
setSystemUiVisibility
(
uiOptions
);
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_NAVIGATION
);
}
}
public
CustomImageCenterDialog
(
@NonNull
Context
context
)
{
super
(
context
,
R
.
style
.
CommonDialog
);
initWindows
();
setCanceledOnTouchOutside
(
false
);
setContentView
(
R
.
layout
.
dialog_center_image
);
setCancelable
(
true
);
initView
();
}
private
void
initView
()
{
tvOk
=
findViewById
(
R
.
id
.
tvOk
);
tvHint
=
findViewById
(
R
.
id
.
tvSubContent
);
ivContent
=
findViewById
(
R
.
id
.
ivContent
);
}
public
CustomImageCenterDialog
setQrContent
(
String
msg
)
{
mImageContent
=
msg
;
return
this
;
}
public
CustomImageCenterDialog
setConfirmContent
(
String
msg
)
{
mConfirmContent
=
msg
;
return
this
;
}
public
CustomImageCenterDialog
setHintContent
(
String
msg
)
{
mHintContentText
=
msg
;
return
this
;
}
/**
* 创建dialog
*
* @return
*/
public
CustomImageCenterDialog
build
()
{
if
(!
TextUtils
.
isEmpty
(
mConfirmContent
)){
tvOk
.
setText
(
mConfirmContent
);
}
if
(!
TextUtils
.
isEmpty
(
mHintContentText
)){
tvHint
.
setText
(
mHintContentText
);
}
if
(!
TextUtils
.
isEmpty
(
mImageContent
)){
mQrCodeBitmap
=
QRCodeUtil
.
createQRCodeBitmap
(
mImageContent
,
SizeUtils
.
dp2px
(
300
));
ivContent
.
setImageBitmap
(
mQrCodeBitmap
);
}
tvOk
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
mQrCodeBitmap
!=
null
)
{
mQrCodeBitmap
.
recycle
();
}
dismiss
();
}
});
if
(
isFullScreen
)
{
setFullScreen
();
}
return
this
;
}
/**
* 初始化对话框(供子类选择调用)
*/
protected
void
initWindows
()
{
Window
win
=
this
.
getWindow
();
win
.
requestFeature
(
Window
.
FEATURE_NO_TITLE
);
win
.
getDecorView
().
setPadding
(
0
,
0
,
0
,
0
);
WindowManager
.
LayoutParams
lp
=
win
.
getAttributes
();
lp
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
;
lp
.
height
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
;
// lp.windowAnimations = R.style.LightInAndOutStyle;
lp
.
gravity
=
Gravity
.
CENTER
;
win
.
setAttributes
(
lp
);
win
.
setBackgroundDrawableResource
(
android
.
R
.
color
.
transparent
);
}
}
app/src/main/java/com/miya/fastcashier/log/CustomImageCenterDialog.kt
0 → 100644
View file @
ce4a1f78
package
com.miya.fastcashier.log
import
android.app.Dialog
import
android.content.Context
import
com.miya.fastcashier.R
import
android.widget.TextView
import
android.graphics.Bitmap
import
com.miya.fastcashier.log.CustomImageCenterDialog
import
android.os.Build
import
android.view.WindowManager
import
android.text.TextUtils
import
com.miya.print.utils.QRCodeUtil
import
com.blankj.utilcode.util.SizeUtils
import
android.view.Gravity
import
android.view.View
import
android.view.Window
import
android.widget.ImageView
class
CustomImageCenterDialog
(
context
:
Context
)
:
Dialog
(
context
,
R
.
style
.
CommonDialog
)
{
private
var
tvOk
:
TextView
?
=
null
private
var
tvHint
:
TextView
?
=
null
private
var
ivContent
:
ImageView
?
=
null
private
var
isFullScreen
=
false
private
var
mImageContent
:
String
?
=
null
private
var
mHintContentText
:
String
?
=
null
private
var
mConfirmContent
:
String
?
=
null
private
var
mQrCodeBitmap
:
Bitmap
?
=
null
init
{
initWindows
()
setCanceledOnTouchOutside
(
false
)
setContentView
(
R
.
layout
.
dialog_center_image
)
setCancelable
(
true
)
initView
()
}
protected
fun
initWindows
()
{
val
win
=
this
.
window
win
!!
.
requestFeature
(
Window
.
FEATURE_NO_TITLE
)
win
.
decorView
.
setPadding
(
0
,
0
,
0
,
0
)
val
lp
=
win
.
attributes
lp
.
width
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
lp
.
height
=
WindowManager
.
LayoutParams
.
MATCH_PARENT
// lp.windowAnimations = R.style.LightInAndOutStyle;
lp
.
gravity
=
Gravity
.
CENTER
win
.
attributes
=
lp
win
.
setBackgroundDrawableResource
(
android
.
R
.
color
.
transparent
)
}
private
fun
initView
()
{
tvOk
=
findViewById
(
R
.
id
.
tvOk
)
tvHint
=
findViewById
(
R
.
id
.
tvSubContent
)
ivContent
=
findViewById
(
R
.
id
.
ivContent
)
}
override
fun
onWindowFocusChanged
(
hasFocus
:
Boolean
)
{
super
.
onWindowFocusChanged
(
hasFocus
)
if
(
isFullScreen
)
{
setFullScreen
()
}
}
/**
* 隐藏虚拟按键,并且全屏
*/
protected
fun
setFullScreen
()
{
if
(
Build
.
VERSION
.
SDK_INT
>
11
&&
Build
.
VERSION
.
SDK_INT
<
19
)
{
// lower api
val
v
=
this
.
window
!!
.
decorView
v
.
systemUiVisibility
=
View
.
GONE
}
else
if
(
Build
.
VERSION
.
SDK_INT
>=
19
)
{
//for new api versions.
val
decorView
=
window
!!
.
decorView
val
uiOptions
=
(
View
.
SYSTEM_UI_FLAG_LAYOUT_STABLE
// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION//暂时不需要hideNavigation
// | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
or
View
.
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or
View
.
SYSTEM_UI_FLAG_FULLSCREEN
// hide status bar
or
View
.
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
)
decorView
.
systemUiVisibility
=
uiOptions
window
!!
.
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_TRANSLUCENT_NAVIGATION
)
}
}
/**
* 设置是否全屏显示
*
* @param isFullScreen
* @return
*/
fun
setFullScreenStatus
(
isFullScreen
:
Boolean
):
CustomImageCenterDialog
{
this
.
isFullScreen
=
isFullScreen
return
this
}
fun
setQrContent
(
msg
:
String
?):
CustomImageCenterDialog
{
mImageContent
=
msg
return
this
}
fun
setConfirmContent
(
msg
:
String
?):
CustomImageCenterDialog
{
mConfirmContent
=
msg
return
this
}
fun
setHintContent
(
msg
:
String
?):
CustomImageCenterDialog
{
mHintContentText
=
msg
return
this
}
/**
* 创建dialog
*
* @return
*/
fun
build
():
CustomImageCenterDialog
{
if
(!
TextUtils
.
isEmpty
(
mConfirmContent
))
{
tvOk
!!
.
text
=
mConfirmContent
}
if
(!
TextUtils
.
isEmpty
(
mHintContentText
))
{
tvHint
!!
.
text
=
mHintContentText
}
if
(!
TextUtils
.
isEmpty
(
mImageContent
))
{
mQrCodeBitmap
=
QRCodeUtil
.
createQRCodeBitmap
(
mImageContent
,
SizeUtils
.
dp2px
(
300f
))
ivContent
!!
.
setImageBitmap
(
mQrCodeBitmap
)
}
tvOk
!!
.
setOnClickListener
{
if
(
mQrCodeBitmap
!=
null
)
{
mQrCodeBitmap
!!
.
recycle
()
}
dismiss
()
}
if
(
isFullScreen
)
{
setFullScreen
()
}
return
this
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/log/LFilePickerActivity.java
View file @
ce4a1f78
...
...
@@ -335,7 +335,7 @@ public class LFilePickerActivity extends BaseActivity {
mCustomImageCenterDialog
=
new
CustomImageCenterDialog
(
this
);
}
mCustomImageCenterDialog
.
setOnDismissListener
(
dialog
->
LFilePickerActivity
.
this
.
finish
());
mCustomImageCenterDialog
.
setFullScreen
(
true
)
mCustomImageCenterDialog
.
setFullScreen
Status
(
true
)
.
setHintContent
(
"请将日志二维码拍照保存"
)
.
setQrContent
(
mQrCodeEncodeMsg
)
.
build
().
show
();
...
...
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