DownloadProgressActivity

public final class DownloadProgressActivity extends AppCompatActivity

DownloadProgressActivity handles the downloading of model files required for the SenseCrypt SDK.

Key Features:

  1. Progress Bar UI: Shows real-time download progress

  2. Error Handling: Uses UIHelper for consistent error presentation

  3. Download Management: Handles model file downloads and status checks

  4. Cleanup: Properly cleans up resources on error/cancellation

Error Handling Strategy:

  • All errors (network, server, etc.) are treated as unrecoverable

  • No retry option is provided to ensure clean app state

  • If error occurs during initial app launch (from MainActivity):

  • Shows error dialog

  • On dialog close, finishes all activities (closes app)

  • If error occurs during manual download (from Settings):

  • Shows error dialog

  • On dialog close, returns to previous screen

Download Process:

  1. Start download session

  2. Monitor download progress

  3. On completion: Initialize SDK and proceed

  4. On error: Show dialog and close/return based on launch source

Constructors

Types

Link copied to clipboard
public class Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
private Job downloadJob
Link copied to clipboard
private final static String EXTRA_FROM_MAIN
Link copied to clipboard
private final FileDownloadInfo frModelBin
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
private final Unit downloadFiles(String fileURl)

Initiates the download of required model files.

Link copied to clipboard
private final String downloadFilesIfNeeded(Context context)

Checks if the directory exist and if not then it will create a directory in the application folder

Link copied to clipboard
Link copied to clipboard
private final Job getDownloadJob()
Link copied to clipboard
private final FileDownloadInfo getFrModelBin()
Link copied to clipboard
private final ProgressBar getProgressBar()
Link copied to clipboard
private final Unit initSDK()

Initializes the SDK in a background thread and shows a loading dialog. This ensures the SDK is set up correctly after switching modes.

Link copied to clipboard
private final Boolean isFetchingStatus()
Link copied to clipboard
protected Unit onCreate(Bundle savedInstanceState)
Link copied to clipboard
private final Unit onDownloadCompleted()

This function gets executed when the models download have been completed

Link copied to clipboard
private final Unit setCancelButton(AppCompatButton cancelButton)
Link copied to clipboard
private final Unit setDownloadJob(Job downloadJob)
Link copied to clipboard
private final Unit setFetchingStatus(Boolean isFetchingStatus)
Link copied to clipboard
private final Unit setProgressBar(ProgressBar progressBar)
Link copied to clipboard
private final Unit setupComponents()
Link copied to clipboard
private final Unit setUpListeners()
Link copied to clipboard
private final Unit stopDownloadSession()

When the cancel button is clicked or exception have been thrown during download session this function gets executed

Link copied to clipboard
private final Unit updateDownloadProgress()

Monitors and updates the download progress.