Properly fix the problem

This commit is contained in:
Hocuri
2020-10-31 18:34:50 +01:00
parent 766d50e602
commit eaa891c8e7
@@ -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);