Improve handling of focus behaviour on Android. Patch by Alexey Petruchik
authorGabriel Jacobo <gabomdq@gmail.com>
Sat, 10 May 2014 18:24:39 -0300
changeset 8768a9520d7a579c
parent 8767 8719af30db6b
child 8769 27789b1ac26d
Improve handling of focus behaviour on Android. Patch by Alexey Petruchik
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Sat May 10 17:00:37 2014 -0300
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Sat May 10 18:24:39 2014 -0300
     1.3 @@ -190,7 +190,7 @@
     1.4          if (SDLActivity.mIsPaused && SDLActivity.mIsSurfaceReady && SDLActivity.mHasFocus) {
     1.5              SDLActivity.mIsPaused = false;
     1.6              SDLActivity.nativeResume();
     1.7 -            mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, true);
     1.8 +            mSurface.handleResume();
     1.9          }
    1.10      }
    1.11          
    1.12 @@ -550,6 +550,15 @@
    1.13          mWidth = 1.0f;
    1.14          mHeight = 1.0f;
    1.15      }
    1.16 +     
    1.17 +    public void handleResume() {
    1.18 +        setFocusable(true);
    1.19 +        setFocusableInTouchMode(true);
    1.20 +        requestFocus();
    1.21 +        setOnKeyListener(this);
    1.22 +        setOnTouchListener(this);
    1.23 +        enableSensor(Sensor.TYPE_ACCELEROMETER, true);
    1.24 +    }
    1.25      
    1.26      public Surface getNativeSurface() {
    1.27          return getHolder().getSurface();