B4A Library DownloadProgressView V1.0.1 (uses the Android Downloadmanager to download)

This is a wrapper for this project.

An android view showing a download progressBar, total size, downloadedSize, percentage downloaded and a cancel button of the android DownloadManager with just few lines of code. Just like Google Play downloading...

Downloads made by this library uses the Android Downloadmanager (Systemservice).
But additional to the Notificationprogress you got you also can show the progress inside own app.

DownloadProgress
Version:
1.02
  • DownloadProgressView
    Events:
    • DownloadCancelled (downloadURL As String)
    • DownloadFailed (downloadURL As String, reason As Int)
    • DownloadProgress (downloadURL As String, bytes_downloaded As Long, bytes_total As Long, download_percentage As Long)
    • DownloadSuccessful (downloadURL As String)
    Fields:
    • ba As BA
    Methods:
    • AddToParent (Parent As ViewGroup, left As Int, top As Int, width As Int, height As Int)
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • download (url As String, title As String, description As String, DestinationFilename As String)
      This method initialize and shows the downloadProgressView.
      downloadID: the downloadID gotten when a download was enqueued.
      downloadStatusListener: the downloadStatusListener to monitor when download is successful,
      failed, cancelled.
    Permissions:
    • android.permission.ACCESS_NETWORK_STATE
    • android.permission.INTERNET
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • DownloadedSizeColor As Int
      This method returns the color of the downloadedSize TextView.
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • PercentageColor As Int
      This method returns the color of the percentage TextView.
    • ProgressBarColor As Int [write only]
      This method sets the color of the progressBar.
    • ProgressBarMode As String [write only]
      This method sets the mode of the progressBar.
    • ProgressBarProgressColor As Int [write only]
      This method sets the 2nd color of the progressBar.
    • ProgressBarProgressMode As String [write only]
      This method sets the 2nr mode of the progressBar.
    • Tag As Object
    • Top As Int
    • TotalSizeColor As Int
      This method returns the color of the totalSize TextView.
    • Visible As Boolean
    • Width As Int


Please note: The STRING you can set with ProgressBarMode or ProgressBarProgressMode is the Porter-Duff-Mode.
porterduff0038.png

In this case the ADD, CLEAR, DARKEN, DST, and so forth, can be used when setting the Mode (just use them as String... ADD -> "ADD")

If you want to donate for my work building the wrapper you can do it here:

Known issues:
As of yet it downloads all files to the internal FILES dir (ASSETS). On my device it works but i dont know about other devices. Working on it to make it changeable. Hopefully this weekend i will release a update.

Please note the changes in the manifest in example.

Dont forget to add
AddPermission(android.permission.INTERNET) ' Allows applications to open network sockets.
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE) ' Allows an application to write to external storage.
to your manifest
 

Attachments

  • libDownloadProgressViewV1.0.0.zip
    13.6 KB · Views: 568
  • libDownloadProgressViewV1.0.1.zip
    14 KB · Views: 510
  • DownloadProgressViewEx.zip
    9.5 KB · Views: 916
  • libDownloadProgressViewV1.0.2.zip
    14.5 KB · Views: 946
Last edited:

Blue.Sky

Active Member
Licensed User
Longtime User
@DonManfred
Sorry.
The library for less than Android 4.4 does not work?
 

Blue.Sky

Active Member
Licensed User
Longtime User
@DonManfred tnx
Use this library to Android 5+ and lower than 5 with this code

B4X:
Dim sdk As Phone
If sdk.SdkVersion >=21 Then
    downloadView.Visible = True
    downloadView.Color = Colors.RGB(136,27,154)
    downloadView.DownloadedSizeColor = Colors.White
    downloadView.TotalSizeColor = Colors.White
    downloadView.PercentageColor = Colors.White
    downloadView.ProgressBarColor = Colors.White
    downloadView.ProgressBarMode = "DST"
    downloadView.ProgressBarProgressMode = "ADD"
    downloadView.ProgressBarProgressColor = Colors.White

  
    downloadView.download(StrDownload,"sc","Description","1.mp4")
Else
    downloadView.Visible = True
    downloadView.Color = Colors.RGB(136,27,154)
    downloadView.TotalSizeColor = Colors.White
    downloadView.DownloadedSizeColor = Colors.White
    downloadView.PercentageColor = Colors.White
    downloadView.download(StrDownload,"sc","Description","1.mp4")
End if
 

susu

Well-Known Member
Licensed User
Longtime User
Hi @DonManfred,
Is there a way to cancel downloading file? Thanks.
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello @DonManfred ,
please, how can I set destination folder like File.DirRootExternal & /testfolder"?
 

Rusty

Well-Known Member
Licensed User
Longtime User
Ok, thanks. I was hoping to see the download progress of the Astreams prefix transfer.
I appreciate your rapid responses :)
 

karizmatik163

New Member
hi broo and tnx for this library
this lib download file in to app default folder but how i can change saved folder ?
and how i can change notfication details about icon ....?
tnx
 
Top