Improve handling of focus behaviour on Android. Patch by Alexey Petruchik

This commit is contained in:
Gabriel Jacobo 2014-05-10 18:24:39 -03:00
parent b701175ab5
commit d5a2e55d48
1 changed files with 10 additions and 1 deletions

View File

@ -190,7 +190,7 @@ public class SDLActivity extends Activity {
if (SDLActivity.mIsPaused && SDLActivity.mIsSurfaceReady && SDLActivity.mHasFocus) {
SDLActivity.mIsPaused = false;
SDLActivity.nativeResume();
mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
mSurface.handleResume();
}
}
@ -550,6 +550,15 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
mWidth = 1.0f;
mHeight = 1.0f;
}
public void handleResume() {
setFocusable(true);
setFocusableInTouchMode(true);
requestFocus();
setOnKeyListener(this);
setOnTouchListener(this);
enableSensor(Sensor.TYPE_ACCELEROMETER, true);
}
public Surface getNativeSurface() {
return getHolder().getSurface();