diff --git a/src/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java b/src/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java index df1739332..c6e305147 100644 --- a/src/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java +++ b/src/org/thoughtcrime/securesms/components/KeyboardAwareLinearLayout.java @@ -120,20 +120,24 @@ public class KeyboardAwareLinearLayout extends LinearLayoutCompat { @TargetApi(VERSION_CODES.LOLLIPOP) private int getViewInset() { - try { - Field attachInfoField = View.class.getDeclaredField("mAttachInfo"); - attachInfoField.setAccessible(true); - Object attachInfo = attachInfoField.get(this); - if (attachInfo != null) { - Field stableInsetsField = attachInfo.getClass().getDeclaredField("mStableInsets"); - stableInsetsField.setAccessible(true); - Rect insets = (Rect)stableInsetsField.get(attachInfo); - return insets.bottom; + // 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) { + try { + Field attachInfoField = View.class.getDeclaredField("mAttachInfo"); + attachInfoField.setAccessible(true); + Object attachInfo = attachInfoField.get(this); + if (attachInfo != null) { + Field stableInsetsField = attachInfo.getClass().getDeclaredField("mStableInsets"); + stableInsetsField.setAccessible(true); + Rect insets = (Rect) stableInsetsField.get(attachInfo); + return insets.bottom; + } + } catch (NoSuchFieldException nsfe) { + Log.w(TAG, "field reflection error when measuring view inset", nsfe); + } catch (IllegalAccessException iae) { + Log.w(TAG, "access reflection error when measuring view inset", iae); } - } catch (NoSuchFieldException nsfe) { - Log.w(TAG, "field reflection error when measuring view inset", nsfe); - } catch (IllegalAccessException iae) { - Log.w(TAG, "access reflection error when measuring view inset", iae); } return 0; }