<commit_before>package gruppn.kasslr;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class AddWordActivity extends AppCompatActivity {
    public static final String EXTRA_IMAGE = "image";
    public static final String EXTRA_IMAGE_DESCRIPTION = "image_description";
    public static final String EXTRA_FINISH_ON_BACK = "finish_back";

    private boolean finishOnBack;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activty_add_word);

        Button btnAdd = (Button) findViewById(R.id.btnAddWord);
        btnAdd.setOnClickListener(v -> returnWord());


        Uri image = (Uri) getIntent().getExtras().get(EXTRA_IMAGE);
        if (image != null) {
            ImageView imgWord = (ImageView) findViewById(R.id.imgWord);
            // TODO Load with picasso? (would break shared element transition)
            Bitmap myImg = BitmapFactory.decodeFile(image.getPath());
            imgWord.setImageBitmap(Bitmap.createScaledBitmap(myImg, 480, 480, false));
        }

        finishOnBack = getIntent().getExtras().getBoolean(EXTRA_FINISH_ON_BACK, false);
    }

    @Override
    public void onBackPressed() {
        if (finishOnBack) {
            finish();
        } else {
            super.onBackPressed();
        }
    }

    private void returnWord() {
        TextView txtWord = (TextView) findViewById(R.id.txtWord);
        Intent data = new Intent();
        data.putExtra(EXTRA_IMAGE_DESCRIPTION, txtWord.getText().toString());
        setResult(txtWord.getText().length() > 0 ? RESULT_OK : RESULT_CANCELED, data);
        finish();
    }
}
<commit_msg>Maintain 4:3 (or well, 3:4) aspect ratio<commit_after>package gruppn.kasslr;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.squareup.picasso.Picasso;

public class AddWordActivity extends AppCompatActivity {
    public static final String EXTRA_IMAGE = "image";
    public static final String EXTRA_IMAGE_DESCRIPTION = "image_description";
    public static final String EXTRA_FINISH_ON_BACK = "finish_back";

    private boolean finishOnBack;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activty_add_word);

        Button btnAdd = (Button) findViewById(R.id.btnAddWord);
        btnAdd.setOnClickListener(v -> returnWord());


        Uri image = (Uri) getIntent().getExtras().get(EXTRA_IMAGE);
        if (image != null) {
            ImageView imgWord = (ImageView) findViewById(R.id.imgWord);
            // TODO Load with picasso? (would break shared element transition)
            Bitmap myImg = BitmapFactory.decodeFile(image.getPath());
            imgWord.setImageBitmap(Bitmap.createScaledBitmap(myImg, getImageWidth(), getImageHeight(), false));
        }

        finishOnBack = getIntent().getExtras().getBoolean(EXTRA_FINISH_ON_BACK, false);
    }

    @Override
    public void onBackPressed() {
        if (finishOnBack) {
            finish();
        } else {
            super.onBackPressed();
        }
    }

    private void returnWord() {
        TextView txtWord = (TextView) findViewById(R.id.txtWord);
        Intent data = new Intent();
        data.putExtra(EXTRA_IMAGE_DESCRIPTION, txtWord.getText().toString());
        setResult(txtWord.getText().length() > 0 ? RESULT_OK : RESULT_CANCELED, data);
        finish();
    }

    private int getImageWidth() {
        return getResources().getDisplayMetrics().widthPixels * 3 / 4;
}

    private int getImageHeight() {
        return getResources().getDisplayMetrics().widthPixels;
    }
}

{'fraction_non_alphanumeric': 0.10493105865856509, 'fraction_numerical': 0.0037391913998597805, 'mean_word_length': 3.331983805668016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3399934', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1184, 'n_words': 262}