<commit_before>package com.andrey.instapoo;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.net.Uri;
import android.nfc.Tag;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by andrey on 24/08/17.
 */

public class Filter extends MainActivity {

    ImageView preview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.change_filter);
        preview = (ImageView)findViewById(R.id.preview);
    }

    public void Averaging(View view){
        Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);

        for (int i = 0; i < mutableBitmap.getWidth(); i++) {
            for (int j = 0; j < mutableBitmap.getHeight(); j++) {
                int pixel = mutableBitmap.getPixel(i, j);
                int red = Color.red(pixel);
                int green = Color.green(pixel);
                int blue = Color.blue(pixel);
                int color = Color.argb(0xFF, (red+blue+green)/3, (red+blue+green)/3, (red+blue+green)/3);
                mutableBitmap.setPixel(i, j, color);
            }
        }
        preview.setImageBitmap(mutableBitmap);
    }

    public void Invert(View view){
        Bitmap finalimage = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());

        int a,r,g,b;
        int pixelColor;
        int height = bitmap.getHeight();
        int width = bitmap.getWidth();

        for (int y = 0; y < height; y++){
            for (int x = 0; x< width; x++){
                pixelColor = bitmap.getPixel(x,y);
                a = Color.alpha(pixelColor);
                b = 255 - Color.blue(pixelColor);
                r = 255 - Color.red(pixelColor);
                g = 255 - Color.green(pixelColor);
                finalimage.setPixel(x,y,Color.argb(a,r,g,b));
            }
        }
        preview.setImageBitmap(finalimage);
    }
}
<commit_msg>Filters added<commit_after>package com.andrey.instapoo;

import static java.lang.Math.max;
import static java.lang.Math.min;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

/**
 * Created by andrey on 24/08/17.
 */

public class Filter extends MainActivity {

    protected ImageView preview;
    protected Bitmap bitmapcopy;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.change_filter);
        preview = (ImageView)findViewById(R.id.preview);
    }

    public Bitmap getCopy(){
        bitmapcopy = bitmap.copy(Bitmap.Config.ARGB_8888, true);
        if(bitmap.getHeight() > 720 || bitmap.getWidth() > 1290){
            Matrix m = new Matrix();
            float reqWidth = 1290;
            float reqHeight = 720;
            m.setRectToRect(new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight()), new RectF(0, 0, reqWidth, reqHeight), Matrix.ScaleToFit.CENTER);
            bitmapcopy = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true);
        }
        return bitmapcopy;
    }

    public void averaging(View view){
        bitmapcopy = getCopy();

        for (int i = 0; i < bitmapcopy.getWidth(); i++) {
            for (int j = 0; j < bitmapcopy.getHeight(); j++) {
                int pixel = bitmapcopy.getPixel(i, j);
                int red = Color.red(pixel);
                int green = Color.green(pixel);
                int blue = Color.blue(pixel);
                int color = Color.argb(0xFF, (red+blue+green)/3, (red+blue+green)/3, (red+blue+green)/3);
                bitmapcopy.setPixel(i, j, color);
            }
        }
        preview.setImageBitmap(bitmapcopy);
    }

    public void invert(View view){
        bitmapcopy = getCopy();

        int a,r,g,b;
        int pixelColor;
        int height = bitmapcopy.getHeight();
        int width = bitmapcopy.getWidth();

        for (int y = 0; y < height; y++){
            for (int x = 0; x< width; x++){
                pixelColor = bitmapcopy.getPixel(x,y);
                a = Color.alpha(pixelColor);
                b = 255 - Color.blue(pixelColor);
                r = 255 - Color.red(pixelColor);
                g = 255 - Color.green(pixelColor);
                bitmapcopy.setPixel(x,y,Color.argb(a,r,g,b));
            }
        }
        preview.setImageBitmap(bitmapcopy);
    }

    public void desaturation(View view){
        bitmapcopy = getCopy();

        int a,r,g,b,D;
        int pixelColor;
        int height = bitmapcopy.getHeight();
        int width = bitmapcopy.getWidth();

        for (int y = 0; y < height; y++){
            for (int x = 0; x< width; x++){
                pixelColor = bitmap.getPixel(x,y);
                a = Color.alpha(pixelColor);
                b = Color.blue(pixelColor);
                r = Color.red(pixelColor);
                g = Color.green(pixelColor);
                D = min(min(r,g),b)+max(max(r,g),b);
                bitmapcopy.setPixel(x,y,Color.argb(a,D,D,D));

            }
        }
        preview.setImageBitmap(bitmapcopy);
    }
}

{'fraction_non_alphanumeric': 0.12409000661813369, 'fraction_numerical': 0.013236267372600927, 'mean_word_length': 2.3269124931205285, 'pattern_counts': {'":': 0, '<': 13, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '675024', 'n_tokens_mistral': 1874, 'n_tokens_neox': 1762, 'n_words': 395}