IME inset for windows only

pull/215/head
M66B 7 months ago
parent eda76545fa
commit 5573492719

@ -86,6 +86,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
private int themeId; private int themeId;
private Context originalContext; private Context originalContext;
private boolean visible; private boolean visible;
private boolean hasWindowFocus;
private boolean contacts; private boolean contacts;
private List<IKeyPressedListener> keyPressedListeners = new ArrayList<>(); private List<IKeyPressedListener> keyPressedListeners = new ArrayList<>();
@ -179,9 +180,11 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
mlp.bottomMargin = insets.bottom; mlp.bottomMargin = insets.bottom;
v.setLayoutParams(mlp); v.setLayoutParams(mlp);
if (hasWindowFocus) {
int bottom = windowInsets.getInsets(WindowInsetsCompat.Type.ime()).bottom; int bottom = windowInsets.getInsets(WindowInsetsCompat.Type.ime()).bottom;
int pad = bottom - insets.bottom; int pad = bottom - insets.bottom;
v.setPaddingRelative(0, 0, 0, pad < 0 ? 0 : pad); v.setPaddingRelative(0, 0, 0, pad < 0 ? 0 : pad);
}
if (edge_to_edge) if (edge_to_edge)
for (View child : Helper.getViewsWithTag(v, "inset")) { for (View child : Helper.getViewsWithTag(v, "inset")) {
@ -241,6 +244,11 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
setContentView(view); setContentView(view);
} }
@Override
public void onWindowFocusChanged(boolean hasFocus) {
hasWindowFocus = hasFocus;
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
EntityLog.log(this, "Activity create " + this.getClass().getName() + EntityLog.log(this, "Activity create " + this.getClass().getName() +

Loading…
Cancel
Save