Skip to content

Commit

Permalink
Fix accessibility issues and some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Oct 8, 2024
1 parent 5f2a3f3 commit 30f76ac
Show file tree
Hide file tree
Showing 55 changed files with 164 additions and 80 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/src/debug/java/org/akanework/gramophone/SdScanner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SdScanner(private val context: Context) {
}
}
}
if (filesToProcess.size == 0) {
if (filesToProcess.isEmpty()) {
scannerEnded()
} else {
val pathsToProcess = filesToProcess.map { it.absolutePath }.toMutableList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import android.util.Log
import android.view.View
import androidx.appcompat.content.res.AppCompatResources
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.doOnLayout
import androidx.recyclerview.widget.ConcatAdapter
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ object LrcUtils {
markTranslations(lyricsList)

lyricsList.takeWhile { it.content.isEmpty() }
.forEach { _ -> lyricsList.removeFirst() }
.forEach { _ -> lyricsList.removeAt(0) }

if (lyricsList.isEmpty() && lrcContent.isNotEmpty()) {
lyricsList.add(MediaStoreUtils.Lyric(null, lrcContent, false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.akanework.gramophone.ui

import android.app.NotificationManager
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ abstract class BaseAdapter<T>(
else comparator?.compare(o1, o2) ?: 0
}
}
val diff = if (((list.size != 0 && newList.size != 0) || allowDiffUtils) && canDiff)
val diff = if (((list.isNotEmpty() && newList.isNotEmpty()) || allowDiffUtils) && canDiff)
DiffUtil.calculateDiff(SongDiffCallback(list, newList)) else null
val oldCount = list.size
val newCount = newList.size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ open class BaseDecorAdapter<T : BaseAdapter<*>>(
shuffleModeEnabled = false
repeatMode = REPEAT_MODE_OFF
setMediaItems(songList, 0, C.TIME_UNSET)
if (songList.size > 0) {
if (songList.isNotEmpty()) {
prepare()
play()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class DetailedFolderAdapter(
override fun getItemCount(): Int = if (enabled) 1 else 0
}

private abstract class FolderCardAdapter(protected val folderFragment: DetailedFolderAdapter) :
private abstract class FolderCardAdapter(val folderFragment: DetailedFolderAdapter) :
MyRecyclerView.Adapter<FolderCardAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder =
ViewHolder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class FolderAdapter(
override fun getItemCount(): Int = if (enabled) 1 else 0
}

private abstract class FolderCardAdapter(protected val folderFragment: FolderAdapter) :
private abstract class FolderCardAdapter(val folderFragment: FolderAdapter) :
MyRecyclerView.Adapter<FolderCardAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder =
ViewHolder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class FullBottomSheet
instance?.addListener(this@FullBottomSheet)
updateTimer()
onRepeatModeChanged(instance?.repeatMode ?: Player.REPEAT_MODE_OFF)
onShuffleModeEnabledChanged(instance?.shuffleModeEnabled ?: false)
onShuffleModeEnabledChanged(instance?.shuffleModeEnabled == true)
onPlaybackStateChanged(instance?.playbackState ?: Player.STATE_IDLE)
onMediaItemTransition(
instance?.currentMediaItem,
Expand Down Expand Up @@ -561,11 +561,11 @@ class FullBottomSheet
private fun refreshSettings(key: String?) {
if (key == null || key == "default_progress_bar") {
if (prefs.getBooleanStrict("default_progress_bar", false)) {
bottomSheetFullSlider.visibility = View.VISIBLE
bottomSheetFullSeekBar.visibility = View.GONE
bottomSheetFullSlider.visibility = VISIBLE
bottomSheetFullSeekBar.visibility = GONE
} else {
bottomSheetFullSlider.visibility = View.GONE
bottomSheetFullSeekBar.visibility = View.VISIBLE
bottomSheetFullSlider.visibility = GONE
bottomSheetFullSeekBar.visibility = VISIBLE
}
}
if (key == null || key == "centered_title") {
Expand Down Expand Up @@ -1086,19 +1086,19 @@ class FullBottomSheet
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): LyricAdapter.ViewHolder =
): ViewHolder =
ViewHolder(
LayoutInflater
.from(parent.context)
.inflate(R.layout.lyrics, parent, false),
)

override fun onBindViewHolder(holder: LyricAdapter.ViewHolder, position: Int) {
override fun onBindViewHolder(holder: ViewHolder, position: Int) {

}

override fun onBindViewHolder(
holder: LyricAdapter.ViewHolder,
holder: ViewHolder,
position: Int,
payloads: MutableList<Any>
) {
Expand All @@ -1123,7 +1123,7 @@ class FullBottomSheet
}

with(holder.lyricTextView) {
visibility = if (lyric.content.isNotEmpty()) View.VISIBLE else View.GONE
visibility = if (lyric.content.isNotEmpty()) VISIBLE else GONE
text = lyric.content
gravity = if (isLyricCentered) Gravity.CENTER else Gravity.START
translationY = 0f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,29 +164,29 @@ class PlayerBottomSheet private constructor(
) {
when (newState) {
BottomSheetBehavior.STATE_COLLAPSED -> {
fullPlayer.visibility = View.GONE
previewPlayer.visibility = View.VISIBLE
fullPlayer.visibility = GONE
previewPlayer.visibility = VISIBLE
previewPlayer.alpha = 1f
fullPlayer.alpha = 0f
bottomSheetBackCallback!!.isEnabled = false
}

BottomSheetBehavior.STATE_DRAGGING, BottomSheetBehavior.STATE_SETTLING -> {
fullPlayer.visibility = View.VISIBLE
previewPlayer.visibility = View.VISIBLE
fullPlayer.visibility = VISIBLE
previewPlayer.visibility = VISIBLE
}

BottomSheetBehavior.STATE_EXPANDED, BottomSheetBehavior.STATE_HALF_EXPANDED -> {
previewPlayer.visibility = View.GONE
fullPlayer.visibility = View.VISIBLE
previewPlayer.visibility = GONE
fullPlayer.visibility = VISIBLE
previewPlayer.alpha = 0f
fullPlayer.alpha = 1f
bottomSheetBackCallback!!.isEnabled = true
}

BottomSheetBehavior.STATE_HIDDEN -> {
previewPlayer.visibility = View.GONE
fullPlayer.visibility = View.GONE
previewPlayer.visibility = GONE
fullPlayer.visibility = GONE
previewPlayer.alpha = 0f
fullPlayer.alpha = 0f
bottomSheetBackCallback!!.isEnabled = false
Expand Down Expand Up @@ -219,7 +219,7 @@ class PlayerBottomSheet private constructor(
bottomSheetBackCallback = object : OnBackPressedCallback(enabled = false) {
override fun handleOnBackStarted(backEvent: BackEventCompat) {
if (fullPlayer.bottomSheetFullLyricRecyclerView.visibility ==
View.VISIBLE
VISIBLE
) {
fullPlayer.bottomSheetFullLyricRecyclerView.fadOutAnimation(FullBottomSheet.LYRIC_FADE_TRANSITION_SEC)
fullPlayer.bottomSheetLyricButton.isChecked = false
Expand All @@ -230,7 +230,7 @@ class PlayerBottomSheet private constructor(

override fun handleOnBackProgressed(backEvent: BackEventCompat) {
if (fullPlayer.bottomSheetFullLyricRecyclerView.visibility ==
View.VISIBLE
VISIBLE
) {
// TODO
} else {
Expand All @@ -240,7 +240,7 @@ class PlayerBottomSheet private constructor(

override fun handleOnBackPressed() {
if (fullPlayer.bottomSheetFullLyricRecyclerView.visibility ==
View.VISIBLE
VISIBLE
) {
fullPlayer.bottomSheetFullLyricRecyclerView.fadOutAnimation(FullBottomSheet.LYRIC_FADE_TRANSITION_SEC)
fullPlayer.bottomSheetLyricButton.isChecked = false
Expand All @@ -251,7 +251,7 @@ class PlayerBottomSheet private constructor(

override fun handleOnBackCancelled() {
if (fullPlayer.bottomSheetFullLyricRecyclerView.visibility ==
View.VISIBLE
VISIBLE
) {
fullPlayer.bottomSheetFullLyricRecyclerView.fadInAnimation(FullBottomSheet.LYRIC_FADE_TRANSITION_SEC)
fullPlayer.bottomSheetLyricButton.isChecked = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import androidx.recyclerview.widget.ItemTouchHelper.DOWN
import androidx.recyclerview.widget.ItemTouchHelper.UP
import androidx.recyclerview.widget.RecyclerView
import org.akanework.gramophone.R
import org.akanework.gramophone.logic.replaceAllSupport
import org.akanework.gramophone.logic.ui.MyRecyclerView
import org.akanework.gramophone.ui.adapters.ViewPager2Adapter.Companion.mapSettingToTabList
import org.akanework.gramophone.ui.adapters.ViewPager2Adapter.Companion.mapTabListToSetting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class DetailDialogFragment : BaseFragment(false) {
if (mediaMetadata.releaseYear != null || mediaMetadata.recordingYear != null) {
yearTextView.text = (mediaMetadata.releaseYear ?: mediaMetadata.recordingYear)?.toLocaleString()
}
mediaMetadata.durationMs?.let { durationTextView.text = convertDurationToTimeStamp(it) }
mediaMetadata.durationMs?.let { durationTextView.text = convertDurationToTimeStamp(it) }
mimeTypeTextView.text = mediaItem.localConfiguration?.mimeType ?: "(null)"
pathTextView.text = mediaItem.getFile()?.path
?: mediaItem.requestMetadata.mediaUri?.toString() ?: "(null)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ class SearchFragment : BaseFragment(false) {
filteredList.clear()
// Filter the library.
libraryViewModel.mediaItemList.value?.filter {
val isMatchingTitle = it.mediaMetadata.title?.contains(text, true) ?: false
val isMatchingTitle = it.mediaMetadata.title?.contains(text, true) == true
val isMatchingAlbum =
it.mediaMetadata.albumTitle?.contains(text, true) ?: false
it.mediaMetadata.albumTitle?.contains(text, true) == true
val isMatchingArtist =
it.mediaMetadata.artist?.contains(text, true) ?: false
it.mediaMetadata.artist?.contains(text, true) == true
isMatchingTitle || isMatchingAlbum || isMatchingArtist
}?.let {
filteredList.addAll(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import org.akanework.gramophone.R
import org.akanework.gramophone.logic.clone
import org.akanework.gramophone.logic.dpToPx
import org.akanework.gramophone.logic.enableEdgeToEdgePaddingListener
import org.akanework.gramophone.logic.getSessionId
import org.akanework.gramophone.logic.needsManualSnackBarInset
Expand Down
27 changes: 25 additions & 2 deletions app/src/main/res/layout-land/full_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:background="@drawable/rp_buttons"
android:tooltipText="@string/expand_less"
android:contentDescription="@string/expand_less"
app:icon="@drawable/ic_expand_more"
app:iconGravity="textStart"
app:iconPadding="0dp"
Expand Down Expand Up @@ -122,14 +124,16 @@
android:id="@+id/slider_squiggly"
style="@style/MediaPlayer.ProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="48dp"
android:layout_gravity="center"
android:progress="0"
android:thumbTint="?attr/colorPrimary"
android:visibility="gone"
android:contentDescription="@string/position_slider"
app:labelBehavior="gone"
tools:progress="20"
tools:visibility="visible" />
tools:visibility="visible"
tools:ignore="DuplicateClickableBoundsCheck" />

<com.google.android.material.slider.Slider
android:id="@+id/slider_vert"
Expand All @@ -138,6 +142,7 @@
android:layout_gravity="center"
android:value="0"
android:visibility="gone"
android:contentDescription="@string/position_slider"
app:labelBehavior="gone"
style="@style/Widget.Material3.Slider.Legacy"
app:thumbElevation="0dp"
Expand Down Expand Up @@ -193,6 +198,8 @@
android:insetTop="0dp"
android:insetRight="0dp"
android:insetBottom="0dp"
android:tooltipText="@string/play"
android:contentDescription="@string/play"
app:backgroundTint="?attr/colorSecondaryContainer"
app:icon="@drawable/play_anim"
app:iconGravity="textStart"
Expand All @@ -216,6 +223,8 @@
android:insetTop="0dp"
android:insetRight="0dp"
android:insetBottom="0dp"
android:tooltipText="@string/skip_previous"
android:contentDescription="@string/skip_previous"
app:icon="@drawable/ic_skip_previous"
app:iconGravity="textStart"
app:iconPadding="0dp"
Expand All @@ -239,6 +248,8 @@
android:insetTop="0dp"
android:insetRight="0dp"
android:insetBottom="0dp"
android:tooltipText="@string/skip_next"
android:contentDescription="@string/skip_next"
app:icon="@drawable/ic_skip_next"
app:iconGravity="textStart"
app:iconPadding="0dp"
Expand Down Expand Up @@ -277,6 +288,8 @@
android:insetRight="0dp"
android:insetBottom="0dp"
android:saveEnabled="false"
android:tooltipText="@string/dialog_lyrics"
android:contentDescription="@string/dialog_lyrics"
app:icon="@drawable/ic_article"
app:iconGravity="textStart"
app:iconPadding="0dp"
Expand All @@ -295,6 +308,8 @@
android:insetRight="0dp"
android:insetBottom="0dp"
android:saveEnabled="false"
android:tooltipText="@string/repeat_mode"
android:contentDescription="@string/repeat_mode"
app:icon="@drawable/ic_repeat"
app:iconGravity="textStart"
app:iconPadding="0dp"
Expand All @@ -313,6 +328,8 @@
android:insetRight="0dp"
android:insetBottom="0dp"
android:saveEnabled="false"
android:tooltipText="@string/shuffle"
android:contentDescription="@string/shuffle"
app:icon="@drawable/ic_shuffle"
app:iconGravity="textStart"
app:iconPadding="0dp"
Expand All @@ -332,6 +349,8 @@
android:insetBottom="0dp"
android:saveEnabled="false"
android:visibility="gone"
android:tooltipText="@string/playlist_favourite"
android:contentDescription="@string/playlist_favourite"
app:icon="@drawable/sl_check_fav"
app:iconGravity="textStart"
app:iconPadding="0dp"
Expand All @@ -350,6 +369,8 @@
android:insetRight="0dp"
android:insetBottom="0dp"
android:saveEnabled="false"
android:tooltipText="@string/timer"
android:contentDescription="@string/timer"
app:toggleCheckedStateOnClick="false"
app:icon="@drawable/sl_check_timer"
app:iconGravity="textStart"
Expand All @@ -367,6 +388,8 @@
android:insetTop="0dp"
android:insetRight="0dp"
android:insetBottom="0dp"
android:tooltipText="@string/current_playlist"
android:contentDescription="@string/current_playlist"
app:icon="@drawable/ic_playlist_play"
app:iconGravity="textStart"
app:iconPadding="0dp"
Expand Down
12 changes: 8 additions & 4 deletions app/src/main/res/layout/activity_audio_preview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
app:layout_constraintBottom_toTopOf="@id/artist_text_view"
app:layout_constraintEnd_toStartOf="@id/play_pause_replay_button"
app:layout_constraintStart_toEndOf="@id/coverCardView"
app:layout_constraintTop_toTopOf="@id/coverCardView" />
app:layout_constraintTop_toTopOf="@id/coverCardView"
tools:ignore="SpeakableTextPresentCheck" />

<org.akanework.gramophone.ui.components.MarqueeTextView
android:id="@+id/artist_text_view"
Expand All @@ -62,12 +63,13 @@
app:layout_constraintEnd_toStartOf="@id/play_pause_replay_button"
app:layout_constraintStart_toEndOf="@id/coverCardView"
app:layout_constraintTop_toBottomOf="@id/title_text_view"
app:layout_constraintVertical_chainStyle="packed" />
app:layout_constraintVertical_chainStyle="packed"
tools:ignore="SpeakableTextPresentCheck" />

<com.google.android.material.button.MaterialButton
android:id="@+id/play_pause_replay_button"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginEnd="16dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:insetLeft="0dp"
Expand All @@ -76,6 +78,8 @@
android:insetBottom="0dp"
android:padding="4dp"
android:src="@drawable/ic_play_arrow"
android:tooltipText="@string/play"
android:contentDescription="@string/play"
app:icon="@drawable/play_anim"
app:iconGravity="textStart"
app:iconPadding="0dp"
Expand Down
Loading

0 comments on commit 30f76ac

Please sign in to comment.