<commit_before>package ca.ualberta.cs.team5geotopics;

import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;

import com.example.team5geotopics.R;

/**
 * Called when a user hits the '+' button at the top of any screen that has one.
 * This action opens this activity which presents the user with options to fill in a Author,
 * Body, Title, and even attach a photo via the camera or via the local storage image gallery. 
 */

public class CreateCommentActivity extends InspectCommentActivity implements
		OnClickListener {
	
	Intent returnIntent;

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

		setTitle("Create Comment");

		// Find the edit text views
		this.title = (EditText) findViewById(R.id.editCommentTitle);
		this.author = (EditText) findViewById(R.id.editCommentAuthor);
		this.body = (EditText) findViewById(R.id.editCommentBody);

		// Associates the button with their ID.
		locationBtn = (ImageButton) findViewById(R.id.imageButtonLocation);
		photoBtn = (ImageButton) findViewById(R.id.imageButtonImage);
		cancelBtn = (ImageButton) findViewById(R.id.imageButtonCancel);
		postBtn = (ImageButton) findViewById(R.id.imageButtonPost);
		// Allows the buttons to be checked for a click event.
		locationBtn.setOnClickListener(this);
		photoBtn.setOnClickListener(this);
		cancelBtn.setOnClickListener(this);
		postBtn.setOnClickListener(this);

		parentID = b.getString("ParentID");
		
		// Replies do not have titles and thus we should disable it OR make
		// a new activity/layout
		if (commentType.equals("ReplyLevel")) {
			this.title.setVisibility(View.GONE);
			findViewById(R.id.textViewTitle).setVisibility(View.GONE);
		}
	}

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

	// This function will check for which button was clicked.
	@SuppressWarnings("deprecation")
	public void onClick(View v) {
		if (v == locationBtn) {
			showDialog(1);
			/*
			 * SIMPLY HERE FOR TESTING PURPOSES:
			 * 
			 * generates a different location than default. TODO: For next part
			 * of project, let users choose a custom location
			 */			///Location loc = new Location("loc");
			//loc.setLongitude(0.1);
			//loc.setLatitude(0);
			//mGeolocation = loc;
			/*------------------------------------------------------------------*/
		}
		if (v == photoBtn) {
			uploadedImage = (ImageView) findViewById(R.id.imageViewPicture);
			showDialog(0);
		}
		if (v == cancelBtn) {
			finish();
		}
		// Gets all the data from the text boxes and submits it as a new
		// comment
		if (v == postBtn) {
			if (commentType.equals("TopLevel"))
				this.mTitle = title.getText().toString();

			this.mAuthor = author.getText().toString();
			if(mAuthor.isEmpty()){
				mAuthor = "Anonymous";
			}
			this.mBody = body.getText().toString();
			if (mGeolocation == null) {
				// Location l = new Location("l");
				//l.setLatitude(0);
				//l.setLongitude(0);
				//mGeolocation = l;
				//mGeolocation = myUser.getCurrentLocation();
			}
			User user = User.getInstance();<commit_msg>just added a default location for if user doesnt press location<commit_after>package ca.ualberta.cs.team5geotopics;

import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;

import com.example.team5geotopics.R;

/**
 * Called when a user hits the '+' button at the top of any screen that has one.
 * This action opens this activity which presents the user with options to fill in a Author,
 * Body, Title, and even attach a photo via the camera or via the local storage image gallery. 
 */

public class CreateCommentActivity extends InspectCommentActivity implements
		OnClickListener {
	
	Intent returnIntent;

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

		setTitle("Create Comment");

		// Find the edit text views
		this.title = (EditText) findViewById(R.id.editCommentTitle);
		this.author = (EditText) findViewById(R.id.editCommentAuthor);
		this.body = (EditText) findViewById(R.id.editCommentBody);

		// Associates the button with their ID.
		locationBtn = (ImageButton) findViewById(R.id.imageButtonLocation);
		photoBtn = (ImageButton) findViewById(R.id.imageButtonImage);
		cancelBtn = (ImageButton) findViewById(R.id.imageButtonCancel);
		postBtn = (ImageButton) findViewById(R.id.imageButtonPost);
		// Allows the buttons to be checked for a click event.
		locationBtn.setOnClickListener(this);
		photoBtn.setOnClickListener(this);
		cancelBtn.setOnClickListener(this);
		postBtn.setOnClickListener(this);

		parentID = b.getString("ParentID");
		
		// Replies do not have titles and thus we should disable it OR make
		// a new activity/layout
		if (commentType.equals("ReplyLevel")) {
			this.title.setVisibility(View.GONE);
			findViewById(R.id.textViewTitle).setVisibility(View.GONE);
		}
	}

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

	// This function will check for which button was clicked.
	@SuppressWarnings("deprecation")
	public void onClick(View v) {
		if (v == locationBtn) {
			showDialog(1);
			/*
			 * SIMPLY HERE FOR TESTING PURPOSES:
			 * 
			 * generates a different location than default. TODO: For next part
			 * of project, let users choose a custom location
			 */			///Location loc = new Location("loc");
			//loc.setLongitude(0.1);
			//loc.setLatitude(0);
			//mGeolocation = loc;
			/*------------------------------------------------------------------*/
		}
		if (v == photoBtn) {
			uploadedImage = (ImageView) findViewById(R.id.imageViewPicture);
			showDialog(0);
		}
		if (v == cancelBtn) {
			finish();
		}
		// Gets all the data from the text boxes and submits it as a new
		// comment
		if (v == postBtn) {
			if (commentType.equals("TopLevel"))
				this.mTitle = title.getText().toString();

			this.mAuthor = author.getText().toString();
			if(mAuthor.isEmpty()){
				mAuthor = "Anonymous";
			}
			this.mBody = body.getText().toString();
			if (mGeolocation == null) {
				 
				Location l = new Location("l");
				l.setLatitude(0);
				l.setLongitude(0);
				mGeolocation = l;
				//mGeolocation = myUser.getCurrentLocation();
			}
			User user = User.getInstance();
{'fraction_non_alphanumeric': 0.13141161509114033, 'fraction_numerical': 0.002543450614667232, 'mean_word_length': 3.5961038961038962, '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': '1568428', 'n_tokens_mistral': 2358, 'n_tokens_neox': 2054, 'n_words': 583}