diff options
author | Shuhao Wu <shuhao@shuhaowu.com> | 2014-12-24 01:58:15 +0000 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2015-10-29 17:36:26 -0700 |
commit | 2f3aeb326c531b520c5c318c0e10fac5a046538c (patch) | |
tree | e6f742243942dd4a1b4d586647b3347f722166ca /src/com/android/settings/ButtonSettings.java | |
parent | 53639c63a55c062a8cc9b26c53fb0131f4f7a72f (diff) | |
download | packages_apps_Settings-2f3aeb326c531b520c5c318c0e10fac5a046538c.zip packages_apps_Settings-2f3aeb326c531b520c5c318c0e10fac5a046538c.tar.gz packages_apps_Settings-2f3aeb326c531b520c5c318c0e10fac5a046538c.tar.bz2 |
[2/2] Left handed navbar during landscape mode
This patch allows for the navbar to be moved to the left side of the
screen during landscape mode. Left handed people are more used to this
option.
Screenshot: http://i.imgur.com/jWqJcEV.png
Contributors:
Decad3nce
https://github.com/CyanogenMod/android_packages_apps_Settings/commit/a2b5ff1542e802f4257e7a7746ceb9e1c9cf333e
romanbb
https://github.com/CyanogenMod/android_packages_apps_Settings/commit/34344a5fa2a03d849901f09340f3dd8010e2a7fe
crpalmer
https://github.com/CyanogenMod/android_packages_apps_Settings/commit/6833e8c627e0b44b0ee7191fce714556ab3eac25
Change-Id: Ic95e3fda1f55efd2ec908c8d7226e638ec0ab80a
Diffstat (limited to 'src/com/android/settings/ButtonSettings.java')
-rw-r--r-- | src/com/android/settings/ButtonSettings.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java index 5cf6e1f..e9fabc0 100644 --- a/src/com/android/settings/ButtonSettings.java +++ b/src/com/android/settings/ButtonSettings.java @@ -57,6 +57,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements private static final String KEY_APP_SWITCH_LONG_PRESS = "hardware_keys_app_switch_long_press"; private static final String KEY_VOLUME_KEY_CURSOR_CONTROL = "volume_key_cursor_control"; private static final String DISABLE_NAV_KEYS = "disable_nav_keys"; + private static final String KEY_NAVIGATION_BAR_LEFT = "navigation_bar_left"; private static final String KEY_POWER_END_CALL = "power_end_call"; private static final String KEY_HOME_ANSWER_CALL = "home_answer_call"; @@ -102,6 +103,7 @@ public class ButtonSettings extends SettingsPreferenceFragment implements private ListPreference mAppSwitchLongPressAction; private ListPreference mVolumeKeyCursorControl; private SwitchPreference mDisableNavigationKeys; + private SwitchPreference mNavigationBarLeftPref; private SwitchPreference mPowerEndCall; private SwitchPreference mHomeAnswerCall; @@ -161,6 +163,8 @@ public class ButtonSettings extends SettingsPreferenceFragment implements // Force Navigation bar related options mDisableNavigationKeys = (SwitchPreference) findPreference(DISABLE_NAV_KEYS); + // Navigation bar left + mNavigationBarLeftPref = (SwitchPreference) findPreference(KEY_NAVIGATION_BAR_LEFT); // Only visible on devices that does not have a navigation bar already, // and don't even try unless the existing keys can be disabled @@ -285,6 +289,26 @@ public class ButtonSettings extends SettingsPreferenceFragment implements } else { prefScreen.removePreference(volumeCategory); } + + try { + // Only show the navigation bar category on devices that have a navigation bar + // unless we are forcing it via development settings + boolean forceNavbar = android.provider.Settings.System.getInt(getContentResolver(), + android.provider.Settings.System.DEV_FORCE_SHOW_NAVBAR, 0) == 1; + boolean hasNavBar = WindowManagerGlobal.getWindowManagerService().hasNavigationBar() + || forceNavbar; + + if (hasNavBar) { + if (!Utils.isPhone(getActivity())) { + mNavigationPreferencesCat.removePreference(mNavigationBarLeftPref); + } + } else if (needsNavigationBar || !isKeyDisablerSupported()) { + // Hide navigation bar category + prefScreen.removePreference(mNavigationPreferencesCat); + } + } catch (RemoteException e) { + Log.e(TAG, "Error getting navigation bar status"); + } } @Override @@ -427,6 +451,9 @@ public class ButtonSettings extends SettingsPreferenceFragment implements if (appSwitchCategory != null) { appSwitchCategory.setEnabled(!enabled); } + if (mNavigationBarLeftPref != null) { + mNavigationBarLeftPref.setEnabled(enabled); + } } public static void restoreKeyDisabler(Context context) { @@ -455,6 +482,15 @@ public class ButtonSettings extends SettingsPreferenceFragment implements return super.onPreferenceTreeClick(preferenceScreen, preference); } + private static boolean isKeyDisablerSupported() { + try { + return KeyDisabler.isSupported(); + } catch (NoClassDefFoundError e) { + // Hardware abstraction framework not installed + return false; + } + } + private void handleTogglePowerButtonEndsCallPreferenceClick() { Settings.Secure.putInt(getContentResolver(), Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, (mPowerEndCall.isChecked() |