<commit_before>package org.telegram.android.views;

import android.content.Context;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.os.SystemClock;
import android.text.TextPaint;
import android.util.AttributeSet;
import org.telegram.android.R;
import org.telegram.android.core.background.MediaSender;
import org.telegram.android.core.background.SenderListener;
import org.telegram.android.core.model.*;
import org.telegram.android.core.model.media.*;
import org.telegram.android.core.wireframes.MessageWireframe;
import org.telegram.android.log.Logger;
import org.telegram.android.media.*;
import org.telegram.android.preview.ImageHolder;
import org.telegram.android.preview.ImageReceiver;
import org.telegram.android.preview.MediaLoader;
import org.telegram.android.preview.PreviewConfig;
import org.telegram.android.ui.*;
import org.telegram.android.util.IOUtils;

import java.io.*;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * Author: <NAME>
 * Created: 15.08.13 1:14
 */
public class MessageMediaView extends BaseDownloadView implements ImageReceiver {

    private static Movie lastMovie;
    private static long lastMovieStart;
    private static int lastDatabaseId;
    private static boolean moviePaused;
    private static Executor movieLoader = Executors.newSingleThreadExecutor();
    private static Bitmap movieDestBitmap;
    private static Canvas movieDestCanvas;

    private static final String TAG = "MessageMediaView";

    private MediaLoader loader;
    private DownloadManager downloadManager;

    private Drawable stateSent;
    private Drawable stateHalfCheck;
    private Drawable stateFailure;
    private Drawable videoIcon;
    private Drawable mapPoint;
    private Drawable unsupportedMark;
    private Drawable downloadIcon;
    private Drawable tryAgainIcon;
    private NinePatchDrawable outMask;
    private NinePatchDrawable inMask;
    private TextPaint videoDurationPaint;
    private TextPaint downloadPaint;
    private TextPaint timePaint;
    private Paint bitmapPaint;
    private Paint bitmapFilteredPaint;
    private Paint timeBgRect;

    private Paint downloadBgRect;
    private Paint downloadBgLightRect;

    private Paint placeholderPaint;
    private Paint clockIconPaint;

    private Path path = new Path();
    private RectF rectF = new RectF();
    private Rect rect1 = new Rect();
    private Rect rect2 = new Rect();

    private int databaseId = -1;
    // private String key;
    private int state;
    private int prevState;
    private long stateChangeTime;

    private long previewAppearTime;

    private ImageHolder oldPreview;
    private ImageHolder preview;

    // private Bitmap previewCached;
    // private int fastPreviewHeight;
    // private int fastPreviewWidth;
    // private int previewHeight;
    // private int previewWidth;
    private boolean isOut;
    private boolean isVideo;
    // private boolean isDownloadable;
    // private boolean isUploadable;
    private boolean showMapPoint;
    private boolean isUnsupported;

    private String duration;
    private String date;

    private boolean isBindSizeCalled;
    private int desiredHeight;
    private int desiredWidth;
    private int desiredPaddingH;
    private int desiredPaddingV;
    private int timeWidth;

    private boolean isAnimatedProgress = true;

    public MessageMediaView(Context context) {
        super(context);
        init();
    }

    public MessageMediaView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public MessageMediaView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    protected void init() {
        super.init();
        loader = application.getUiKernel().getMediaLoader();
        downloadManager = application.getDownloadManager();
        videoIcon = getResources().getDrawable(R.drawable.st_bubble_media_play);
        mapPoint = getResources().getDrawable(R.drawable.st_map_pin);
        unsupportedMark = getResources().getDrawable(R.drawable.st_bubble_unknown);

        if (FontController.USE_SUBPIXEL) {
            videoDurationPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        } else {
            videoDurationPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        }
        videoDurationPaint.setTextSize(getSp(15));
        videoDurationPaint.setTypeface(FontController.loadTypeface(getContext(), "regular"));
        videoDurationPaint.setColor(0xE6FFFFFF);

        if (FontController.USE_SUBPIXEL) {
            downloadPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        } else {
            downloadPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        }
        downloadPaint.setTextSize(getSp(15));
        downloadPaint.setTypeface(FontController.loadTypeface(getContext(), "regular"));
        downloadPaint.setColor(0xE6FFFFFF);

        if (FontController.USE_SUBPIXEL) {
            timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        } else {
            timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        }
        timePaint.setTextSize(getSp(13));
        timePaint.setTypeface(FontController.loadTypeface(getContext(), "regular"));
        timePaint.setColor(0xB6FFFFFF);

        bitmapPaint = new Paint(/*Paint.ANTI_ALIAS_FLAG*/);
        //bitmapPaint.setAntiAlias(true);
        //bitmapPaint.setFilterBitmap(true);
        //bitmapPaint.setDither(true);

        bitmapFilteredPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
        bitmapFilteredPaint.setAntiAlias(true);
        bitmapFilteredPaint.setFilterBitmap(true);
        bitmapFilteredPaint.setDither(true);

//        ColorMatrix saturation = new ColorMatrix();
//        saturation.setSaturation(2.2f);
//
//        ColorMatrix scale = new ColorMatrix();
//        scale.setScale(1.7f, 1.7f, 1.7f, 1.0f);
//
//        ColorMatrix white = new ColorMatrix();
//        white.set(new float[]{
//                0.7f, 0, 0, 0, 255 * 0.3f,
//                0, 0.7f, 0, 0, 255 * 0.3f,
//                0, 0, 0.7f, 0, 255 * 0.3f,
//                0, 0, 0, 1, 0,
//        });
//
//        ColorMatrix result = new ColorMatrix();
//        result.set(saturation);
//        result.postConcat(scale);
//        result.postConcat(white);
//
//        bitmapFilteredPaint.setColorFilter(new ColorMatrixColorFilter(result));

        timeBgRect = new Paint();
        timeBgRect.setColor(0xb6000000);

        downloadBgRect = new Paint();
        downloadBgRect.setColor(0xB6000000);
        downloadBgRect.setStyle(Paint.Style.FILL);
        downloadBgRect.setAntiAlias(true);

        downloadBgLightRect = new Paint();
        downloadBgLightRect.setColor(0x60ffffff);
        downloadBgLightRect.setStyle(Paint.Style.FILL);
        downloadBgLightRect.setAntiAlias(true);

        stateSent = getResources().getDrawable(R.drawable.st_bubble_ic_check_photo);
        stateHalfCheck = getResources().getDrawable(R.drawable.st_bubble_ic_halfcheck_photo);
        stateFailure = getResources().getDrawable(R.drawable.st_bubble_ic_warning);
<commit_msg>Lighter media bg<commit_after>package org.telegram.android.views;

import android.content.Context;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.os.SystemClock;
import android.text.TextPaint;
import android.util.AttributeSet;
import org.telegram.android.R;
import org.telegram.android.core.background.MediaSender;
import org.telegram.android.core.background.SenderListener;
import org.telegram.android.core.model.*;
import org.telegram.android.core.model.media.*;
import org.telegram.android.core.wireframes.MessageWireframe;
import org.telegram.android.log.Logger;
import org.telegram.android.media.*;
import org.telegram.android.preview.ImageHolder;
import org.telegram.android.preview.ImageReceiver;
import org.telegram.android.preview.MediaLoader;
import org.telegram.android.preview.PreviewConfig;
import org.telegram.android.ui.*;
import org.telegram.android.util.IOUtils;

import java.io.*;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * Author: <NAME>
 * Created: 15.08.13 1:14
 */
public class MessageMediaView extends BaseDownloadView implements ImageReceiver {

    private static Movie lastMovie;
    private static long lastMovieStart;
    private static int lastDatabaseId;
    private static boolean moviePaused;
    private static Executor movieLoader = Executors.newSingleThreadExecutor();
    private static Bitmap movieDestBitmap;
    private static Canvas movieDestCanvas;

    private static final String TAG = "MessageMediaView";

    private MediaLoader loader;
    private DownloadManager downloadManager;

    private Drawable stateSent;
    private Drawable stateHalfCheck;
    private Drawable stateFailure;
    private Drawable videoIcon;
    private Drawable mapPoint;
    private Drawable unsupportedMark;
    private Drawable downloadIcon;
    private Drawable tryAgainIcon;
    private NinePatchDrawable outMask;
    private NinePatchDrawable inMask;
    private TextPaint videoDurationPaint;
    private TextPaint downloadPaint;
    private TextPaint timePaint;
    private Paint bitmapPaint;
    private Paint bitmapFilteredPaint;
    private Paint timeBgRect;

    private Paint downloadBgRect;
    private Paint downloadBgLightRect;

    private Paint placeholderPaint;
    private Paint clockIconPaint;

    private Path path = new Path();
    private RectF rectF = new RectF();
    private Rect rect1 = new Rect();
    private Rect rect2 = new Rect();

    private int databaseId = -1;
    // private String key;
    private int state;
    private int prevState;
    private long stateChangeTime;

    private long previewAppearTime;

    private ImageHolder oldPreview;
    private ImageHolder preview;

    // private Bitmap previewCached;
    // private int fastPreviewHeight;
    // private int fastPreviewWidth;
    // private int previewHeight;
    // private int previewWidth;
    private boolean isOut;
    private boolean isVideo;
    // private boolean isDownloadable;
    // private boolean isUploadable;
    private boolean showMapPoint;
    private boolean isUnsupported;

    private String duration;
    private String date;

    private boolean isBindSizeCalled;
    private int desiredHeight;
    private int desiredWidth;
    private int desiredPaddingH;
    private int desiredPaddingV;
    private int timeWidth;

    private boolean isAnimatedProgress = true;

    public MessageMediaView(Context context) {
        super(context);
        init();
    }

    public MessageMediaView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public MessageMediaView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }

    protected void init() {
        super.init();
        loader = application.getUiKernel().getMediaLoader();
        downloadManager = application.getDownloadManager();
        videoIcon = getResources().getDrawable(R.drawable.st_bubble_media_play);
        mapPoint = getResources().getDrawable(R.drawable.st_map_pin);
        unsupportedMark = getResources().getDrawable(R.drawable.st_bubble_unknown);

        if (FontController.USE_SUBPIXEL) {
            videoDurationPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        } else {
            videoDurationPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        }
        videoDurationPaint.setTextSize(getSp(15));
        videoDurationPaint.setTypeface(FontController.loadTypeface(getContext(), "regular"));
        videoDurationPaint.setColor(0xE6FFFFFF);

        if (FontController.USE_SUBPIXEL) {
            downloadPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        } else {
            downloadPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        }
        downloadPaint.setTextSize(getSp(15));
        downloadPaint.setTypeface(FontController.loadTypeface(getContext(), "regular"));
        downloadPaint.setColor(0xE6FFFFFF);

        if (FontController.USE_SUBPIXEL) {
            timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
        } else {
            timePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
        }
        timePaint.setTextSize(getSp(13));
        timePaint.setTypeface(FontController.loadTypeface(getContext(), "regular"));
        timePaint.setColor(0xB6FFFFFF);

        bitmapPaint = new Paint(/*Paint.ANTI_ALIAS_FLAG*/);
        //bitmapPaint.setAntiAlias(true);
        //bitmapPaint.setFilterBitmap(true);
        //bitmapPaint.setDither(true);

        bitmapFilteredPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
        bitmapFilteredPaint.setAntiAlias(true);
        bitmapFilteredPaint.setFilterBitmap(true);
        bitmapFilteredPaint.setDither(true);

//        ColorMatrix saturation = new ColorMatrix();
//        saturation.setSaturation(2.2f);
//
//        ColorMatrix scale = new ColorMatrix();
//        scale.setScale(1.7f, 1.7f, 1.7f, 1.0f);
//
//        ColorMatrix white = new ColorMatrix();
//        white.set(new float[]{
//                0.7f, 0, 0, 0, 255 * 0.3f,
//                0, 0.7f, 0, 0, 255 * 0.3f,
//                0, 0, 0.7f, 0, 255 * 0.3f,
//                0, 0, 0, 1, 0,
//        });
//
//        ColorMatrix result = new ColorMatrix();
//        result.set(saturation);
//        result.postConcat(scale);
//        result.postConcat(white);
//
//        bitmapFilteredPaint.setColorFilter(new ColorMatrixColorFilter(result));

        timeBgRect = new Paint();
        timeBgRect.setColor(0x59000000);

        downloadBgRect = new Paint();
        downloadBgRect.setColor(0xB6000000);
        downloadBgRect.setStyle(Paint.Style.FILL);
        downloadBgRect.setAntiAlias(true);

        downloadBgLightRect = new Paint();
        downloadBgLightRect.setColor(0x60ffffff);
        downloadBgLightRect.setStyle(Paint.Style.FILL);
        downloadBgLightRect.setAntiAlias(true);

        stateSent = getResources().getDrawable(R.drawable.st_bubble_ic_check_photo);
        stateHalfCheck = getResources().getDrawable(R.drawable.st_bubble_ic_halfcheck_photo);
        stateFailure = getResources().getDrawable(R.drawable.st_bubble_ic_warning);

{'fraction_non_alphanumeric': 0.09421635375833849, 'fraction_numerical': 0.012172477821332784, 'mean_word_length': 3.2758012349309027, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 46, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '15999', 'n_tokens_mistral': 4265, 'n_tokens_neox': 4061, 'n_words': 870}