Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
p x
GeelyHMIWeb
Commits
6ba1ff6b
Commit
6ba1ff6b
authored
Jun 11, 2025
by
p x
Browse files
天地图
parent
b00e32f2
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
app/src/main/AndroidManifest.xml
View file @
6ba1ff6b
...
...
@@ -3,6 +3,8 @@
xmlns:tools=
"http://schemas.android.com/tools"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.READ_EXTERNAL_STORAGE"
/>
<application
android:name=
".MyApplication"
...
...
app/src/main/assets/dist/index.html
View file @
6ba1ff6b
This diff is collapsed.
Click to expand it.
app/src/main/java/com/sd/geelyhmiweb/MainActivity.kt
View file @
6ba1ff6b
...
...
@@ -12,12 +12,8 @@ import android.webkit.WebResourceResponse
import
android.webkit.WebSettings
import
android.webkit.WebView
import
android.webkit.WebViewClient
import
androidx.activity.enableEdgeToEdge
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.view.ViewCompat
import
androidx.core.view.WindowInsetsCompat
import
com.sd.geelyhmiweb.databinding.ActivityMainBinding
import
com.sd.geelyhmiweb.dsbridge.DWebView
import
dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
...
...
@@ -34,9 +30,11 @@ class MainActivity : AppCompatActivity() {
fun
initWeb
()
{
DWebView
.
setWebContentsDebuggingEnabled
(
true
)
//
DWebView.setWebContentsDebuggingEnabled(true)
binding
.
dwebview
.
settings
.
run
{
userAgentString
=
"Mozilla/5.0 (Linux; Android 10; Mobile) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Mobile Safari/537.36"
javaScriptEnabled
=
true
javaScriptCanOpenWindowsAutomatically
=
true
loadWithOverviewMode
=
true
...
...
@@ -57,6 +55,17 @@ class MainActivity : AppCompatActivity() {
binding
.
dwebview
.
loadUrl
(
url
)
binding
.
dwebview
.
webViewClient
=
object
:
WebViewClient
()
{
override
fun
shouldInterceptRequest
(
view
:
WebView
?,
request
:
WebResourceRequest
):
WebResourceResponse
?
{
var
headers
=
request
.
requestHeaders
headers
.
put
(
"Referer"
,
"https://www.tianditu.gov.cn/"
)
// headers.put("sec-ch-ua-platform", "")
// headers.put("","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0")
return
super
.
shouldInterceptRequest
(
view
,
request
)
}
override
fun
onReceivedSslError
(
view
:
WebView
?,
...
...
@@ -85,6 +94,8 @@ class MainActivity : AppCompatActivity() {
}
binding
.
dwebview
.
webChromeClient
=
object
:
WebChromeClient
()
{
override
fun
onConsoleMessage
(
message
:
ConsoleMessage
?):
Boolean
{
Log
.
d
(
"---pxl "
,
...
...
app/src/main/java/com/sd/geelyhmiweb/ui/LoginActivity.kt
View file @
6ba1ff6b
package
com.sd.geelyhmiweb.ui
import
android.Manifest
import
android.content.Intent
import
android.os.Bundle
import
androidx.activity.viewModels
import
androidx.appcompat.app.AppCompatActivity
import
com.permissionx.guolindev.PermissionX
import
com.sd.geelyhmiweb.MainActivity
import
com.sd.geelyhmiweb.databinding.ActivityLoginBinding
import
com.sd.geelyhmiweb.utils.ToastHelper
import
com.sd.geelyhmiweb.viewmodels.LoginVM
import
dagger.hilt.android.AndroidEntryPoint
...
...
@@ -19,7 +22,7 @@ class LoginActivity : AppCompatActivity() {
super
.
onCreate
(
savedInstanceState
)
binding
=
ActivityLoginBinding
.
inflate
(
layoutInflater
)
setContentView
(
binding
.
root
)
requestPers
()
setLisener
()
}
...
...
@@ -42,4 +45,36 @@ class LoginActivity : AppCompatActivity() {
}
fun
requestPers
()
{
var
list
=
listOf
(
Manifest
.
permission
.
WRITE_EXTERNAL_STORAGE
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
,
)
PermissionX
.
init
(
this
)
.
permissions
(
list
)
.
onExplainRequestReason
{
scope
,
deniedList
->
scope
.
showRequestReasonDialog
(
deniedList
,
"需要同意以下授权才能正常使用"
,
"好的"
,
"取消"
)
}
// .onForwardToSettings { scope, deniedList ->
// scope.showForwardToSettingsDialog(deniedList, "您需要手动在‘设置’中允许必要的权限", "OK", "Cancel")
// }
.
request
{
allGranted
,
grantedList
,
deniedList
->
if
(
allGranted
)
{
// ToastHelper.showShort(this, "All permissions are granted")
}
else
{
ToastHelper
.
showShort
(
this
,
"权限被拒"
)
binding
.
root
.
postDelayed
({
finish
()
},
150
)
}
}
}
}
\ No newline at end of file
app/src/main/res/xml/network_security_config.xml
View file @
6ba1ff6b
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config
cleartextTrafficPermitted=
"true"
/>
<base-config
cleartextTrafficPermitted=
"true"
>
</base-config>
<!-- <domain-config cleartextTrafficPermitted="true">-->
<!-- <domain includeSubdomains="true">t0.tianditu.gov.cn</domain>-->
<!-- <domain includeSubdomains="true">t1.tianditu.gov.cn</domain>-->
<!-- <domain includeSubdomains="true">t2.tianditu.gov.cn</domain>-->
<!-- <domain includeSubdomains="true">t3.tianditu.gov.cn</domain>-->
<!-- </domain-config>-->
</network-security-config>
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