Fix encode message showing when it shouldn't

This commit is contained in:
Matthieu 2023-10-01 16:07:42 +02:00
parent eb014290ff
commit 8268e9e8b5
7 changed files with 18 additions and 18 deletions

View File

@ -1,7 +1,6 @@
package org.pixeldroid.app.postCreation
import android.os.*
import androidx.core.view.WindowCompat
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import org.pixeldroid.app.R

View File

@ -92,6 +92,7 @@ class PostCreationFragment : BaseFragment() {
if(model.storyCreation){
binding.carousel.showCaption = false
//TODO hide grid button, hide dot (indicator), hide arrows, limit photos to 1
}
model.getPhotoData().observe(viewLifecycleOwner) { newPhotoData ->
@ -281,14 +282,16 @@ class PostCreationFragment : BaseFragment() {
private fun validatePost(): Boolean {
if (model.getPhotoData().value?.all { !it.video || it.videoEncodeComplete } == false) {
MaterialAlertDialogBuilder(requireActivity()).apply {
setMessage(R.string.still_encoding)
setNegativeButton(android.R.string.ok) { _, _ -> }
}.show()
return false
if (model.getPhotoData().value?.none { it.video && it.videoEncodeComplete == false } == true) {
// Encoding is done, i.e. none of the items are both a video and not done encoding
return true
}
return true
// Encoding is not done, show a dialog and return false to indicate validation failed
MaterialAlertDialogBuilder(requireActivity()).apply {
setMessage(R.string.still_encoding)
setNegativeButton(android.R.string.ok) { _, _ -> }
}.show()
return false
}
private val editResultContract: ActivityResultLauncher<Intent> = registerForActivityResult(

View File

@ -99,7 +99,7 @@ data class PhotoData(
var video: Boolean,
var videoEncodeProgress: Int? = null,
var videoEncodeStabilizationFirstPass: Boolean? = null,
var videoEncodeComplete: Boolean = true,
var videoEncodeComplete: Boolean? = null,
var videoEncodeError: Boolean = false,
) : Parcelable

View File

@ -8,6 +8,6 @@ data class CarouselItem constructor(
val video: Boolean,
var encodeProgress: Int?,
var stabilizationFirstPass: Boolean?,
var encodeComplete: Boolean = false,
var encodeComplete: Boolean? = null,
var encodeError: Boolean = false,
)

View File

@ -102,7 +102,6 @@ class ImageCarousel(
* ****************************************************************
*/
//FIXME this is modified a bunch of times all over the place, so it can't be set to false and stay there
var showCaption = false
set(value) {
field = value
@ -245,14 +244,14 @@ class ImageCarousel(
showNavigationButtons = showNavigationButtons
binding.editMediaDescriptionLayout.visibility = if(editingMediaDescription) VISIBLE else INVISIBLE
showCaption = !editingMediaDescription
binding.tvCaption.visibility = if(editingMediaDescription || !showCaption) INVISIBLE else VISIBLE
} else {
recyclerView.layoutManager = GridLayoutManager(context, 3)
binding.btnNext.visibility = GONE
binding.btnPrevious.visibility = GONE
binding.editMediaDescriptionLayout.visibility = INVISIBLE
showCaption = false
binding.tvCaption.visibility = INVISIBLE
}
showIndicator = value
@ -279,8 +278,7 @@ class ImageCarousel(
updateDescriptionCallback?.invoke(currentPosition, description)
}
binding.editMediaDescriptionLayout.visibility = if(value) VISIBLE else INVISIBLE
showCaption = !value
binding.tvCaption.visibility = if(value || !showCaption) INVISIBLE else VISIBLE
}
}
@ -561,7 +559,7 @@ class ImageCarousel(
binding.encodeInfoText.setText(R.string.encode_error)
binding.encodeInfoText.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(context, R.drawable.error),
null, null, null)
} else if(it.encodeComplete){
} else if(it.encodeComplete == true){
binding.encodeInfoCard.visibility = VISIBLE
binding.encodeProgress.visibility = GONE
binding.encodeInfoText.setText(R.string.encode_success)

View File

@ -11,7 +11,7 @@
android:id="@+id/carousel"
android:layout_width="match_parent"
android:layout_height="0dp"
app:showCaption="false"
app:showCaption="true"
app:layout_constraintBottom_toTopOf="@+id/buttonConstraints"
app:layout_constraintTop_toTopOf="parent"/>

View File

@ -7,7 +7,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong