mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-10 00:27:45 +00:00
more reliable fix for bottom inset padding on edge-to-edge (#1486)
This commit is contained in:
parent
7748ed75fe
commit
1012386c8c
4 changed files with 33 additions and 8 deletions
|
@ -148,8 +148,6 @@ public class KeyboardView extends View {
|
|||
|
||||
mPaint.setAntiAlias(true);
|
||||
mTypeface = Settings.getInstance().getCustomTypeface();
|
||||
|
||||
setFitsSystemWindows(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -71,7 +71,6 @@ class ClipboardHistoryView @JvmOverloads constructor(
|
|||
getEnabledClipboardToolbarKeys(context.prefs())
|
||||
.forEach { toolbarKeys.add(createToolbarKey(context, KeyboardIconsSet.instance, it)) }
|
||||
keyboardAttr.recycle()
|
||||
fitsSystemWindows = true
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
|
|
|
@ -106,7 +106,6 @@ public final class EmojiPalettesView extends LinearLayout
|
|||
R.styleable.EmojiPalettesView_categoryPageIndicatorColor, 0);
|
||||
emojiPalettesViewAttr.recycle();
|
||||
mEmojiLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
|
||||
setFitsSystemWindows(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,10 +7,15 @@
|
|||
package helium314.keyboard.latin;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Insets;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowMetrics;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.core.view.ViewKt;
|
||||
|
@ -21,8 +26,12 @@ import helium314.keyboard.latin.common.ColorType;
|
|||
import helium314.keyboard.latin.settings.Settings;
|
||||
import helium314.keyboard.latin.suggestions.PopupSuggestionsView;
|
||||
import helium314.keyboard.latin.suggestions.SuggestionStripView;
|
||||
import kotlin.Unit;
|
||||
|
||||
|
||||
public final class InputView extends FrameLayout {
|
||||
private static final int[] LOCATION = new int[2];
|
||||
|
||||
private final Rect mInputViewRect = new Rect();
|
||||
private MainKeyboardView mMainKeyboardView;
|
||||
private KeyboardTopPaddingForwarder mKeyboardTopPaddingForwarder;
|
||||
|
@ -43,10 +52,7 @@ public final class InputView extends FrameLayout {
|
|||
mMainKeyboardView, suggestionStripView);
|
||||
mMoreSuggestionsViewCanceler = new MoreSuggestionsViewCanceler(
|
||||
mMainKeyboardView, suggestionStripView);
|
||||
ViewKt.doOnNextLayout(this, v -> {
|
||||
Settings.getValues().mColors.setBackground(findViewById(R.id.main_keyboard_frame), ColorType.MAIN_BACKGROUND);
|
||||
return null;
|
||||
});
|
||||
ViewKt.doOnNextLayout(this, this::onNextLayout);
|
||||
}
|
||||
|
||||
public void setKeyboardTopPadding(final int keyboardTopPadding) {
|
||||
|
@ -104,6 +110,29 @@ public final class InputView extends FrameLayout {
|
|||
return mActiveForwarder.onTouchEvent(x, y, me);
|
||||
}
|
||||
|
||||
private Unit onNextLayout(View v) {
|
||||
Settings.getValues().mColors.setBackground(findViewById(R.id.main_keyboard_frame), ColorType.MAIN_BACKGROUND);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
getLocationOnScreen(LOCATION);
|
||||
WindowManager wm = getContext().getSystemService(WindowManager.class);
|
||||
WindowMetrics windowMetrics = wm.getCurrentWindowMetrics();
|
||||
if (LOCATION[1] + getHeight() == windowMetrics.getBounds().height()) {
|
||||
// Edge-to-edge mode
|
||||
WindowInsets windowInsets = windowMetrics.getWindowInsets();
|
||||
int insetTypes = WindowInsets.Type.systemBars() | WindowInsets.Type.displayCutout();
|
||||
Insets insets = windowInsets.getInsetsIgnoringVisibility(insetTypes);
|
||||
|
||||
// Can't set padding on this view, since it results in an overlap with window above the keyboard.
|
||||
mMainKeyboardView.setPadding(0, 0, 0, insets.bottom);
|
||||
findViewById(R.id.emoji_palettes_view).setPadding(0, 0, 0, insets.bottom);
|
||||
findViewById(R.id.clipboard_history_view).setPadding(0, 0, 0, insets.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class forwards series of {@link MotionEvent}s from <code>SenderView</code> to
|
||||
* <code>ReceiverView</code>.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue