<commit_before>package ca.ualberta.trinkettrader.Trades;

import android.content.Intent;
import android.net.Uri;
import android.util.Log;

import ca.ualberta.trinkettrader.ApplicationState;
import ca.ualberta.trinkettrader.User.LoggedInUser;

/**
 * Created by Me on 2015-11-28.
 */
public class TradeReceivedController {
    private TradeReceivedActivity activity;
    private Trade clickedTrade = ApplicationState.getInstance().getClickedTrade();

    public TradeReceivedController(TradeReceivedActivity activity) {
        this.activity = activity;
    }

    public void acceptTradeButtonOnClick(){
        Trade clickedTrade = ApplicationState.getInstance().getClickedTrade();
        clickedTrade.setStatus("Accepted");
        // TODO push trade back to server ... maybe re-propose the trade


        String senderUsername = clickedTrade.getReceiver().getUsername();
        String receiverUsername = clickedTrade.getSender().getUsername();
        String emailList[] = { senderUsername,receiverUsername };

        Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
        emailIntent.setType("text/plain");
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "New Trade!!");
        emailIntent.putExtra(Intent.EXTRA_TEXT, clickedTrade.toEmailString());
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{senderUsername, receiverUsername});
        emailIntent.setData(Uri.parse("mailto:"));
        emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(emailIntent);


        Intent intent = new Intent(activity, TradesActivity.class);
        activity.startActivity(intent);
    }

    public void updateTextViews() {
        //TODO add friend that you will be trading with
        clickedTrade.getReceiver().getUsername();
        activity.getFriendInTradeTextView().setText(clickedTrade.getSender().getUsername());

        activity.getStatusOfTradeTextView().setText(clickedTrade.getStatus());
    }

    public void declineTradeButtonOnClick() {
        Trade clickedTrade = ApplicationState.getInstance().getClickedTrade();
        clickedTrade.setStatus("Declined");
        LoggedInUser.getInstance().getTradeManager().getTradeArchiver().getPastTrades().add(clickedTrade);
        LoggedInUser.getInstance().getTradeManager().getTradeArchiver().getCurrentTrades().remove(clickedTrade);
        Intent intent = new Intent(activity, CounterTradeActivity.class);
        activity.startActivity(intent);
    }

    public void tradeCompletedRadioButtonOnClick() {
        Trade clickedTrade = ApplicationState.getInstance().getClickedTrade();
        clickedTrade.setStatus("Completed");
        LoggedInUser.getInstance().getTradeManager().getTradeArchiver().getPastTrades().add(clickedTrade);
        LoggedInUser.getInstance().getTradeManager().getTradeArchiver().getCurrentTrades().remove(clickedTrade);
        Intent intent = new Intent(activity, TradesActivity.class);<commit_msg>Mini change<commit_after>package ca.ualberta.trinkettrader.Trades;

import android.content.Intent;
import android.net.Uri;
import android.util.Log;

import ca.ualberta.trinkettrader.ApplicationState;
import ca.ualberta.trinkettrader.User.LoggedInUser;

/**
 * Created by Me on 2015-11-28.
 */
public class TradeReceivedController {
    private TradeReceivedActivity activity;
    private Trade clickedTrade = ApplicationState.getInstance().getClickedTrade();

    public TradeReceivedController(TradeReceivedActivity activity) {
        this.activity = activity;
    }

    public void acceptTradeButtonOnClick(){
        Trade clickedTrade = ApplicationState.getInstance().getClickedTrade();
        clickedTrade.setStatus("Accepted");
        // TODO push trade back to server ... maybe re-propose the trade


        String senderUsername = clickedTrade.getReceiver().getUsername();
        String receiverUsername = clickedTrade.getSender().getUsername();

        // MKJParekh; http://stackoverflow.com/questions/9097080/intent-extra-email-not-populating-the-to-field; 2015-11-29
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
        emailIntent.setType("text/plain");
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "New Trade!!");
        emailIntent.putExtra(Intent.EXTRA_TEXT, clickedTrade.toEmailString());
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{senderUsername, receiverUsername});
        emailIntent.setData(Uri.parse("mailto:"));
        emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(emailIntent);

        Intent intent = new Intent(activity, TradesActivity.class);
        activity.startActivity(intent);
    }

    public void updateTextViews() {
        //TODO add friend that you will be trading with
        clickedTrade.getReceiver().getUsername();
        activity.getFriendInTradeTextView().setText(clickedTrade.getSender().getUsername());

        activity.getStatusOfTradeTextView().setText(clickedTrade.getStatus());
    }

    public void declineTradeButtonOnClick() {
        Trade clickedTrade = ApplicationState.getInstance().getClickedTrade();
        clickedTrade.setStatus("Declined");
        LoggedInUser.getInstance().getTradeManager().getTradeArchiver().getPastTrades().add(clickedTrade);
        LoggedInUser.getInstance().getTradeManager().getTradeArchiver().getCurrentTrades().remove(clickedTrade);
        Intent intent = new Intent(activity, CounterTradeActivity.class);
        activity.startActivity(intent);
    }

    public void tradeCompletedRadioButtonOnClick() {
        Trade clickedTrade = ApplicationState.getInstance().getClickedTrade();
        clickedTrade.setStatus("Completed");
        LoggedInUser.getInstance().getTradeManager().getTradeArchiver().getPastTrades().add(clickedTrade);
        LoggedInUser.getInstance().getTradeManager().getTradeArchiver().getCurrentTrades().remove(clickedTrade);
        Intent intent = new Intent(activity, TradesActivity.class);
{'fraction_non_alphanumeric': 0.10969259197043507, 'fraction_numerical': 0.00520745842432387, 'mean_word_length': 4.222807017543859, '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': '2772781', 'n_tokens_mistral': 1639, 'n_tokens_neox': 1604, 'n_words': 250}