home: fix misaligned grant/retry button

Caused by naive visibility logic when I added the "More" button prior.

Resolves #544.
This commit is contained in:
Alexander Capehart 2023-08-15 20:48:17 -06:00
parent e912120f9f
commit e32fc6b609
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 39 additions and 36 deletions

View file

@ -335,7 +335,6 @@ class HomeFragment :
logD("Received ok response")
binding.homeFab.show()
binding.homeIndexingContainer.visibility = View.INVISIBLE
binding.homeIndexingError.visibility = View.INVISIBLE
return
}
@ -343,13 +342,13 @@ class HomeFragment :
val context = requireContext()
binding.homeIndexingContainer.visibility = View.VISIBLE
binding.homeIndexingProgress.visibility = View.INVISIBLE
binding.homeIndexingActions.visibility = View.VISIBLE
when (error) {
is NoAudioPermissionException -> {
logD("Showing permission prompt")
binding.homeIndexingStatus.text = context.getString(R.string.err_no_perms)
// Configure the action to act as a permission launcher.
binding.homeIndexingAction.apply {
visibility = View.VISIBLE
binding.homeIndexingTry.apply {
text = context.getString(R.string.lbl_grant)
setOnClickListener {
requireNotNull(storagePermissionLauncher) {
@ -358,29 +357,29 @@ class HomeFragment :
.launch(PERMISSION_READ_AUDIO)
}
}
binding.homeIndexingError.visibility = View.INVISIBLE
binding.homeIndexingMore.visibility = View.GONE
}
is NoMusicException -> {
logD("Showing no music error")
binding.homeIndexingStatus.text = context.getString(R.string.err_no_music)
// Configure the action to act as a reload trigger.
binding.homeIndexingAction.apply {
binding.homeIndexingTry.apply {
visibility = View.VISIBLE
text = context.getString(R.string.lbl_retry)
setOnClickListener { musicModel.refresh() }
}
binding.homeIndexingError.visibility = View.INVISIBLE
binding.homeIndexingMore.visibility = View.GONE
}
else -> {
logD("Showing generic error")
binding.homeIndexingStatus.text = context.getString(R.string.err_index_failed)
// Configure the action to act as a reload trigger.
binding.homeIndexingAction.apply {
binding.homeIndexingTry.apply {
visibility = View.VISIBLE
text = context.getString(R.string.lbl_retry)
setOnClickListener { musicModel.rescan() }
}
binding.homeIndexingError.apply {
binding.homeIndexingMore.apply {
visibility = View.VISIBLE
setOnClickListener {
findNavController().navigateSafe(HomeFragmentDirections.reportError(error))
@ -394,7 +393,7 @@ class HomeFragment :
// Remove all content except for the progress indicator.
binding.homeIndexingContainer.visibility = View.VISIBLE
binding.homeIndexingProgress.visibility = View.VISIBLE
binding.homeIndexingAction.visibility = View.INVISIBLE
binding.homeIndexingActions.visibility = View.INVISIBLE
when (progress) {
is IndexingProgress.Indeterminate -> {

View file

@ -29,6 +29,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.async
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.coroutines.yield

View file

@ -70,8 +70,8 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="@dimen/spacing_medium"
android:fitsSystemWindows="true"
android:visibility="invisible">
android:visibility="invisible"
android:fitsSystemWindows="true">
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
@ -90,7 +90,7 @@
android:layout_margin="@dimen/spacing_medium"
android:gravity="center"
android:textAppearance="@style/TextAppearance.Auxio.BodyLarge"
app:layout_constraintBottom_toTopOf="@+id/home_indexing_action"
app:layout_constraintBottom_toTopOf="@+id/home_indexing_actions"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:text="Status" />
@ -103,37 +103,40 @@
android:layout_marginEnd="@dimen/spacing_medium"
android:indeterminate="true"
app:indeterminateAnimationType="disjoint"
app:layout_constraintBottom_toBottomOf="@+id/home_indexing_action"
app:layout_constraintTop_toTopOf="@+id/home_indexing_action" />
app:layout_constraintBottom_toBottomOf="@+id/home_indexing_actions"
app:layout_constraintTop_toTopOf="@+id/home_indexing_actions" />
<org.oxycblt.auxio.ui.RippleFixMaterialButton
android:id="@+id/home_indexing_action"
android:layout_width="0dp"
<LinearLayout
android:id="@+id/home_indexing_actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_small"
android:layout_marginEnd="@dimen/spacing_medium"
android:layout_marginBottom="@dimen/spacing_medium"
android:text="@string/lbl_retry"
style="@style/Widget.Auxio.Button.Secondary"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/home_indexing_error"
app:layout_constraintTop_toBottomOf="@+id/home_indexing_status" />
tools:layout_editor_absoluteX="16dp">
<org.oxycblt.auxio.ui.RippleFixMaterialButton
android:id="@+id/home_indexing_error"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_small"
android:layout_marginEnd="@dimen/spacing_medium"
android:text="@string/lbl_show_error_info"
style="@style/Widget.Auxio.Button.Primary"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/home_indexing_action"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/home_indexing_action"
app:layout_constraintTop_toTopOf="@+id/home_indexing_action" />
<org.oxycblt.auxio.ui.RippleFixMaterialButton
android:id="@+id/home_indexing_try"
style="@style/Widget.Auxio.Button.Primary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_small"
android:layout_weight="1"
android:text="@string/lbl_retry" />
<org.oxycblt.auxio.ui.RippleFixMaterialButton
android:id="@+id/home_indexing_more"
style="@style/Widget.Auxio.Button.Secondary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_small"
android:layout_weight="1"
android:text="@string/lbl_show_error_info" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>