<commit_before>package com.example.etaspare.stitchcounter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;

public class NewCounterActivity extends AppCompatActivity {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Allows the OnTouchEvent to recognize when outside touches occur, allows dialog and
        // keyboard to be dismissed when grey screen is tapped.
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);

        /*
        Sets dialog content based on whether single or double counter
        was tapped in main activity.
        */
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            String value = extras.getString("Layout");
            if (value.equals("single")) {
                setContentView(R.layout.activity_dialog_new_single_counter);
            } else if (value.equals("double")) {
                setContentView(R.layout.activity_dialog_new_double_counter);
            }
        }

        /* Single Counter Dialog */
        final Button buttonSingleOk = (Button) findViewById(R.id.button_single_ok);
        final EditText textProjectNameSingle = (EditText) findViewById(R.id.text_project_name_3);
        if (textProjectNameSingle != null) {
            /* Makes the keyboard appear automatically */
            openKeyboard();
        }
        if (buttonSingleOk != null) {
            /* OnClick listener for ok button */
            buttonSingleOk.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismissKeyboard();
                    String name = textProjectNameSingle.getText().toString(); //TODO put in logic to handle if text is not entered
                    Intent intent = new Intent(v.getContext(), SingleCounterActivity.class);
                    intent.putExtra("name", name);
                    startActivity(intent);
                }
            });
        }
        /* Double Counter Dialog */
        final Button buttonDoubleOk = (Button) findViewById(R.id.button_double_ok);
        final EditText textProjectNameDouble = (EditText) findViewById(R.id.text_project_name_4);
        final EditText totalRows = (EditText) findViewById(R.id.text_total_rows_input_2);
        if (textProjectNameDouble != null) {
            /* Makes the keyboard appear automatically */
            openKeyboard();
        }
        if (buttonDoubleOk != null) {
            /* OnClick listener for ok button */
            buttonDoubleOk.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismissKeyboard();
                    Intent intent = new Intent(v.getContext(), DoubleCounterActivity.class);
                    String name = textProjectNameDouble.getText().toString();
                    intent.putExtra("name", name);

                    if (totalRows.getText().toString().length() > 0) {
                        int total_rows = Integer.parseInt(totalRows.getText().toString());
                        intent.putExtra("total_rows", total_rows);
                    }
                    startActivity(intent);
                }
            });
        }
    }

    /* Open Keyboard */
    public void openKeyboard() {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    }

    /* Dismiss Keyboard */
    public void dismissKeyboard() {
        InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);

        if(imm.isAcceptingText()) { // verify if the soft keyboard is open
            imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
        }
    }

    /* Dismiss Dialog */
    public void dismissDialog (View view) {
        dismissKeyboard();
        finish();
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        // If a touch notification has been received that the user has touched
        // outside the dialog, dismiss the activity.
        if (MotionEvent.ACTION_OUTSIDE == event.getAction()) {
            dismissDialog(null);
            return true;
        }
        return super.onTouchEvent(event);
    }
}
<commit_msg>Made it so outside touches don't close the newCounterActivity dialog.<commit_after>package com.example.etaspare.stitchcounter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;

public class NewCounterActivity extends AppCompatActivity {

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

        // Prevents outside clicks to dismiss the dialog
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);

        /*
        Sets dialog content based on whether single or double counter
        was tapped in main activity.
        */
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            String value = extras.getString("Layout");
            if (value.equals("single")) {
                setContentView(R.layout.activity_dialog_new_single_counter);
            } else if (value.equals("double")) {
                setContentView(R.layout.activity_dialog_new_double_counter);
            }
        }

        /* Single Counter Dialog */
        final Button buttonSingleOk = (Button) findViewById(R.id.button_single_ok);
        final EditText textProjectNameSingle = (EditText) findViewById(R.id.text_project_name_3);
        if (textProjectNameSingle != null) {
            /* Makes the keyboard appear automatically */
            openKeyboard();
        }
        if (buttonSingleOk != null) {
            /* OnClick listener for ok button */
            buttonSingleOk.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismissKeyboard();
                    String name = textProjectNameSingle.getText().toString(); //TODO put in logic to handle if text is not entered
                    Intent intent = new Intent(v.getContext(), SingleCounterActivity.class);
                    intent.putExtra("name", name);
                    startActivity(intent);
                }
            });
        }
        /* Double Counter Dialog */
        final Button buttonDoubleOk = (Button) findViewById(R.id.button_double_ok);
        final EditText textProjectNameDouble = (EditText) findViewById(R.id.text_project_name_4);
        final EditText totalRows = (EditText) findViewById(R.id.text_total_rows_input_2);
        if (textProjectNameDouble != null) {
            /* Makes the keyboard appear automatically */
            openKeyboard();
        }
        if (buttonDoubleOk != null) {
            /* OnClick listener for ok button */
            buttonDoubleOk.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismissKeyboard();
                    Intent intent = new Intent(v.getContext(), DoubleCounterActivity.class);
                    String name = textProjectNameDouble.getText().toString();
                    intent.putExtra("name", name);

                    if (totalRows.getText().toString().length() > 0) {
                        int total_rows = Integer.parseInt(totalRows.getText().toString());
                        intent.putExtra("total_rows", total_rows);
                    }
                    startActivity(intent);
                }
            });
        }
    }

    /* Open Keyboard */
    public void openKeyboard() {
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    }

    /* Dismiss Keyboard */
    public void dismissKeyboard() {
        InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);

        if(imm.isAcceptingText()) { // verify if the soft keyboard is open
            imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
        }
    }

    /* Dismiss Dialog */
    public void dismissDialog (View view) {
        dismissKeyboard();
        finish();
    }
}

{'fraction_non_alphanumeric': 0.09114969299174254, 'fraction_numerical': 0.0012703789964005929, 'mean_word_length': 2.314736842105263, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3837769', 'n_tokens_mistral': 2382, 'n_tokens_neox': 2292, 'n_words': 526}