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
faa5eb46
Commit
faa5eb46
authored
Sep 09, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
66eaf512
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
20 deletions
+27
-20
WebBrowserActivity.kt
...browserwhite/ui/activity/webbrowser/WebBrowserActivity.kt
+1
-2
WebViewFragment.kt
...se/browserwhite/ui/activity/webbrowser/WebViewFragment.kt
+26
-18
No files found.
app/src/main/java/com/base/browserwhite/ui/activity/webbrowser/WebBrowserActivity.kt
View file @
faa5eb46
...
@@ -435,8 +435,7 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
...
@@ -435,8 +435,7 @@ class WebBrowserActivity : BaseActivity<ActivityWebBrowserBinding>() {
fragmentList
.
add
(
myFragment
)
fragmentList
.
add
(
myFragment
)
currentFragment
=
myFragment
currentFragment
=
myFragment
currentFragment
?.
onPageFinished
=
{
uriString
->
currentFragment
?.
onPageFinished
=
{
uriString
->
binding
.
editWeb
.
setText
(
currentFragment
?.
bookmarkBean
?.
name
?:
""
)
binding
.
editWeb
.
text
=
currentFragment
?.
bookmarkBean
?.
name
?:
""
// uriString?.let { binding.editWeb.setText(it) }
checkLeftRight
()
checkLeftRight
()
}
}
}
}
...
...
app/src/main/java/com/base/browserwhite/ui/activity/webbrowser/WebViewFragment.kt
View file @
faa5eb46
...
@@ -24,6 +24,7 @@ import android.webkit.WebView
...
@@ -24,6 +24,7 @@ import android.webkit.WebView
import
android.webkit.WebViewClient
import
android.webkit.WebViewClient
import
androidx.core.view.isVisible
import
androidx.core.view.isVisible
import
androidx.lifecycle.lifecycleScope
import
androidx.lifecycle.lifecycleScope
import
com.applovin.sdk.AppLovinSdkUtils.runOnUiThread
import
com.base.browserwhite.MyApplication
import
com.base.browserwhite.MyApplication
import
com.base.browserwhite.ads.AdmobMaxHelper
import
com.base.browserwhite.ads.AdmobMaxHelper
import
com.base.browserwhite.ads.AdmobMaxHelper.lastShowInter
import
com.base.browserwhite.ads.AdmobMaxHelper.lastShowInter
...
@@ -116,7 +117,23 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -116,7 +117,23 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
binding
.
flDownload
.
setOnClickListener
{
binding
.
flDownload
.
setOnClickListener
{
callDownloadDialog
()
callDownloadDialog
()
}
}
binding
.
webView
.
setFindListener
{
activeMatchOrdinal
,
numberOfMatches
,
isDoneCounting
->
LogEx
.
logDebug
(
TAG
,
"activeMatchOrdinal=$activeMatchOrdinal numberOfMatches=$numberOfMatches isDoneCounting=$isDoneCounting"
)
if
(
numberOfMatches
>
0
)
{
if
(
isDoneCounting
)
{
binding
.
webView
.
loadUrl
(
"javascript:window.android.onSearchResult(document.body.innerText);"
)
}
}
else
{
if
(
activity
is
WebBrowserActivity
)
{
(
activity
as
WebBrowserActivity
?)
?.
setSearchNum
(
0
,
0
)
}
searchResult
.
clear
()
searchPosition
=
0
}
}
}
}
private
fun
callDownloadDialog
()
{
private
fun
callDownloadDialog
()
{
...
@@ -183,19 +200,7 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -183,19 +200,7 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
}
}
requireContext
().
saveDownloadRecordFile
(
downloadList
)
requireContext
().
saveDownloadRecordFile
(
downloadList
)
}
}
binding
.
webView
.
setFindListener
{
activeMatchOrdinal
,
numberOfMatches
,
isDoneCounting
->
if
(
numberOfMatches
>
0
)
{
if
(
isDoneCounting
)
{
binding
.
webView
.
loadUrl
(
"javascript:window.android.onSearchResult(document.body.innerText);"
)
}
}
else
{
if
(
activity
is
WebBrowserActivity
)
{
(
activity
as
WebBrowserActivity
)
?.
setSearchNum
(
0
,
0
)
}
searchResult
.
clear
()
searchPosition
=
0
}
}
}
}
private
var
keyword
=
""
private
var
keyword
=
""
...
@@ -243,6 +248,7 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -243,6 +248,7 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
@JavascriptInterface
@JavascriptInterface
fun
onSearchResult
(
text
:
String
?)
{
fun
onSearchResult
(
text
:
String
?)
{
LogEx
.
logDebug
(
TAG
,
"onSearchResult"
)
text
?.
let
{
text
?.
let
{
val
filteredText
=
Html
.
fromHtml
(
it
).
toString
()
val
filteredText
=
Html
.
fromHtml
(
it
).
toString
()
val
pattern
=
Pattern
.
compile
(
keyword
,
Pattern
.
CASE_INSENSITIVE
)
val
pattern
=
Pattern
.
compile
(
keyword
,
Pattern
.
CASE_INSENSITIVE
)
...
@@ -253,10 +259,12 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
...
@@ -253,10 +259,12 @@ class WebViewFragment() : BaseFragment<FragmentWebViewBinding>() {
searchResult
.
add
(
start
)
searchResult
.
add
(
start
)
}
}
if
(
activity
is
WebBrowserActivity
)
{
if
(
activity
is
WebBrowserActivity
)
{
(
activity
as
WebBrowserActivity
)
?.
setSearchNum
(
runOnUiThread
{
searchPosition
+
1
,
(
activity
as
WebBrowserActivity
?)
?.
setSearchNum
(
searchResult
.
size
searchPosition
+
1
,
searchResult
.
size
)
)
}
}
}
highlightSearchResult
()
highlightSearchResult
()
}
}
...
...
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