<commit_before>package com.cmput301f16t11.a2b;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.text.DecimalFormat;

/**
 * ProfileActivity allows a user to view their own profile as well as though of other users
 */
public class ProfileActivity extends AppCompatActivity {
    /**
     * The following work, ProfileActivity, contains a derivative of an answer to
     * "How to make a phone call programatically?" by "Lior," edited by "The Alpha,"
     * users on stack overflow. It is used under CC-BY-SA by CMPUT301F16T11.
     *
     * Available here: http://stackoverflow.com/questions/4816683/how-to-make-a-phone-call-programatically
     * Date accessed: Nov. 11, 2016
     *
     * The following work, ProfileActivity, contains a derivative of android developer tutorial
     * "Requesting Permissions at Run Time." Used under Apache 2.0.
     *
     * Available here:
     * https://developer.android.com/training/permissions/requesting.html
     * Date accessed: Nov. 11, 2016
     *
     */
    private User user;
    private Context context;

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

    @Override
    public void onResume() {
        super.onResume();  // Always call the superclass method first;
        Intent intent = getIntent();
        String username = intent.getStringExtra("username");
        if(username == null){
            user = UserController.getUserFromId(UserController.getUser().getId());
            UserController.setUser(user);
            UserController.saveInFile(this);
        }
        else{
            user = UserController.getUserFromName(username);
        }

        setTextViews();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (UserController.getUser().equals(user)) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.profile_menu, menu);
        }
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Only option available is profile editor
        if (item.getItemId()==R.id.edit_profile) {
            launchProfileEditor();
            return true;
        }<commit_msg>Save updated user when loading ProfileActivity<commit_after>package com.cmput301f16t11.a2b;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.text.DecimalFormat;

/**
 * ProfileActivity allows a user to view their own profile as well as though of other users
 */
public class ProfileActivity extends AppCompatActivity {
    /**
     * The following work, ProfileActivity, contains a derivative of an answer to
     * "How to make a phone call programatically?" by "Lior," edited by "The Alpha,"
     * users on stack overflow. It is used under CC-BY-SA by CMPUT301F16T11.
     *
     * Available here: http://stackoverflow.com/questions/4816683/how-to-make-a-phone-call-programatically
     * Date accessed: Nov. 11, 2016
     *
     * The following work, ProfileActivity, contains a derivative of android developer tutorial
     * "Requesting Permissions at Run Time." Used under Apache 2.0.
     *
     * Available here:
     * https://developer.android.com/training/permissions/requesting.html
     * Date accessed: Nov. 11, 2016
     *
     */
    private User user;
    private Context context;

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

    @Override
    public void onResume() {
        super.onResume();  // Always call the superclass method first;
        Intent intent = getIntent();
        String username = intent.getStringExtra("username");
        if(username == null){
            user = UserController.getUserFromId(UserController.getUser().getId());
        }
        else{
            user = UserController.getUserFromName(username);
        }

        if (user.getId().equals(UserController.getUser().getId())) {
            UserController.setUser(user);
            UserController.saveInFile(this);
        }

        setTextViews();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (UserController.getUser().equals(user)) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.profile_menu, menu);
        }
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Only option available is profile editor
        if (item.getItemId()==R.id.edit_profile) {
            launchProfileEditor();
            return true;
        }
{'fraction_non_alphanumeric': 0.09539780137879635, 'fraction_numerical': 0.014160611142165084, 'mean_word_length': 2.837026447462473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6959309', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1427, 'n_words': 387}