Skip to content

Commit 4aad3a3

Browse files
committed
[[ Bug ]] Send keyboard messages after effective rect changes
This patch ensures that `keyboardActivated` and `keyboardDeactivated` are sent after the `effective working screenRect` changes so that any scripts requesting that will have access to the returned values. This bug appears to have been introduced with the change to building against api 26.
1 parent 47c2953 commit 4aad3a3

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

engine/src/java/com/runrev/android/Engine.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,7 @@ public void showKeyboard()
607607

608608
// HH-2017-01-18: [[ Bug 18058 ]] Fix keyboard not show in landscape orientation
609609
imm.showSoftInput(this, InputMethodManager.SHOW_FORCED);
610-
updateKeyboardVisible(true);
611-
}
610+
}
612611

613612
public void hideKeyboard()
614613
{
@@ -620,8 +619,7 @@ public void hideKeyboard()
620619
imm.restartInput(this);
621620

622621
imm.hideSoftInputFromWindow(getWindowToken(), 0);
623-
updateKeyboardVisible(false);
624-
}
622+
}
625623

626624
public void resetKeyboard()
627625
{
@@ -1423,23 +1421,6 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh)
14231421
{
14241422
// Log.i(TAG, "onSizeChanged({" + w + "x" + h + "}, {" + oldw + ", " + oldh + "})");
14251423

1426-
// status bar height
1427-
int t_status_bar_height = 0;
1428-
int t_resource_id = getResources().getIdentifier("status_bar_height", "dimen", "android");
1429-
if (t_resource_id > 0)
1430-
{
1431-
t_status_bar_height = getResources().getDimensionPixelSize(t_resource_id);
1432-
}
1433-
1434-
// display window size for the app layout
1435-
Rect t_app_rect = new Rect();
1436-
getActivity().getWindow().getDecorView().getWindowVisibleDisplayFrame(t_app_rect);
1437-
1438-
// keyboard height equals (screen height - (user app height + status))
1439-
int t_keyboard_height = getContainer().getRootView().getHeight() - (t_app_rect.height() + t_status_bar_height);
1440-
1441-
updateKeyboardVisible(t_keyboard_height > 0);
1442-
14431424
Rect t_rect;
14441425
t_rect = null;
14451426

engine/src/java/com/runrev/android/LiveCodeActivity.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.widget.*;
2525
import android.util.*;
2626
import android.content.pm.PackageManager;
27+
import android.graphics.*;
2728

2829
// This is the main activity exported by the application. This is
2930
// split into two parts, a customizable sub-class that gets dynamically
@@ -76,6 +77,32 @@ protected void onCreate(Bundle p_saved_state)
7677

7778
// prevent soft keyboard from resizing our view when shown
7879
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
80+
81+
s_main_layout.getRootView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
82+
{
83+
@Override
84+
public void onGlobalLayout()
85+
{
86+
// status bar height
87+
int t_status_bar_height = 0;
88+
int t_resource_id = getResources().getIdentifier("status_bar_height", "dimen", "android");
89+
if (t_resource_id > 0)
90+
{
91+
t_status_bar_height = getResources().getDimensionPixelSize(t_resource_id);
92+
}
93+
94+
// display window size for the app layout
95+
Rect t_app_rect = new Rect();
96+
getWindow().getDecorView().getWindowVisibleDisplayFrame(t_app_rect);
97+
98+
int t_screen_height = s_main_layout.getRootView().getHeight();
99+
100+
// keyboard height equals (screen height - (user app height + status))
101+
int t_keyboard_height = t_screen_height - (t_app_rect.height() + t_status_bar_height);
102+
103+
s_main_view.updateKeyboardVisible(t_keyboard_height > 0);
104+
}
105+
});
79106
}
80107

81108
@Override

0 commit comments

Comments
 (0)