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 | |
| parent | 53639c63a55c062a8cc9b26c53fb0131f4f7a72f (diff) | |
| download | packages_apps_Settings-2f3aeb326c531b520c5c318c0e10fac5a046538c.tar.gz packages_apps_Settings-2f3aeb326c531b520c5c318c0e10fac5a046538c.tar.bz2 packages_apps_Settings-2f3aeb326c531b520c5c318c0e10fac5a046538c.zip | |
[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
| -rw-r--r-- | res/values/cm_strings.xml | 5 | ||||
| -rw-r--r-- | res/xml/button_settings.xml | 12 | ||||
| -rw-r--r-- | src/com/android/settings/ButtonSettings.java | 36 |
3 files changed, 53 insertions, 0 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index fa5a9b28c..6b7389532 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -251,6 +251,11 @@ <string name="profile_setup_setup_triggers_description">Please select triggers which will activate this profile</string> <string name="profile_setup_actions_description">Now configure what happens when the profile is activated</string> + <!-- Navigation Bar --> + <string name="navigation_bar_category">Navigation bar</string> + <string name="navigation_bar_left_title">Left-handed mode</string> + <string name="navigation_bar_left_summary">Place the navigation bar on the left side of the screen in landscape mode</string> + <!-- Notification light dialogs --> <string name="edit_light_settings">Edit light settings</string> <string name="pulse_speed_title">Pulse length and speed</string> diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml index 9a7752d46..df76f5774 100644 --- a/res/xml/button_settings.xml +++ b/res/xml/button_settings.xml @@ -24,6 +24,18 @@ android:defaultValue="false" /> <PreferenceCategory + android:key="navigation_bar" + android:title="@string/navigation_bar_category" > + + <com.android.settings.cyanogenmod.SystemSettingSwitchPreference + android:key="navigation_bar_left" + android:title="@string/navigation_bar_left_title" + android:summary="@string/navigation_bar_left_summary" + android:defaultValue="false" /> + + </PreferenceCategory> + + <PreferenceCategory android:key="power_key" android:title="@string/hardware_keys_power_key_title" > diff --git a/src/com/android/settings/ButtonSettings.java b/src/com/android/settings/ButtonSettings.java index 5cf6e1f12..e9fabc0a7 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() |
