/** @brief update helper function for the polaroid bg layer */
  private void updatePolaroidDrawable(Rect bounds) {
    PDEColor highColor;
    PDEColor lowColor;
    float red, green, blue;
    Rect frameRect = new Rect(0, 0, bounds.width(), bounds.height());

    mElementCornerRadius = bounds.width() * 0.07f;
    // update Frame
    mElementPolaroidDrawable.setBounds(frameRect);
    mElementPolaroidDrawable.setElementCornerRadius(mElementCornerRadius);
    mElementPolaroidDrawable.setElementBorderColor(mElementPolaroidFrameColor);
    // todo: this border stuff does not work properly!!! So we take a workaround.
    // mElementPolaroidDrawable.setElementBorderWidth(polaroidRelativeValue(2.5f));
    int border = Math.round(polaroidRelativeValue(2.5f));
    mElementGradientDrawable.setBounds(
        frameRect.left + border,
        frameRect.top + border,
        frameRect.right - border,
        frameRect.bottom - border);

    red = mElementPolaroidFrameColor.getRed();
    blue = mElementPolaroidFrameColor.getBlue();
    green = mElementPolaroidFrameColor.getGreen();

    highColor = new PDEColor(red, green, blue, 0.0f);
    lowColor = new PDEColor(red - 0.33f, green - 0.33f, blue - 0.33f, 0.75f);
    mElementGradientDrawable.setElementBackgroundGradientColors(highColor, highColor, lowColor);
    mElementGradientDrawable.setElementGradientDistributionPositions(0.0f, 0.85f, 1.0f);

    // set other layer data
    mElementPolaroidDrawable.setElementBackgroundColor(mElementPolaroidFrameColor);
    mElementGradientDrawable.setElementCornerRadius(mElementCornerRadius);
    mElementGradientDrawable.setElementBorderColor(PDEColor.valueOf("DTTransparentBlack"));
  }
  /** @brief update function for the image layer (image self, image gradient, image inner-shadow) */
  private void updateElementImageDrawable(Rect bounds) {
    PDEColor highColor, mainColor;
    PDEColor lowColor;
    //        float placeHolderFrameDistance;
    Rect imgBounds;

    // int
    //        placeHolderFrameDistance = (bounds.width() - polaroidRelativeValue(176.5f) )/2.0f +
    // Math.round(polaroidRelativeValue(2.5f));
    //        Rect frameRect = new Rect((int)placeHolderFrameDistance,
    // (int)placeHolderFrameDistance,
    //                                  (int)placeHolderFrameDistance +
    // (int)polaroidRelativeValue(176.5f),
    //                                  (int)placeHolderFrameDistance +
    // (int)polaroidRelativeValue(176.5f));
    int border = Math.round(polaroidRelativeValue(2.5f));
    //        Rect frameRect = new Rect(bounds.left + border,bounds.top + border,bounds.right -
    // border,
    //                                  bounds.bottom - border);

    Rect frameRect = new Rect(0, 0, bounds.width(), bounds.height());
    // mElementImageDrawable.enableAspectRatio(false);
    //        mElementImageDrawable.setBounds(frameRect.left + border, frameRect.top + border,
    // frameRect.right - 2 * border,
    //                                        frameRect.right - border);

    mElementImageDrawable.setLayoutOffset(frameRect.left + 2 * border, frameRect.top + 2 * border);
    mElementImageDrawable.setLayoutWidth(frameRect.width() - 4 * border);

    Path clipPath;
    clipPath = new Path();
    float radius = mElementPolaroidDrawable.getElementCornerRadius() - border / 2.0f;
    // calculate clip path
    //        clipPath.addRoundRect(new RectF(mElementImageDrawable.getBounds().left /*+ border*/,
    //                                        mElementImageDrawable.getBounds().top /*+ border*/,
    //                                        mElementImageDrawable.getBounds().right,
    //                                        mElementImageDrawable.getBounds().bottom),radius,
    // radius,
    //                Path.Direction.CW);

    clipPath.addRoundRect(
        new RectF(
            0.5f /*+ border*/,
            0.5f /*+ border*/,
            mElementImageDrawable.getBounds().width() - 0.5f,
            mElementImageDrawable.getBounds().height() - 0.5f),
        radius,
        radius,
        Path.Direction.CW);

    clipPath.close();
    //        mElementImageDrawable.setElementClipPath(clipPath,true);
    mElementImageDrawable.setElementClipPath(clipPath);

    // Add some gradient to the image view.
    highColor = new PDEColor(1.0f, 1.0f, 1.0f, 0.5f);
    mainColor = new PDEColor(0.5f, 0.5f, 0.5f, 0.25f);
    lowColor = new PDEColor(0.0f, 0.0f, 0.0f, 0.0f);

    //        highColor = new PDEColor(1.0f,0.0f,0.0f,0.5f);
    //        mainColor = new PDEColor(1.0f,0.0f,0.0f,0.5f);
    //        lowColor = new PDEColor(1.0f,0.0f,0.0f,0.5f);

    imgBounds = mElementImageDrawable.getBounds();
    mElementImageGradientDrawable.setLayoutRect(
        new Rect(imgBounds.left - 1, imgBounds.top - 1, imgBounds.right + 1, imgBounds.bottom + 1));

    mElementImageGradientDrawable.setElementBorderColor(PDEColor.valueOf("DTTransparentBlack"));
    mElementImageGradientDrawable.setElementCornerRadius(radius);
    mElementImageGradientDrawable.setElementBackgroundGradientColors(
        highColor, mainColor, lowColor);

    // set inner shadow on image
    mElementInnerShadowDrawable.setElementBlurRadius(polaroidRelativeValue(8.0f));
    /*        RectF layoutRect = new RectF(mElementImageDrawable.getBounds().left, mElementImageDrawable.getBounds().top,
    mElementImageDrawable.getBounds().right,
    mElementImageDrawable.getBounds().bottom);*/
    mElementInnerShadowDrawable.setLayoutRect(mElementImageGradientDrawable.getBounds());
    mElementInnerShadowDrawable.setElementShapeRoundedRect(radius);
  }