<commit_before>package com.chrynan.android_guitar_tuner.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.transition.TransitionManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;

import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.ui.fragment.CircleGuitarTunerFragment;
import com.chrynan.android_guitar_tuner.ui.fragment.PitchPlayerFragment;
import com.chrynan.android_guitar_tuner.ui.transition.CircularRevealTransition;
import com.chrynan.android_guitar_tuner.ui.view.TunerPitchToggleView;

import butterknife.BindView;
import butterknife.ButterKnife;

public class GuitarTunerActivity extends AppCompatActivity implements TunerPitchToggleView,
        CircleGuitarTunerFragment.OnPlayNoteListener {

    public static Intent newIntent(final Context context) {
        return new Intent(context, GuitarTunerActivity.class);
    }

    private static final String SHOW_PITCH_PLAYER_KEY = "showPitchPlayer";
    private static final String NOTE_NAME_KEY = "noteName";
    private static final String FREQUENCY_KEY = "frequency";

    private static final int TRANSITION_DURATION = 500;
    private static final int TRANSITION_DELAY = 0;
    private static final Interpolator TRANSITION_INTERPOLATOR = new AccelerateDecelerateInterpolator();

    @BindView(R.id.toolbar)
    Toolbar toolbar;

    private final CircleGuitarTunerFragment circleGuitarTunerFragment = CircleGuitarTunerFragment.newInstance();

    private final CircularRevealTransition circularRevealTransition = new CircularRevealTransition()
            .setDuration(TRANSITION_DURATION)
            .setStartDelay(TRANSITION_DELAY)
            .setInterpolator(TRANSITION_INTERPOLATOR);

    private boolean showPitchPlayer;
    private String lastNoteName = "";
    private double lastFrequency = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_guitar_tuner);

        ButterKnife.bind(this);

        setSupportActionBar(toolbar);

        String noteName = "";
        double frequency = 0;

        if (savedInstanceState != null) {
            showPitchPlayer = savedInstanceState.getBoolean(SHOW_PITCH_PLAYER_KEY, false);
            noteName = savedInstanceState.getString(NOTE_NAME_KEY, "");
            frequency = savedInstanceState.getDouble(FREQUENCY_KEY);
        }

        if (showPitchPlayer) {
            showPitchPlayback(noteName, frequency, 0, 0, false);
        } else {
            showGuitarTuner();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.guitar_tuner_activity_menu, menu);

        ActionBar actionBar = getSupportActionBar();

        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(showPitchPlayer);

            if (showPitchPlayer) {
                actionBar.setTitle(PitchPlayerFragment.TITLE);
            } else {
                actionBar.setTitle(CircleGuitarTunerFragment.TITLE);
            }
        }

        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            // Respond to the action bar's Up/Home button
            case android.R.id.home:
                showGuitarTuner();
                return true;
            case R.id.shareAction:
                shareApp();
                return true;
        }

        return super.onOptionsItemSelected(item);
    }<commit_msg>Fixed Permission Change Bug<commit_after>package com.chrynan.android_guitar_tuner.ui.activity;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.transition.TransitionManager;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;

import com.chrynan.android_guitar_tuner.R;
import com.chrynan.android_guitar_tuner.ui.fragment.CircleGuitarTunerFragment;
import com.chrynan.android_guitar_tuner.ui.fragment.PitchPlayerFragment;
import com.chrynan.android_guitar_tuner.ui.transition.CircularRevealTransition;
import com.chrynan.android_guitar_tuner.ui.view.TunerPitchToggleView;

import butterknife.BindView;
import butterknife.ButterKnife;

public class GuitarTunerActivity extends AppCompatActivity implements TunerPitchToggleView,
        CircleGuitarTunerFragment.OnPlayNoteListener {

    public static Intent newIntent(final Context context) {
        return new Intent(context, GuitarTunerActivity.class);
    }

    private static final String SHOW_PITCH_PLAYER_KEY = "showPitchPlayer";
    private static final String NOTE_NAME_KEY = "noteName";
    private static final String FREQUENCY_KEY = "frequency";

    private static final int TRANSITION_DURATION = 500;
    private static final int TRANSITION_DELAY = 0;
    private static final Interpolator TRANSITION_INTERPOLATOR = new AccelerateDecelerateInterpolator();

    @BindView(R.id.toolbar)
    Toolbar toolbar;

    private final CircleGuitarTunerFragment circleGuitarTunerFragment = CircleGuitarTunerFragment.newInstance();

    private final CircularRevealTransition circularRevealTransition = new CircularRevealTransition()
            .setDuration(TRANSITION_DURATION)
            .setStartDelay(TRANSITION_DELAY)
            .setInterpolator(TRANSITION_INTERPOLATOR);

    private boolean showPitchPlayer;
    private String lastNoteName = "";
    private double lastFrequency = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_guitar_tuner);

        ButterKnife.bind(this);

        setSupportActionBar(toolbar);

        String noteName = "";
        double frequency = 0;

        if (savedInstanceState != null) {
            showPitchPlayer = savedInstanceState.getBoolean(SHOW_PITCH_PLAYER_KEY, false);
            noteName = savedInstanceState.getString(NOTE_NAME_KEY, "");
            frequency = savedInstanceState.getDouble(FREQUENCY_KEY);
        }

        if (showPitchPlayer) {
            showPitchPlayback(noteName, frequency, 0, 0, false);
        } else {
            showGuitarTuner();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.guitar_tuner_activity_menu, menu);

        ActionBar actionBar = getSupportActionBar();

        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(showPitchPlayer);

            if (showPitchPlayer) {
                actionBar.setTitle(PitchPlayerFragment.TITLE);
            } else {
                actionBar.setTitle(CircleGuitarTunerFragment.TITLE);
            }
        }

        return true;
    }

    @Override
    public void onResume() {
        super.onResume();

        // Check if we still have the correct permissions
        // If we don't we have to close this Activity and open the Permission Activity
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_DENIED) {
            startActivity(PermissionActivity.newIntent(this));
            finish();
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            // Respond to the action bar's Up/Home button
            case android.R.id.home:
                showGuitarTuner();
                return true;
            case R.id.shareAction:
                shareApp();
                return true;
        }

        return super.onOptionsItemSelected(item);
    }
{'fraction_non_alphanumeric': 0.07667464114832535, 'fraction_numerical': 0.002751196172248804, 'mean_word_length': 3.2658163265306124, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1223878', 'n_tokens_mistral': 2461, 'n_tokens_neox': 2337, 'n_words': 446}