Please add these 3 changes to Android code to allow support for orientation change

It is easy to add orientation change to Cocos2dx on Android but it needs some very small changes within core cocos files.

It will be great if these 3 changes can be made in core files so that users don’t need to manually redo them after every new release.

  1. Declare a new native function in Cocos2dxRenderer.java:

     private static native void nativeSurfaceChanged(final int w, final int h);
    
  2. Call that new function in onSurfaceChanged in Cocos2dxRenderer.java:

     public void onSurfaceChanged(final GL10 pGL10, final int pWidth, final int pHeight) {
         nativeSurfaceChanged(pWidth, pHeight);
     }
    
  3. Define that new native function in main.cpp that is generated when creating a new Android project:

    void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeSurfaceChanged(JNIEnv* env, jobject thiz, jint w, jint h)
    {
    cocos2d::CCEGLView* view = cocos2d::CCDirector::sharedDirector()->getOpenGLView();
    if (view)
    {
    if (view->getFrameSize().width != w || view->getFrameSize().height != h)
    {
    // Do app specific orientation change coding here. One easy approach is to restart current scene.
    // It is app’s responsibility to restore state of elements in their scene and reposition them for new size
    // eg: CCDirector::sharedDirector()->replaceScene(currentScene);
    }
    }
    }