This repository has been archived by the owner on Apr 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #1865 - Move workaround to separate file.
- Loading branch information
Showing
2 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app/src/main/java/org/mozilla/tv/firefox/webrender/YoutubeGreyScreenWorkaround.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.tv.firefox.webrender | ||
|
||
import android.app.Activity | ||
import android.view.KeyEvent | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.launch | ||
|
||
/** | ||
* Workaround fix for intermittent grey screen that shows instead of WebView when returning to | ||
* YouTube from the home screen, see #1865. Follow-up investigation in #1940. | ||
* | ||
* This fix sends navigation key events on the UI thread to dispel the grey screen. | ||
* | ||
* Other failed attempted workarounds: | ||
* - Calling engineView.resume to trigger the webview to "load" from grey screen | ||
* - Scrolling webview | ||
* - Sending non-view-changing key events | ||
*/ | ||
object YoutubeGreyScreenWorkaround { | ||
fun invoke(activity: Activity?) { | ||
GlobalScope.launch(Dispatchers.Main) { | ||
delay(50) | ||
activity?.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_RIGHT)) | ||
activity?.dispatchKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_LEFT)) | ||
} | ||
} | ||
} |