Merge pull request #2083 from Kruna1Pate1/fix/link-open-issue

Fix activity goes in PiP mode on link opening
This commit is contained in:
Bnyro 2022-11-26 16:25:00 +01:00 committed by GitHub
commit 9c4928b862
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -340,6 +340,15 @@ class MainActivity : BaseActivity() {
}
private fun loadIntentData() {
// If activity is running in PiP mode, then start it in front.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &&
isInPictureInPictureMode
) {
moveTaskToBack(true)
intent?.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
startActivity(intent)
}
intent?.getStringExtra(IntentData.channelId)?.let {
navController.navigate(
R.id.channelFragment,

View File

@ -25,6 +25,7 @@ import com.github.libretube.ui.base.BaseFragment
import com.github.libretube.ui.extensions.withMaxSize
import com.github.libretube.util.LocaleHelper
import com.github.libretube.util.PreferenceHelper
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -141,6 +142,9 @@ class HomeFragment : BaseFragment() {
lifecycleScope.launch(Dispatchers.IO) {
try {
action.invoke()
// Can be caused due to activity launch in front view from PiP mode.
} catch (e: CancellationException) {
Log.e("fetching home tab", e.toString())
} catch (e: Exception) {
e.localizedMessage?.let { context?.toastFromMainThread(it) }
Log.e("fetching home tab", e.toString())