diff --git a/app/src/main/java/charlyn23/c4q/nyc/projectx/Constants.java b/app/src/main/java/charlyn23/c4q/nyc/projectx/Constants.java index a78cb5e..9b19f8e 100644 --- a/app/src/main/java/charlyn23/c4q/nyc/projectx/Constants.java +++ b/app/src/main/java/charlyn23/c4q/nyc/projectx/Constants.java @@ -48,6 +48,7 @@ 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"; @@ -55,6 +56,7 @@ public class Constants { 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"; diff --git a/app/src/main/java/charlyn23/c4q/nyc/projectx/MainActivity.java b/app/src/main/java/charlyn23/c4q/nyc/projectx/MainActivity.java index b6cce42..11fb4ff 100644 --- a/app/src/main/java/charlyn23/c4q/nyc/projectx/MainActivity.java +++ b/app/src/main/java/charlyn23/c4q/nyc/projectx/MainActivity.java @@ -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; @@ -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; @@ -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(); } diff --git a/app/src/main/java/charlyn23/c4q/nyc/projectx/map/ShameSQLiteHelper.java b/app/src/main/java/charlyn23/c4q/nyc/projectx/map/ShameSQLiteHelper.java index 3345b1b..9424cab 100644 --- a/app/src/main/java/charlyn23/c4q/nyc/projectx/map/ShameSQLiteHelper.java +++ b/app/src/main/java/charlyn23/c4q/nyc/projectx/map/ShameSQLiteHelper.java @@ -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"; @@ -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," + @@ -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)); @@ -110,6 +113,7 @@ public List 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, @@ -131,6 +135,7 @@ public List 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)), @@ -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, @@ -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(); @@ -171,6 +179,8 @@ 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(); } @@ -178,6 +188,7 @@ else if (zipCode.length() > 0){ types[0] = numCatcall; types[1] = numPhysical; types[2] = numOther; + types[3] = numPolice; return types; } diff --git a/app/src/main/java/charlyn23/c4q/nyc/projectx/shames/Shame.java b/app/src/main/java/charlyn23/c4q/nyc/projectx/shames/Shame.java index e6ffd85..d05a281 100644 --- a/app/src/main/java/charlyn23/c4q/nyc/projectx/shames/Shame.java +++ b/app/src/main/java/charlyn23/c4q/nyc/projectx/shames/Shame.java @@ -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; @@ -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; @@ -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; } diff --git a/app/src/main/java/charlyn23/c4q/nyc/projectx/shames/ShameDialogs.java b/app/src/main/java/charlyn23/c4q/nyc/projectx/shames/ShameDialogs.java index 26aba88..5251192 100644 --- a/app/src/main/java/charlyn23/c4q/nyc/projectx/shames/ShameDialogs.java +++ b/app/src/main/java/charlyn23/c4q/nyc/projectx/shames/ShameDialogs.java @@ -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; @@ -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; @@ -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) @@ -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; @@ -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; diff --git a/app/src/main/java/charlyn23/c4q/nyc/projectx/stats/PieChartFragment.java b/app/src/main/java/charlyn23/c4q/nyc/projectx/stats/PieChartFragment.java index 846f4c3..0f07911 100644 --- a/app/src/main/java/charlyn23/c4q/nyc/projectx/stats/PieChartFragment.java +++ b/app/src/main/java/charlyn23/c4q/nyc/projectx/stats/PieChartFragment.java @@ -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; @@ -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); @@ -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); } @@ -148,11 +135,11 @@ private void setDataPieChart(ArrayList yVals, ArrayList 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 bars = new ArrayList<>(); ArrayList yVals = new ArrayList(); @@ -160,6 +147,7 @@ private Data setBars(int numVerbalShame, int numPhysicalShame, int numOtherShame 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++) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d5be87e..ea63108 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,6 +15,7 @@ Back What did they say? What did they do? + What did they do? What did they do? How did you feel? Submit Shame @@ -29,6 +30,7 @@ Catcall Physical + Police Encounter Other @@ -48,6 +50,13 @@ Sexually assaulted me + + Intimidation + False arrest + Racial profiling + Sexual abuse + + Followed me Exposed themself