Bug 1253426 - When Fennec is brought to the foreground, soft keyboard needs to be restored if it was previously visible r=snorp

This commit is contained in:
Randall Barker 2016-03-02 14:13:26 -08:00
parent e0df9454b0
commit 3ab57f32f0
3 changed files with 36 additions and 0 deletions

View File

@ -473,6 +473,8 @@ class GeckoInputConnection
return mEditableClient.setInputConnectionHandler(getBackgroundHandler());
}
private boolean mIsVisible = false;
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
if (mIMEState == IME_STATE_DISABLED) {
@ -585,6 +587,13 @@ class GeckoInputConnection
Editable editable = getEditable();
outAttrs.initialSelStart = Selection.getSelectionStart(editable);
outAttrs.initialSelEnd = Selection.getSelectionEnd(editable);
if (mIsVisible) {
// The app has been brought to the foreground and the Soft Keyboard
// was previously visible, so request that it be shown again.
showSoftInput();
}
return this;
}
@ -790,6 +799,16 @@ class GeckoInputConnection
return processKey(KeyEvent.ACTION_UP, keyCode, event);
}
@Override
public void onWindowVisibilityChanged (int visibility) {
if (visibility == View.VISIBLE) {
mIsVisible = true;
} else {
mIsVisible = false;
hideSoftInput();
}
}
/**
* Get a key that represents a given character.
*/

View File

@ -343,8 +343,24 @@ public class GeckoView extends LayerView
}
}
private int mLastVisibility = View.GONE;
/* package */ void setInputConnectionListener(final InputConnectionListener icl) {
mInputConnectionListener = icl;
if (mInputConnectionListener != null) {
mInputConnectionListener.onWindowVisibilityChanged(mLastVisibility);
}
}
@Override
protected void onWindowVisibilityChanged (int visibility) {
mLastVisibility = visibility;
if (mInputConnectionListener != null) {
mInputConnectionListener.onWindowVisibilityChanged(visibility);
}
super.onWindowVisibilityChanged(visibility);
}
@Override

View File

@ -21,5 +21,6 @@ interface InputConnectionListener
boolean onKeyLongPress(int keyCode, KeyEvent event);
boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event);
boolean onKeyUp(int keyCode, KeyEvent event);
void onWindowVisibilityChanged (int visibility);
boolean isIMEEnabled();
}