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
e0f31f6f
Commit
e0f31f6f
authored
May 10, 2022
by
赵鹏翔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update file
parent
290ba320
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
3 deletions
+83
-3
SystemParameterDialog.java
.../java/com/miya/fastcashier/log/SystemParameterDialog.java
+4
-3
BaseFunction.kt
app/src/main/java/com/miya/fastcashier/utils/BaseFunction.kt
+79
-0
No files found.
app/src/main/java/com/miya/fastcashier/log/SystemParameterDialog.java
View file @
e0f31f6f
...
...
@@ -13,6 +13,7 @@ import com.miya.fastcashier.beans.SelfCashierAccountInfo;
import
com.miya.fastcashier.databinding.DialogSystemParameterBinding
;
import
com.miya.fastcashier.service.AccountService
;
import
com.miya.fastcashier.service.LoginService
;
import
com.miya.fastcashier.utils.BaseFunctionKt
;
import
com.miya.print.PrinterManager
;
import
androidx.annotation.NonNull
;
...
...
@@ -35,7 +36,7 @@ public class SystemParameterDialog extends Dialog {
private
void
init
()
{
SelfCashierAccountInfo
accountInfo
=
AccountService
.
INSTANCE
.
getAccountInfo
();
//
setInfo(viewBinding.tvVersion, BaseFunctionKt.getVersion(getContext()));
setInfo
(
viewBinding
.
tvVersion
,
BaseFunctionKt
.
getVersion
(
getContext
()));
setInfo
(
viewBinding
.
tvStoreName
,
accountInfo
.
getShopInfo
().
getStoreName
());
setInfo
(
viewBinding
.
tvStoreNum
,
accountInfo
.
getShopInfo
().
getStoreId
());
setInfo
(
viewBinding
.
tvMerchantNum
,
accountInfo
.
getShopInfo
().
getHhMerchant
());
...
...
@@ -44,8 +45,8 @@ public class SystemParameterDialog extends Dialog {
setInfo
(
viewBinding
.
tvVersionType
,
"fastCashier_"
+
BuildConfig
.
appType
);
setInfo
(
viewBinding
.
tvEquipment
,
"sunmi_v2pro"
);
setInfo
(
viewBinding
.
tvServerUrl
,
LoginService
.
Companion
.
getBaseUrl
());
//
setInfo(viewBinding.tvWifiName, BaseFunctionKt.getWifyName(getContext()));
//
setInfo(viewBinding.tvNetIp, BaseFunctionKt.getNetIp(getContext()) == null ? "未知" : BaseFunctionKt.getNetIp(getContext()));
setInfo
(
viewBinding
.
tvWifiName
,
BaseFunctionKt
.
getWifyName
(
getContext
()));
setInfo
(
viewBinding
.
tvNetIp
,
BaseFunctionKt
.
getNetIp
(
getContext
())
==
null
?
"未知"
:
BaseFunctionKt
.
getNetIp
(
getContext
()));
setInfo
(
viewBinding
.
tvPrintType
,
PrinterManager
.
getInstance
().
getPrinter
()
==
null
?
getContext
().
getResources
().
getString
(
R
.
string
.
app_unkown
)
:
PrinterManager
.
getInstance
().
getPrinter
().
getPrinterName
());
...
...
app/src/main/java/com/miya/fastcashier/utils/BaseFunction.kt
View file @
e0f31f6f
package
com.miya.fastcashier.utils
import
android.content.Context
import
android.content.pm.PackageInfo
import
android.content.pm.PackageManager
import
android.net.ConnectivityManager
import
android.net.NetworkInfo
import
android.net.wifi.WifiInfo
import
android.net.wifi.WifiManager
import
android.text.TextUtils
import
java.net.Inet4Address
import
java.net.NetworkInterface
import
java.net.SocketException
fun
isEmpty
(
s
:
String
?):
Boolean
{
return
TextUtils
.
isEmpty
(
s
)
...
...
@@ -23,3 +32,73 @@ fun dp2px(context: Context, dpValue: Float): Int {
val
scale
=
context
.
resources
.
displayMetrics
.
density
return
(
dpValue
*
scale
+
0.5f
).
toInt
()
}
fun
getNetIp
(
c
:
Context
):
String
?
{
val
info
=
(
c
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
)
as
ConnectivityManager
).
activeNetworkInfo
if
(
info
!=
null
&&
info
.
isConnected
)
{
if
(
info
.
type
==
ConnectivityManager
.
TYPE_MOBILE
)
{
//当前使用2G/3G/4G网络
try
{
//Enumeration<NetworkInterface> en=NetworkInterface.getNetworkInterfaces();
val
en
=
NetworkInterface
.
getNetworkInterfaces
()
while
(
en
.
hasMoreElements
())
{
val
intf
=
en
.
nextElement
()
val
enumIpAddr
=
intf
.
inetAddresses
while
(
enumIpAddr
.
hasMoreElements
())
{
val
inetAddress
=
enumIpAddr
.
nextElement
()
if
(!
inetAddress
.
isLoopbackAddress
&&
inetAddress
is
Inet4Address
)
{
return
inetAddress
.
getHostAddress
()
}
}
}
}
catch
(
e
:
SocketException
)
{
e
.
printStackTrace
()
}
}
else
if
(
info
.
type
==
ConnectivityManager
.
TYPE_WIFI
)
{
//当前使用无线网络
val
wifiManager
=
c
.
getSystemService
(
Context
.
WIFI_SERVICE
)
as
WifiManager
val
wifiInfo
=
wifiManager
.
connectionInfo
return
intIP2StringIP
(
wifiInfo
.
ipAddress
)
//得到IPV4地址
}
}
else
{
//当前无网络连接,请在设置中打开网络
}
return
null
}
/**
* 将得到的int类型的IP转换为String类型
*
* @param ip
* @return
*/
fun
intIP2StringIP
(
ip
:
Int
):
String
?
{
return
(
ip
and
0
xFF
).
toString
()
+
"."
+
(
ip
shr
8
and
0
xFF
)
+
"."
+
(
ip
shr
16
and
0
xFF
)
+
"."
+
(
ip
shr
24
and
0
xFF
)
}
/**
* 获取wifi名称(即ssid)
*
* @param c
* @return
*/
fun
getWifyName
(
c
:
Context
):
String
?
{
val
mWifiManager
=
c
.
getSystemService
(
Context
.
WIFI_SERVICE
)
as
WifiManager
return
mWifiManager
.
connectionInfo
.
ssid
}
fun
getVersion
(
context
:
Context
):
String
?
{
val
packageManager
=
context
.
packageManager
val
packageInfo
:
PackageInfo
var
version
=
""
try
{
packageInfo
=
packageManager
.
getPackageInfo
(
context
.
packageName
,
0
)
version
=
"${packageInfo.versionCode}_v${packageInfo.versionName}"
}
catch
(
e
:
PackageManager
.
NameNotFoundException
)
{
e
.
printStackTrace
()
}
return
version
}
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