Skip to content

Commit 7c4781a

Browse files
Merge pull request livecode#6705 from montegoulding/keyboardactivated
[[ Bug ]] Send keyboard messages after effective rect changes
2 parents 20f1468 + 4aad3a3 commit 7c4781a

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
@@ -609,8 +609,7 @@ public void showKeyboard()
609609

610610
// HH-2017-01-18: [[ Bug 18058 ]] Fix keyboard not show in landscape orientation
611611
imm.showSoftInput(this, InputMethodManager.SHOW_FORCED);
612-
updateKeyboardVisible(true);
613-
}
612+
}
614613

615614
public void hideKeyboard()
616615
{
@@ -622,8 +621,7 @@ public void hideKeyboard()
622621
imm.restartInput(this);
623622

624623
imm.hideSoftInputFromWindow(getWindowToken(), 0);
625-
updateKeyboardVisible(false);
626-
}
624+
}
627625

628626
public void resetKeyboard()
629627
{
@@ -1425,23 +1423,6 @@ protected void onSizeChanged(int w, int h, int oldw, int oldh)
14251423
{
14261424
// Log.i(TAG, "onSizeChanged({" + w + "x" + h + "}, {" + oldw + ", " + oldh + "})");
14271425

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

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)