diff --git a/engine/android/AndroidManifest.xml b/engine/android/AndroidManifest.xml index cc4f412bf..dde0a832d 100644 --- a/engine/android/AndroidManifest.xml +++ b/engine/android/AndroidManifest.xml @@ -2,11 +2,11 @@ - - + + @@ -24,7 +24,7 @@ android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> diff --git a/engine/android/jni/openbor/video.c b/engine/android/jni/openbor/video.c index f69a029ff..f44438068 100644 --- a/engine/android/jni/openbor/video.c +++ b/engine/android/jni/openbor/video.c @@ -27,7 +27,8 @@ extern int videoMode; SDL_Window *window = NULL; SDL_Renderer *renderer = NULL; -SDL_Texture *texture = NULL; +SDL_Texture *texture = NULL; +SDL_Texture *texture_base = NULL; //For Android - Textures and a surface for the buttons SDL_Texture *buttons = NULL; @@ -355,7 +356,12 @@ int video_set_mode(s_videomodes videomodes) // 8-bit color should be transparently converted to 32-bit assert(videomodes.pixel == 2 || videomodes.pixel == 4); - //destroy all + //destroy all + if(texture_base) + { + SDL_DestroyTexture(texture_base); + texture_base = NULL; + } if(texture) { SDL_DestroyTexture(texture); @@ -397,6 +403,20 @@ int video_set_mode(s_videomodes videomodes) textureWidth = videomodes.hRes; textureHeight = videomodes.vRes; + + if(!texture_base) + { + SDL_Surface *tmp_surface = SDL_CreateRGBSurface(0, 800, 480, 32, 0, 0, 0, 0); + SDL_FillRect(tmp_surface, NULL, SDL_MapRGB(tmp_surface->format, 0, 0, 0)); + SDL_SetSurfaceBlendMode(tmp_surface, SDL_BLENDMODE_NONE); + if(!tmp_surface || !(texture_base = SDL_CreateTextureFromSurface(renderer, tmp_surface))) + { + printf("error: %s\n", SDL_GetError()); + return 0; + } + SDL_FreeSurface(tmp_surface); + tmp_surface = NULL; + } if(!(texture = SDL_CreateTexture(renderer, pixelformats[videomodes.pixel-1], SDL_TEXTUREACCESS_STREAMING, textureWidth, textureHeight))) { @@ -408,14 +428,14 @@ int video_set_mode(s_videomodes videomodes) if(!buttons) { - SDL_Surface *bscreen = pngToSurface(buttonpng); - if(!bscreen || !(buttons = SDL_CreateTextureFromSurface(renderer, bscreen))) + SDL_Surface *btn_screen = pngToSurface(buttonpng); + if(!btn_screen || !(buttons = SDL_CreateTextureFromSurface(renderer, btn_screen))) { printf("error: %s\n", SDL_GetError()); return 0; } - SDL_FreeSurface(bscreen); - bscreen = NULL; + SDL_FreeSurface(btn_screen); + btn_screen = NULL; } SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); @@ -434,6 +454,13 @@ void blit() int hide_touch; extern int hide_t; + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0); + SDL_RenderClear(renderer); + + SDL_RenderSetLogicalSize(renderer, 0, 0); + SDL_SetTextureBlendMode(texture_base, SDL_BLENDMODE_NONE); + SDL_RenderCopy(renderer, texture_base, NULL, NULL); + if(stretch) { SDL_RenderSetLogicalSize(renderer, 0, 0); @@ -442,9 +469,6 @@ void blit() { SDL_RenderSetLogicalSize(renderer, textureWidth, textureHeight); } - - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0); - SDL_RenderClear(renderer); SDL_RenderCopy(renderer, texture, NULL, NULL); if(brightness > 0) diff --git a/engine/android/project.properties b/engine/android/project.properties index 9b84a6b4b..4ab125693 100644 --- a/engine/android/project.properties +++ b/engine/android/project.properties @@ -11,4 +11,4 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-16 +target=android-19 diff --git a/engine/android/src/org/libsdl/app/SDLActivity.java b/engine/android/src/org/libsdl/app/SDLActivity.java index df1b5cdd8..e30bbb8d4 100644 --- a/engine/android/src/org/libsdl/app/SDLActivity.java +++ b/engine/android/src/org/libsdl/app/SDLActivity.java @@ -75,7 +75,8 @@ public enum NativeState { protected static boolean mScreenKeyboardShown; protected static ViewGroup mLayout; protected static SDLClipboardHandler mClipboardHandler; - protected static WakeLock wakeLock; + protected static WakeLock wakeLock; + protected static View decorView; // This is what SDL runs in. It invokes SDL_main(), eventually @@ -227,8 +228,24 @@ public void onClick(DialogInterface dialog,int id) { mLayout.addView(mSurface); setContentView(mLayout); - setWindowStyle(false); - CopyPak("BOR"); + setWindowStyle(false); + + CopyPak("BOR"); + + //White Dragon: hide navigation bar programmatically + SDLActivity.decorView = getWindow().getDecorView(); + hideSystemUI(); + + SDLActivity.decorView.setOnSystemUiVisibilityChangeListener + (new View.OnSystemUiVisibilityChangeListener() { + @Override + public void onSystemUiVisibilityChange(int visibility) { + if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { + hideSystemUI(); + } + } + }); + //CRxTRDude - Added FLAG_KEEP_SCREEN_ON to prevent screen timeout. getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -250,7 +267,21 @@ public void onClick(DialogInterface dialog,int id) { }*/ } - public static native void setRootDir(String dir); + public static native void setRootDir(String dir); + + private void hideSystemUI() { + // Set the IMMERSIVE flag. + // Set the content to appear under the system bars so that the content + // doesn't resize when the system bars hide and show. + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar + | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar + | View.SYSTEM_UI_FLAG_IMMERSIVE); + } + private void CopyPak(String pakName) { @@ -333,7 +364,9 @@ public void onWindowFocusChanged(boolean hasFocus) { SDLActivity.mHasFocus = hasFocus; if (hasFocus) { - mNextNativeState = NativeState.RESUMED; + mNextNativeState = NativeState.RESUMED; + + hideSystemUI(); } else { mNextNativeState = NativeState.PAUSED; }