public int getNotificationWidth(Context context, int width, int height, int padding) { if (mWidth > 0) { return mWidth; } int w = getDefaultWidth(width, padding); if (OSUtils.getInstance().isEmui()) { // huawei's emui w = getEMUINotificationWidth(context, width, height); } else if (OSUtils.getInstance().isMiui()) { if (Build.VERSION.SDK_INT >= 21) { padding = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10f, context.getResources().getDisplayMetrics())); w = getMIUINotificationWidth(context, width - padding * 2, height); } else { padding = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25f, context.getResources().getDisplayMetrics())); w = getMIUINotificationWidth(context, width - padding * 2, height); } } mWidth = w; return w; }
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) { if (remoteViews == null || notification.icon == 0) return; if (!mNotificationCompat.isSystemLayout(remoteViews)) { return; } try { //noinspection deprecation int id = R_Hide.id.icon.get(); //only fake small icon if (!hasIconBitmap && notification.largeIcon == null) { Drawable drawable = resources.getDrawable(notification.icon); drawable.setLevel(notification.iconLevel); Bitmap bitmap = drawableToBitMap(drawable); remoteViews.setImageViewBitmap(id, bitmap); //emui if(OSUtils.getInstance().isEmui()) { if (notification.largeIcon == null) { notification.largeIcon = bitmap; } } } } catch (Exception e) { e.printStackTrace(); } }
public int getNotificationWidth(Context context, int width, int height, int padding) { if (mWidth > 0) { return mWidth; } int w = getDefaultWidth(width, padding); if (OSUtils.getInstance().isEmui()) { // huawei's emui w = getEMUINotificationWidth(context, width, height); } else if (OSUtils.getInstance().isMiui()) { if (Build.VERSION.SDK_INT >= 21) { padding = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10f, context.getResources().getDisplayMetrics())); w = getMIUINotificationWidth(context, width - padding * 2, height); } else { padding = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25f, context.getResources().getDisplayMetrics())); w = getMIUINotificationWidth(context, width - padding * 2, height); } } mWidth = w; return w; }
public int getNotificationWidth(Context context, int width, int height, int padding) { if (mWidth > 0) { return mWidth; } int w = getDefaultWidth(width, padding); if (OSUtils.getInstance().isEmui()) { // huawei's emui w = getEMUINotificationWidth(context, width, height); } else if (OSUtils.getInstance().isMiui()) { if (Build.VERSION.SDK_INT >= 21) { padding = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10f, context.getResources().getDisplayMetrics())); w = getMIUINotificationWidth(context, width - padding * 2, height); } else { padding = Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25f, context.getResources().getDisplayMetrics())); w = getMIUINotificationWidth(context, width - padding * 2, height); } } mWidth = w; return w; }
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) { if (remoteViews == null || notification.icon == 0) return; if (!mNotificationCompat.isSystemLayout(remoteViews)) { return; } try { //noinspection deprecation int id = R_Hide.id.icon.get(); //only fake small icon if (!hasIconBitmap && notification.largeIcon == null) { Drawable drawable = resources.getDrawable(notification.icon); drawable.setLevel(notification.iconLevel); Bitmap bitmap = drawableToBitMap(drawable); remoteViews.setImageViewBitmap(id, bitmap); //emui if(OSUtils.getInstance().isEmui()) { if (notification.largeIcon == null) { notification.largeIcon = bitmap; } } } } catch (Exception e) { e.printStackTrace(); } }
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) { if (remoteViews == null || notification.icon == 0) return; if (!mNotificationCompat.isSystemLayout(remoteViews)) { return; } try { //noinspection deprecation int id = R_Hide.id.icon.get(); //only fake small icon if (!hasIconBitmap && notification.largeIcon == null) { Drawable drawable = resources.getDrawable(notification.icon); drawable.setLevel(notification.iconLevel); Bitmap bitmap = drawableToBitMap(drawable); remoteViews.setImageViewBitmap(id, bitmap); //emui if(OSUtils.getInstance().isEmui()) { if (notification.largeIcon == null) { notification.largeIcon = bitmap; } } } } catch (Exception e) { e.printStackTrace(); } }