Merge branch 'master' of github.com:sagidayan/TheSocialNotework-Android
This commit is contained in:
commit
00f361ce79
3 changed files with 35 additions and 11 deletions
|
@ -1,10 +1,12 @@
|
||||||
package com.android_app.matan.ara.sagi.thesocialnotework;
|
package com.android_app.matan.ara.sagi.thesocialnotework;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
//import android.app.Fragment;
|
//import android.app.Fragment;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -72,7 +74,7 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||||
}
|
}
|
||||||
mainActivity = (MainActivity)getActivity();
|
mainActivity = (MainActivity) getActivity();
|
||||||
|
|
||||||
gpsUtils = mainActivity.getGPSUtils();
|
gpsUtils = mainActivity.getGPSUtils();
|
||||||
|
|
||||||
|
@ -108,11 +110,22 @@ public class GmapFragment extends Fragment implements OnMapReadyCallback {
|
||||||
|
|
||||||
mMap = googleMap;
|
mMap = googleMap;
|
||||||
|
|
||||||
VolleyUtilSingleton.getInstance(getActivity()).get(mainActivity.BASE_URL + "/note/all?uid=" +mainActivity.getUserId() , getNotesSuccessListener, mainActivity.genericErrorListener);
|
VolleyUtilSingleton.getInstance(getActivity()).get(mainActivity.BASE_URL + "/note/all?uid=" + mainActivity.getUserId(), getNotesSuccessListener, mainActivity.genericErrorListener);
|
||||||
|
|
||||||
LatLng userLocation = new LatLng(gpsUtils.getLatitude(), gpsUtils.getLongitude());
|
LatLng userLocation = new LatLng(gpsUtils.getLatitude(), gpsUtils.getLongitude());
|
||||||
mMap.addMarker(new MarkerOptions().position(userLocation).title("I Am Here!"));
|
mMap.addMarker(new MarkerOptions().position(userLocation).title("I Am Here!"));
|
||||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(userLocation));
|
if (ActivityCompat.checkSelfPermission(mainActivity, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mainActivity, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
// TODO: Consider calling
|
||||||
|
// ActivityCompat#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 ActivityCompat#requestPermissions for more details.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mMap.setMyLocationEnabled(true);
|
||||||
|
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(userLocation, 12));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.android_app.matan.ara.sagi.thesocialnotework;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.android_app.matan.ara.sagi.thesocialnotework;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
|
@ -38,6 +40,7 @@ public class MainActivity extends AppCompatActivity
|
||||||
public static ProgressDialog progress;
|
public static ProgressDialog progress;
|
||||||
private GmapFragment gmapFragment;
|
private GmapFragment gmapFragment;
|
||||||
private PersonalFragment personalFragment;
|
private PersonalFragment personalFragment;
|
||||||
|
private Toolbar toolbar;
|
||||||
public static final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
|
public static final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +48,8 @@ public class MainActivity extends AppCompatActivity
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
toolbar.setTitle("Personal Notes");
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
gmapFragment = new GmapFragment();
|
gmapFragment = new GmapFragment();
|
||||||
personalFragment = new PersonalFragment();
|
personalFragment = new PersonalFragment();
|
||||||
|
@ -119,13 +123,13 @@ public class MainActivity extends AppCompatActivity
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
if (id == R.id.nav_explore) {
|
if (id == R.id.nav_explore) {
|
||||||
// Handle the camera action
|
toolbar.setTitle("Explore");
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
} else if (id == R.id.nav_map) {
|
} else if (id == R.id.nav_map) {
|
||||||
//
|
|
||||||
Log.d(TAG,"Before going to map");
|
Log.d(TAG,"Before going to map");
|
||||||
// gmapFragment.("note_list", (ArrayList<Note>) listOfNotes);
|
toolbar.setTitle("Map");
|
||||||
// gmapFragment.put("user_lat", gpsUtils.getLatitude());
|
setSupportActionBar(toolbar);
|
||||||
// gmapFragment.putExtra("user_lng", gpsUtils.getLongitude());
|
|
||||||
ft.replace(R.id.fragment_container, gmapFragment);
|
ft.replace(R.id.fragment_container, gmapFragment);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
} else if (id == R.id.nav_personal) {
|
} else if (id == R.id.nav_personal) {
|
||||||
|
@ -134,9 +138,17 @@ public class MainActivity extends AppCompatActivity
|
||||||
ft.replace(R.id.fragment_container, personalFragment);
|
ft.replace(R.id.fragment_container, personalFragment);
|
||||||
ft.commit();
|
ft.commit();
|
||||||
} else if (id == R.id.nav_settings) {
|
} else if (id == R.id.nav_settings) {
|
||||||
|
toolbar.setTitle("Settings");
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
} else if (id == R.id.nav_logout) {
|
} else if (id == R.id.nav_logout) {
|
||||||
|
|
||||||
|
SharedPreferences sharedPref = this.getSharedPreferences(MainActivity.LOCAL_DATA_TSN, Context.MODE_PRIVATE);
|
||||||
|
SharedPreferences.Editor editor = sharedPref.edit();
|
||||||
|
editor.remove("UserId");
|
||||||
|
editor.commit();
|
||||||
|
Intent loginActivity = new Intent(MainActivity.this, LoginActivity.class);
|
||||||
|
startActivity(loginActivity);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||||
|
|
Loading…
Reference in a new issue