mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-07 12:50:38 +08:00
XashActivity: enable navbar menu key
This commit is contained in:
@@ -102,6 +102,28 @@ public class XashActivity extends Activity {
|
|||||||
{
|
{
|
||||||
System.loadLibrary( "xash" );
|
System.loadLibrary( "xash" );
|
||||||
}
|
}
|
||||||
|
public void enableNavbarMenu()
|
||||||
|
{
|
||||||
|
if( sdk < 21 )
|
||||||
|
return;
|
||||||
|
Window w = getWindow();
|
||||||
|
for (Class clazz = w.getClass(); clazz != null; clazz = clazz.getSuperclass()) {
|
||||||
|
try {
|
||||||
|
Method method = clazz.getDeclaredMethod("setNeedsMenuKey", int.class);
|
||||||
|
method.setAccessible(true);
|
||||||
|
try {
|
||||||
|
method.invoke(w, 1); // 1 == WindowManager.LayoutParams.NEEDS_MENU_SET_TRUE
|
||||||
|
break;
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
Log.d(TAG, "IllegalAccessException on window.setNeedsMenuKey");
|
||||||
|
} catch (java.lang.reflect.InvocationTargetException e) {
|
||||||
|
Log.d(TAG, "InvocationTargetException on window.setNeedsMenuKey");
|
||||||
|
}
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// Log.d(TAG, "NoSuchMethodException");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
@Override
|
@Override
|
||||||
@@ -123,11 +145,13 @@ public class XashActivity extends Activity {
|
|||||||
|
|
||||||
// fullscreen
|
// fullscreen
|
||||||
requestWindowFeature( Window.FEATURE_NO_TITLE );
|
requestWindowFeature( Window.FEATURE_NO_TITLE );
|
||||||
|
final int FLAG_NEEDS_MENU_KEY = 0x08000000;
|
||||||
|
|
||||||
int flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
|
int flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
|
||||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | FLAG_NEEDS_MENU_KEY;
|
||||||
getWindow().setFlags( flags, flags );
|
getWindow().setFlags( flags, flags );
|
||||||
|
|
||||||
|
enableNavbarMenu();
|
||||||
// landscapeSensor is not supported until API9
|
// landscapeSensor is not supported until API9
|
||||||
if( sdk < 9 )
|
if( sdk < 9 )
|
||||||
setRequestedOrientation( 0 );
|
setRequestedOrientation( 0 );
|
||||||
@@ -1389,6 +1413,7 @@ class AndroidBug5497Workaround
|
|||||||
FWGSLib.cmp.applyImmersiveMode( XashActivity.keyboardVisible, XashActivity.mDecorView );
|
FWGSLib.cmp.applyImmersiveMode( XashActivity.keyboardVisible, XashActivity.mDecorView );
|
||||||
|
|
||||||
mChildOfContent.requestLayout();
|
mChildOfContent.requestLayout();
|
||||||
|
XashActivity.mSingleton.enableNavbarMenu();
|
||||||
usableHeightPrevious = usableHeightNow;
|
usableHeightPrevious = usableHeightNow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1399,4 +1424,4 @@ class AndroidBug5497Workaround
|
|||||||
mChildOfContent.getWindowVisibleDisplayFrame( r );
|
mChildOfContent.getWindowVisibleDisplayFrame( r );
|
||||||
return r.bottom - r.top;
|
return r.bottom - r.top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user