package io.flutter.plugins.webviewflutter; import android.content.Context; import android.graphics.Rect; import android.os.Build; import android.view.View; import android.view.inputmethod.InputMethodManager; import android.webkit.WebView; import android.widget.ListPopupWindow; /* loaded from: classes6.dex */ class InputAwareWebView extends WebView { private static final String TAG = "InputAwareWebView"; private View containerView; private ThreadedInputConnectionProxyAdapterView proxyAdapterView; private View threadedInputConnectionProxyView; /* JADX INFO: Access modifiers changed from: package-private */ public InputAwareWebView(Context context, View view) { super(context); this.containerView = view; } /* JADX INFO: Access modifiers changed from: package-private */ public void setContainerView(View view) { this.containerView = view; ThreadedInputConnectionProxyAdapterView threadedInputConnectionProxyAdapterView = this.proxyAdapterView; if (threadedInputConnectionProxyAdapterView == null || view == null) { return; } setInputConnectionTarget(threadedInputConnectionProxyAdapterView); } /* JADX INFO: Access modifiers changed from: package-private */ public void lockInputConnection() { ThreadedInputConnectionProxyAdapterView threadedInputConnectionProxyAdapterView = this.proxyAdapterView; if (threadedInputConnectionProxyAdapterView == null) { return; } threadedInputConnectionProxyAdapterView.setLocked(true); } /* JADX INFO: Access modifiers changed from: package-private */ public void unlockInputConnection() { ThreadedInputConnectionProxyAdapterView threadedInputConnectionProxyAdapterView = this.proxyAdapterView; if (threadedInputConnectionProxyAdapterView == null) { return; } threadedInputConnectionProxyAdapterView.setLocked(false); } /* JADX INFO: Access modifiers changed from: package-private */ public void dispose() { resetInputConnection(); } @Override // android.view.View public boolean checkInputConnectionProxy(View view) { View view2 = this.threadedInputConnectionProxyView; this.threadedInputConnectionProxyView = view; if (view2 == view) { return super.checkInputConnectionProxy(view); } View view3 = this.containerView; if (view3 == null) { return super.checkInputConnectionProxy(view); } ThreadedInputConnectionProxyAdapterView threadedInputConnectionProxyAdapterView = new ThreadedInputConnectionProxyAdapterView(view3, view, view.getHandler()); this.proxyAdapterView = threadedInputConnectionProxyAdapterView; setInputConnectionTarget(threadedInputConnectionProxyAdapterView); return super.checkInputConnectionProxy(view); } @Override // android.view.ViewGroup, android.view.View public void clearFocus() { super.clearFocus(); resetInputConnection(); } private void resetInputConnection() { View view; if (this.proxyAdapterView == null || (view = this.containerView) == null) { return; } setInputConnectionTarget(view); } void setInputConnectionTarget(View view) { if (this.containerView == null) { return; } view.requestFocus(); this.containerView.post(new Runnable(this, view) { // from class: io.flutter.plugins.webviewflutter.InputAwareWebView.1 final InputAwareWebView this$0; final View val$targetView; { this.this$0 = this; this.val$targetView = view; } @Override // java.lang.Runnable public void run() { if (this.this$0.containerView == null) { return; } InputMethodManager inputMethodManager = (InputMethodManager) this.this$0.getContext().getSystemService("input_method"); this.val$targetView.onWindowFocusChanged(true); inputMethodManager.isActive(this.this$0.containerView); } }); } @Override // android.webkit.WebView, android.view.View protected void onFocusChanged(boolean z, int i, Rect rect) { if (Build.VERSION.SDK_INT >= 28 || !isCalledFromListPopupWindowShow() || z) { super.onFocusChanged(z, i, rect); } } private boolean isCalledFromListPopupWindowShow() { for (StackTraceElement stackTraceElement : Thread.currentThread().getStackTrace()) { if (stackTraceElement.getClassName().equals(ListPopupWindow.class.getCanonicalName()) && stackTraceElement.getMethodName().equals("show")) { return true; } } return false; } }