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: 666
  • libDownloadProgressViewV1.0.1.zip
    14 KB · Views: 597
  • DownloadProgressViewEx.zip
    9.5 KB · Views: 1,025
  • libDownloadProgressViewV1.0.2.zip
    14.5 KB · Views: 1,053
Last edited:

aidymp

Well-Known Member
Licensed User
Longtime User
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
  • DownloadProgressView
    Events:
    • DownloadCancelled (downloadURL As String)
    • DownloadFailed (downloadURL As String, reason As Int)
    • 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.
    • Tag As Object
    • Top As Int
    • TotalSizeColor As Int
      This method returns the color of the totalSize TextView.
    • Visible As Boolean
    • Width As Int

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 to your manifest


Hi, @DonManfred This library is good, but can I just get the Progress from it? I use a custom control to display download % and this lib could save me a lot of headaches!

Thanks

Aidy
 

aidymp

Well-Known Member
Licensed User
Longtime User
Yes. That´s what the library is made for.

You can for sure start multiple downloads... They all will be put into a queue for the android downloadmanager.

Sorry maybe my questions was unclear, Where is the Download progress value? as in a value I can use to display the progress in my own controls?

Thanks

Aidy
 

Rantor777

Member
Licensed User
Hello.

Can you add add Event DOWNLOAD PROGRESS and Add two exposed variables that returns DownloadedSize and TotalSize ?
 

DonManfred

Expert
Licensed User
Longtime User
Can you add add Event DOWNLOAD PROGRESS and Add two exposed variables that returns DownloadedSize and TotalSize ?
This dude wants to get the progress from the view.
Yes thats what I want! X=DownProgress.Progress!

See new version V1.0.1 and also updated example in post #1
B4X:
Sub DownloadProgress_DownloadProgress(downloadURL As String, bytes_downloaded As Long, bytes_total As Long, download_percentage As Long)
    event_count = event_count +1
    Log($"DLProgress_DownloadProgress(${event_count}: ${downloadURL},${bytes_downloaded},${bytes_total},${download_percentage})"$)
   
End Sub

But in my tries total was always -1 :-/
 

aidymp

Well-Known Member
Licensed User
Longtime User
See new version V1.0.1 and also updated example in post #1
B4X:
Sub DownloadProgress_DownloadProgress(downloadURL As String, bytes_downloaded As Long, bytes_total As Long, download_percentage As Long)
    event_count = event_count +1
    Log($"DLProgress_DownloadProgress(${event_count}: ${downloadURL},${bytes_downloaded},${bytes_total},${download_percentage})"$)
  
End Sub

But in my tries total was always -1 :-/

Excellent!

Thanks

Aidy
 

chefe82

Member
Licensed User
Longtime User
Hallo,
wie lässt sich die Schriftfarbe ändern?
habe es schon mit

download.TotalSizeColor = Colors.White
download.DownloadedSizeColor = Colors.White

Probiert das funktioniert aber nicht
 

DonManfred

Expert
Licensed User
Longtime User
Even if you know i´m a german; this is the english part of the forum. Please write ONLY english here as it will irritate all others which maybe don´t know the german language... Better ask in english or create a thread in the german forum...

Anyway:
See updated Example and docs and new lib V1.0.2 in post #1
 
Top