package edu.rit.se.waypoints;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationServices;

public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
    GoogleApiClient mGoogleApiClient;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();


    }

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

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onConnected(Bundle bundle) {
        Location last= LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    }

    @Override
    public void onConnectionSuspended(int i) {

    }

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {

    }
}

@@ -192,16 +192,138 @@
 oid.
-os.Bundl
+content.Intent;%0Aimport android.net.Uri;%0Aimport android.os.Bundle;%0Aimport android.os.Environment;%0Aimport android.provider.MediaStor
 e;%0Ai
@@ -597,16 +597,125 @@
 rvices;%0A
+import java.io.File;%0Aimport java.io.IOException;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;%0A%0A%0A
 %0Apublic 
@@ -1894,24 +1894,24 @@
 %0A        %7D%0A%0A
-
         retu
@@ -1947,32 +1947,2058 @@
 d(item);%0A    %7D%0A%0A
+    static final int REQUEST_TAKE_PHOTO = 1;%0A%0A    private void dispatchTakePictureIntent() %7B%0A        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);%0A        // Ensure that there's a camera activity to handle the intent%0A        if (takePictureIntent.resolveActivity(getPackageManager()) != null) %7B%0A            // Create the File where the photo should go%0A            File photoFile = null;%0A            try %7B%0A                photoFile = createImageFile();%0A            %7D catch (IOException ex) %7B%0A                // Error occurred while creating the File%0A                System.out.println(%22Failed to create the file%22);%0A            %7D%0A            // Continue only if the File was successfully created%0A            if (photoFile != null) %7B%0A                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,%0A                        Uri.fromFile(photoFile));%0A                startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);%0A            %7D%0A        %7D%0A    %7D%0A%0A    String mCurrentPhotoPath;%0A%0A    private File createImageFile() throws IOException %7B%0A        // Create an image file name%0A        String timeStamp = new SimpleDateFormat(%22yyyyMMdd_HHmmss%22).format(new Date());%0A        String imageFileName = %22JPEG_%22 + timeStamp + %22_%22;%0A        File storageDir = Environment.getExternalStoragePublicDirectory(%0A                Environment.DIRECTORY_PICTURES);%0A        File image = File.createTempFile(%0A                imageFileName,  /* prefix */%0A                %22.jpg%22,         /* suffix */%0A                storageDir      /* directory */%0A        );%0A%0A        // Save a file: path for use with ACTION_VIEW intents%0A        mCurrentPhotoPath = %22file:%22 + image.getAbsolutePath();%0A        return image;%0A    %7D%0A%0A    private void galleryAddPic() %7B%0A        Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);%0A        File f = new File(mCurrentPhotoPath);%0A        Uri contentUri = Uri.fromFile(f);%0A        mediaScanIntent.setData(contentUri);%0A        this.sendBroadcast(mediaScanIntent);%0A    %7D%0A%0A
     @Override%0A  

Set up of Locationlistener and updater in main activity, still need to set up functionality of location methods