Change web search intent logic (#62)

This commit is contained in:
vfsfitvnm
2022-06-30 21:02:29 +02:00
parent 8066dce73b
commit 174520b616
2 changed files with 14 additions and 7 deletions

View File

@@ -10,6 +10,9 @@
<intent> <intent>
<action android:name="android.media.action.DISPLAY_AUDIO_EFFECT_CONTROL_PANEL" /> <action android:name="android.media.action.DISPLAY_AUDIO_EFFECT_CONTROL_PANEL" />
</intent> </intent>
<intent>
<action android:name="android.intent.action.WEB_SEARCH" />
</intent>
</queries> </queries>
<application <application

View File

@@ -2,6 +2,7 @@ package it.vfsfitvnm.vimusic.ui.views
import android.app.SearchManager import android.app.SearchManager
import android.content.Intent import android.content.Intent
import android.widget.Toast
import androidx.compose.animation.AnimatedContentScope import androidx.compose.animation.AnimatedContentScope
import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.animateColorAsState import androidx.compose.animation.animateColorAsState
@@ -218,13 +219,16 @@ fun PlayerBottomSheet(
} }
}, },
onSearchOnline = { onSearchOnline = {
player?.mediaMetadata?.let { val mediaMetadata = player?.mediaMetadata ?: return@LyricsView
context.startActivity(Intent(Intent.ACTION_WEB_SEARCH).apply {
putExtra( val intent = Intent(Intent.ACTION_WEB_SEARCH).apply {
SearchManager.QUERY, putExtra(SearchManager.QUERY, "${mediaMetadata.title} ${mediaMetadata.artist} lyrics")
"${it.title} ${it.artist} lyrics" }
)
}) if (intent.resolveActivity(context.packageManager) != null) {
context.startActivity(intent)
} else {
Toast.makeText(context, "No browser app found!", Toast.LENGTH_SHORT).show()
} }
}, },
onLyricsUpdate = { lyrics -> onLyricsUpdate = { lyrics ->