Source:
protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_proxy_override); setTitle(R.string.proxy_override_activity_title); WebkitHelpers.appendWebViewVersionToTitle(this); mProxy = new Proxy(0, () -> mRequestCountTextView.setText(getResources().getString( R.string.proxy_override_requests_served, mProxy.getRequestCount())) ); mProxy.start(); mProxyUrl = "localhost:" + mProxy.getPort(); mRequestCountTextView = findViewById(R.id.proxy_override_textview); mRequestCountTextView.setText(getResources().getString( R.string.proxy_override_requests_served, 0)); mWebView = findViewById(R.id.proxy_override_webview); mWebView.setWebViewClient(new WebViewClient()); mInputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); mEditText = findViewById(R.id.proxy_override_edittext); mEditText.setOnEditorActionListener((TextView v, int actionId, KeyEvent event) -> { if (actionId == EditorInfo.IME_ACTION_NEXT) { String url = mEditText.getText().toString(); if (!url.isEmpty()) { if (!url.startsWith("http")) url = "http://" + url; mWebView.loadUrl(url); mEditText.setText(""); } mInputMethodManager.hideSoftInputFromWindow(mEditText.getWindowToken(), 0); mWebView.requestFocus(); return true; } return false; }); if (!WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE)) { mRequestCountTextView.setVisibility(View.GONE); mEditText.setVisibility(View.GONE); mWebView.loadData("<html><body>Proxy override not available</body></html>", "text/html", "utf-8"); return; } setProxyOverride(); }

Target:
protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_proxy_override); setTitle(R.string.proxy_override_activity_title); WebkitHelpers.appendWebViewVersionToTitle(this); mProxy = new Proxy(0, () -> mRequestCountTextView.setText(getResources().getString( R.string.proxy_override_requests_served, mProxy.getRequestCount())) ); mProxy.start(); mRequestCountTextView = findViewById(R.id.proxy_override_textview); mRequestCountTextView.setText(getResources().getString( R.string.proxy_override_requests_served, 0)); mWebView = findViewById(R.id.proxy_override_webview); mWebView.setWebViewClient(new WebViewClient()); mInputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE); mNavigationBar = findViewById(R.id.proxy_override_edittext); mNavigationBar.setOnEditorActionListener((TextView v, int actionId, KeyEvent event) -> { if (actionId == EditorInfo.IME_ACTION_NEXT) { String url = mNavigationBar.getText().toString(); if (!url.isEmpty()) { if (!url.startsWith("http")) url = "http://" + url; mWebView.loadUrl(url); mNavigationBar.setText(""); } mInputMethodManager.hideSoftInputFromWindow(mNavigationBar.getWindowToken(), 0); mWebView.requestFocus(); return true; } return false; }); if (!WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE)) { mRequestCountTextView.setVisibility(View.GONE); mNavigationBar.setVisibility(View.GONE); mWebView.loadData("<html><body>Proxy override not available</body></html>", "text/html", null); return; } setProxyOverride("localhost:" + mProxy.getPort()); }