Settings: Only show gesture navigation if device has a software nav bar
Change-Id: Ic90c8a194a736807c2e101ffd5f7e90c86a55381
This commit is contained in:
parent
2e10956562
commit
71b30e4772
1 changed files with 17 additions and 2 deletions
|
|
@ -23,6 +23,10 @@ import android.content.ComponentName;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.RemoteException;
|
||||
import android.view.Display;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.WindowManagerGlobal;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
|
|
@ -54,9 +58,20 @@ public class SystemNavigationPreferenceController extends BasePreferenceControll
|
|||
|
||||
/** Returns {@code true} if gesture is available. */
|
||||
public static boolean isGestureAvailable(Context context) {
|
||||
boolean hasNavigationBar = false;
|
||||
final boolean configEnabled = context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_swipe_up_gesture_setting_available);
|
||||
|
||||
try {
|
||||
IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService();
|
||||
hasNavigationBar = windowManager.hasNavigationBar(Display.DEFAULT_DISPLAY);
|
||||
} catch (RemoteException ex) {
|
||||
// no window manager? good luck with that
|
||||
}
|
||||
|
||||
// Skip if the swipe up settings are not available
|
||||
if (!context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_swipe_up_gesture_setting_available)) {
|
||||
// or if on-screen navbar is disabled (for devices with hardware keys)
|
||||
if (!configEnabled || !hasNavigationBar) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue