Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
B
Browser White
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
Browser White
Commits
97eceac0
Commit
97eceac0
authored
Aug 16, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
0eebeedd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
4 deletions
+54
-4
WebBrowserActivity.kt
...browserwhite/ui/activity/webbrowser/WebBrowserActivity.kt
+14
-0
WebViewFragment.kt
...java/com/base/browserwhite/ui/fragment/WebViewFragment.kt
+8
-1
bg_progress_web.xml
app/src/main/res/drawable/bg_progress_web.xml
+4
-0
progress_bar_web.xml
app/src/main/res/drawable/progress_bar_web.xml
+16
-0
activity_web_browser.xml
app/src/main/res/layout/activity_web_browser.xml
+0
-1
fragment_web_view.xml
app/src/main/res/layout/fragment_web_view.xml
+12
-2
No files found.
app/src/main/java/com/base/browserwhite/ui/activity/webbrowser/WebBrowserActivity.kt
View file @
97eceac0
...
...
@@ -2,6 +2,9 @@ package com.base.browserwhite.ui.activity.webbrowser
import
android.graphics.Color
import
android.view.KeyEvent
import
android.view.inputmethod.EditorInfo
import
android.widget.TextView
import
androidx.activity.addCallback
import
androidx.core.view.updatePadding
import
androidx.fragment.app.Fragment
...
...
@@ -46,6 +49,17 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
}
else
{
binding
.
ivRight
.
setImageResource
(
R
.
mipmap
.
right_n
)
}
binding
.
editWeb
.
setOnEditorActionListener
(
object
:
TextView
.
OnEditorActionListener
{
override
fun
onEditorAction
(
v
:
TextView
?,
actionId
:
Int
,
event
:
KeyEvent
?):
Boolean
{
if
(
actionId
==
EditorInfo
.
IME_ACTION_DONE
)
{
val
url
=
v
.
toString
()
currentFragment
?.
jumpUrl
(
url
)
return
true
;
// 返回true表示事件已处理
}
return
false
}
})
}
override
fun
initListener
()
{
...
...
app/src/main/java/com/base/browserwhite/ui/fragment/WebViewFragment.kt
View file @
97eceac0
...
...
@@ -12,15 +12,17 @@ import android.webkit.WebStorage
import
android.webkit.WebView
import
android.webkit.WebViewClient
import
com.base.browserwhite.databinding.FragmentWebViewBinding
import
com.base.browserwhite.utils.LogEx
class
WebViewFragment
(
val
uri
:
String
)
:
BaseFragment
<
FragmentWebViewBinding
>()
{
private
val
TAG
=
"WebViewFragment"
override
val
binding
:
FragmentWebViewBinding
by
lazy
{
FragmentWebViewBinding
.
inflate
(
layoutInflater
)
}
var
onPageFinished
:
((
uri
:
String
?)
->
Unit
)?
=
null
var
onPageFinished
:
((
uri
:
String
?)
->
Unit
)?
=
null
override
fun
setView
()
{
...
...
@@ -61,6 +63,7 @@ class WebViewFragment(val uri: String) : BaseFragment<FragmentWebViewBinding>()
//设置WebChromeClient
binding
.
webView
.
webChromeClient
=
object
:
WebChromeClient
()
{
override
fun
onProgressChanged
(
view
:
WebView
,
newProgress
:
Int
)
{
// LogEx.logDebug(TAG, )
}
override
fun
onReceivedTitle
(
view
:
WebView
?,
title
:
String
?)
{
...
...
@@ -123,4 +126,8 @@ class WebViewFragment(val uri: String) : BaseFragment<FragmentWebViewBinding>()
binding
.
webView
.
evaluateJavascript
(
"window.history.back();"
,
null
)
}
fun
jumpUrl
(
url
:
String
)
{
binding
.
webView
.
loadUrl
(
url
)
}
}
\ No newline at end of file
app/src/main/res/drawable/bg_progress_web.xml
0 → 100644
View file @
97eceac0
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<solid
android:color=
"@android:color/transparent"
/>
</shape>
\ No newline at end of file
app/src/main/res/drawable/progress_bar_web.xml
0 → 100644
View file @
97eceac0
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<!-- 设置背景色 -->
<item
android:id=
"@android:id/background"
android:drawable=
"@drawable/bg_progress_web"
/>
<!-- 设置进度条颜色 -->
<item
android:id=
"@android:id/progress"
>
<clip>
<shape>
<solid
android:color=
"#0571ED"
/>
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
app/src/main/res/layout/activity_web_browser.xml
View file @
97eceac0
...
...
@@ -97,7 +97,6 @@
android:id=
"@+id/container"
android:layout_width=
"match_parent"
android:layout_height=
"0dp"
android:layout_marginVertical=
"15dp"
app:layout_constraintBottom_toTopOf=
"@id/cl_bottom"
app:layout_constraintTop_toBottomOf=
"@id/cl_top"
tools:ignore=
"UselessLeaf"
/>
...
...
app/src/main/res/layout/fragment_web_view.xml
View file @
97eceac0
<?xml version="1.0" encoding="utf-8"?>
<
Frame
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
tools:context=
".ui.fragment.WebViewFragment"
>
<ProgressBar
android:id=
"@+id/progress"
style=
"@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"3dp"
android:max=
"100"
android:progress=
"50"
android:progressDrawable=
"@drawable/progress_bar_web"
/>
<WebView
android:id=
"@+id/webView"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
</FrameLayout>
\ No newline at end of file
</LinearLayout>
\ 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