Skip to content

Commit c453f89

Browse files
committed
Restoring WebView's context to the Activity instead of the app context
Using the application context for a WebView will result in the webview failing to handle dialog pickers (like an HTML SELECT tag for instance). Also, removed the import for `View.FOCUSABLE` and lint checks can't determine the API level for the import, but it does when it is used inside of the `if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)` check. (one less yellow warning in the IDE)
1 parent 7d85c20 commit c453f89

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserActivity.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import android.view.KeyEvent.KEYCODE_ENTER
3232
import android.view.Menu
3333
import android.view.MenuItem
3434
import android.view.View
35-
import android.view.View.FOCUSABLE
3635
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
3736
import android.webkit.CookieManager
3837
import android.webkit.WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE
@@ -107,14 +106,14 @@ class BrowserActivity : DuckDuckGoActivity() {
107106
popupMenu = BrowserPopupMenu(layoutInflater)
108107
}
109108

110-
// inspired by https://stackoverflow.com/a/8011027/73479
111109
private fun createWebView() {
112-
webView = NestedWebView(this.applicationContext)
110+
webView = NestedWebView(this)
113111
webView.gone()
114112
webView.isFocusableInTouchMode = true
115113
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
116-
webView.focusable = FOCUSABLE
114+
webView.focusable = View.FOCUSABLE
117115
}
116+
118117
webViewContainer.addView(webView)
119118
}
120119

0 commit comments

Comments
 (0)