Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/java/charlyn23/c4q/nyc/projectx/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ public class Constants {
public static final String SHAME_DOING_COLUMN = "shameDoing";
public static final String VERBAL_SHAME_COLUMN = "verbalShame";
public static final String PHYSICAL_SHAME_COLUMN = "physicalShame";
public static final String POLICE_SHAME_COLUMN = "policeShame";
public static final String OTHER_SHAME_COLUMN = "otherShame";
public static final String SHAME_TIME_COLUMN = "shameTime";
public static final String SHAME_LATITUDE_COLUMN = "latitude";
public static final String SHAME_LONGITUDE_COLUMN = "longitude";
public static final String SHAME_ZIPCODE_COLUMN = "zipCode";
public static final String VERBAL = "Catcall";
public static final String PHYSICAL = "Physical";
public static final String POLICE = "Police Encounter";
public static final String OTHER = "Other";
public static final String WOMAN = "Woman";
public static final String WOMEN = "Women";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.support.design.widget.TabLayout;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
Expand All @@ -26,13 +23,9 @@
import android.widget.Toast;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.Scopes;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.Scope;
import com.google.android.gms.plus.Plus;

import java.util.List;

import charlyn23.c4q.nyc.projectx.map.NoSwipeViewPager;
import charlyn23.c4q.nyc.projectx.map.PagerAdapter;
import charlyn23.c4q.nyc.projectx.map.ProjectXMapFragment;
Expand Down Expand Up @@ -73,7 +66,7 @@ protected synchronized void buildGoogleApiClient(Context context) {
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(new Scope(Scopes.EMAIL))
// .addScope(new Scope(Scopes.EMAIL))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public static abstract class DataEntry implements BaseColumns {
public static final String COLUMN_SHAME_TYPE = "shameType";
public static final String COLUMN_VERBAL_SHAME = "verbalShame";
public static final String COLUMN_PHYSICAL_SHAME = "physicalShame";
public static final String COLUMN_POLICE_SHAME = "policeShame";
public static final String COLUMN_OTHER_SHAME = "otherShame";
public static final String COLUMN_GROUP = "groupEffected";
public static final String COLUMN_SHAME_DOING = "shameDoing";
Expand All @@ -69,6 +70,7 @@ public static abstract class DataEntry implements BaseColumns {
DataEntry.COLUMN_SHAME_TYPE + " TEXT," +
DataEntry.COLUMN_VERBAL_SHAME + " TEXT," +
DataEntry.COLUMN_PHYSICAL_SHAME + " TEXT," +
DataEntry.COLUMN_POLICE_SHAME + " TEXT, " +
DataEntry.COLUMN_OTHER_SHAME + " TEXT," +
DataEntry.COLUMN_SHAME_DOING + " TEXT," +
DataEntry.COLUMN_SHAME_FEEL + " TEXT," +
Expand All @@ -92,6 +94,7 @@ public void insertRow(Shame incident) {
values.put(DataEntry.COLUMN_SHAME_TYPE, incident.getString(Constants.SHAME_TYPE_COLUMN));
values.put(DataEntry.COLUMN_VERBAL_SHAME, incident.getString(Constants.VERBAL_SHAME_COLUMN));
values.put(DataEntry.COLUMN_PHYSICAL_SHAME, incident.getString(Constants.PHYSICAL_SHAME_COLUMN));
values.put(DataEntry.COLUMN_POLICE_SHAME, incident.getString(Constants.POLICE_SHAME_COLUMN));
values.put(DataEntry.COLUMN_OTHER_SHAME, incident.getString(Constants.OTHER_SHAME_COLUMN));
values.put(DataEntry.COLUMN_SHAME_DOING, incident.getString(Constants.SHAME_DOING_COLUMN));
values.put(DataEntry.COLUMN_SHAME_FEEL, incident.getString(Constants.SHAME_FEEL_COLUMN));
Expand All @@ -110,6 +113,7 @@ public List<Shame> loadData(String[] time) {
DataEntry.COLUMN_SHAME_TYPE,
DataEntry.COLUMN_VERBAL_SHAME,
DataEntry.COLUMN_PHYSICAL_SHAME,
DataEntry.COLUMN_POLICE_SHAME,
DataEntry.COLUMN_OTHER_SHAME,
DataEntry.COLUMN_SHAME_DOING,
DataEntry.COLUMN_SHAME_FEEL,
Expand All @@ -131,6 +135,7 @@ public List<Shame> loadData(String[] time) {
cursor.getString(cursor.getColumnIndex(DataEntry.COLUMN_SHAME_TYPE)),
cursor.getString(cursor.getColumnIndex(DataEntry.COLUMN_VERBAL_SHAME)),
cursor.getString(cursor.getColumnIndex(DataEntry.COLUMN_PHYSICAL_SHAME)),
cursor.getString(cursor.getColumnIndex(DataEntry.COLUMN_POLICE_SHAME)),
cursor.getString(cursor.getColumnIndex(DataEntry.COLUMN_OTHER_SHAME)),
cursor.getString(cursor.getColumnIndex(DataEntry.COLUMN_SHAME_FEEL)),
cursor.getString(cursor.getColumnIndex(DataEntry.COLUMN_SHAME_DOING)),
Expand All @@ -148,9 +153,10 @@ public int[] countTypes (String zipCode) {
Cursor cursor = null;
int numCatcall = 0;
int numPhysical = 0;
int numPolice = 0;
int numOther = 0;
SQLiteDatabase db = getWritableDatabase();
int[] types = new int[3];
int[] types = new int[4];

String[] projection = {
DataEntry.COLUMN_SHAME_TYPE,
Expand All @@ -161,6 +167,8 @@ public int[] countTypes (String zipCode) {
numCatcall = cursor.getCount();
cursor = db.query(DataEntry.TABLE_NAME, projection, DataEntry.COLUMN_SHAME_TYPE + " = ?", new String[]{Constants.PHYSICAL}, null, null, null);
numPhysical = cursor.getCount();
cursor = db.query(DataEntry.TABLE_NAME, projection, DataEntry.COLUMN_SHAME_TYPE + " = ?", new String[]{Constants.POLICE}, null, null, null);
numPolice = cursor.getCount();
cursor = db.query(DataEntry.TABLE_NAME, projection, DataEntry.COLUMN_SHAME_TYPE + " = ?", new String[]{Constants.OTHER}, null, null, null);
numOther = cursor.getCount();

Expand All @@ -171,13 +179,16 @@ else if (zipCode.length() > 0){
numCatcall = cursor.getCount();
cursor = db.query(DataEntry.TABLE_NAME, projection, DataEntry.COLUMN_ZIPCODE + " = ? and " + DataEntry.COLUMN_SHAME_TYPE + " = ?", new String[]{zipCode, Constants.PHYSICAL}, null, null, null);
numPhysical = cursor.getCount();
cursor = db.query(DataEntry.TABLE_NAME, projection, DataEntry.COLUMN_ZIPCODE + " = ? and " + DataEntry.COLUMN_SHAME_TYPE + " = ?", new String[]{zipCode, Constants.POLICE}, null, null, null);
numPolice = cursor.getCount();
cursor = db.query(DataEntry.TABLE_NAME, projection, DataEntry.COLUMN_ZIPCODE + " = ? and " + DataEntry.COLUMN_SHAME_TYPE + " = ?", new String[]{zipCode, Constants.OTHER}, null, null, null);
numOther = cursor.getCount();
}
cursor.close();
types[0] = numCatcall;
types[1] = numPhysical;
types[2] = numOther;
types[3] = numPolice;
return types;
}

Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/charlyn23/c4q/nyc/projectx/shames/Shame.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Shame extends ParseObject {
private String shameType;
private String verbalShame;
private String physicalShame;
private String policeShame;
private String otherShame;
private String shameFeel;
private String shameDoing;
Expand All @@ -20,13 +21,14 @@ public class Shame extends ParseObject {
private String zipcode;

public Shame(double latitude, double longitude, String shameType, String verbalShame,
String physicalShame, String otherShame, String shameFeel, String shameDoing,
String physicalShame, String otherShame, String policeShame, String shameFeel, String shameDoing,
String shameTime, String group, String zipcode){
this.latitude = latitude;
this.longitude = longitude;
this.shameType = shameType;
this.verbalShame = verbalShame;
this.physicalShame = physicalShame;
this.policeShame = policeShame;
this.otherShame = otherShame;
this.shameFeel = shameFeel;
this.shameDoing = shameDoing;
Expand Down Expand Up @@ -79,6 +81,14 @@ public void setOtherShame(String otherShame) {
this.otherShame = otherShame;
}

public String getPoliceShame() {
return policeShame;
}

public void setPoliceShame(String policeShame) {
this.policeShame = policeShame;
}

public String getPhysicalShame() {
return physicalShame;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import android.location.Location;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.support.design.widget.FloatingActionButton;
import android.util.Log;
import android.view.Gravity;
Expand Down Expand Up @@ -42,6 +41,7 @@ public class ShameDialogs {
private String shameType;
private String verbalShame;
private String physicalShame;
private String policeShame;
private String otherShame;
private String shameFeel;
private String shameDoing;
Expand Down Expand Up @@ -114,10 +114,15 @@ public void shameTypeDialog(final Context context) {
content = R.string.physical_shame;
items = R.array.physical_types;
break;
case Constants.POLICE:
content = R.string.police_shame;
items = R.array.police_types;
break;
case Constants.OTHER:
content = R.string.other_shame;
items = R.array.other_types;
break;

}

new MaterialDialog.Builder(context)
Expand All @@ -136,6 +141,9 @@ public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequ
case Constants.PHYSICAL:
physicalShame = type_choice.toString();
break;
case Constants.POLICE:
policeShame = type_choice.toString();
break;
case Constants.OTHER:
otherShame = type_choice.toString();
break;
Expand Down Expand Up @@ -430,6 +438,9 @@ public void saveShame() {
case Constants.PHYSICAL:
newShame.put(Constants.PHYSICAL_SHAME_COLUMN, physicalShame);
break;
case Constants.POLICE:
newShame.put(Constants.POLICE_SHAME_COLUMN, policeShame);
break;
case Constants.OTHER:
newShame.put(Constants.OTHER_SHAME_COLUMN, otherShame);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,34 @@

import android.graphics.Color;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.github.mikephil.charting.animation.AnimationEasing;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.data.BarEntry;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.google.android.gms.maps.model.LatLng;
import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;

import net.steamcrafted.materialiconlib.MaterialIconView;

import java.util.ArrayList;
import java.util.List;

import charlyn23.c4q.nyc.projectx.Constants;
import charlyn23.c4q.nyc.projectx.MainActivity;
import charlyn23.c4q.nyc.projectx.R;
import charlyn23.c4q.nyc.projectx.map.ShameSQLiteHelper;
import charlyn23.c4q.nyc.projectx.shames.Shame;

public class PieChartFragment extends Fragment {
public PieChart pieChart;
private int numVerbalShame;
private int numPhysicalShame;
private int numPoliceShame;
private int numOtherShame;
private Typeface questrial;
private TextView numInstances;
Expand Down Expand Up @@ -91,10 +77,11 @@ protected void onPostExecute(int[] countTypes) {
numVerbalShame = countTypes[0];
numPhysicalShame = countTypes[1];
numOtherShame = countTypes[2];
Data data = setBars(numVerbalShame, numPhysicalShame, numOtherShame);
numPoliceShame = countTypes[3];
Data data = setBars(numVerbalShame, numPhysicalShame, numPoliceShame, numOtherShame);
setDataPieChart(data.getyValues(), data.getxValues());
//no harassment instances reported in the area
if (numVerbalShame == 0 && numPhysicalShame == 0 && numOtherShame == 0) {
if (numVerbalShame == 0 && numPhysicalShame == 0 && numPoliceShame == 0 && numOtherShame == 0) {
pieChart.setVisibility(View.GONE);
header.setVisibility(View.GONE);
numInstances.setVisibility(View.GONE);
Expand All @@ -107,7 +94,7 @@ protected void onPostExecute(int[] countTypes) {
noHarassmentMessage.setVisibility(View.GONE);
numInstances.setVisibility(View.VISIBLE);
header.setVisibility(View.VISIBLE);
int totalInstances = numVerbalShame + numPhysicalShame + numOtherShame;
int totalInstances = numVerbalShame + numPhysicalShame + numPoliceShame + numOtherShame;
numInstances.setText(getString(R.string.total_instances) + " " + totalInstances);
}

Expand Down Expand Up @@ -148,18 +135,19 @@ private void setDataPieChart(ArrayList<Entry> yVals, ArrayList<String> xVals) {
}

public void animateChart() {
pieChart.animateY(2000);
pieChart.animateY(1500);
}

//sets up the number of bars in the chart
private Data setBars(int numVerbalShame, int numPhysicalShame, int numOtherShame) {
private Data setBars(int numVerbalShame, int numPhysicalShame,int numPoliceShame, int numOtherShame) {
int count = 0;
ArrayList<Bar> bars = new ArrayList<>();
ArrayList<Entry> yVals = new ArrayList<Entry>();
ArrayList<String> xVals = new ArrayList<String>();

bars.add(new Bar(Constants.VERBAL, numVerbalShame));
bars.add(new Bar(Constants.PHYSICAL, numPhysicalShame));
bars.add(new Bar("Police", numPoliceShame));
bars.add(new Bar(Constants.OTHER, numOtherShame));

for (int i = 0; i < bars.size(); i++) {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<string name="back">Back</string>
<string name="verbal_shame">What did they say?</string>
<string name="physical_shame">What did they do?</string>
<string name="police_shame">What did they do?</string>
<string name="other_shame">What did they do?</string>
<string name="shame_feel">How did you feel?</string>
<string name="submit">Submit Shame</string>
Expand All @@ -29,6 +30,7 @@
<array name="shame_types">
<item>Catcall</item>
<item>Physical</item>
<item>Police Encounter</item>
<item>Other</item>
</array>

Expand All @@ -48,6 +50,13 @@
<item>Sexually assaulted me</item>
</array>

<array name="police_types">
<item>Intimidation</item>
<item>False arrest</item>
<item>Racial profiling</item>
<item>Sexual abuse</item>
</array>

<array name="other_types">
<item>Followed me</item>
<item>Exposed themself</item>
Expand Down