Merge branch 'master' of https://github.com/sagidayan/TheSocialNotework-Android
This commit is contained in:
commit
9273c8a35e
4 changed files with 716 additions and 750 deletions
|
@ -1,22 +1,11 @@
|
|||
package com.android_app.matan.ara.sagi.thesocialnotework;
|
||||
|
||||
import android.*;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.StrictMode;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
|
@ -29,54 +18,42 @@ import android.view.MenuItem;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class MainActivity extends AppCompatActivity
|
||||
implements NavigationView.OnNavigationItemSelectedListener {
|
||||
public static final String LOCAL_DATA_TSN = "TSN_DATA_STORE";
|
||||
protected final String TAG = "[TSN / MainActivity]";
|
||||
protected User user;
|
||||
private GPSUtils gpsUtils;
|
||||
private boolean locationPermission;
|
||||
private GmapFragment gmapFragment;
|
||||
private PersonalFragment personalFragment;
|
||||
private SettingsFragment settingsFragment;
|
||||
private ExploreFragment exploreFragment;
|
||||
private Toolbar toolbar;
|
||||
public static final String BASE_URL = "http://thesocialnotework-api.appspot.com/api";
|
||||
private ImageView menu_avatar;
|
||||
private MainActivity self;
|
||||
private NavigationView nav_view;
|
||||
private final int FINE_PERM = 0, CAMERA_PERM = 1;
|
||||
|
||||
private final int FINE_PERM = 0;
|
||||
|
||||
/**
|
||||
* On Activity Start
|
||||
* @param savedInstanceState
|
||||
*/
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
this.self = this;
|
||||
toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setTitle("Personal Notes");
|
||||
setSupportActionBar(toolbar);
|
||||
gmapFragment = new GmapFragment();
|
||||
personalFragment = new PersonalFragment();
|
||||
settingsFragment = new SettingsFragment();
|
||||
exploreFragment = new ExploreFragment();
|
||||
this.toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
this.toolbar.setTitle("Personal Notes");
|
||||
this.setSupportActionBar(toolbar);
|
||||
this.gmapFragment = new GmapFragment();
|
||||
this.personalFragment = new PersonalFragment();
|
||||
this.settingsFragment = new SettingsFragment();
|
||||
this.exploreFragment = new ExploreFragment();
|
||||
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
|
||||
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
|
@ -99,7 +76,6 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
//Change Layout
|
||||
Log.d(TAG, "Changing Fragment to Personal Activity");
|
||||
// PersonalFragment personalFragment = new PersonalFragment();
|
||||
personalFragment.setArguments(b);
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.fragment_container, personalFragment);
|
||||
|
@ -129,15 +105,18 @@ public class MainActivity extends AppCompatActivity
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param item - Action bar item (Menu)
|
||||
* @return
|
||||
*/
|
||||
@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();
|
||||
|
||||
Log.d(TAG, "onOptionsItemSelected: id -> "+id);
|
||||
//noinspection SimplifiableIfStatement
|
||||
// Settings
|
||||
if (id == R.id.action_settings) {
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
toolbar.setTitle("Settings");
|
||||
|
@ -146,17 +125,19 @@ public class MainActivity extends AppCompatActivity
|
|||
ft.commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will be called when an item is selected from the nav bar.
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("StatementWithEmptyBody")
|
||||
@Override
|
||||
public boolean onNavigationItemSelected(MenuItem item) {
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.nav_explore) {
|
||||
toolbar.setTitle("Explore");
|
||||
setSupportActionBar(toolbar);
|
||||
|
@ -193,16 +174,17 @@ public class MainActivity extends AppCompatActivity
|
|||
finish();
|
||||
}
|
||||
|
||||
// Close the drawer
|
||||
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
|
||||
drawer.closeDrawer(GravityCompat.START);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public GPSUtils getGPSUtils() {
|
||||
return this.gpsUtils;
|
||||
}
|
||||
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
@ -211,6 +193,12 @@ public class MainActivity extends AppCompatActivity
|
|||
return user.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permittion handlers
|
||||
* @param requestCode
|
||||
* @param permissions
|
||||
* @param grantResults
|
||||
*/
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode,
|
||||
String permissions[], int[] grantResults) {
|
||||
|
@ -248,6 +236,9 @@ public class MainActivity extends AppCompatActivity
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Navbar avatar
|
||||
*/
|
||||
public void updateNavAvatar() {
|
||||
//Change The Avatar
|
||||
Utils.URLtoImageView(menu_avatar, user.getAvatar());
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.android_app.matan.ara.sagi.thesocialnotework;
|
||||
|
||||
import com.google.android.gms.maps.model.Marker;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
/**
|
||||
* Created by JERLocal on 7/8/2016.
|
||||
* This class will hold information about a Mark on the Map.
|
||||
*/
|
||||
public class MarkerNoteStruct {
|
||||
private Note note;
|
||||
|
|
|
@ -10,211 +10,220 @@ import java.util.Date;
|
|||
|
||||
/**
|
||||
* Created by JERLocal on 7/1/2016.
|
||||
* A Note Class - Represents a note Object
|
||||
*/
|
||||
public class Note implements Parcelable {
|
||||
|
||||
protected int likes;
|
||||
protected ArrayList<String> tags;
|
||||
protected float lat, lon;
|
||||
protected String id, address, title, body, timestamp, avatar, ownerId;
|
||||
protected boolean isPublic;
|
||||
protected int likes;
|
||||
protected ArrayList<String> tags;
|
||||
protected float lat, lon;
|
||||
protected String id, address, title, body, timestamp, avatar, ownerId;
|
||||
protected boolean isPublic;
|
||||
|
||||
|
||||
public Note(String id, float lat, float lon, String address, String title, String body, String timestamp, boolean isPublic, int likes, String avatar, String ownerId, ArrayList<String> tags) {
|
||||
this.id = id;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.address = address;
|
||||
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
this.timestamp = timestamp;
|
||||
this.isPublic = isPublic;
|
||||
this.likes = likes;
|
||||
this.tags = tags;
|
||||
this.avatar = avatar;
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
public Note(String id, float lat, float lon, String address, String title, String body, String timestamp, boolean isPublic, int likes, String avatar, String ownerId, ArrayList<String> tags) {
|
||||
this.id = id;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.address = address;
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
this.timestamp = timestamp;
|
||||
this.isPublic = isPublic;
|
||||
this.likes = likes;
|
||||
this.tags = tags;
|
||||
this.avatar = avatar;
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
|
||||
protected Note(Parcel in) {
|
||||
likes = in.readInt();
|
||||
tags = in.createStringArrayList();
|
||||
lat = in.readFloat();
|
||||
lon = in.readFloat();
|
||||
|
||||
id = in.readString();
|
||||
address = in.readString();
|
||||
title = in.readString();
|
||||
body = in.readString();
|
||||
timestamp = in.readString();
|
||||
avatar = in.readString();
|
||||
ownerId = in.readString();
|
||||
isPublic = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Creator<Note> CREATOR = new Creator<Note>() {
|
||||
@Override
|
||||
public Note createFromParcel(Parcel in) {
|
||||
return new Note(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Note[] newArray(int size) {
|
||||
return new Note[size];
|
||||
}
|
||||
};
|
||||
|
||||
protected Note(Parcel in) {
|
||||
likes = in.readInt();
|
||||
tags = in.createStringArrayList();
|
||||
lat = in.readFloat();
|
||||
lon = in.readFloat();
|
||||
id = in.readString();
|
||||
address = in.readString();
|
||||
title = in.readString();
|
||||
body = in.readString();
|
||||
timestamp = in.readString();
|
||||
avatar = in.readString();
|
||||
ownerId = in.readString();
|
||||
isPublic = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Creator<Note> CREATOR = new Creator<Note>() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Note{" +
|
||||
"id=" + id +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
|
||||
", address='" + address + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", body='" + body + '\'' +
|
||||
", timestamp=" + timestamp +
|
||||
", isPublic=" + isPublic +
|
||||
", avatar=" + avatar +
|
||||
", ownerId=" + ownerId +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public float getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(float lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public float getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(float lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public void setPublic(boolean aPublic) {
|
||||
isPublic = aPublic;
|
||||
}
|
||||
|
||||
public String getLocationAndTime() {
|
||||
return getTimestamp() + " at " + getAddress();
|
||||
}
|
||||
|
||||
public int getLikes() {
|
||||
return likes;
|
||||
}
|
||||
|
||||
public void setLikes(int likes) {
|
||||
this.likes = likes;
|
||||
}
|
||||
|
||||
public ArrayList<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(ArrayList<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getOwnerId() {
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
public void setOwnerId(String ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
public Note createFromParcel(Parcel in) {
|
||||
return new Note(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(likes);
|
||||
dest.writeList(tags);
|
||||
dest.writeFloat(lat);
|
||||
dest.writeFloat(lon);
|
||||
dest.writeString(id);
|
||||
dest.writeString(address);
|
||||
dest.writeString(title);
|
||||
dest.writeString(body);
|
||||
dest.writeString(timestamp);
|
||||
dest.writeString(avatar);
|
||||
dest.writeString(ownerId);
|
||||
dest.writeByte((byte) (isPublic ? 1 : 0));
|
||||
public Note[] newArray(int size) {
|
||||
return new Note[size];
|
||||
}
|
||||
};
|
||||
|
||||
public String getTime() {
|
||||
Date d = new Date(timestamp);
|
||||
DateFormat format = new SimpleDateFormat("HH:mm");
|
||||
return format.format(d);
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
Date d = new Date(timestamp);
|
||||
DateFormat format = new SimpleDateFormat("dd MMM yyy");
|
||||
return format.format(d);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Note{" +
|
||||
"id=" + id +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
|
||||
", address='" + address + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", body='" + body + '\'' +
|
||||
", timestamp=" + timestamp +
|
||||
", isPublic=" + isPublic +
|
||||
", avatar=" + avatar +
|
||||
", ownerId=" + ownerId +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public float getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(float lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public float getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(float lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public void setPublic(boolean aPublic) {
|
||||
isPublic = aPublic;
|
||||
}
|
||||
|
||||
public String getLocationAndTime() {
|
||||
return getTimestamp() + " at " + getAddress();
|
||||
}
|
||||
|
||||
public int getLikes() {
|
||||
return likes;
|
||||
}
|
||||
|
||||
public void setLikes(int likes) {
|
||||
this.likes = likes;
|
||||
}
|
||||
|
||||
public ArrayList<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(ArrayList<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public void setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
}
|
||||
|
||||
public String getOwnerId() {
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
public void setOwnerId(String ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(likes);
|
||||
dest.writeList(tags);
|
||||
dest.writeFloat(lat);
|
||||
dest.writeFloat(lon);
|
||||
dest.writeString(id);
|
||||
dest.writeString(address);
|
||||
dest.writeString(title);
|
||||
dest.writeString(body);
|
||||
dest.writeString(timestamp);
|
||||
dest.writeString(avatar);
|
||||
dest.writeString(ownerId);
|
||||
dest.writeByte((byte) (isPublic ? 1 : 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Simplified Readable Time (Creation of the note)
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getTime() {
|
||||
Date d = new Date(timestamp);
|
||||
DateFormat format = new SimpleDateFormat("HH:mm");
|
||||
return format.format(d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Simplified Readable Date (Creation of the note)
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getDate() {
|
||||
Date d = new Date(timestamp);
|
||||
DateFormat format = new SimpleDateFormat("dd MMM yyy");
|
||||
return format.format(d);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue