<commit_before>package com.example.henzoshimada.feeltrip;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;

import android.Manifest;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.places.Places;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import java.util.ArrayList;
import java.util.concurrent.ExecutionException;

//http://www.latlong.net/
//(PermissionUtils.java, MyLocationDemoActivity.java)https://github.com/googlemaps/android-samples
//https://developers.google.com/maps/documentation/android-api/current-place-tutorial
public class MapActivity extends FragmentActivity
        implements
        OnMyLocationButtonClickListener,
        OnMapReadyCallback,
        GoogleMap.OnMarkerClickListener,
        GoogleMap.OnMapClickListener,
        ActivityCompat.OnRequestPermissionsResultCallback {

    /**
     * Request code for location permission request.
     *
     * @see #onRequestPermissionsResult(int, String[], int[])
     */
    private static final int LOCATION_PERMISSION_REQUEST_CODE = 1;

    /**
     * Flag indicating whether a requested permission has been denied after returning in
     * {@link #onRequestPermissionsResult(int, String[], int[])}.
     */
    private boolean mPermissionDenied = false;

    private GoogleMap mMap;

    private GoogleApiClient mGoogleApiClient;
    private Location mLastKnownLocation;

    private CameraPosition mCameraPosition;
    private static final String KEY_CAMERA_POSITION = "camera_position";
    private static final String KEY_LOCATION = "location";


    private ArrayList<Mood> moodArrayList = new ArrayList<Mood>();

    private  Marker mSelectedMarker;
    //creates and sets up map
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //Log.d("mapTag","on create");
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_map);

        //testing get array of moods
        try {
            Log.d("mapTag","before");
            testCreateMoodArray();
            Log.d("mapTag","after");
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        // Build the Play services client for use by the Fused Location Provider and the Places API.
        // Use the addApi() method to request the Google Places API and the Fused Location Provider.
        mGoogleApiClient = new GoogleApiClient.Builder(this)


                .addApi(LocationServices.API)
                .addApi(Places.GEO_DATA_API)
                .addApi(Places.PLACE_DETECTION_API)
                .build();
        mGoogleApiClient.connect();

        SupportMapFragment mapFragment =
                (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    /*
    @Override
    protected void onResume(){
        super.onResume();
        Log.d("mapTag","on resume");
        if (mLastKnownLocation != null) {
            Log.d("mapTag", "use last known location");
            mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
                    new LatLng(mLastKnownLocation.getLatitude(),
                            mLastKnownLocation.getLongitude()), 15));
            Circle circle = mMap.addCircle(new CircleOptions()
                    .center(new LatLng(mLastKnownLocation.getLatitude(),
                            mLastKnownLocation.getLongitude()))
                    .radius(5000) //in meters
                    .strokeColor(Color.RED));
        }
    }

    @Override
    protected void onPause(){
        super.onPause();

    }
*/

    //called when map is ready
    @Override
    public void onMapReady(GoogleMap map) {
        mMap = map;
        // Set listener for marker click event.  See the bottom of this class for its behavior.
        mMap.setOnMarkerClickListener(this);
        // Set listener for map click event.  See the bottom of this class for its behavior.
        mMap.setOnMapClickListener(this);
        mMap.setOnMyLocationButtonClickListener(this);
        mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
            @Override
            public View getInfoWindow(Marker marker) {
                //use default InfoWindow frame
                return null;
            }

            @Override
            public View getInfoContents(Marker marker) {
                Log.d("mapTag", "get info contents");
                View view = getLayoutInflater().inflate(R.layout.info_window_layout, null);
                view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); //width, height

                int index = Integer.parseInt(marker.getSnippet());
                Mood mood = moodArrayList.get(index);
                TextView usernameView = (TextView) view.findViewById(R.id.person);
                TextView social_situationView = (TextView) view.findViewById(R.id.social_situation);
                usernameView.setText(mood.getUser());
                //social_situationView.setText(mood.getSocialSit());

                return view;
            }
        });

        enableMyLocation();
        setMoodMarker();
    }

    private void setMoodMarker(){
        Log.d("mapTag", "set mood marker");
        if (mMap != null) {
            Mood mood;
            Marker marker;
            Log.d("mapTag","mood array size: "+moodArrayList.size());
            for(int i = 0; i < moodArrayList.size(); i++){
                mood = moodArrayList.get(i);
                //get longitude
                //get latitude
                marker = mMap.addMarker(new MarkerOptions()
                        .position(new LatLng(53.528033+i, -113.525355+i))
                        .snippet(String.valueOf(i)));
                Log.d("mapTag", "i= "+String.valueOf(i));
            }
        }
    }
    /**
     * Enables the My Location layer if the fine location permission has been granted.
     */
    private void enableMyLocation() {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
                != PackageManager.PERMISSION_GRANTED) {
            // Permission to access the location is missing.
            PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE,
                    Manifest.permission.ACCESS_FINE_LOCATION, true);
        } else if (mMap != null) {
            // Access to the location has been granted to the app.
            mMap.setMyLocationEnabled(true);<commit_msg>removed on resume<commit_after>package com.example.henzoshimada.feeltrip;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMyLocationButtonClickListener;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;

import android.Manifest;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.places.Places;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import java.util.ArrayList;
import java.util.concurrent.ExecutionException;

//http://www.latlong.net/
//(PermissionUtils.java, MyLocationDemoActivity.java)https://github.com/googlemaps/android-samples
//https://developers.google.com/maps/documentation/android-api/current-place-tutorial
public class MapActivity extends FragmentActivity
        implements
        OnMyLocationButtonClickListener,
        OnMapReadyCallback,
        GoogleMap.OnMarkerClickListener,
        GoogleMap.OnMapClickListener,
        ActivityCompat.OnRequestPermissionsResultCallback {

    /**
     * Request code for location permission request.
     *
     * @see #onRequestPermissionsResult(int, String[], int[])
     */
    private static final int LOCATION_PERMISSION_REQUEST_CODE = 1;

    /**
     * Flag indicating whether a requested permission has been denied after returning in
     * {@link #onRequestPermissionsResult(int, String[], int[])}.
     */
    private boolean mPermissionDenied = false;

    private GoogleMap mMap;

    private GoogleApiClient mGoogleApiClient;
    private static Location mLastKnownLocation;

    private CameraPosition mCameraPosition;
    private static final String KEY_CAMERA_POSITION = "camera_position";
    private static final String KEY_LOCATION = "location";


    private ArrayList<Mood> moodArrayList = new ArrayList<Mood>();

    private Marker mSelectedMarker;

    //creates and sets up map
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //Log.d("mapTag","on create");
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_map);

        //testing get array of moods
        try {
            Log.d("mapTag", "before");
            testCreateMoodArray();
            Log.d("mapTag", "after");
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        // Build the Play services client for use by the Fused Location Provider and the Places API.
        // Use the addApi() method to request the Google Places API and the Fused Location Provider.
        mGoogleApiClient = new GoogleApiClient.Builder(this)


                .addApi(LocationServices.API)
                .addApi(Places.GEO_DATA_API)
                .addApi(Places.PLACE_DETECTION_API)
                .build();
        mGoogleApiClient.connect();

        SupportMapFragment mapFragment =
                (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    //called when map is ready
    @Override
    public void onMapReady(GoogleMap map) {
        mMap = map;
        // Set listener for marker click event.  See the bottom of this class for its behavior.
        mMap.setOnMarkerClickListener(this);
        // Set listener for map click event.  See the bottom of this class for its behavior.
        mMap.setOnMapClickListener(this);
        mMap.setOnMyLocationButtonClickListener(this);
        mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
            @Override
            public View getInfoWindow(Marker marker) {
                //use default InfoWindow frame
                return null;
            }

            @Override
            public View getInfoContents(Marker marker) {
                Log.d("mapTag", "get info contents");
                View view = getLayoutInflater().inflate(R.layout.info_window_layout, null);
                view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)); //width, height

                int index = Integer.parseInt(marker.getSnippet());
                Mood mood = moodArrayList.get(index);
                TextView usernameView = (TextView) view.findViewById(R.id.person);
                TextView social_situationView = (TextView) view.findViewById(R.id.social_situation);
                usernameView.setText(mood.getUser());
                //social_situationView.setText(mood.getSocialSit());

                return view;
            }
        });

        enableMyLocation();
        setMoodMarker();
    }

    private void setMoodMarker(){
        //Log.d("mapTag", "set mood marker");
        if (mMap != null) {
            Mood mood;
            Marker marker;
            //Log.d("mapTag","mood array size: "+moodArrayList.size());
            for(int i = 0; i < moodArrayList.size(); i++){
                mood = moodArrayList.get(i);
                //get longitude
                //get latitude
                marker = mMap.addMarker(new MarkerOptions()
                        .position(new LatLng(53.528033+i, -113.525355+i))
                        .snippet(String.valueOf(i)));
                //Log.d("mapTag", "i= "+String.valueOf(i));
            }
        }
    }
    /**
     * Enables the My Location layer if the fine location permission has been granted.
     */
    private void enableMyLocation() {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
                != PackageManager.PERMISSION_GRANTED) {
            // Permission to access the location is missing.
            PermissionUtils.requestPermission(this, LOCATION_PERMISSION_REQUEST_CODE,
                    Manifest.permission.ACCESS_FINE_LOCATION, true);
        } else if (mMap != null) {
            // Access to the location has been granted to the app.
            mMap.setMyLocationEnabled(true);
{'fraction_non_alphanumeric': 0.09727573852497803, 'fraction_numerical': 0.0035151760968025417, 'mean_word_length': 2.634889434889435, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '1219352', 'n_tokens_mistral': 4066, 'n_tokens_neox': 3888, 'n_words': 852}