From 3931eddf6d661c43745a081ef79d97974cb41dbe Mon Sep 17 00:00:00 2001 From: Emily Dixon Date: Wed, 22 May 2024 10:51:58 -0700 Subject: [PATCH] fix: currentStatus always READY (#135) * Fix currentStatus * cleanup builder ctor * More cleanup * Update gradle plugin --- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../java/com/mux/video/upload/api/MuxUpload.kt | 15 ++++----------- .../java/com/mux/video/upload/api/UploadResult.kt | 1 + .../java/com/mux/video/upload/api/UploadStatus.kt | 6 +++--- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index 64bfd76e..0f56ba5e 100644 --- a/build.gradle +++ b/build.gradle @@ -4,8 +4,8 @@ buildscript { } }// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '8.1.2' apply false - id 'com.android.library' version '8.1.2' apply false + id 'com.android.application' version '8.4.0' apply false + id 'com.android.library' version '8.4.0' apply false id 'org.jetbrains.kotlin.android' version '1.9.22' apply false id 'com.mux.gradle.android.mux-android-distribution' version '1.1.2' apply false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d5e1fba2..3155ea18 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Jan 19 16:04:49 PST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/library/src/main/java/com/mux/video/upload/api/MuxUpload.kt b/library/src/main/java/com/mux/video/upload/api/MuxUpload.kt index 3bbf5490..d94c2786 100644 --- a/library/src/main/java/com/mux/video/upload/api/MuxUpload.kt +++ b/library/src/main/java/com/mux/video/upload/api/MuxUpload.kt @@ -37,7 +37,6 @@ import java.io.File class MuxUpload private constructor( private var uploadInfo: UploadInfo, private val autoManage: Boolean = true, - initialStatus: UploadStatus = UploadStatus.Ready ) { /** @@ -60,7 +59,7 @@ class MuxUpload private constructor( * To be notified of status updates (including upload progress), use [setStatusListener] */ @Suppress("MemberVisibilityCanBePrivate") - val uploadStatus: UploadStatus + val uploadStatus: UploadStatus get() = uploadInfo.statusFlow?.value ?: currentStatus /** * True when the upload is running, false if it's paused, failed, or canceled @@ -307,10 +306,6 @@ class MuxUpload private constructor( observerJob = newObserveProgressJob(uploadInfo) } - init { - uploadStatus = initialStatus - } - /** * The current progress of an upload, in terms of time elapsed and data transmitted */ @@ -345,7 +340,7 @@ class MuxUpload private constructor( * @param videoFile a File that represents the video file you want to upload */ @Suppress("MemberVisibilityCanBePrivate") - class Builder constructor(val uploadUri: Uri, val videoFile: File) { + class Builder(val uploadUri: Uri, val videoFile: File) { /** * Create a new Builder with the specified input file and upload URL @@ -354,8 +349,7 @@ class MuxUpload private constructor( * @param videoFile a File that represents the video file you want to upload */ @Suppress("unused") - constructor(uploadUri: String, videoFile: File) - : this(Uri.parse(uploadUri), videoFile) + constructor(uploadUri: String, videoFile: File): this(Uri.parse(uploadUri), videoFile) private var manageTask: Boolean = true private var uploadInfo: UploadInfo = UploadInfo( @@ -446,7 +440,6 @@ class MuxUpload private constructor( * [MuxUploadManager] */ @JvmSynthetic - internal fun create(uploadInfo: UploadInfo, initialStatus: UploadStatus = UploadStatus.Ready) - = MuxUpload(uploadInfo = uploadInfo, initialStatus = initialStatus) + internal fun create(uploadInfo: UploadInfo) = MuxUpload(uploadInfo = uploadInfo) } } diff --git a/library/src/main/java/com/mux/video/upload/api/UploadResult.kt b/library/src/main/java/com/mux/video/upload/api/UploadResult.kt index 31e96440..41ddb334 100644 --- a/library/src/main/java/com/mux/video/upload/api/UploadResult.kt +++ b/library/src/main/java/com/mux/video/upload/api/UploadResult.kt @@ -5,6 +5,7 @@ package com.mux.video.upload.api * * Kotlin callers can use the [Result] API as normal */ +@Suppress("unused") class UploadResult { companion object { diff --git a/library/src/main/java/com/mux/video/upload/api/UploadStatus.kt b/library/src/main/java/com/mux/video/upload/api/UploadStatus.kt index 556150ad..d4df0a55 100644 --- a/library/src/main/java/com/mux/video/upload/api/UploadStatus.kt +++ b/library/src/main/java/com/mux/video/upload/api/UploadStatus.kt @@ -35,19 +35,19 @@ sealed class UploadStatus { /** * This upload hos not been started. It is ready to start by calling [MuxUpload.start] */ - object Ready: UploadStatus() + data object Ready: UploadStatus() /** * This upload has been started via [MuxUpload.start] but has not yet started processing anything */ - object Started: UploadStatus() + data object Started: UploadStatus() /** * This upload is being prepared. If standardization is required, it is done during this step * * @see MuxUpload.Builder.standardizationRequested */ - object Preparing: UploadStatus() + data object Preparing: UploadStatus() /** * The upload is currently being sent to Mux Video. The progress is available