private String getProperSummary(String uri) { if (uri == null) return AwesomeConstants.getProperName(mContext, "**null**"); if (uri.startsWith("**")) { return AwesomeConstants.getProperName(mContext, uri); } else { return mPicker.getFriendlyNameForUri(uri); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.title_navbar); // Load the preferences from an XML resource addPreferencesFromResource(R.xml.navbar_settings); PreferenceScreen prefs = getPreferenceScreen(); mPicker = new ShortcutPickerHelper(this, this); mPackMan = getPackageManager(); mResources = mContext.getResources(); // Get NavBar Actions mActionCodes = NavBarHelpers.getNavBarActions(); mActions = new String[mActionCodes.length]; int actionqty = mActions.length; for (int i = 0; i < actionqty; i++) { mActions[i] = AwesomeConstants.getProperName(mContext, mActionCodes[i]); } menuDisplayLocation = (ListPreference) findPreference(PREF_MENU_UNLOCK); menuDisplayLocation.setOnPreferenceChangeListener(this); menuDisplayLocation.setValue( Settings.System.getInt(mContentRes, Settings.System.MENU_LOCATION, 0) + ""); mNavBarMenuDisplay = (ListPreference) findPreference(PREF_NAVBAR_MENU_DISPLAY); mNavBarMenuDisplay.setOnPreferenceChangeListener(this); mNavBarMenuDisplay.setValue( Settings.System.getInt(mContentRes, Settings.System.MENU_VISIBILITY, 0) + ""); mNavBarHideEnable = (CheckBoxPreference) findPreference(NAVBAR_HIDE_ENABLE); mNavBarHideEnable.setChecked( Settings.System.getBoolean(mContentRes, Settings.System.NAV_HIDE_ENABLE, false)); final int defaultDragOpacity = Settings.System.getInt(mContentRes, Settings.System.DRAG_HANDLE_OPACITY, 50); mDragHandleOpacity = (SeekBarPreference) findPreference(DRAG_HANDLE_OPACITY); mDragHandleOpacity.setInitValue((int) (defaultDragOpacity)); mDragHandleOpacity.setOnPreferenceChangeListener(this); final int defaultDragWidth = Settings.System.getInt(mContentRes, Settings.System.DRAG_HANDLE_WEIGHT, 5); mDragHandleWidth = (SeekBarPreference) findPreference(DRAG_HANDLE_WIDTH); mDragHandleWidth.setInitValue((int) (defaultDragWidth)); mDragHandleWidth.setOnPreferenceChangeListener(this); mNavBarHideTimeout = (ListPreference) findPreference(NAVBAR_HIDE_TIMEOUT); mNavBarHideTimeout.setOnPreferenceChangeListener(this); mNavBarHideTimeout.setValue( Settings.System.getInt(mContentRes, Settings.System.NAV_HIDE_TIMEOUT, 3000) + ""); boolean hasNavBarByDefault = mContext.getResources().getBoolean(com.android.internal.R.bool.config_showNavigationBar); mEnableNavigationBar = (CheckBoxPreference) findPreference(ENABLE_NAVIGATION_BAR); mEnableNavigationBar.setChecked( Settings.System.getBoolean( mContentRes, Settings.System.NAVIGATION_BAR_SHOW, hasNavBarByDefault)); mNavigationColor = (ColorPickerPreference) findPreference(NAVIGATION_BAR_COLOR); mNavigationColor.setOnPreferenceChangeListener(this); mNavigationBarColor = (ColorPickerPreference) findPreference(PREF_NAV_COLOR); mNavigationBarColor.setOnPreferenceChangeListener(this); mColorizeAllIcons = (CheckBoxPreference) findPreference("navigation_bar_allcolor"); mColorizeAllIcons.setChecked( Settings.System.getBoolean(mContentRes, Settings.System.NAVIGATION_BAR_ALLCOLOR, false)); mNavigationBarGlowColor = (ColorPickerPreference) findPreference(PREF_NAV_GLOW_COLOR); mNavigationBarGlowColor.setOnPreferenceChangeListener(this); mGlowTimes = (ListPreference) findPreference(PREF_GLOW_TIMES); mGlowTimes.setOnPreferenceChangeListener(this); final float defaultButtonAlpha = Settings.System.getFloat(mContentRes, Settings.System.NAVIGATION_BAR_BUTTON_ALPHA, 0.6f); mButtonAlpha = (SeekBarPreference) findPreference("button_transparency"); mButtonAlpha.setInitValue((int) (defaultButtonAlpha * 100)); mButtonAlpha.setOnPreferenceChangeListener(this); mWidthHelp = (Preference) findPreference("width_help"); float defaultPort = Settings.System.getFloat(mContentRes, Settings.System.NAVIGATION_BAR_WIDTH_PORT, 0f); mWidthPort = (SeekBarPreference) findPreference("width_port"); mWidthPort.setInitValue((int) (defaultPort * 2.5f)); mWidthPort.setOnPreferenceChangeListener(this); float defaultLand = Settings.System.getFloat(mContentRes, Settings.System.NAVIGATION_BAR_WIDTH_LAND, 0f); mWidthLand = (SeekBarPreference) findPreference("width_land"); mWidthLand.setInitValue((int) (defaultLand * 2.5f)); mWidthLand.setOnPreferenceChangeListener(this); mNavigationBarHeight = (ListPreference) findPreference("navigation_bar_height"); mNavigationBarHeight.setOnPreferenceChangeListener(this); mNavigationBarHeightLandscape = (ListPreference) findPreference("navigation_bar_height_landscape"); mNavigationBarHeightLandscape.setOnPreferenceChangeListener(this); mNavigationBarWidth = (ListPreference) findPreference("navigation_bar_width"); mNavigationBarWidth.setOnPreferenceChangeListener(this); mConfigureWidgets = findPreference(NAVIGATION_BAR_WIDGETS); mMenuArrowKeysCheckBox = (CheckBoxPreference) findPreference(PREF_MENU_ARROWS); mMenuArrowKeysCheckBox.setChecked( Settings.System.getBoolean( mContentRes, Settings.System.NAVIGATION_BAR_MENU_ARROW_KEYS, true)); // don't allow devices that must use a navigation bar to disable it if (hasNavBarByDefault) { prefs.removePreference(mEnableNavigationBar); } PreferenceGroup pg = (PreferenceGroup) prefs.findPreference("advanced_cat"); if (isTablet(mContext)) { mNavigationBarHeight.setTitle(R.string.system_bar_height_title); mNavigationBarHeight.setSummary(R.string.system_bar_height_summary); mNavigationBarHeightLandscape.setTitle(R.string.system_bar_height_landscape_title); mNavigationBarHeightLandscape.setSummary(R.string.system_bar_height_landscape_summary); pg.removePreference(mNavigationBarWidth); mNavBarHideEnable.setEnabled(false); mDragHandleOpacity.setEnabled(false); mDragHandleWidth.setEnabled(false); mNavBarHideTimeout.setEnabled(false); } else { // Phones&Phablets don't have SystemBar pg.removePreference(mWidthPort); pg.removePreference(mWidthLand); pg.removePreference(mWidthHelp); } if (Integer.parseInt(menuDisplayLocation.getValue()) == 4) { mNavBarMenuDisplay.setEnabled(false); } // Only show the hardware keys config on a device that does not have a navbar IWindowManager windowManager = IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE)); if (hasNavBarByDefault) { // Let's assume they don't have hardware keys getPreferenceScreen().removePreference(findPreference(KEY_HARDWARE_KEYS)); } refreshSettings(); setHasOptionsMenu(true); updateGlowTimesSummary(); }