diff --git a/GeoTag.iml b/GeoTag.iml
new file mode 100644
index 0000000..478ac72
--- /dev/null
+++ b/GeoTag.iml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/app.iml b/app/app.iml
new file mode 100644
index 0000000..b840008
--- /dev/null
+++ b/app/app.iml
@@ -0,0 +1,163 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 57ca55b..23b54a7 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,11 +1,12 @@
apply plugin: 'com.android.application'
+apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.android.geotag"
- minSdkVersion 15
+ minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
@@ -23,7 +24,18 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation 'com.google.firebase:firebase-auth:16.0.5'
+ implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
+ /*implementation 'com.google.android.gms:play-services:12.0.1'*/
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
+
+ implementation 'com.google.android.gms:play-services-maps:16.1.0'
+ implementation 'com.google.android.gms:play-services-auth:16.0.1'
+ implementation 'com.google.android.gms:play-services-location:16.0.0'
+ implementation 'com.google.android.gms:play-services-analytics:16.0.7'
+ implementation 'com.google.android.gms:play-services-places:16.0.0'
+ implementation 'com.google.android.gms:play-services-gcm:16.0.0'
+ implementation 'com.google.android.gms:play-services-base:16.1.0'
}
diff --git a/app/google-services.json b/app/google-services.json
new file mode 100644
index 0000000..f3d003b
--- /dev/null
+++ b/app/google-services.json
@@ -0,0 +1,48 @@
+{
+ "project_info": {
+ "project_number": "738961992255",
+ "firebase_url": "https://geotag-132b1.firebaseio.com",
+ "project_id": "geotag-132b1",
+ "storage_bucket": "geotag-132b1.appspot.com"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:738961992255:android:ecd6ace57e76d9a0a5e68a",
+ "android_client_info": {
+ "package_name": "com.example.android.geotag"
+ }
+ },
+ "oauth_client": [
+ {
+ "client_id": "738961992255-77psa62dbf840amvf4n62s9pbqe57fse.apps.googleusercontent.com",
+ "client_type": 1,
+ "android_info": {
+ "package_name": "com.example.android.geotag",
+ "certificate_hash": "be538e123a2a75a47a281f9a25722d3c07cb7568"
+ }
+ },
+ {
+ "client_id": "738961992255-ehpu3gd9kvtetfge2p84v94aedp77bgl.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ],
+ "api_key": [
+ {
+ "current_key": "AIzaSyAkm6w7-QM9XiJ3uhiDQKiwxkWf9XT_bvw"
+ }
+ ],
+ "services": {
+ "appinvite_service": {
+ "other_platform_oauth_client": [
+ {
+ "client_id": "738961992255-ehpu3gd9kvtetfge2p84v94aedp77bgl.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "configuration_version": "1"
+}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index dd1ca4d..82e5cc8 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -9,6 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
+
@@ -16,6 +17,16 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/android/geotag/MainActivity.java b/app/src/main/java/com/example/android/geotag/MainActivity.java
index b41cdc6..153af1a 100644
--- a/app/src/main/java/com/example/android/geotag/MainActivity.java
+++ b/app/src/main/java/com/example/android/geotag/MainActivity.java
@@ -1,14 +1,114 @@
package com.example.android.geotag;
+import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
+import android.content.Intent;
import android.os.Bundle;
+import android.view.View;
+import android.widget.ListView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.firebase.ui.auth.AuthUI;
+import com.firebase.ui.auth.IdpResponse;
+import com.google.firebase.auth.FirebaseAuth;
+import com.google.firebase.auth.FirebaseUser;
+
+import java.util.Arrays;
+import java.util.List;
+
public class MainActivity extends AppCompatActivity {
+ public static final int RC_SIGN_IN = 1;
+
+ private FirebaseAuth mFirebaseAuth;
+ private FirebaseAuth.AuthStateListener mAuthStateListener;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
+
+ mFirebaseAuth = FirebaseAuth.getInstance();
+
+ mAuthStateListener = new FirebaseAuth.AuthStateListener() {
+
+ @Override
+ public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
+ updateUi();
+ }
+ };
+ }
+
+ private void updateUi() {
+ FirebaseUser user = mFirebaseAuth.getCurrentUser();
+ if (user == null) {
+ // Choose authentication providers
+ List providers = Arrays.asList(
+ new AuthUI.IdpConfig.EmailBuilder().build(),
+ new AuthUI.IdpConfig.GoogleBuilder().build());
+ // Create and launch sign-in intent
+ startActivityForResult(
+ AuthUI.getInstance()
+ .createSignInIntentBuilder()
+ .setAvailableProviders(providers)
+ .build(),
+ RC_SIGN_IN);
+
+ } else {
+
+ TextView nameText = findViewById(R.id.nameText);
+ TextView emailText = findViewById(R.id.emailText);
+ nameText.setText(mFirebaseAuth.getCurrentUser().getDisplayName());
+ emailText.setText(mFirebaseAuth.getCurrentUser().getEmail());
+
+ }
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+
+ if (requestCode == RC_SIGN_IN) {
+ IdpResponse response = IdpResponse.fromResultIntent(data);
+
+ if (resultCode == RESULT_OK) {
+ // Successfully signed in
+ FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
+ // ...
+ } else {
+ // Sign in failed. If response is null the user canceled the
+ // sign-in flow using the back button. Otherwise check
+ // response.getError().getErrorCode() and handle the error.
+ // ...
+ }
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mFirebaseAuth.addAuthStateListener(mAuthStateListener);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ if (mAuthStateListener != null) {
+ mFirebaseAuth.removeAuthStateListener(mAuthStateListener);
+ }
+ }
+
+ //signout the user
+ public void signOut(View view){
+ FirebaseAuth.getInstance().signOut();
+ }
+
+ //go to activity_map.xml
+ public void map(View view) {
+ startActivity(new Intent(MainActivity.this, map.class));
}
}
diff --git a/app/src/main/java/com/example/android/geotag/map.java b/app/src/main/java/com/example/android/geotag/map.java
new file mode 100644
index 0000000..10c5213
--- /dev/null
+++ b/app/src/main/java/com/example/android/geotag/map.java
@@ -0,0 +1,292 @@
+package com.example.android.geotag;
+
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
+import androidx.fragment.app.FragmentActivity;
+
+import android.Manifest;
+import android.content.pm.PackageManager;
+import android.location.Address;
+import android.location.Geocoder;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.nfc.Tag;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.AutoCompleteTextView;
+import android.widget.EditText;
+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.LocationRequest;
+import com.google.android.gms.location.LocationServices;
+import com.google.android.gms.maps.CameraUpdateFactory;
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.LocationSource;
+import com.google.android.gms.maps.OnMapReadyCallback;
+import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.BitmapDescriptorFactory;
+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.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class map extends FragmentActivity
+ implements OnMapReadyCallback, GoogleMap.OnMyLocationButtonClickListener, LocationSource.OnLocationChangedListener {
+
+ private GoogleMap mMap;
+ LocationManager locationManager;
+
+ //widget
+ private EditText mSearchText;
+
+ //marker
+ private Marker marker;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // Retrieve the content view that renders the map.
+ setContentView(R.layout.activity_map);
+
+ //editText searchbar
+ mSearchText = (EditText) findViewById(R.id.input_search);
+
+ // Get the SupportMapFragment and request notification
+ // when the map is ready to be used.
+ SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.map);
+ mapFragment.getMapAsync(this);
+ // mMap.setMyLocationEnabled(true);
+
+ //position the myLocation button
+ View locationButton = ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2"));
+ RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
+ rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0);
+ rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
+ rlp.setMargins(0, 0, 30, 300);
+
+ locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
+ if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
+ // TODO: Consider calling
+ // Activity#requestPermissions
+ // here to request the missing permissions, and then overriding
+ // public void onRequestPermissionsResult(int requestCode, String[] permissions,
+ // int[] grantResults)
+ // to handle the case where the user grants the permission. See the documentation
+ // for Activity#requestPermissions for more details.
+ return;
+ }
+ //check network provider
+ if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
+ locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10000000, 0, new LocationListener() {
+ @Override
+ public void onLocationChanged(Location location) {
+ //get latitude
+ double latitude = location.getLatitude();
+ //get longitude
+ double longitude = location.getLongitude();
+ //instantiate LatLng class
+ LatLng latLng = new LatLng(latitude, longitude);
+ //instantiate Geocoder class
+ Geocoder geocoder = new Geocoder(getApplicationContext());
+ try {
+ List addressList = geocoder.getFromLocation(latitude, longitude,1);
+ String str = addressList.get(0).getLocality()+", ";
+ str += addressList.get(0).getCountryName();
+ //setInfoText
+ //infoTextview
+ TextView infoTextview = findViewById(R.id.locationInfoText);
+ infoTextview.setText(str);
+
+ //add marker
+ MarkerOptions a = new MarkerOptions().position(latLng);
+ marker = mMap.addMarker(a);
+ marker.setDraggable(true);
+
+ //mMap.addMarker(new MarkerOptions().position(latLng).title(str)).setDraggable(true);
+ mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 10.2f));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+
+ }
+ });
+ }
+
+ //check gps provider
+ else if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000000, 0, new LocationListener() {
+ @Override
+ public void onLocationChanged(Location location) {
+ //get latitude
+ double latitude = location.getLatitude();
+ //get longitude
+ double longitude = location.getLongitude();
+ //instantiate LatLng class
+ LatLng latLng = new LatLng(latitude, longitude);
+ //instantiate Geocoder class
+ Geocoder geocoder = new Geocoder(getApplicationContext());
+ try {
+ List addressList = geocoder.getFromLocation(latitude, longitude,1);
+ String str = addressList.get(0).getLocality()+", ";
+ str += addressList.get(0).getCountryName();
+ //setInfoText
+ //infoTextview
+ TextView infoTextview = findViewById(R.id.locationInfoText);
+ infoTextview.setText(str);
+
+
+ //add marker
+ MarkerOptions a = new MarkerOptions().position(latLng);
+ marker = mMap.addMarker(a);
+ marker.setDraggable(true);
+
+ //mMap.addMarker(new MarkerOptions().position(latLng).title(str)).setDraggable(true);
+ mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 10.2f));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+
+ }
+ });
+ }
+
+ }
+
+ private void init(){
+
+ mSearchText.setOnKeyListener(new View.OnKeyListener() {
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ // If the event is a key-down event on the "enter" button
+ if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
+ (keyCode == KeyEvent.KEYCODE_ENTER)) {
+ // execute method for searching
+ geoLocate();
+
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+
+ private void geoLocate(){
+
+ String searchString = mSearchText.getText().toString();
+
+ Geocoder geocoder = new Geocoder(map.this);
+ List list = new ArrayList<>();
+ try{
+ list = geocoder.getFromLocationName(searchString, 1);
+ }catch (IOException e){
+ //something
+ }
+
+ if(list.size() > 0){
+ Address address = list.get(0);
+ double latitude = address.getLatitude();
+ double longitude = address.getLongitude();
+
+ //instantiate LatLng class
+ LatLng latLng = new LatLng(latitude, longitude);
+ //instantiate Geocoder class
+ Geocoder newgeocoder = new Geocoder(getApplicationContext());
+ try {
+ List addressList = newgeocoder.getFromLocation(latitude, longitude,1);
+ String str = new String();
+ str += addressList.get(0).getLocality()+", ";
+ str += addressList.get(0).getCountryName();
+ //setInfoText
+ //infoTextview
+ TextView infoTextview = findViewById(R.id.locationInfoText);
+ infoTextview.setText(str);
+
+ //add marker
+ MarkerOptions a = new MarkerOptions().position(latLng);
+ marker.setPosition(latLng);
+ marker.setDraggable(true);
+
+ //mMap.addMarker(new MarkerOptions().position(latLng).title(str));
+ mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 10.2f));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+
+ @Override
+ public void onMapReady(GoogleMap googleMap) {
+ mMap = googleMap;
+ mMap.setMyLocationEnabled(true);
+ mMap.setOnMyLocationButtonClickListener(this);
+ init();
+ }
+
+ @Override
+ public boolean onMyLocationButtonClick() {
+ //TODO update infoText
+ //TODO update marker
+
+ return false;
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+
+ double latitude = location.getLatitude();
+ double longitude = location.getLongitude();
+
+ //instantiate LatLng class
+ LatLng latLng = new LatLng(latitude, longitude);
+
+ //update marker
+ MarkerOptions a = new MarkerOptions().position(latLng);
+ marker = mMap.addMarker(a);
+ marker.setDraggable(true);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable-anydpi/ic_magnify.xml b/app/src/main/res/drawable-anydpi/ic_magnify.xml
new file mode 100644
index 0000000..6decaab
--- /dev/null
+++ b/app/src/main/res/drawable-anydpi/ic_magnify.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable-hdpi/ic_magnify.png b/app/src/main/res/drawable-hdpi/ic_magnify.png
new file mode 100644
index 0000000..64c0f9f
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_magnify.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_magnify.png b/app/src/main/res/drawable-mdpi/ic_magnify.png
new file mode 100644
index 0000000..5b4b7e7
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_magnify.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_magnify.png b/app/src/main/res/drawable-xhdpi/ic_magnify.png
new file mode 100644
index 0000000..a34b333
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_magnify.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_magnify.png b/app/src/main/res/drawable-xxhdpi/ic_magnify.png
new file mode 100644
index 0000000..5a5799b
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_magnify.png differ
diff --git a/app/src/main/res/drawable/white_border.xml b/app/src/main/res/drawable/white_border.xml
new file mode 100644
index 0000000..349970f
--- /dev/null
+++ b/app/src/main/res/drawable/white_border.xml
@@ -0,0 +1,10 @@
+
+
+ -
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 4fc2444..65bef2c 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -5,14 +5,39 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
+
-
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_map.xml b/app/src/main/res/layout/activity_map.xml
new file mode 100644
index 0000000..a3221ab
--- /dev/null
+++ b/app/src/main/res/layout/activity_map.xml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 5885930..0eb88fe 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -1,7 +1,7 @@
-