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
9309eada
Commit
9309eada
authored
Apr 07, 2022
by
zhaopengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加请求日志
parent
623672f3
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
264 additions
and
13 deletions
+264
-13
BaseApplication.kt
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
+24
-7
ResetAuthorizePasswordActivity.kt
...com/miya/fastcashier/ui/ResetAuthorizePasswordActivity.kt
+4
-0
LogFileUtils.kt
app/src/main/java/com/miya/fastcashier/utils/LogFileUtils.kt
+229
-0
OrderRecordManageKit.kt
...com/miya/fastcashier/utils/manage/OrderRecordManageKit.kt
+1
-2
activity_reset_authorize_password.xml
...src/main/res/layout/activity_reset_authorize_password.xml
+1
-1
activity_setting.xml
app/src/main/res/layout/activity_setting.xml
+1
-1
dialog_common.xml
app/src/main/res/layout/dialog_common.xml
+2
-1
fragment_search_order.xml
app/src/main/res/layout/fragment_search_order.xml
+1
-1
colors.xml
app/src/main/res/values/colors.xml
+1
-0
No files found.
app/src/main/java/com/miya/fastcashier/BaseApplication.kt
View file @
9309eada
package
com.miya.fastcashier
package
com.miya.fastcashier
import
android.app.Activity
import
android.app.Activity
import
android.app.Application
import
android.content.Context
import
android.content.Intent
import
android.os.Bundle
import
android.os.Bundle
import
android.view.Gravity
import
androidx.multidex.MultiDexApplication
import
androidx.multidex.MultiDexApplication
import
com.blankj.utilcode.util.LogUtils
import
com.elvishew.xlog.LogConfiguration
import
com.elvishew.xlog.LogConfiguration
import
com.elvishew.xlog.LogLevel
import
com.elvishew.xlog.LogLevel
import
com.elvishew.xlog.LogUtils
import
com.elvishew.xlog.XLog
import
com.elvishew.xlog.XLog
import
com.elvishew.xlog.printer.AndroidPrinter
import
com.elvishew.xlog.printer.AndroidPrinter
import
com.elvishew.xlog.printer.ConsolePrinter
import
com.elvishew.xlog.printer.ConsolePrinter
...
@@ -18,13 +14,14 @@ import com.elvishew.xlog.printer.file.FilePrinter
...
@@ -18,13 +14,14 @@ import com.elvishew.xlog.printer.file.FilePrinter
import
com.elvishew.xlog.printer.file.backup.NeverBackupStrategy
import
com.elvishew.xlog.printer.file.backup.NeverBackupStrategy
import
com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
import
com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.service.AccountService
import
com.miya.fastcashier.ui.LoginActivity
import
com.miya.fastcashier.ui.dialog.CommonDialog
import
com.miya.fastcashier.utils.ContextUtils
import
com.miya.fastcashier.utils.ContextUtils
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.fastcashier.utils.DensityUtils
import
com.miya.fastcashier.utils.DensityUtils
import
com.miya.fastcashier.utils.LogFileUtils
import
com.miya.fastcashier.utils.manage.OrderRecordManageKit
import
com.miya.fastcashier.utils.manage.OrderRecordManageKit
import
com.miya.print.PrinterManager
import
com.miya.print.PrinterManager
import
com.sdy.miya.moblie.component.pay.core.net.MiYaPayMobileApiClient
import
com.sdy.miya.moblie.component.pay.core.net.MiyaHttpLoggingInterceptor
import
com.sdy.miya.moblie.component.pay.core.utils.PayLogFileUtils
import
com.sdy.miya.moblie.component.pay.core.utils.PayLogFileUtils
import
com.tencent.mmkv.MMKV
import
com.tencent.mmkv.MMKV
import
java.io.File
import
java.io.File
...
@@ -91,6 +88,26 @@ class BaseApplication : MultiDexApplication() {
...
@@ -91,6 +88,26 @@ class BaseApplication : MultiDexApplication() {
.
absolutePath
.
absolutePath
+
File
.
separator
+
"payLog"
+
File
.
separator
+
"payLog"
)
)
var
loggingInterceptor
:
MiyaHttpLoggingInterceptor
?
=
null
try
{
loggingInterceptor
=
MiyaHttpLoggingInterceptor
{
message
->
if
(!
LogFileUtils
.
isProhibitWrite
)
{
LogFileUtils
.
writeLog
(
ContextUtils
.
getContext
(),
DateUtils
.
getDateStringByTimeStamp
(
System
.
currentTimeMillis
())
.
toString
()
+
" "
+
message
+
"\n"
)
}
if
(
BuildConfig
.
DEBUG
)
{
LogUtils
.
d
(
"fastcashier"
,
message
)
}
}
loggingInterceptor
.
level
=
MiyaHttpLoggingInterceptor
.
Level
.
BODY
}
catch
(
ex
:
Exception
)
{
ex
.
printStackTrace
()
}
MiYaPayMobileApiClient
.
init
(
true
,
loggingInterceptor
)
}
}
private
fun
screenAdapt
()
{
private
fun
screenAdapt
()
{
...
...
app/src/main/java/com/miya/fastcashier/ui/ResetAuthorizePasswordActivity.kt
View file @
9309eada
...
@@ -73,6 +73,10 @@ class ResetAuthorizePasswordActivity : BaseActivity() {
...
@@ -73,6 +73,10 @@ class ResetAuthorizePasswordActivity : BaseActivity() {
return
return
}
}
if
(
newPassword
.
equals
(
originPassword
))
{
CenterToasty
.
error
(
this
,
"新密码与原密码不能相同!"
).
show
()
return
}
if
(!
newPassword
.
equals
(
newConfirmPassword
))
{
if
(!
newPassword
.
equals
(
newConfirmPassword
))
{
CenterToasty
.
error
(
this
,
"新密码两次输入不一致!"
).
show
()
CenterToasty
.
error
(
this
,
"新密码两次输入不一致!"
).
show
()
...
...
app/src/main/java/com/miya/fastcashier/utils/LogFileUtils.kt
0 → 100644
View file @
9309eada
package
com.miya.fastcashier.utils
import
android.content.Context
import
android.content.pm.PackageInfo
import
com.miya.fastcashier.utils.LogFileUtils
import
android.content.pm.PackageManager
import
com.miya.fastcashier.utils.LogFileUtils.DeleteLogTask
import
android.os.AsyncTask
import
android.os.Environment
import
android.util.Log
import
java.io.*
import
java.lang.Exception
import
java.nio.charset.Charset
import
java.text.ParseException
import
java.text.SimpleDateFormat
import
java.util.*
import
java.util.concurrent.Executors
object
LogFileUtils
{
private
var
logFiles
//日志文件夹
:
File
?
=
null
private
var
logFile
//单个日志文件
:
File
?
=
null
private
val
sExecutor
=
Executors
.
newSingleThreadExecutor
()
val
CACHE_FILE_PATH
=
Environment
.
getExternalStorageDirectory
().
path
+
File
.
separator
+
"miyaterminal"
+
File
.
separator
+
"log"
+
File
.
separator
var
isProhibitWrite
=
false
//是否禁止写入文件
private
var
allFileBeanList
//所有的文件列表
:
MutableList
<
FileBean
>?
=
null
private
var
deleteFilePathList
//需要删除的文件列表
:
MutableList
<
File
>?
=
null
private
const
val
logSuffix
=
".txt"
private
const
val
logLink
=
"_"
fun
writeLog
(
c
:
Context
,
input
:
String
):
Boolean
{
sExecutor
.
execute
{
writeLogToFile
(
c
,
input
)
}
return
false
}
private
fun
writeLogToFile
(
context
:
Context
,
input
:
String
)
{
var
fos
:
FileOutputStream
?
=
null
var
writer
:
OutputStreamWriter
?
=
null
try
{
logFiles
=
File
(
CACHE_FILE_PATH
)
if
(!
logFiles
!!
.
exists
())
{
logFiles
!!
.
mkdirs
()
}
val
logPath
=
(
CACHE_FILE_PATH
+
getVersionCode
(
context
)
+
"_"
+
DateUtils
.
format8
(
Date
())
+
".txt"
)
logFile
=
File
(
logPath
)
fos
=
FileOutputStream
(
logFile
,
true
)
writer
=
OutputStreamWriter
(
fos
,
Charset
.
forName
(
"utf-8"
))
writer
.
write
(
input
)
writer
.
flush
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
finally
{
try
{
writer
?.
close
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
try
{
fos
?.
close
()
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
}
}
private
fun
getVersionCode
(
context
:
Context
):
String
{
val
packageManager
=
context
.
packageManager
val
packageInfo
:
PackageInfo
var
versionCode
=
""
try
{
packageInfo
=
packageManager
.
getPackageInfo
(
context
.
packageName
,
0
)
versionCode
=
packageInfo
.
versionCode
.
toString
()
+
""
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
e
.
printStackTrace
()
}
return
versionCode
}
/**
* 自动拼装时间戳的日志
*/
fun
writeLogFormat
(
c
:
Context
,
input
:
String
):
Boolean
{
val
calendar
=
Calendar
.
getInstance
()
calendar
.
timeInMillis
=
System
.
currentTimeMillis
()
val
sdf
=
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
)
return
writeLog
(
c
,
"""${sdf.format(calendar.time)} $input
"""
)
}
/**
* 写入throwable
*/
fun
writeThrowable
(
context
:
Context
,
throwable
:
Throwable
?):
Boolean
{
return
try
{
if
(
throwable
==
null
)
{
return
false
}
val
stringWriter
=
StringWriter
()
throwable
.
printStackTrace
(
PrintWriter
(
stringWriter
))
writeLogFormat
(
context
,
stringWriter
.
toString
())
}
catch
(
e
:
Exception
)
{
writeLogFormat
(
context
,
"error occur when writing throwable , error content is:"
+
e
.
message
)
false
}
}
/**
* 删除指定天数之前的日志,此处的天数不是精确到小时的,只精确到日
*
* @param days
*/
fun
deleteLog
(
days
:
Int
)
{
files
if
(
deleteFilePathList
==
null
)
{
deleteFilePathList
=
ArrayList
()
}
else
{
deleteFilePathList
!!
.
clear
()
}
if
(
allFileBeanList
!=
null
&&
allFileBeanList
!!
.
size
>
0
)
{
for
(
i
in
allFileBeanList
!!
.
indices
)
{
getDeleteFileList
(
days
,
allFileBeanList
!!
[
i
])
}
}
if
(
deleteFilePathList
!=
null
&&
deleteFilePathList
!!
.
size
>
0
)
{
val
deleteFiles
=
deleteFilePathList
!!
.
toTypedArray
()
DeleteLogTask
().
execute
(*
deleteFiles
)
}
}
/**
* 执行符合条件的删除日志操作
*
* @param days
* @param fileBean
*/
private
fun
getDeleteFileList
(
days
:
Int
,
fileBean
:
FileBean
)
{
val
currentLongTimes
=
System
.
currentTimeMillis
()
if
(
fileBean
.
fileName
!!
.
endsWith
(
logSuffix
))
{
if
(
fileBean
.
fileName
!!
.
contains
(
logLink
))
{
try
{
val
fileNameWithOutSuffix
=
fileBean
.
fileName
!!
.
substring
(
0
,
fileBean
.
fileName
!!
.
indexOf
(
"."
))
val
fileNameDate
=
fileNameWithOutSuffix
.
substring
(
fileNameWithOutSuffix
.
lastIndexOf
(
logLink
)
+
1
)
val
fileNameLongTimes
=
DateUtils
.
stringToLong
(
fileNameDate
,
DateUtils
.
DF_YYYYMMDD
)
if
(
currentLongTimes
-
fileNameLongTimes
>=
days
*
24L
*
60L
*
60L
*
1000L
)
{
//符合要求,加入删除列表
deleteFilePathList
!!
.
add
(
File
(
fileBean
.
filePath
))
}
}
catch
(
e
:
ParseException
)
{
e
.
printStackTrace
()
}
}
}
}
/**
* 获得日志文件夹下的文件名和文件路径
*/
private
val
files
:
Unit
private
get
()
{
if
(
allFileBeanList
==
null
)
{
allFileBeanList
=
ArrayList
()
}
else
{
allFileBeanList
!!
.
clear
()
}
val
files
=
logFiles
!!
.
listFiles
()
if
(
files
!=
null
)
{
for
(
i
in
files
.
indices
)
{
val
fileBean
=
FileBean
()
fileBean
.
fileName
=
files
[
i
].
name
fileBean
.
filePath
=
files
[
i
].
absolutePath
allFileBeanList
!!
.
add
(
fileBean
)
}
}
}
private
fun
doDeleteFiles
(
file
:
File
)
{
//flie:要删除的文件夹的所在位置
if
(
file
.
isDirectory
)
{
val
files
=
file
.
listFiles
()
for
(
i
in
files
.
indices
)
{
val
f
=
files
[
i
]
doDeleteFiles
(
f
)
}
file
.
delete
()
//如要保留文件夹,只删除文件,请注释这行
}
else
if
(
file
.
exists
())
{
file
.
delete
()
}
}
private
class
DeleteLogTask
:
AsyncTask
<
File
,
Void
?,
Boolean
>()
{
override
fun
doInBackground
(
vararg
files
:
File
):
Boolean
{
for
(
file
in
files
)
{
doDeleteFiles
(
file
)
}
return
true
}
override
fun
onPostExecute
(
aBoolean
:
Boolean
)
{
super
.
onPostExecute
(
aBoolean
)
if
(
aBoolean
)
{
Log
.
i
(
"LogFileUtils"
,
"日志删除成功!"
)
}
}
}
private
class
FileBean
{
var
fileName
:
String
?
=
null
var
filePath
:
String
?
=
null
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/utils/manage/OrderRecordManageKit.kt
View file @
9309eada
package
com.miya.fastcashier.utils.manage
package
com.miya.fastcashier.utils.manage
import
android.util.Log
import
com.blankj.utilcode.util.LogUtils
import
com.blankj.utilcode.util.LogUtils
import
com.miya.fastcashier.utils.DateUtils
import
com.miya.fastcashier.utils.DateUtils
import
com.tencent.mmkv.MMKV
import
com.tencent.mmkv.MMKV
...
@@ -21,7 +20,7 @@ class OrderRecordManageKit {
...
@@ -21,7 +20,7 @@ class OrderRecordManageKit {
val
today
=
DateUtils
.
format8
(
Date
())
val
today
=
DateUtils
.
format8
(
Date
())
val
no
=
getOrderMMKV
().
getInt
(
today
,
0
).
toString
()
val
no
=
getOrderMMKV
().
getInt
(
today
,
0
).
toString
()
var
listNo
=
no
var
listNo
=
no
//真
是流水单号需满足
五位
//真
实流水单号
五位
for
(
index
in
1
..
(
5
-
no
.
length
))
{
for
(
index
in
1
..
(
5
-
no
.
length
))
{
listNo
=
"0$listNo"
listNo
=
"0$listNo"
}
}
...
...
app/src/main/res/layout/activity_reset_authorize_password.xml
View file @
9309eada
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/color_
E5E5E5
"
android:background=
"@color/color_
F8F8F8
"
tools:context=
".ui.SettingActivity"
>
tools:context=
".ui.SettingActivity"
>
<View
<View
...
...
app/src/main/res/layout/activity_setting.xml
View file @
9309eada
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/color_
E5E5E5
"
android:background=
"@color/color_
F8F8F8
"
tools:context=
".ui.SettingActivity"
>
tools:context=
".ui.SettingActivity"
>
<View
<View
...
...
app/src/main/res/layout/dialog_common.xml
View file @
9309eada
...
@@ -16,8 +16,9 @@
...
@@ -16,8 +16,9 @@
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
android:textColor=
"
#
323233"
android:textColor=
"
@color/color_
323233"
android:textSize=
"28sp"
android:textSize=
"28sp"
android:textStyle=
"bold"
tools:text=
"是否确认退款"
tools:text=
"是否确认退款"
android:layout_marginTop=
"61dp"
android:layout_marginTop=
"61dp"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
...
...
app/src/main/res/layout/fragment_search_order.xml
View file @
9309eada
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
android:id=
"@+id/cpEmptyView"
android:id=
"@+id/cpEmptyView"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/color_
E5E5E5
"
android:background=
"@color/color_
F8F8F8
"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
android:visibility=
"gone"
android:visibility=
"gone"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
...
...
app/src/main/res/values/colors.xml
View file @
9309eada
...
@@ -22,4 +22,5 @@
...
@@ -22,4 +22,5 @@
<color
name=
"color_111235"
>
#111235
</color>
<color
name=
"color_111235"
>
#111235
</color>
<color
name=
"color_141C30"
>
#141C30
</color>
<color
name=
"color_141C30"
>
#141C30
</color>
<color
name=
"color_D1D1DC"
>
#D1D1DC
</color>
<color
name=
"color_D1D1DC"
>
#D1D1DC
</color>
<color
name=
"color_323233"
>
#323233
</color>
</resources>
</resources>
\ 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