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
cc436a26
Commit
cc436a26
authored
Sep 05, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
a88dce78
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
14 deletions
+41
-14
DownloadAdapter.kt
...base/browserwhite/ui/activity/download/DownloadAdapter.kt
+4
-1
DownloadDialog.kt
.../base/browserwhite/ui/activity/download/DownloadDialog.kt
+5
-7
DownloadGuideFragment.kt
...rowserwhite/ui/activity/download/DownloadGuideFragment.kt
+0
-1
WebViewFragment.kt
...se/browserwhite/ui/activity/webbrowser/WebViewFragment.kt
+19
-4
FileFragment.kt
...in/java/com/base/browserwhite/ui/fragment/FileFragment.kt
+13
-1
No files found.
app/src/main/java/com/base/browserwhite/ui/activity/download/DownloadAdapter.kt
View file @
cc436a26
...
...
@@ -33,7 +33,9 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
inner
class
DownloadViewHolder
(
view
:
View
)
:
ViewHolder
(
view
)
var
downloadAction
:
(()
->
Unit
)?
=
null
var
downloadAction
:
(()
->
Unit
)?
=
null
//下载按钮
var
downloadFinishAction
:
((
id
:
Int
)
->
Unit
)?
=
null
//下载完成
var
moreAction
:
((
archView
:
View
,
item
:
DownloadBean
)
->
Unit
)?
=
null
var
itemClick
:
((
path
:
String
)
->
Unit
)?
=
null
...
...
@@ -308,6 +310,7 @@ class DownloadAdapter : BaseQuickAdapter<DownloadBean, DownloadAdapter.DownloadV
item
.
status
=
FileDownloader
.
getImpl
().
getStatus
(
item
.
url
,
item
.
path
)
item
.
time
=
System
.
currentTimeMillis
()
notifyItemChanged
(
position
,
"aaa"
)
task
?.
let
{
downloadFinishAction
?.
invoke
(
it
.
id
)
}
}
override
fun
paused
(
task
:
BaseDownloadTask
?,
soFarBytes
:
Int
,
totalBytes
:
Int
)
{
...
...
app/src/main/java/com/base/browserwhite/ui/activity/download/DownloadDialog.kt
View file @
cc436a26
...
...
@@ -29,9 +29,9 @@ object DownloadDialog {
adapter
:
DownloadAdapter
,
list
:
List
<
DownloadBean
>,
dismissAction
:
()
->
Unit
)
{
)
:
BottomSheetDialog
{
val
TAG
=
"DownloadVideoDialog"
val
dialog
=
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
)
val
dialog
=
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
)
val
binding
=
DialogDownloadVideoBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
dialog
.
setContentView
(
binding
.
root
)
dialog
.
setCanceledOnTouchOutside
(
false
)
...
...
@@ -51,9 +51,6 @@ object DownloadDialog {
//展开
behavior
.
state
=
BottomSheetBehavior
.
STATE_EXPANDED
adapter
.
downloadAction
=
{
dialog
.
dismiss
()
}
binding
.
rv
.
adapter
=
adapter
adapter
.
submitList
(
list
)
...
...
@@ -65,10 +62,11 @@ object DownloadDialog {
dialog
.
dismiss
()
startActivity
(
Intent
(
this
,
WebDownloadManagerActivity
::
class
.
java
))
}
return
dialog
}
fun
Context
.
showDownloadConfirmDialog
(
item
:
DownloadBean
,
download
:
()
->
Unit
)
{
val
dialog
=
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
)
val
dialog
=
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
)
val
binding
=
DialogDownloadConfirmBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
dialog
.
setContentView
(
binding
.
root
)
dialog
.
setCanceledOnTouchOutside
(
false
)
...
...
@@ -81,7 +79,7 @@ object DownloadDialog {
Glide
.
with
(
this
).
load
(
item
.
url
).
centerCrop
().
into
(
binding
.
iv
)
binding
.
editName
.
setText
(
item
.
url
.
split
(
"/"
).
last
())
binding
.
tvSize
.
text
=
item
.
size
.
toFormatSize
()
binding
.
tvSize
.
text
=
item
.
size
.
toFormatSize
()
binding
.
ivEdit
.
setOnClickListener
{
binding
.
editName
.
isEnabled
=
true
binding
.
editName
.
setBackgroundResource
(
android
.
R
.
drawable
.
edit_text
)
...
...
app/src/main/java/com/base/browserwhite/ui/activity/download/DownloadGuideFragment.kt
View file @
cc436a26
...
...
@@ -2,7 +2,6 @@ package com.base.browserwhite.ui.activity.download
import
android.annotation.SuppressLint
import
androidx.constraintlayout.widget.ConstraintLayout
import
androidx.core.view.marginRight
import
com.base.browserwhite.R
import
com.base.browserwhite.databinding.FragmentDownloadGuideBinding
import
com.base.browserwhite.ui.fragment.BaseFragment
...
...
app/src/main/java/com/base/browserwhite/ui/activity/webbrowser/WebViewFragment.kt
View file @
cc436a26
package
com.base.browserwhite.ui.activity.webbrowser
import
android.annotation.SuppressLint
import
android.app.Dialog
import
android.content.Context
import
android.net.Uri
import
android.net.http.SslError
...
...
@@ -23,9 +24,11 @@ import com.base.browserwhite.bean.DownloadBean
import
com.base.browserwhite.bean.HistoryBean
import
com.base.browserwhite.databinding.FragmentWebViewBinding
import
com.base.browserwhite.ui.activity.download.DownloadAdapter
import
com.base.browserwhite.ui.activity.download.DownloadDialog.showDownloadFinishDialog
import
com.base.browserwhite.ui.fragment.BaseFragment
import
com.base.browserwhite.ui.activity.download.DownloadDialog.showDownloadVideoDialog
import
com.base.browserwhite.utils.ColorUtils
import
com.base.browserwhite.utils.DownloadUtils
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJson
import
com.base.browserwhite.utils.DownloadUtils.getDownloadJsonBean
import
com.base.browserwhite.utils.DownloadUtils.saveDownloadRecordFile
...
...
@@ -68,6 +71,7 @@ class WebViewFragment : BaseFragment<FragmentWebViewBinding>() {
loadWebView
(
url
)
}
var
downloadDialog
:
Dialog
?
=
null
override
fun
setListener
()
{
super
.
setListener
()
binding
.
tvReload
.
setOnClickListener
{
...
...
@@ -94,15 +98,26 @@ class WebViewFragment : BaseFragment<FragmentWebViewBinding>() {
downloadAdapter
=
DownloadAdapter
()
}
downloadAdapter
?.
let
{
adapter
->
requireContext
().
showDownloadVideoDialog
(
downloadDialog
=
requireContext
().
showDownloadVideoDialog
(
adapter
,
downloadList
,
dismissAction
=
{
requireContext
().
saveDownloadRecordFile
(
downloadList
)
downloadDialog
=
null
},
)
}
}
downloadAdapter
?.
downloadAction
=
{
downloadDialog
?.
dismiss
()
}
downloadAdapter
?.
downloadFinishAction
=
{
id
->
downloadDialog
?.
dismiss
()
val
recordFile
=
requireContext
().
getDownloadJson
()
val
bean
=
DownloadUtils
.
getDownloadJsonBean
(
recordFile
).
filter
{
it
.
downloadId
==
id
}
requireContext
().
showDownloadFinishDialog
()
}
}
...
...
@@ -112,6 +127,7 @@ class WebViewFragment : BaseFragment<FragmentWebViewBinding>() {
binding
.
progressBar
.
visibility
=
View
.
VISIBLE
binding
.
progressBar
.
progress
=
0
downloadList
.
clear
()
binding
.
flDownload
.
visibility
=
View
.
GONE
binding
.
webView
.
reload
()
}
...
...
@@ -259,10 +275,9 @@ class WebViewFragment : BaseFragment<FragmentWebViewBinding>() {
private
val
downloadList
=
arrayListOf
<
DownloadBean
>()
@SuppressLint
(
"NotifyDataSetChanged"
)
fun
addVideoLink
(
addUri
:
String
)
{
val
olderList
=
arrayListOf
<
DownloadBean
>()
val
olderList
=
arrayListOf
<
DownloadBean
>()
val
recordFile
=
requireContext
().
getDownloadJson
()
olderList
.
addAll
(
getDownloadJsonBean
(
recordFile
,
Gson
()))
olderList
.
forEach
{
...
...
app/src/main/java/com/base/browserwhite/ui/fragment/FileFragment.kt
View file @
cc436a26
...
...
@@ -127,7 +127,19 @@ class FileFragment : BaseFragment<FragmentFileBinding>() {
})
}
binding
.
llDownload
.
setOnClickListener
{
startActivity
(
Intent
(
requireContext
(),
WebDownloadManagerActivity
::
class
.
java
))
if
(
requireContext
().
checkStorePermission
())
{
startActivity
(
Intent
(
requireContext
(),
WebDownloadManagerActivity
::
class
.
java
))
}
else
{
requireContext
().
showGerPermission
(
desc
=
"This feature requires access to your storage to manage your downloads. We will not transfer your data to any third-party services. Please grant permission so that we can provide you with better services."
,
deny
=
{
},
allow
=
{
val
launcher
=
(
requireActivity
()
as
MainActivity
).
launcher
requireContext
().
requestStorePermission
(
launcher
,
result
=
{
if
(
it
)
startActivity
(
Intent
(
requireContext
(),
WebDownloadManagerActivity
::
class
.
java
))
})
})
}
// startActivity(Intent(requireContext(), WebBrowserActivity::class.java).apply {
// putExtra("url", "https://mixkit.co/free-stock-video/girl-dancing-happily-in-a-field-of-flowers-4702/")
// })
...
...
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