@@ -24,6 +24,8 @@ public class CustomKeyboardLayout implements ReactSoftKeyboardMonitor.Listener,
24
24
private final InputMethodManager mInputMethodManager ;
25
25
private final ReactSoftKeyboardMonitor mKeyboardMonitor ;
26
26
private WeakReference <CustomKeyboardRootViewShadow > mShadowNode = new WeakReference <>(null );
27
+ private int mSoftInputMode ;
28
+ private boolean mIsShown = false ;
27
29
28
30
public CustomKeyboardLayout (ReactContext reactContext , ReactSoftKeyboardMonitor keyboardMonitor , ReactScreenMonitor screenMonitor ) {
29
31
mKeyboardMonitor = keyboardMonitor ;
@@ -33,6 +35,18 @@ public CustomKeyboardLayout(ReactContext reactContext, ReactSoftKeyboardMonitor
33
35
screenMonitor .addListener (this );
34
36
}
35
37
38
+ public void setShown (boolean isShown ) {
39
+ mIsShown = isShown ;
40
+ Window window = getWindow ();
41
+ if (window != null ) {
42
+ if (mIsShown ) {
43
+ mSoftInputMode = window .getAttributes ().softInputMode ;
44
+ } else {
45
+ window .setSoftInputMode (mSoftInputMode );
46
+ }
47
+ }
48
+ }
49
+
36
50
@ Override
37
51
public void onSoftKeyboardVisible (boolean distinct ) {
38
52
if (distinct ) {
@@ -167,16 +181,19 @@ private int getHeightForCustomContent() {
167
181
}
168
182
169
183
private void setKeyboardOverlayMode () {
170
- Window window = getWindow ();
171
- if (window != null ) {
172
- window .setSoftInputMode (WindowManager .LayoutParams .SOFT_INPUT_ADJUST_PAN );
173
- }
184
+ setSoftInputMode (WindowManager .LayoutParams .SOFT_INPUT_ADJUST_PAN );
174
185
}
175
186
176
187
private void clearKeyboardOverlayMode () {
177
- Window window = getWindow ();
178
- if (window != null ) {
179
- window .setSoftInputMode (WindowManager .LayoutParams .SOFT_INPUT_ADJUST_RESIZE );
188
+ setSoftInputMode (WindowManager .LayoutParams .SOFT_INPUT_ADJUST_RESIZE );
189
+ }
190
+
191
+ private void setSoftInputMode (int softInputMode ) {
192
+ if (mIsShown ) {
193
+ Window window = getWindow ();
194
+ if (window != null ) {
195
+ window .setSoftInputMode (softInputMode );
196
+ }
180
197
}
181
198
}
182
199
0 commit comments