Add callback before hiding the soft keyboard
This commit is contained in:
parent
e6d5346e5e
commit
e1a7901c4c
@ -6,6 +6,7 @@ import android.content.Context;
|
|||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.view.inputmethod.InputConnection;
|
import android.view.inputmethod.InputConnection;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
// We need to extend EditText instead of view to allow copying to our STK
|
// We need to extend EditText instead of view to allow copying to our STK
|
||||||
@ -75,4 +76,10 @@ public class STKEditText extends EditText
|
|||||||
editText2STKEditbox(getText().toString(), getSelectionStart(),
|
editText2STKEditbox(getText().toString(), getSelectionStart(),
|
||||||
getSelectionEnd(), m_composing_start, m_composing_end);
|
getSelectionEnd(), m_composing_start, m_composing_end);
|
||||||
}
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
public void beforeHideKeyboard()
|
||||||
|
{
|
||||||
|
clearFocus();
|
||||||
|
setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ public class STKInputConnection extends InputConnectionWrapper
|
|||||||
{
|
{
|
||||||
/* The global edittext which will be "copied" to the current focused STK
|
/* The global edittext which will be "copied" to the current focused STK
|
||||||
* box. */
|
* box. */
|
||||||
private STKEditText m_stk_edittext;
|
final private STKEditText m_stk_edittext;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
public STKInputConnection(InputConnection target, STKEditText stk_edittext)
|
public STKInputConnection(InputConnection target, STKEditText stk_edittext)
|
||||||
|
@ -22,6 +22,18 @@ public class SuperTuxKartActivity extends NativeActivity
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
private native void saveKeyboardHeight(int height);
|
private native void saveKeyboardHeight(int height);
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
private void hideKeyboardNative()
|
||||||
|
{
|
||||||
|
if (m_stk_edittext == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_stk_edittext.beforeHideKeyboard();
|
||||||
|
|
||||||
|
InputMethodManager imm = (InputMethodManager)
|
||||||
|
getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
imm.hideSoftInputFromWindow(m_stk_edittext.getWindowToken(), 0);
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
private void hideNavBar(View decor_view)
|
private void hideNavBar(View decor_view)
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT < 19)
|
if (Build.VERSION.SDK_INT < 19)
|
||||||
@ -72,6 +84,13 @@ public class SuperTuxKartActivity extends NativeActivity
|
|||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
|
public void onPause()
|
||||||
|
{
|
||||||
|
super.onPause();
|
||||||
|
hideKeyboardNative();
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
@Override
|
||||||
public void onWindowFocusChanged(boolean has_focus)
|
public void onWindowFocusChanged(boolean has_focus)
|
||||||
{
|
{
|
||||||
super.onWindowFocusChanged(has_focus);
|
super.onWindowFocusChanged(has_focus);
|
||||||
@ -142,6 +161,7 @@ public class SuperTuxKartActivity extends NativeActivity
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
/* Called by STK in JNI. */
|
||||||
public void hideKeyboard()
|
public void hideKeyboard()
|
||||||
{
|
{
|
||||||
runOnUiThread(new Runnable()
|
runOnUiThread(new Runnable()
|
||||||
@ -149,16 +169,7 @@ public class SuperTuxKartActivity extends NativeActivity
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (m_stk_edittext == null)
|
hideKeyboardNative();
|
||||||
return;
|
|
||||||
|
|
||||||
m_stk_edittext.clearFocus();
|
|
||||||
m_stk_edittext.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager)
|
|
||||||
getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
imm.hideSoftInputFromWindow(m_stk_edittext.getWindowToken(),
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user