<commit_before>package ninja.nosheep.keywi;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.Hashtable;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Main activity.
 * Contains all the texts in a RecyclerView.
 *
 * @author <NAME>
 * @since 2015-10-26
 */

public class MainActivity extends AppCompatActivity {

    @Bind(R.id.content_main_listview)
    ListView messageListView;

    private ArrayList<SMSObject> textMsgList = new ArrayList<>();
    private Hashtable<String, Conversation> conversationList = new Hashtable<>();
    private MessageHandler messageHandler;
    private MessageAdapter messageAdapter;

    private final static int REQUEST_CODE_PERMISSION_READ_SMS = 100;
    private final static int REQUEST_CODE_PERMISSION_READ_CONTACTS = 101;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle(getString(R.string.app_name));
        setSupportActionBar(toolbar);

        askForPermissionOnStart();

        messageAdapter = new MessageAdapter(this);
        messageListView.setAdapter(messageAdapter);

        messageHandler = new MessageHandler(this);

        if (PermissionHandler.isOkToReadSMS()) {
            messageHandler.createConversationList();
            conversationList = messageHandler.getConversationList();
        }


        messageListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Snackbar.make(view,
                        ((Conversation) parent.getItemAtPosition(position)).getDisplayAddress(),
                        Snackbar.LENGTH_LONG)
                        .show();
            }
        });

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Snackbar.make(v,
                        "Keep it real.",
                        Snackbar.LENGTH_LONG)
                        .show();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.<commit_msg>Minor changes.<commit_after>package ninja.nosheep.keywi;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.Hashtable;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Main activity.
 * Contains all the texts in a RecyclerView.
 *
 * @author <NAME>
 * @since 2015-10-26
 */

public class MainActivity extends AppCompatActivity {

    @Bind(R.id.content_main_listview)
    ListView messageListView;

    private ArrayList<SMSObject> textMsgList = new ArrayList<>();
    private Hashtable<String, Conversation> conversationList = new Hashtable<>();
    private MessageHandler messageHandler;
    private MessageAdapter messageAdapter;

    private final static int REQUEST_CODE_PERMISSION_READ_SMS = 100;
    private final static int REQUEST_CODE_PERMISSION_READ_CONTACTS = 101;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        long startTime = System.currentTimeMillis();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle(getString(R.string.app_name));
        setSupportActionBar(toolbar);

        Log.d(TagHandler.MAIN_TAG, "Creating toolbar and stuff in " + (System.currentTimeMillis() - startTime) + "ms.");

        askForPermissionOnStart();

        messageAdapter = new MessageAdapter(this);
        messageListView.setAdapter(messageAdapter);

        messageHandler = new MessageHandler(this);

        if (PermissionHandler.isOkToReadSMS()) {
            messageHandler.createConversationList();
            conversationList = messageHandler.getConversationList();
        }


        messageListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Snackbar.make(view,
                        ((Conversation) parent.getItemAtPosition(position)).getDisplayAddress(),
                        Snackbar.LENGTH_LONG)
                        .show();
            }
        });

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Snackbar.make(v,
                        "Keep it real.",
                        Snackbar.LENGTH_LONG)
                        .show();
            }
        });

        Log.d(TagHandler.MAIN_TAG, "Total onCreateTime: " + (System.currentTimeMillis() - startTime) + "ms");
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
{'fraction_non_alphanumeric': 0.09181944230472963, 'fraction_numerical': 0.005546140810352796, 'mean_word_length': 2.9633699633699635, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4437458', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1699, 'n_words': 364}