<commit_before>package org.kdt.tagsimulator;

import java.nio.charset.Charset;

import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class SelectTagActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_tag);
        
		NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
		
		NdefRecord  uriRecord = NdefRecord.createUri("http://github.com/jthurne/kanban-data-tracker");
		NdefRecord  mimeRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, 
				"application/vnd.kdt".getBytes(Charset.forName("US-ASCII")),
				new byte[0], 
				"You've been BEAMED!".getBytes(Charset.forName("US-ASCII")));
		
		NdefMessage message = new NdefMessage(new NdefRecord[] {mimeRecord});
		
		if (nfcAdapter == null) return;
		nfcAdapter.setNdefPushMessage(message, this);        
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.select_tag, menu);
        return true;
    }
    
}<commit_msg>Refactored the push tag code for better readability<commit_after>package org.kdt.tagsimulator;

import java.nio.charset.Charset;

import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class SelectTagActivity extends Activity {
    private static final String APP_MIME_TYPE = "application/vnd.kdt";
	private static final Charset ASCII = Charset.forName("US-ASCII");

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

        configureNFCTag(createMessage());
    }


	private void configureNFCTag(NdefMessage message) {
		NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
		if (nfcAdapter == null) return;
		nfcAdapter.setNdefPushMessage(message, this);
	}


	private NdefMessage createMessage() {
		NdefRecord  mimeRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
				encode(APP_MIME_TYPE),
				new byte[0],
				encode("You've been BEAMED!"));

		return new NdefMessage(new NdefRecord[] {mimeRecord});
	}


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.select_tag, menu);
        return true;
    }

    private byte[] encode(String toConvert) {
	return toConvert.getBytes(ASCII);
    }

}
{'fraction_non_alphanumeric': 0.09953287818900466, 'fraction_numerical': 0.0007186489399928135, 'mean_word_length': 4.08029197080292, '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': '1694907', 'n_tokens_mistral': 926, 'n_tokens_neox': 848, 'n_words': 187}