private void setupNavigationItems() {
    ContentResolver resolver = mContext.getContentResolver();
    // Get minimum allowed image size for layout
    int minimumImageSize = (int) mContext.getResources().getDimension(R.dimen.pie_item_size);

    mNavigationSlice.clear();

    // Reset mIconResizeFactor
    mIconResizeFactor = 1.0f;
    // Check the size set from the user and set resize values if needed
    float diff =
        PieView.PIE_ICON_START_SIZE_FACTOR
            - Settings.System.getFloatForUser(
                resolver,
                Settings.System.PIE_SIZE,
                PieView.PIE_CONTROL_SIZE_DEFAULT,
                UserHandle.USER_CURRENT);
    if (diff > 0.0f) {
      mIconResize = true;
      mIconResizeFactor = 1.0f - diff;
    } else {
      mIconResize = false;
    }

    // Prepare IME back icon
    mBackAltIcon = mContext.getResources().getDrawable(R.drawable.ic_sysbar_back_ime);
    mBackAltIcon = prepareBackIcon(mBackAltIcon, false);

    ArrayList<ActionConfig> buttonsConfig;

    // First we construct first buttons layer
    buttonsConfig = ActionHelper.getPieConfig(mContext);
    getCustomActionsAndConstruct(resolver, buttonsConfig, false, minimumImageSize);

    if (mSecondLayerActive) {
      // If second layer is active we construct second layer now
      mNavigationSliceSecondLayer.clear();
      buttonsConfig = ActionHelper.getPieSecondLayerConfig(mContext);
      getCustomActionsAndConstruct(resolver, buttonsConfig, true, minimumImageSize);
    }

    mShowMenuVisibility =
        Settings.System.getIntForUser(
            mContext.getContentResolver(),
            Settings.System.PIE_MENU,
            MENU_VISIBILITY_SYSTEM,
            UserHandle.USER_CURRENT);

    setNavigationIconHints(mNavigationIconHints, true);
    setMenuVisibility(mShowMenu);
  }
Esempio n. 2
0
 /** Fetch the brightness from the system settings and update the slider */
 private void updateSlider() {
   if (mAutomatic) {
     float value =
         Settings.System.getFloatForUser(
             mContext.getContentResolver(),
             Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ,
             0,
             UserHandle.USER_CURRENT);
     mControl.setMax((int) BRIGHTNESS_ADJ_RESOLUTION);
     mControl.setValue((int) ((value + 1) * BRIGHTNESS_ADJ_RESOLUTION / 2f));
   } else {
     int value;
     value =
         Settings.System.getIntForUser(
             mContext.getContentResolver(),
             Settings.System.SCREEN_BRIGHTNESS,
             mMaximumBacklight,
             UserHandle.USER_CURRENT);
     mControl.setMax(mMaximumBacklight - mMinimumBacklight);
     mControl.setValue(value - mMinimumBacklight);
   }
 }