package androidx.core.view; import android.R; import android.os.Build; import android.view.View; import android.view.WindowInsets; import android.view.WindowInsetsController; import android.view.inputmethod.InputMethodManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.core.view.SoftwareKeyboardControllerCompat; import java.util.concurrent.atomic.AtomicBoolean; /* loaded from: classes.dex */ public final class SoftwareKeyboardControllerCompat { private final Impl mImpl; public static class Impl { public void hide() { } public void show() { } } public SoftwareKeyboardControllerCompat(@NonNull View view) { if (Build.VERSION.SDK_INT >= 30) { this.mImpl = new Impl30(view); } else { this.mImpl = new Impl20(view); } } @RequiresApi(30) @Deprecated public SoftwareKeyboardControllerCompat(@NonNull WindowInsetsController windowInsetsController) { this.mImpl = new Impl30(windowInsetsController); } public void show() { this.mImpl.show(); } public void hide() { this.mImpl.hide(); } @RequiresApi(20) public static class Impl20 extends Impl { @Nullable private final View mView; public Impl20(@Nullable View view) { this.mView = view; } @Override // androidx.core.view.SoftwareKeyboardControllerCompat.Impl public void show() { final View view = this.mView; if (view == null) { return; } if (view.isInEditMode() || view.onCheckIsTextEditor()) { view.requestFocus(); } else { view = view.getRootView().findFocus(); } if (view == null) { view = this.mView.getRootView().findViewById(R.id.content); } if (view == null || !view.hasWindowFocus()) { return; } view.post(new Runnable() { // from class: androidx.core.view.SoftwareKeyboardControllerCompat$Impl20$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { SoftwareKeyboardControllerCompat.Impl20.lambda$show$0(view); } }); } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ void lambda$show$0(View view) { ((InputMethodManager) view.getContext().getSystemService("input_method")).showSoftInput(view, 0); } @Override // androidx.core.view.SoftwareKeyboardControllerCompat.Impl public void hide() { View view = this.mView; if (view != null) { ((InputMethodManager) view.getContext().getSystemService("input_method")).hideSoftInputFromWindow(this.mView.getWindowToken(), 0); } } } @RequiresApi(30) public static class Impl30 extends Impl20 { @Nullable private View mView; @Nullable private WindowInsetsController mWindowInsetsController; public Impl30(@NonNull View view) { super(view); this.mView = view; } public Impl30(@Nullable WindowInsetsController windowInsetsController) { super(null); this.mWindowInsetsController = windowInsetsController; } @Override // androidx.core.view.SoftwareKeyboardControllerCompat.Impl20, androidx.core.view.SoftwareKeyboardControllerCompat.Impl public void show() { int ime; View view = this.mView; if (view != null && Build.VERSION.SDK_INT < 33) { ((InputMethodManager) view.getContext().getSystemService("input_method")).isActive(); } WindowInsetsController windowInsetsController = this.mWindowInsetsController; if (windowInsetsController == null) { View view2 = this.mView; windowInsetsController = view2 != null ? view2.getWindowInsetsController() : null; } if (windowInsetsController != null) { ime = WindowInsets.Type.ime(); windowInsetsController.show(ime); } super.show(); } @Override // androidx.core.view.SoftwareKeyboardControllerCompat.Impl20, androidx.core.view.SoftwareKeyboardControllerCompat.Impl public void hide() { int ime; View view; WindowInsetsController windowInsetsController = this.mWindowInsetsController; if (windowInsetsController == null) { View view2 = this.mView; windowInsetsController = view2 != null ? view2.getWindowInsetsController() : null; } if (windowInsetsController != null) { final AtomicBoolean atomicBoolean = new AtomicBoolean(false); WindowInsetsController.OnControllableInsetsChangedListener onControllableInsetsChangedListener = new WindowInsetsController.OnControllableInsetsChangedListener() { // from class: androidx.core.view.SoftwareKeyboardControllerCompat$Impl30$$ExternalSyntheticLambda6 @Override // android.view.WindowInsetsController.OnControllableInsetsChangedListener public final void onControllableInsetsChanged(WindowInsetsController windowInsetsController2, int i) { SoftwareKeyboardControllerCompat.Impl30.lambda$hide$0(atomicBoolean, windowInsetsController2, i); } }; windowInsetsController.addOnControllableInsetsChangedListener(onControllableInsetsChangedListener); if (!atomicBoolean.get() && (view = this.mView) != null) { ((InputMethodManager) view.getContext().getSystemService("input_method")).hideSoftInputFromWindow(this.mView.getWindowToken(), 0); } windowInsetsController.removeOnControllableInsetsChangedListener(onControllableInsetsChangedListener); ime = WindowInsets.Type.ime(); windowInsetsController.hide(ime); return; } super.hide(); } /* JADX INFO: Access modifiers changed from: private */ public static /* synthetic */ void lambda$hide$0(AtomicBoolean atomicBoolean, WindowInsetsController windowInsetsController, int i) { atomicBoolean.set((i & 8) != 0); } } }