mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Merge pull request #4472 from FineFindus/feat/tooltips
feat: add tooltips to various icon buttons for better accessibility
This commit is contained in:
commit
eef864a819
@ -19,11 +19,11 @@ import com.github.libretube.obj.NewPipeSubscription
|
||||
import com.github.libretube.obj.NewPipeSubscriptions
|
||||
import com.github.libretube.obj.PipedImportPlaylist
|
||||
import com.github.libretube.obj.PipedImportPlaylistFile
|
||||
import java.util.stream.Collectors
|
||||
import kotlin.streams.toList
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.json.decodeFromStream
|
||||
import kotlinx.serialization.json.encodeToStream
|
||||
import java.util.stream.Collectors
|
||||
|
||||
object ImportHelper {
|
||||
/**
|
||||
|
@ -62,7 +62,11 @@ class AddToPlaylistDialog(
|
||||
if (playlists.isEmpty()) return@repeatOnLifecycle
|
||||
|
||||
binding.playlistsSpinner.adapter =
|
||||
ArrayAdapter(requireContext(), R.layout.dropdown_item, playlists.map { it.name!! })
|
||||
ArrayAdapter(
|
||||
requireContext(),
|
||||
R.layout.dropdown_item,
|
||||
playlists.map { it.name!! }
|
||||
)
|
||||
|
||||
// select the last used playlist
|
||||
viewModel.lastSelectedPlaylistId?.let { id ->
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.github.libretube.ui.extensions
|
||||
|
||||
import android.os.Build
|
||||
import android.widget.ImageView
|
||||
|
||||
/**
|
||||
* Attempts to set the tooltip for the ImageView.
|
||||
* If the OS does not support tooltips, this function will have no effect.
|
||||
* @param tooltip The tooltip of the image
|
||||
*/
|
||||
fun ImageView.trySetTooltip(tooltip: String) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
tooltipText = tooltip
|
||||
}
|
||||
}
|
@ -49,6 +49,7 @@ import com.github.libretube.helpers.PreferenceHelper
|
||||
import com.github.libretube.obj.BottomSheetItem
|
||||
import com.github.libretube.ui.base.BaseActivity
|
||||
import com.github.libretube.ui.extensions.toggleSystemBars
|
||||
import com.github.libretube.ui.extensions.trySetTooltip
|
||||
import com.github.libretube.ui.interfaces.PlayerGestureOptions
|
||||
import com.github.libretube.ui.interfaces.PlayerOptions
|
||||
import com.github.libretube.ui.listeners.PlayerGestureController
|
||||
@ -127,13 +128,15 @@ open class CustomExoPlayerView(
|
||||
// locking the player
|
||||
binding.lockPlayer.setOnClickListener {
|
||||
// change the locked/unlocked icon
|
||||
binding.lockPlayer.setImageResource(
|
||||
if (!isPlayerLocked) {
|
||||
R.drawable.ic_locked
|
||||
} else {
|
||||
R.drawable.ic_unlocked
|
||||
}
|
||||
)
|
||||
val icon = if (!isPlayerLocked) R.drawable.ic_locked else R.drawable.ic_unlocked
|
||||
val tooltip = if (!isPlayerLocked) {
|
||||
R.string.tooltip_unlocked
|
||||
} else {
|
||||
R.string.tooltip_locked
|
||||
}
|
||||
|
||||
binding.lockPlayer.setImageResource(icon)
|
||||
binding.lockPlayer.trySetTooltip(context.getString(tooltip))
|
||||
|
||||
// show/hide all the controls
|
||||
lockPlayer(isPlayerLocked)
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/notification_bell"
|
||||
android:tooltipText="@string/notifications"
|
||||
style="@style/ElevatedIconButton"
|
||||
android:layout_gravity="center"
|
||||
app:icon="@drawable/ic_notification"
|
||||
|
@ -54,6 +54,7 @@
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/btnScrollToTop"
|
||||
android:tooltipText="@string/tooltip_scroll_to_top"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
@ -64,6 +65,7 @@
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/btnClose"
|
||||
android:tooltipText="@string/tooltip_close"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close_imageButton"
|
||||
android:tooltipText="@string/tooltip_minimize"
|
||||
style="@style/PlayerControlTop"
|
||||
android:layout_marginEnd="-10dp"
|
||||
android:src="@drawable/ic_close"
|
||||
@ -68,6 +69,7 @@
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/autoPlay"
|
||||
android:tooltipText="@string/player_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="2dp"
|
||||
@ -81,6 +83,7 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/sb_toggle"
|
||||
android:tooltipText="@string/tooltip_sponsorblock"
|
||||
style="@style/PlayerControlTop"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:src="@drawable/ic_sb_enabled"
|
||||
@ -89,6 +92,7 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/queue_toggle"
|
||||
android:tooltipText="@string/queue"
|
||||
style="@style/PlayerControlTop"
|
||||
android:layout_marginEnd="2dp"
|
||||
android:src="@drawable/ic_queue"
|
||||
@ -97,6 +101,7 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/toggle_options"
|
||||
android:tooltipText="@string/tooltip_options"
|
||||
style="@style/PlayerControlTop"
|
||||
android:src="@drawable/ic_player_settings"
|
||||
app:tint="@android:color/white" />
|
||||
@ -311,6 +316,7 @@
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/fullscreen"
|
||||
android:tooltipText="@string/tooltip_fullscreen"
|
||||
style="@style/PlayerControlBottom"
|
||||
android:src="@drawable/ic_fullscreen"
|
||||
app:tint="@android:color/white" />
|
||||
|
@ -72,12 +72,14 @@
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/channel_share"
|
||||
android:tooltipText="@string/share"
|
||||
style="@style/ElevatedIconButton"
|
||||
app:icon="@drawable/ic_share"
|
||||
tools:targetApi="m" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/notification_bell"
|
||||
android:tooltipText="@string/notifications"
|
||||
style="@style/ElevatedIconButton"
|
||||
app:icon="@drawable/ic_notification"
|
||||
tools:targetApi="m" />
|
||||
|
@ -96,6 +96,7 @@
|
||||
<TextView
|
||||
android:id="@+id/sortTV"
|
||||
android:layout_width="0dp"
|
||||
android:tooltipText="@string/tooltip_sort"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawablePadding="5dp"
|
||||
@ -182,6 +183,7 @@
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/create_playlist"
|
||||
android:tooltipText="@string/tooltip_create_playlist"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
|
@ -367,6 +367,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/close_imageView"
|
||||
android:tooltipText="@string/tooltip_close"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0"
|
||||
@ -380,6 +381,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/play_imageView"
|
||||
android:tooltipText="@string/tooltip_play"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0"
|
||||
|
@ -106,6 +106,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/filterTV"
|
||||
android:tooltipText="@string/tooltip_filter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
@ -118,6 +119,7 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sortTV"
|
||||
android:tooltipText="@string/tooltip_sort"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
@ -142,6 +144,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/edit_groups"
|
||||
android:tooltipText="@string/tooltip_edit_groups"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
|
@ -57,6 +57,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reset_speed"
|
||||
android:tooltipText="@string/reset"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
@ -95,6 +96,7 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reset_pitch"
|
||||
android:tooltipText="@string/reset"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
|
@ -39,40 +39,49 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/repeat"
|
||||
android:tooltipText="@string/tooltip_repeat"
|
||||
style="@style/QueueSheetOption"
|
||||
android:src="@drawable/ic_repeat" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/shuffle"
|
||||
android:tooltipText="@string/shuffle"
|
||||
style="@style/QueueSheetOption"
|
||||
android:src="@drawable/ic_shuffle" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reverse"
|
||||
android:tooltipText="@string/tooltip_reverse"
|
||||
style="@style/QueueSheetOption"
|
||||
android:src="@drawable/ic_reverse" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/add_to_playlist"
|
||||
android:tooltipText="@string/addToPlaylist"
|
||||
style="@style/QueueSheetOption"
|
||||
android:src="@drawable/ic_playlist_add" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sort"
|
||||
android:tooltipText="@string/tooltip_sort"
|
||||
style="@style/QueueSheetOption"
|
||||
android:src="@drawable/ic_sort" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/watch_positions_options"
|
||||
android:tooltipText="@string/tooltip_watch_position"
|
||||
style="@style/QueueSheetOption"
|
||||
android:src="@drawable/ic_eye" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/clear_queue"
|
||||
android:tooltipText="@string/tooltip_clear_queue"
|
||||
style="@style/QueueSheetOption"
|
||||
android:src="@drawable/ic_close" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dismiss"
|
||||
android:tooltipText="@string/tooltip_dismiss"
|
||||
style="@style/QueueSheetOption"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
@ -486,4 +486,24 @@
|
||||
<item quantity="one">%d new stream</item>
|
||||
<item quantity="other">%d new streams</item>
|
||||
</plurals>
|
||||
|
||||
<!--Tooltips -->
|
||||
<string name="tooltip_repeat">Repeat</string>
|
||||
<string name="tooltip_reverse">Reverse</string>
|
||||
<string name="tooltip_sort">Sort</string>
|
||||
<string name="tooltip_watch_position">Watch position</string>
|
||||
<string name="tooltip_clear_queue">Clear queue</string>
|
||||
<string name="tooltip_dismiss">Dismiss</string>
|
||||
<string name="tooltip_locked">Lock player</string>
|
||||
<string name="tooltip_unlocked">Unlock player</string>
|
||||
<string name="tooltip_sponsorblock">Toggle Sponsorblock</string>
|
||||
<string name="tooltip_options">Options</string>
|
||||
<string name="tooltip_minimize">Minimze</string>
|
||||
<string name="tooltip_fullscreen">Fullscreen</string>
|
||||
<string name="tooltip_close">Close</string>
|
||||
<string name="tooltip_play">Play</string>
|
||||
<string name="tooltip_filter">Filter</string>
|
||||
<string name="tooltip_edit_groups">Edit groups</string>
|
||||
<string name="tooltip_create_playlist">Create playlist</string>
|
||||
<string name="tooltip_scroll_to_top">Scroll to top</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user