Ejemplo n.º 1
0
  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);
  }
Ejemplo n.º 2
0
  private int setPieItemIcon(ImageView view, String iconUri, String clickAction) {
    Drawable d = ActionHelper.getActionIconImage(mContext, clickAction, iconUri);
    if (d != null) {
      view.setImageDrawable(d);
    }

    if (iconUri != null
        && !iconUri.equals(ActionConstants.ICON_EMPTY)
        && !iconUri.startsWith(ActionConstants.SYSTEM_ICON_IDENTIFIER)) {
      if (clickAction.equals(ActionConstants.ACTION_BACK)) {
        // Back icon image needs to be handled seperatly.
        // All other is handled in PieItem.
        mBackIcon = prepareBackIcon(d, true);
      } else {
        // Custom images need to be forced to resize to fit better
        resizeIcon(view, null, true);
      }
      return 2;
    } else {
      if (clickAction.startsWith("**")
          || iconUri.startsWith(ActionConstants.SYSTEM_ICON_IDENTIFIER)) {
        if (clickAction.equals(ActionConstants.ACTION_BACK)) {
          mBackIcon = prepareBackIcon(d, false);
        }
        if (mIconResize) {
          resizeIcon(view, null, false);
        }
        return 0;
      }
      resizeIcon(view, null, true);
      return 1;
    }
  }
Ejemplo n.º 3
0
    @Override
    public void onChange(boolean selfChange, Uri uri) {
      super.onChange(selfChange, uri);

      if (uri.equals(Settings.System.getUriFor(Settings.System.PIE_BUTTONS_CONFIG_SECOND_LAYER))) {

        ArrayList<ActionConfig> buttonsConfig = ActionHelper.getPieSecondLayerConfig(mContext);
        if (mSecondLayerActive != buttonsConfig.size() > 0) {
          constructSlices();
        }
      }
      refreshContainer();
    }
Ejemplo n.º 4
0
  public void constructSlices() {
    final Resources res = mContext.getResources();

    // Clear the slices
    mPieContainer.clearSlices();

    // Construct navbar slice
    int inner = res.getDimensionPixelSize(R.dimen.pie_navbar_radius);
    int outer = inner + res.getDimensionPixelSize(R.dimen.pie_navbar_height);
    mNavigationSlice =
        new PieSliceContainer(mPieContainer, PieSlice.IMPORTANT | PieDrawable.DISPLAY_ALL);
    mNavigationSlice.setGeometry(START_ANGLE, 180 - 2 * EMPTY_ANGLE, inner, outer);

    // Construct maybe navbar slice second layer
    ArrayList<ActionConfig> buttonsConfig = ActionHelper.getPieSecondLayerConfig(mContext);
    mSecondLayerActive = buttonsConfig.size() > 0;
    if (mSecondLayerActive) {
      inner = res.getDimensionPixelSize(R.dimen.pie_navbar_second_layer_radius);
      outer = inner + res.getDimensionPixelSize(R.dimen.pie_navbar_height);
      mNavigationSliceSecondLayer =
          new PieSliceContainer(mPieContainer, PieSlice.IMPORTANT | PieDrawable.DISPLAY_ALL);
      mNavigationSliceSecondLayer.setGeometry(START_ANGLE, 180 - 2 * EMPTY_ANGLE, inner, outer);
    }

    // Setup buttons and add the slices finally
    mPieContainer.addSlice(mNavigationSlice);
    if (mSecondLayerActive) {
      mPieContainer.addSlice(mNavigationSliceSecondLayer);
      // Adjust dimensions for sysinfo when second layer is active
      inner = res.getDimensionPixelSize(R.dimen.pie_sysinfo_second_layer_radius);
    } else {
      inner = res.getDimensionPixelSize(R.dimen.pie_sysinfo_radius);
    }

    // Construct sysinfo slice
    outer = inner + res.getDimensionPixelSize(R.dimen.pie_sysinfo_height);
    mSysInfo = new PieSysInfo(mContext, mPieContainer, this, PieDrawable.DISPLAY_NOT_AT_TOP);
    mSysInfo.setGeometry(START_ANGLE, 180 - 2 * EMPTY_ANGLE, inner, outer);
    mPieContainer.addSlice(mSysInfo);
  }