don't hide titlebar for board if there's no menu key, since on such

devices there's no other way to get to the menu.
This commit is contained in:
Eric House 2013-11-14 08:07:00 -08:00
parent 85a533c74f
commit 5826f080be
2 changed files with 47 additions and 9 deletions

View file

@ -21,13 +21,16 @@
package org.eehouse.android.xw4;
import android.app.Activity;
import android.content.Context;
import android.view.ViewConfiguration;
public class ABUtils {
private static int s_sdkVersion =
Integer.valueOf( android.os.Build.VERSION.SDK );
private static interface SafeInvalOptionsMenu {
public void doInval( Activity activity );
}
private static class SafeInvalOptionsMenuImpl
implements SafeInvalOptionsMenu {
public void doInval( Activity activity ) {
@ -35,11 +38,26 @@ public class ABUtils {
}
}
private static SafeInvalOptionsMenu s_safeInval = null;
private static interface SafeHasMenuKey {
public boolean hasMenuKey( Context context );
}
private static class SafeHasMenuKeyImpl
implements SafeHasMenuKey {
public boolean hasMenuKey( Context context )
{
return ViewConfiguration.get(context).hasPermanentMenuKey();
}
}
private static SafeHasMenuKey s_safeHas = null;
static {
int sdkVersion = Integer.valueOf( android.os.Build.VERSION.SDK );
if ( 11 <= sdkVersion ) {
if ( 11 <= s_sdkVersion ) {
s_safeInval = new SafeInvalOptionsMenuImpl();
}
if ( 14 <= s_sdkVersion ) {
s_safeHas = new SafeHasMenuKeyImpl();
}
}
public static void invalidateOptionsMenuIf( Activity activity )
@ -54,4 +72,20 @@ public class ABUtils {
return null != s_safeInval;
}
// http://stackoverflow.com/questions/10929579/how-to-check-if-android-phone-has-hardware-menu-button-in-android-2-1:
// If SDK <= 10, assume yes; >= 14, use the API; in the middle,
// assume no
public static boolean haveMenuKey( Context context )
{
boolean result;
if ( s_sdkVersion <= 10 ) {
result = true;
} else if ( s_sdkVersion < 14 ) {
result = false;
} else {
result = s_safeHas.hasMenuKey( context );
}
return result;
}
}

View file

@ -543,7 +543,8 @@ public class BoardActivity extends XWActivity
super.onCreate( savedInstanceState );
getBundledData( savedInstanceState );
if ( CommonPrefs.getHideTitleBar( this ) ) {
if ( CommonPrefs.getHideTitleBar( this )
&& ABUtils.haveMenuKey( this ) ) {
requestWindowFeature( Window.FEATURE_NO_TITLE );
}
@ -2047,10 +2048,13 @@ public class BoardActivity extends XWActivity
clearThis();
// Before we dispose, and after JNIThread has relinquished
// interest, redraw on smaller scale.
Bitmap thumb = GameUtils.takeSnapshot( this, m_jniGamePtr, m_gi );
if ( XWPrefs.getThumbEnabled( this ) ) {
// Before we dispose, and after JNIThread has
// relinquished interest, redraw on smaller scale.
Bitmap thumb =
GameUtils.takeSnapshot( this, m_jniGamePtr, m_gi );
DBUtils.saveThumbnail( this, m_gameLock, thumb );
}
XwJNI.game_dispose( m_jniGamePtr );
m_jniGamePtr = 0;