Merge pull request #5719 from Isira-Seneviratne/TooltipCompat

feature: Display tooltips on Android versions below 8.0
This commit is contained in:
Isira Seneviratne 2024-03-09 19:50:56 +05:30 committed by GitHub
commit 85d9cb3a46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 17 deletions

View File

@ -1,15 +0,0 @@
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
}
}

View File

@ -17,6 +17,7 @@ import android.view.Window
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.TooltipCompat
import androidx.core.content.ContextCompat
import androidx.core.os.postDelayed
import androidx.core.view.WindowInsetsCompat
@ -52,7 +53,6 @@ import com.github.libretube.helpers.WindowHelper
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.fragments.PlayerFragment
import com.github.libretube.ui.interfaces.PlayerGestureOptions
import com.github.libretube.ui.interfaces.PlayerOptions
@ -141,7 +141,7 @@ open class CustomExoPlayerView(
}
binding.lockPlayer.setImageResource(icon)
binding.lockPlayer.trySetTooltip(context.getString(tooltip))
TooltipCompat.setTooltipText(binding.lockPlayer, context.getString(tooltip))
// show/hide all the controls
lockPlayer(isPlayerLocked)