mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 762309 - Show and hide the on-screen keyboard along with the Find In Page bar [r=bnicholson]
This commit is contained in:
parent
b0860d1763
commit
3f0c0cb5de
@ -12,15 +12,19 @@ import android.view.View;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
public class CustomEditText extends EditText {
|
public class CustomEditText extends EditText {
|
||||||
|
public CustomEditText(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
mOnKeyPreImeListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
OnKeyPreImeListener mOnKeyPreImeListener;
|
OnKeyPreImeListener mOnKeyPreImeListener;
|
||||||
|
|
||||||
public interface OnKeyPreImeListener {
|
public interface OnKeyPreImeListener {
|
||||||
public boolean onKeyPreIme(View v, int keyCode, KeyEvent event);
|
public boolean onKeyPreIme(View v, int keyCode, KeyEvent event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CustomEditText(Context context, AttributeSet attrs) {
|
public void setOnKeyPreImeListener(OnKeyPreImeListener listener) {
|
||||||
super(context, attrs);
|
mOnKeyPreImeListener = listener;
|
||||||
mOnKeyPreImeListener = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -31,7 +35,20 @@ public class CustomEditText extends EditText {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnKeyPreImeListener(OnKeyPreImeListener listener) {
|
public void setOnWindowFocusChangeListener(OnWindowFocusChangeListener listener) {
|
||||||
mOnKeyPreImeListener = listener;
|
mOnWindowFocusChangeListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
OnWindowFocusChangeListener mOnWindowFocusChangeListener;
|
||||||
|
|
||||||
|
public interface OnWindowFocusChangeListener {
|
||||||
|
public void onWindowFocusChanged(boolean hasFocus);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
|
super.onWindowFocusChanged(hasFocus);
|
||||||
|
if (mOnWindowFocusChangeListener != null)
|
||||||
|
mOnWindowFocusChangeListener.onWindowFocusChanged(hasFocus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import android.view.KeyEvent;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.RelativeLayout.LayoutParams;
|
import android.widget.RelativeLayout.LayoutParams;
|
||||||
|
|
||||||
@ -58,13 +59,34 @@ public class FindInPageBar extends RelativeLayout implements TextWatcher, View.O
|
|||||||
|
|
||||||
setVisibility(VISIBLE);
|
setVisibility(VISIBLE);
|
||||||
mFindText.requestFocus();
|
mFindText.requestFocus();
|
||||||
|
|
||||||
|
// Show the virtual keyboard.
|
||||||
|
if (mFindText.hasWindowFocus()) {
|
||||||
|
getInputMethodManager(mFindText).showSoftInput(mFindText, 0);
|
||||||
|
} else {
|
||||||
|
// showSoftInput won't work until after the window is focused.
|
||||||
|
mFindText.setOnWindowFocusChangeListener(new CustomEditText.OnWindowFocusChangeListener() {
|
||||||
|
public void onWindowFocusChanged(boolean hasFocus) {
|
||||||
|
if (!hasFocus)
|
||||||
|
return;
|
||||||
|
mFindText.setOnWindowFocusChangeListener(null);
|
||||||
|
getInputMethodManager(mFindText).showSoftInput(mFindText, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide() {
|
public void hide() {
|
||||||
setVisibility(GONE);
|
setVisibility(GONE);
|
||||||
|
getInputMethodManager(mFindText).hideSoftInputFromWindow(mFindText.getWindowToken(), 0);
|
||||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FindInPage:Closed", null));
|
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FindInPage:Closed", null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private InputMethodManager getInputMethodManager(View view) {
|
||||||
|
Context context = view.getContext();
|
||||||
|
return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
}
|
||||||
|
|
||||||
// TextWatcher implementation
|
// TextWatcher implementation
|
||||||
|
|
||||||
public void afterTextChanged(Editable s) {
|
public void afterTextChanged(Editable s) {
|
||||||
|
Loading…
Reference in New Issue
Block a user