private Drawable getNavbarIconImage(String uri) { if (uri == null) uri = AwesomeConstant.ACTION_NULL.value(); if (uri.startsWith("**")) { return AwesomeConstants.getActionIcon(mContext, uri); } else { try { return mPackMan.getActivityIcon(Intent.parseUri(uri, 0)); } catch (NameNotFoundException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } } return mResources.getDrawable(R.drawable.ic_sysbar_null); }
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); } }
public void refreshButtons() { if (mNumberofButtons == 0) { return; } int navBarColor = Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_COLOR, -1); int navButtonColor = Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_TINT, -1); float navButtonAlpha = Settings.System.getFloat( mContentRes, Settings.System.NAVIGATION_BAR_BUTTON_ALPHA, STOCK_ALPHA); int glowColor = Settings.System.getInt(mContentRes, Settings.System.NAVIGATION_BAR_GLOW_TINT, 0); float BarAlpha = 1.0f; String alphas[]; String settingValue = Settings.System.getString(mContentRes, Settings.System.NAVIGATION_BAR_ALPHA_CONFIG); if (!TextUtils.isEmpty(settingValue)) { alphas = settingValue.split(";"); BarAlpha = Float.parseFloat(alphas[0]) / 255; } int a = Math.round(BarAlpha * 255); Drawable mBackground = AwesomeConstants.getSystemUIDrawable(mContext, "com.android.systemui:drawable/nav_bar_bg"); if (mBackground instanceof ColorDrawable) { BackgroundAlphaColorDrawable bacd = new BackgroundAlphaColorDrawable( navBarColor > 0 ? navBarColor : ((ColorDrawable) mBackground).getColor()); bacd.setAlpha(a); mNavBarContainer.setBackground(bacd); } else { mBackground.setAlpha(a); mNavBarContainer.setBackground(mBackground); } for (int i = 0; i < mNumberofButtons; i++) { ImageButton ib = mButtonViews.get(i); Drawable d = mButtons.get(i).getIcon(); if (navButtonColor != -1) { d.setColorFilter(navButtonColor, PorterDuff.Mode.SRC_ATOP); } ib.setImageDrawable(d); ib.setOnClickListener(mNavBarClickListener); ib.setVisibility(View.VISIBLE); ib.setAlpha(navButtonAlpha); StateListDrawable sld = new StateListDrawable(); sld.addState(new int[] {android.R.attr.state_pressed}, new ColorDrawable(glowColor)); sld.addState(StateSet.WILD_CARD, mNavBarContainer.getBackground()); ib.setBackground(sld); } for (int i = mNumberofButtons; i < mButtonViews.size(); i++) { ImageButton ib = mButtonViews.get(i); ib.setVisibility(View.GONE); } int menuloc = Settings.System.getInt(mContentRes, Settings.System.MENU_LOCATION, 0); switch (menuloc) { case SHOW_BOTH_MENU: mLeftMenu.setVisibility(View.VISIBLE); mRightMenu.setVisibility(View.VISIBLE); break; case SHOW_LEFT_MENU: mLeftMenu.setVisibility(View.VISIBLE); mRightMenu.setVisibility(View.INVISIBLE); break; case SHOW_RIGHT_MENU: mLeftMenu.setVisibility(View.INVISIBLE); mRightMenu.setVisibility(View.VISIBLE); break; case SHOW_DONT: mLeftMenu.setVisibility(View.GONE); mRightMenu.setVisibility(View.GONE); break; } if (navButtonColor != -1) { mLeftMenu.setColorFilter(navButtonColor); mRightMenu.setColorFilter(navButtonColor); } }
@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(); }