Skip to content

Commit

Permalink
Releases/v0.4.1 (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
daytime-em authored Jul 21, 2023
1 parent 07cd966 commit 796e4d6
Show file tree
Hide file tree
Showing 18 changed files with 1,101 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ object ImaginaryBackend {
// note: You shouldn't do basic auth with hard-coded keys in a real app
private fun basicCredential(): String = Credentials.basic(ACCESS_TOKEN_ID, ACCESS_TOKEN_SECRET)

private const val ACCESS_TOKEN_ID = "YOUR ACCESS TOKEN ID HERE"
private const val ACCESS_TOKEN_ID = "YOUR TOKEN ID HERE"
private const val ACCESS_TOKEN_SECRET = "YOUR TOKEN SECRET HERE"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PlainViewListExampleActivity : AppCompatActivity() {
{ grantedPermissions ->
if (!grantedPermissions.containsKey(android.Manifest.permission.READ_EXTERNAL_STORAGE)
|| grantedPermissions.containsKey(android.Manifest.permission.READ_MEDIA_VIDEO)
|| grantedPermissions.containsKey(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
) {
maybeRequestPermissionsApi33()
}
Expand Down Expand Up @@ -84,10 +85,18 @@ class PlainViewListExampleActivity : AppCompatActivity() {
this,
android.Manifest.permission.READ_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED
val hasWriteStorage =
ActivityCompat.checkSelfPermission(
this,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED

if (!hasReadStorage) {
requestPermissions.launch(arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE))
}
if (!hasWriteStorage) {
requestPermissions.launch(arrayOf(android.Manifest.permission.WRITE_EXTERNAL_STORAGE))
}
}

@TargetApi(Build.VERSION_CODES.TIRAMISU)
Expand All @@ -101,12 +110,17 @@ class PlainViewListExampleActivity : AppCompatActivity() {
this,
android.Manifest.permission.READ_MEDIA_VIDEO
) == PackageManager.PERMISSION_GRANTED
val hasWriteStorage = ActivityCompat.checkSelfPermission(
this,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED

if (!hasReadVideo || !hasReadStorage) {
if (!hasReadVideo || !hasReadStorage || ! hasWriteStorage) {
requestPermissions.launch(
arrayOf(
android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.READ_MEDIA_VIDEO
android.Manifest.permission.READ_MEDIA_VIDEO,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ class UploadListAdapter(

override fun onBindViewHolder(holder: MediaStoreVideoViewHolder, position: Int) {
val listItem = items[position]
val elapsedTime = listItem.currentState.updatedTime - listItem.currentState.startTime
val bytesPerMs = listItem.currentState.bytesUploaded / elapsedTime.toDouble()
val stateMsg = if (listItem.currentState.bytesUploaded >= listItem.currentState.totalBytes) {
val elapsedTime = listItem.currentProgress.updatedTime - listItem.currentProgress.startTime
val bytesPerMs = listItem.currentProgress.bytesUploaded / elapsedTime.toDouble()
val stateMsg = if (listItem.currentProgress.bytesUploaded >= listItem.currentProgress.totalBytes) {
"done"
} else {
"not done"
}
val progressPercent =
(listItem.currentState.bytesUploaded / listItem.currentState.totalBytes.toDouble()) * 100.0
(listItem.currentProgress.bytesUploaded / listItem.currentProgress.totalBytes.toDouble()) * 100.0
val df = DecimalFormat("#.00")
val formattedRate = df.format(bytesPerMs)

Expand All @@ -40,7 +40,7 @@ class UploadListAdapter(
holder.viewBinding.mediastoreVideoProgress.max = 100
holder.viewBinding.mediastoreVideoFilename.text = listItem.videoFile.absolutePath
holder.viewBinding.mediastoreVideoDate.text =
"${listItem.currentState.bytesUploaded} bytes in ${elapsedTime / 1000F} s elapsed "
"${listItem.currentProgress.bytesUploaded} bytes in ${elapsedTime / 1000F} s elapsed "
holder.viewBinding.mediastoreVideoFilesize.text = "${formattedRate} KBytes/s"

if (listItem.isRunning) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,16 @@ private fun RequestPermissionsEffect(context: Context) {
launcher.launch(
arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.READ_MEDIA_VIDEO
Manifest.permission.READ_MEDIA_VIDEO,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
)
} else {
launcher.launch(
arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE)
arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE
)
)
}
} // MainScope().launch {
Expand Down Expand Up @@ -293,10 +297,18 @@ private fun hasPermissions(context: Context): Boolean {
context,
Manifest.permission.READ_MEDIA_VIDEO
) == PackageManager.PERMISSION_GRANTED
ContextCompat.checkSelfPermission(
context,
Manifest.permission.WRITE_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED
} else {
ContextCompat.checkSelfPermission(
context,
Manifest.permission.READ_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED
ContextCompat.checkSelfPermission(
context,
Manifest.permission.WRITE_EXTERNAL_STORAGE
) == PackageManager.PERMISSION_GRANTED
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private fun ListItemContent(upload: MuxUpload) {
ErrorOverlay(modifier = Modifier.fillMaxSize())
} else if (upload.isRunning) {
ProgressOverlay(
upload.currentState,
upload.currentProgress,
modifier = Modifier
.align(Alignment.BottomStart)
.fillMaxWidth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,5 @@ class CreateUploadViewModel(private val app: Application) : AndroidViewModel(app
val thumbnail: Bitmap? = null,
val uploadUri: Uri? = null
)

}
1 change: 1 addition & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ muxDistribution {
dependencies {
implementation "com.squareup.okhttp3:logging-interceptor:4.11.0"
implementation "com.squareup.okhttp3:okhttp:4.11.0"
implementation "io.github.crow-misia.libyuv:libyuv-android:0.27.0"

implementation 'androidx.core:core-ktx:1.10.1'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.2"
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/java/com/mux/video/upload/MuxUploadSdk.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ object MuxUploadSdk {
@Suppress("unused")
@JvmOverloads
fun initialize(appContext: Context, resumeStoppedUploads: Boolean = true) {
MuxUploadManager.appContext = appContext;
initializeUploadPersistence(appContext)
UploadMetrics.initialize(appContext)

if (resumeStoppedUploads) {
val upl = MuxUploadManager.resumeAllCachedJobs()
MuxUploadManager.resumeAllCachedJobs()
}
}

Expand Down
Loading

0 comments on commit 796e4d6

Please sign in to comment.