diff --git a/src/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java b/src/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java index c6e305147..d98dd158a 100644 --- a/src/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java +++ b/src/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java @@ -22,11 +22,13 @@ import android.graphics.Rect; import android.os.Build; import android.os.Build.VERSION_CODES; import android.preference.PreferenceManager; -import androidx.appcompat.widget.LinearLayoutCompat; import android.util.AttributeSet; import android.util.Log; import android.view.Surface; import android.view.View; +import android.view.WindowInsets; + +import androidx.appcompat.widget.LinearLayoutCompat; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.util.ServiceUtil; @@ -120,9 +122,13 @@ public class KeyboardAwareLinearLayout extends LinearLayoutCompat { @TargetApi(VERSION_CODES.LOLLIPOP) private int getViewInset() { - // In Android 10 we can't use mAttatchInfo anymore, so we don't even need to try it - // https://developer.android.com/about/versions/10/non-sdk-q - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + // In Android 10 we can't use mAttatchInfo anymore, instead use the SDK interface: + if (Build.VERSION.SDK_INT >= VERSION_CODES.Q) { + WindowInsets insets = getRootWindowInsets(); + if (insets == null) return 0; + return insets.getStableInsetBottom(); + } else { + // Some older Android versions don't know `getRootViewInsets()` yet, so we still need the old way: try { Field attachInfoField = View.class.getDeclaredField("mAttachInfo"); attachInfoField.setAccessible(true);