<commit_before>package edu.rit.se.crashavoidance.views;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import edu.rit.se.crashavoidance.R;
import edu.rit.se.crashavoidance.wifi.WifiDirectHandler;


public class MainFragment extends Fragment {

    private WiFiDirectHandlerAccessor wifiDirectHandlerAccessor;

    // Buttons
    private Button toggleWifiButton;
    private Button receiverRegistrationButton;
    private Button wifiDirectRegistrationButton;
    private Button serviceRegistrationButton;
    private Button discoverServicesButton;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_main, container, false);

        // Initialize Buttons
        toggleWifiButton = (Button) view.findViewById(R.id.toggleWifiButton);
        toggleWifiButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
                WifiDirectHandler handler = wifiDirectHandlerAccessor.getWifiHandler();
                if(wifiDirectHandlerAccessor.getWifiHandler().isWifiEnabled()) {
                    wifiDirectHandlerAccessor.getWifiHandler().setWifiEnabled(false);
                    toggleWifiButton.setText("Enable Wifi");
                } else {
                    wifiDirectHandlerAccessor.getWifiHandler().setWifiEnabled(true);
                    toggleWifiButton.setText("Disable Wifi");
                }
            }
        });
        wifiDirectRegistrationButton = (Button) view.findViewById(R.id.wifiDirectRegistrationButton);
        wifiDirectRegistrationButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
            }
        });
        receiverRegistrationButton = (Button) view.findViewById(R.id.receiverRegistrationButton);
        receiverRegistrationButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
            }
        });
        serviceRegistrationButton = (Button) view.findViewById(R.id.serviceRegistrationButton);
        serviceRegistrationButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
            }
        });
        discoverServicesButton = (Button) view.findViewById(R.id.discoverServicesButton);
        discoverServicesButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
            }
        });

        return view;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        try {
            wifiDirectHandlerAccessor = ((WiFiDirectHandlerAccessor) getActivity());
        } catch (ClassCastException e) {
            throw new ClassCastException(getActivity().toString() + " must implement WiFiDirectHandlerAccessor");
        }
    }
}<commit_msg>Basic hookup of service registration. Needs testing<commit_after>package edu.rit.se.crashavoidance.views;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import java.util.HashMap;

import edu.rit.se.crashavoidance.R;
import edu.rit.se.crashavoidance.wifi.ServiceData;
import edu.rit.se.crashavoidance.wifi.WifiDirectHandler;


public class MainFragment extends Fragment {

    private WiFiDirectHandlerAccessor wifiDirectHandlerAccessor;

    // Buttons
    private Button toggleWifiButton;
    private Button receiverRegistrationButton;
    private Button wifiDirectRegistrationButton;
    private Button serviceRegistrationButton;
    private Button discoverServicesButton;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_main, container, false);

        // Initialize Buttons
        toggleWifiButton = (Button) view.findViewById(R.id.toggleWifiButton);
        toggleWifiButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
                WifiDirectHandler handler = wifiDirectHandlerAccessor.getWifiHandler();
                if(wifiDirectHandlerAccessor.getWifiHandler().isWifiEnabled()) {
                    wifiDirectHandlerAccessor.getWifiHandler().setWifiEnabled(false);
                    toggleWifiButton.setText("Enable Wifi");
                } else {
                    wifiDirectHandlerAccessor.getWifiHandler().setWifiEnabled(true);
                    toggleWifiButton.setText("Disable Wifi");
                }
            }
        });
        wifiDirectRegistrationButton = (Button) view.findViewById(R.id.wifiDirectRegistrationButton);
        wifiDirectRegistrationButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {

            }
        });
        receiverRegistrationButton = (Button) view.findViewById(R.id.receiverRegistrationButton);
        receiverRegistrationButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
            }
        });
        serviceRegistrationButton = (Button) view.findViewById(R.id.serviceRegistrationButton);
        serviceRegistrationButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
                ServiceData serviceData = new ServiceData("wifiTester", 4545, new HashMap<String, String>());
                wifiDirectHandlerAccessor.getWifiHandler().startAddingLocalService(serviceData);
            }
        });
        discoverServicesButton = (Button) view.findViewById(R.id.discoverServicesButton);
        discoverServicesButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
            }
        });

        return view;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        try {
            wifiDirectHandlerAccessor = ((WiFiDirectHandlerAccessor) getActivity());
        } catch (ClassCastException e) {
            throw new ClassCastException(getActivity().toString() + " must implement WiFiDirectHandlerAccessor");
        }
    }
}
{'fraction_non_alphanumeric': 0.0809315866084425, 'fraction_numerical': 0.0008733624454148472, 'mean_word_length': 2.550904392764858, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2497212', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1622, 'n_words': 305}