gt:         final IntentFilter intentFilter = new IntentFilter();
context: package de.vier_bier.habpanelviewer;
  
  import android.annotation.TargetApi;
  import android.app.Activity;
  import android.content.Context;
  import android.content.IntentFilter;
  import android.content.SharedPreferences;
  import android.net.ConnectivityManager;
  import android.net.http.SslCertificate;
  import android.net.http.SslError;
  import android.os.Build;
  import android.support.v7.app.AlertDialog;
  import android.text.InputType;
  import android.util.AttributeSet;
  import android.util.Log;
  import android.view.MotionEvent;
  import android.view.View;
  import android.webkit.ConsoleMessage;
  import android.webkit.CookieManager;
  import android.webkit.HttpAuthHandler;
  import android.webkit.SslErrorHandler;
  import android.webkit.WebBackForwardList;
  import android.webkit.WebChromeClient;
  import android.webkit.WebHistoryItem;
  import android.webkit.WebSettings;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  import android.webkit.WebViewDatabase;
  import android.widget.EditText;
  
  import java.net.MalformedURLException;
  import java.net.URI;
  import java.net.URISyntaxException;
  import java.net.URL;
  import java.text.SimpleDateFormat;
  
  import de.vier_bier.habpanelviewer.openhab.IConnectionListener;
  import de.vier_bier.habpanelviewer.ssl.ConnectionUtil;
  
  /**
   * WebView
   */
  public class ClientWebView extends WebView implements NetworkTracker.INetworkListener {
      private static final String TAG = "HPV-ClientWebView";
  
      private boolean mAllowMixedContent;
      private boolean mDraggingPrevented;
      private String mServerURL;
      private String mStartPage;
      private boolean mKioskMode;
      private boolean mHwAccelerated;
      private NetworkTracker mNetworkTracker;
  
      public ClientWebView(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public ClientWebView(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
      }
  
      @TargetApi(Build.VERSION_CODES.LOLLIPOP)
      public ClientWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
          super(context, attrs, defStyleAttr, defStyleRes);
      }
  
      public ClientWebView(Context context) {
          super(context);
      }
  
      @Override
      public void onWindowFocusChanged(boolean hasFocus) {
          super.onWindowFocusChanged(hasFocus);
          if (hasFocus) {
              setSystemUiVisibility(
                      View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                              | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                              | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                              | View.SYSTEM_UI_FLAG_FULLSCREEN
                              | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
          }
      }
  
      @Override
      public void setKeepScreenOn(boolean keepScreenOn) {
          // disable chromium power save blocker
          StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
          for (StackTraceElement ele : stackTraceElements) {
              if (ele.getClassName().contains("PowerSaveBlocker")) {
                  return;
              }
          }
  
          super.setKeepScreenOn(keepScreenOn);
      }
  
      synchronized void initialize(final IConnectionListener cl, final NetworkTracker nt) {
          mNetworkTracker = nt;
          Log.d(TAG, "registering as network listener...");
          mNetworkTracker.addListener(this);
  
          setLayerType(LAYER_TYPE_SOFTWARE, null);
  
          setWebChromeClient(new WebChromeClient() {
              @Override
              public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                  if (consoleMessage.message().contains("SSE error, closing EventSource")) {
                      cl.disconnected();
                  }
  
                  return super.onConsoleMessage(consoleMessage);
              }
          });
  
          setWebViewClient(new WebViewClient() {
              @Override
              public void onPageFinished(WebView view, String url) {
                  super.onPageFinished(view, url);
  
                  if (isHabPanelUrl(url)) {
                      evaluateJavascript("angular.element(document.body).scope().$root.kioskMode", s -> {
                          mKioskMode = Boolean.parseBoolean(s);
                          Log.d(TAG, "HABPanel page loaded. kioskMode=" + mKioskMode);
                      });
                  }
              }
  
              @Override
              public void onReceivedSslError(WebView view, final SslErrorHandler handler, final SslError error) {
                  Log.d(TAG, "onReceivedSslError: " + error.getUrl());
  
                  SslCertificate cert = error.getCertificate();
                  if (ConnectionUtil.isTrusted(error.getCertificate())) {
                      Log.d(TAG, "certificate is trusted: " + error.getUrl());
  
                      handler.proceed();
                      return;
                  }
  
                  String h;
                  try {
                      URL url = new URL(error.getUrl());
                      h = url.getHost();
                  } catch (MalformedURLException e) {
                      h = getContext().getString(R.string.unknownHost);
                  }
  
                  final String host = h;
  
                  String r = getContext().getString(R.string.notValid);
                  switch (error.getPrimaryError()) {
                      case SslError.SSL_DATE_INVALID:
                          r = getContext().getString(R.string.invalidDate);
                          break;
                      case SslError.SSL_EXPIRED:
                          r = getContext().getString(R.string.expired);
                          break;
                      case SslError.SSL_IDMISMATCH:
                          r = getContext().getString(R.string.hostnameMismatch);
                          break;
                      case SslError.SSL_NOTYETVALID:
                          r = getContext().getString(R.string.notYetValid);
                          break;
                      case SslError.SSL_UNTRUSTED:
                          r = getContext().getString(R.string.untrusted);
                          break;
                  }
  
                  final String reason = r;
  
                  String c = getContext().getString(R.string.issuedBy) + cert.getIssuedBy().getDName() + "<br/>";
                  c += getContext().getString(R.string.issuedTo) + cert.getIssuedTo().getDName() + "<br/>";
                  c += getContext().getString(R.string.validFrom) + SimpleDateFormat.getDateInstance().format(cert.getValidNotBeforeDate()) + "<br/>";
                  c += getContext().getString(R.string.validUntil) + SimpleDateFormat.getDateInstance().format(cert.getValidNotAfterDate()) + "<br/>";
  
                  final String certInfo = c;
  
                  AlertDialog alert = new AlertDialog.Builder(getContext())
                          .setTitle(getContext().getString(R.string.certInvalid))
                          .setMessage(getContext().getString(R.string.sslCert) + "https://" + host + " " + reason + ".\n\n"
                                  + certInfo.replaceAll("<br/>", "\n") + "\n"
                                  + getContext().getString(R.string.storeSecurityException))
                          .setIcon(android.R.drawable.ic_dialog_alert)
                          .setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
                              try {
                                  ConnectionUtil.addCertificate(error.getCertificate());
                              } catch (Exception e) {
                                  e.printStackTrace();
                              }
                              handler.proceed();
                          })
                          .setNegativeButton(android.R.string.no, (dialog, whichButton) -> loadData("<html><body><h1>" + getContext().getString(R.string.certInvalid)
                                  + "</h1><h2>" + getContext().getString(R.string.sslCert) + "https://" + host + " "
                                  + reason + ".</h2>" + certInfo + "</body></html>", "text/html", "UTF-8")).create();
  
                  if (!((Activity) getContext()).isFinishing()) {
                      alert.show();
                  }
              }
  
  
              @Override
              public void onReceivedHttpAuthRequest(WebView view, final HttpAuthHandler handler, final String host, final String realm) {
                  final AlertDialog alert = new AlertDialog.Builder(getContext())
                          .setCancelable(false)
                          .setTitle(R.string.login_required)
                          .setMessage(getContext().getString(R.string.host_realm, host, realm))
                          .setView(R.layout.dialog_login)
                          .setPositiveButton(R.string.okay, (dialog12, id) -> {
                              EditText userT = ((AlertDialog) dialog12).findViewById(R.id.username);
                              EditText passT = ((AlertDialog) dialog12).findViewById(R.id.password);
  
                              handler.proceed(userT.getText().toString(), passT.getText().toString());
                          }).setNegativeButton(R.string.cancel, (dialog1, which) -> handler.cancel())
                          .create();
  
                  if (!((Activity) getContext()).isFinishing()) {
                      alert.show();
                  }
              }
          });
  
          setOnTouchListener((v, event) -> (event.getAction() == MotionEvent.ACTION_MOVE && mDraggingPrevented));
  
          CookieManager.getInstance().setAcceptCookie(true);
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
              CookieManager.getInstance().setAcceptThirdPartyCookies(this, true);
          }
  
          WebSettings webSettings = getSettings();
          webSettings.setDomStorageEnabled(true);
  
  