Skip to content

Commit

Permalink
Defer content view resolve for KeyboardHeightProvider to allow for la…
Browse files Browse the repository at this point in the history
…te setContentView (libgdx#7553)
  • Loading branch information
Berstanio authored Dec 27, 2024
1 parent e67b29d commit 5ca5b71
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Added XmlReader.getChildren() and XmlReader.replaceChild()
- LWJGL3: Fix pauseWhenLostFocus not working as expected
- API Addition: Added FPSLogger#setBound
- Android: Fix crash on startup if `setContentView` was manually called after `initializeForView`

[1.13.0]
- [BREAKING CHANGE] GWT: Updated to 2.11.0. `com.google.jsinterop:jsinterop-annotations:2.0.2:sources` must be added as a dependency to your html project dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

public class AndroidXKeyboardHeightProvider implements KeyboardHeightProvider {

private final View view;
private final Activity activity;
private View view;
private KeyboardHeightObserver observer;

/** The cached landscape height of the keyboard */
Expand All @@ -24,12 +24,12 @@ public class AndroidXKeyboardHeightProvider implements KeyboardHeightProvider {
private static int keyboardPortraitHeight;

public AndroidXKeyboardHeightProvider (final Activity activity) {
this.view = activity.findViewById(android.R.id.content);
this.activity = activity;
}

@Override
public void start () {
this.view = activity.findViewById(android.R.id.content);
ViewCompat.setOnApplyWindowInsetsListener(view, new OnApplyWindowInsetsListener() {
@NotNull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ public StandardKeyboardHeightProvider (Activity activity) {
setSoftInputMode(LayoutParams.SOFT_INPUT_ADJUST_RESIZE | LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);

parentView = activity.findViewById(android.R.id.content);

setWidth(0);
setHeight(android.view.ViewGroup.LayoutParams.MATCH_PARENT);

Expand All @@ -94,7 +92,7 @@ public void onGlobalLayout () {
* be registered before the onResume has finished of the Activity. */
@Override
public void start () {

parentView = activity.findViewById(android.R.id.content);
if (!isShowing() && parentView.getWindowToken() != null) {
setBackgroundDrawable(new ColorDrawable(0));
showAtLocation(parentView, Gravity.NO_GRAVITY, 0, 0);
Expand Down

0 comments on commit 5ca5b71

Please sign in to comment.