Ejemplo n.º 1
0
 private Drawable prepareBackIcon(Drawable d, boolean customIcon) {
   int customImageColorize =
       Settings.System.getIntForUser(
           mContext.getContentResolver(),
           Settings.System.PIE_ICON_COLOR_MODE,
           0,
           UserHandle.USER_CURRENT);
   int drawableColor =
       Settings.System.getIntForUser(
           mContext.getContentResolver(),
           Settings.System.PIE_ICON_COLOR,
           -2,
           UserHandle.USER_CURRENT);
   if (drawableColor == -2) {
     drawableColor = mContext.getResources().getColor(R.color.pie_foreground_color);
   }
   if (mIconResize && !customIcon) {
     d = resizeIcon(null, d, false);
   } else if (customIcon) {
     d = resizeIcon(null, d, true);
   }
   if ((customImageColorize != 1 || !customIcon) && customImageColorize != 3) {
     d =
         new BitmapDrawable(
             mContext.getResources(),
             ImageHelper.drawableToBitmap(ImageHelper.getColoredDrawable(d, drawableColor)));
   }
   return d;
 }
Ejemplo n.º 2
0
  private Drawable resizeIcon(ImageView view, Drawable d, boolean useSystemDimens) {
    if (view == null && d == null) {
      return null;
    }
    int size = 0;
    Drawable dOriginal = d;
    if (d == null) {
      dOriginal = view.getDrawable();
    }
    if (useSystemDimens) {
      size =
          mContext.getResources().getDimensionPixelSize(com.android.internal.R.dimen.app_icon_size);
    } else {
      size = Math.max(dOriginal.getIntrinsicHeight(), dOriginal.getIntrinsicWidth());
    }

    Drawable dResized =
        ImageHelper.resize(
            mContext, dOriginal, Converter.pxToDp(mContext, (int) (size * mIconResizeFactor)));
    if (d == null) {
      view.setImageDrawable(dResized);
      return null;
    } else {
      return (dResized);
    }
  }