<commit_before>package com.sumitgouthaman.raven;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputType;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.sumitgouthaman.raven.listadapters.ChatThreadAdapter;
import com.sumitgouthaman.raven.models.Message;
import com.sumitgouthaman.raven.models.MessageTypes;
import com.sumitgouthaman.raven.persistence.Persistence;
import com.sumitgouthaman.raven.utils.MessageDispatcher;

import org.json.JSONException;
import org.json.JSONObject;


public class SelfDestructingMessageCompose extends ActionBarActivity {

    String targetSecretUsername;
    String targetUsername;
    String mySecretUsername;
    String targetRegId;

    TextView contactNameField;
    EditText messageField;
    RadioGroup durationRadioGroup;
    int customValue = 5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sefl_destructing_message_compose);

        Intent thisIntent = getIntent();
        targetSecretUsername = thisIntent.getStringExtra("secretUsername");
        targetUsername = thisIntent.getStringExtra("username");
        mySecretUsername = Persistence.getSecretUsername(this);
        targetRegId = thisIntent.getStringExtra("registrationID");

        contactNameField = (TextView) findViewById(R.id.textView_contactName);
        durationRadioGroup = (RadioGroup) findViewById(R.id.radioGroup_destroy_after);
        messageField = (EditText) findViewById(R.id.editText_newMessageText);

        contactNameField.setText(targetUsername);

        RadioButton customButton = (RadioButton) findViewById(R.id.radioButton_custom);
        customButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b) {
                    final EditText input = new EditText(SelfDestructingMessageCompose.this);
                    input.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
                    new AlertDialog.Builder(SelfDestructingMessageCompose.this)
                            .setTitle(R.string.custom_time)
                            .setMessage(R.string.pick_custom_time)
                            .setView(input)
                            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int whichButton) {
                                    int value;
                                    try {
                                        value = Integer.parseInt(input.getText().toString().trim());
                                        customValue = value;
                                    } catch (NumberFormatException nfe) {
                                        Toast.makeText(SelfDestructingMessageCompose.this, R.string.not_a_number, Toast.LENGTH_SHORT).show();
                                        RadioButton btn5sec = (RadioButton) findViewById(R.id.radioButton_5sec);<commit_msg>Adds visual indication of the custom time set for Read-once messages<commit_after>package com.sumitgouthaman.raven;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputType;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.sumitgouthaman.raven.listadapters.ChatThreadAdapter;
import com.sumitgouthaman.raven.models.Message;
import com.sumitgouthaman.raven.models.MessageTypes;
import com.sumitgouthaman.raven.persistence.Persistence;
import com.sumitgouthaman.raven.utils.MessageDispatcher;

import org.json.JSONException;
import org.json.JSONObject;


public class SelfDestructingMessageCompose extends ActionBarActivity {

    String targetSecretUsername;
    String targetUsername;
    String mySecretUsername;
    String targetRegId;

    TextView contactNameField;
    EditText messageField;
    RadioGroup durationRadioGroup;
    int customValue = 5;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sefl_destructing_message_compose);

        Intent thisIntent = getIntent();
        targetSecretUsername = thisIntent.getStringExtra("secretUsername");
        targetUsername = thisIntent.getStringExtra("username");
        mySecretUsername = Persistence.getSecretUsername(this);
        targetRegId = thisIntent.getStringExtra("registrationID");

        contactNameField = (TextView) findViewById(R.id.textView_contactName);
        durationRadioGroup = (RadioGroup) findViewById(R.id.radioGroup_destroy_after);
        messageField = (EditText) findViewById(R.id.editText_newMessageText);

        contactNameField.setText(targetUsername);

        RadioButton customButton = (RadioButton) findViewById(R.id.radioButton_custom);
        customButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(final CompoundButton compoundButton, boolean b) {
                if (b) {
                    final EditText input = new EditText(SelfDestructingMessageCompose.this);
                    input.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
                    new AlertDialog.Builder(SelfDestructingMessageCompose.this)
                            .setTitle(R.string.custom_time)
                            .setMessage(R.string.pick_custom_time)
                            .setView(input)
                            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int whichButton) {
                                    int value;
                                    try {
                                        value = Integer.parseInt(input.getText().toString().trim());
                                        customValue = value;
                                        compoundButton.setText(value + " (" + getString(R.string.destroy_after_custom) + ")");
                                    } catch (NumberFormatException nfe) {
                                        Toast.makeText(SelfDestructingMessageCompose.this, R.string.not_a_number, Toast.LENGTH_SHORT).show();
                                        RadioButton btn5sec = (RadioButton) findViewById(R.id.radioButton_5sec);
{'fraction_non_alphanumeric': 0.07827476038338659, 'fraction_numerical': 0.0010649627263045794, 'mean_word_length': 2.782980866062437, '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': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6349225', 'n_tokens_mistral': 1888, 'n_tokens_neox': 1816, 'n_words': 328}