@DT: Changes over Christmas: Maps Performance improved, Report-WF changed, a lot of minor changes
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
package org.deke.risk.riskahead;
|
package org.deke.risk.riskahead;
|
||||||
|
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
import android.support.v4.app.TaskStackBuilder;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -15,7 +19,6 @@ import com.android.volley.Request;
|
|||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
import com.beardedhen.androidbootstrap.font.FontAwesome;
|
|
||||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||||
import com.mikepenz.iconics.IconicsDrawable;
|
import com.mikepenz.iconics.IconicsDrawable;
|
||||||
|
|
||||||
@@ -23,9 +26,13 @@ import org.deke.risk.riskahead.helper.AppConfig;
|
|||||||
import org.deke.risk.riskahead.helper.AppController;
|
import org.deke.risk.riskahead.helper.AppController;
|
||||||
import org.deke.risk.riskahead.helper.BaseActivity;
|
import org.deke.risk.riskahead.helper.BaseActivity;
|
||||||
import org.deke.risk.riskahead.helper.SessionManager;
|
import org.deke.risk.riskahead.helper.SessionManager;
|
||||||
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -87,10 +94,133 @@ public class MainActivity extends BaseActivity{
|
|||||||
|
|
||||||
map.setCompoundDrawables(null,null, mapIcon, null);
|
map.setCompoundDrawables(null,null, mapIcon, null);
|
||||||
|
|
||||||
|
startNotifyTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Runnable mNotifyTask = new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Log.d(this.toString(),"Run Notification Task");
|
||||||
|
|
||||||
|
myPosition = session.getLocation();
|
||||||
|
if(myPosition != null){
|
||||||
|
|
||||||
|
String lastNotificationTime = "";
|
||||||
|
|
||||||
|
if(session.getLastNotification().equals("")){
|
||||||
|
lastNotificationTime = getUser().get(SessionManager.KEY_LASTLOGIN_AT);
|
||||||
|
}else{
|
||||||
|
lastNotificationTime = session.getLastNotification();
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.d(this.toString(),"Lookup location with position: "+myPosition+" Radius: 15 lastNotifyTime: "+lastNotificationTime);
|
||||||
|
StringRequest strReq = getStringRequestIncidentsFromAreaAndTime(myPosition.latitude, myPosition.longitude, 15, lastNotificationTime);
|
||||||
|
String tag_string_req = "req_incidents";
|
||||||
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
|
}
|
||||||
|
|
||||||
|
mNotifyHandler.postDelayed(mNotifyTask, INTERVAL_NOTIFICATION);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void startNotifyTask()
|
||||||
|
{
|
||||||
|
mNotifyTask.run();
|
||||||
|
Log.d("BaseActivity","Start NotfiyTask");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopNotifyTask()
|
||||||
|
{
|
||||||
|
mNotifyHandler.removeCallbacks(mNotifyTask);
|
||||||
|
Log.d("BaseActivity", "Stop NotfiyTask");
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringRequest getStringRequestIncidentsFromAreaAndTime(final Double latitude, final Double longitude, final int radius, final String time) {
|
||||||
|
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
Log.d(TAG, "Incident notifications: " + response);
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jObj = new JSONObject(response);
|
||||||
|
boolean error = jObj.getBoolean("error");
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
JSONArray notification = jObj.getJSONArray("msg");
|
||||||
|
|
||||||
|
sentNotification(notification);
|
||||||
|
} else {
|
||||||
|
String errorMsg = jObj.getString("error_msg");
|
||||||
|
Log.e(TAG, "Error getting incident notification (server returned error): " + errorMsg);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
Log.e(TAG, "Error getting incident notification: " + error.getMessage());
|
||||||
|
showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||||
|
stopNotifyTask();
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("tag", "getincidentsinareaandtime");
|
||||||
|
params.put("uid", user.get(SessionManager.KEY_UID));
|
||||||
|
params.put("token", user.get(SessionManager.TOKEN));
|
||||||
|
params.put("latitude", Double.toString(latitude));
|
||||||
|
params.put("longitude", Double.toString(longitude));
|
||||||
|
params.put("radius", Integer.toString(radius));
|
||||||
|
params.put("time", "'"+time+"'");
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sentNotification(JSONArray notification) {
|
||||||
|
NotificationCompat.Builder mBuilder =
|
||||||
|
new NotificationCompat.Builder(getApplicationContext())
|
||||||
|
.setSmallIcon(R.drawable.logo_riskahead_header)
|
||||||
|
.setContentTitle("New incidents reported in your area!")
|
||||||
|
.setContentText(notification.length() + " new incidents near your last location. Watch out!");
|
||||||
|
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
|
||||||
|
Intent resultIntent = new Intent(this, MapsActivity.class);
|
||||||
|
try {
|
||||||
|
resultIntent.putExtra(EXTRA_MESSAGE, notification.getJSONObject(notification.length()-1).getDouble("latitude")+":"+notification.getJSONObject(notification.length()-1).getDouble("longitude"));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
|
||||||
|
stackBuilder.addParentStack(MapsActivity.class);
|
||||||
|
|
||||||
|
stackBuilder.addNextIntent(resultIntent);
|
||||||
|
PendingIntent resultPendingIntent =
|
||||||
|
stackBuilder.getPendingIntent(
|
||||||
|
0,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
);
|
||||||
|
mBuilder.setContentIntent(resultPendingIntent);
|
||||||
|
|
||||||
|
int mId = 1;
|
||||||
|
mNotificationManager.notify(mId, mBuilder.build());
|
||||||
|
|
||||||
|
session.setLastNotification(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
@@ -108,13 +238,20 @@ public class MainActivity extends BaseActivity{
|
|||||||
stopRepeatingTask();
|
stopRepeatingTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy(){
|
||||||
|
super.onDestroy();
|
||||||
|
stopNotifyTask();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume(){
|
protected void onResume(){
|
||||||
super.onResume();
|
super.onResume();
|
||||||
result.setSelection(mainAvtivityID,false);
|
navDrawer.setSelection(mainAvtivityID,false);
|
||||||
startRepeatingTask();
|
startRepeatingTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Runnable mHandlerTask = new Runnable()
|
Runnable mHandlerTask = new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -149,12 +286,12 @@ public class MainActivity extends BaseActivity{
|
|||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
JSONObject jCount = jObj.getJSONObject("msg");
|
JSONObject jCount = jObj.getJSONObject("msg");
|
||||||
|
DecimalFormat nf = new DecimalFormat();
|
||||||
count.setText(jCount.getString("total"));
|
String decimalNumber = nf.format(jCount.getInt("total"));
|
||||||
|
count.setText(decimalNumber);
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error getting incident count (server returned error): " + errorMsg);
|
Log.e(TAG, "Error getting incident count (server returned error): " + errorMsg);
|
||||||
showMessage(errorMsg);
|
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.google.android.gms.maps.model.TileOverlayOptions;
|
|||||||
import com.google.maps.android.clustering.Cluster;
|
import com.google.maps.android.clustering.Cluster;
|
||||||
import com.google.maps.android.clustering.ClusterManager;
|
import com.google.maps.android.clustering.ClusterManager;
|
||||||
import com.google.maps.android.heatmaps.HeatmapTileProvider;
|
import com.google.maps.android.heatmaps.HeatmapTileProvider;
|
||||||
|
import com.google.maps.android.heatmaps.WeightedLatLng;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.helper.IncidentReport;
|
import org.deke.risk.riskahead.helper.IncidentReport;
|
||||||
import org.deke.risk.riskahead.helper.AppConfig;
|
import org.deke.risk.riskahead.helper.AppConfig;
|
||||||
@@ -51,7 +52,6 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@@ -60,21 +60,17 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
|
|
||||||
private final static String mActivityTitle = "Risk Map";
|
private final static String mActivityTitle = "Risk Map";
|
||||||
private static final String TAG = MapsActivity.class.getSimpleName();
|
private static final String TAG = MapsActivity.class.getSimpleName();
|
||||||
|
private static final Double PRELOAD_PERCENTAGE = 0.3;
|
||||||
|
|
||||||
private static GoogleMap mMap;
|
private static GoogleMap mMap;
|
||||||
private Marker mMarker;
|
private Marker mMarker;
|
||||||
|
private Marker markerShowingInfoWindow;
|
||||||
|
|
||||||
private IncidentReport clickedClusterItem;
|
private IncidentReport clickedClusterItem;
|
||||||
private ArrayList<IncidentReport> myMarkers = new ArrayList<IncidentReport>();
|
|
||||||
private HashMap<Integer, IncidentReport> visibleMarkers = new HashMap<Integer, IncidentReport>();
|
|
||||||
private List<LatLng> mHeatMapPositionList = new ArrayList<>();
|
|
||||||
|
|
||||||
private ClusterManager<IncidentReport> mClusterManager;
|
private ClusterManager<IncidentReport> mClusterManager;
|
||||||
|
|
||||||
TileOverlay mOverlay;
|
private TileOverlay mOverlay;
|
||||||
HeatmapTileProvider mProvider;
|
private HeatmapTileProvider mProvider;
|
||||||
|
|
||||||
private boolean isMarkerShown = false;
|
|
||||||
|
|
||||||
private LatLng myLocation;
|
private LatLng myLocation;
|
||||||
private LatLng markedLocation;
|
private LatLng markedLocation;
|
||||||
@@ -82,19 +78,35 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
private static final int DEFAULT_ZOOM_LEVEL = 14;
|
private static final int DEFAULT_ZOOM_LEVEL = 14;
|
||||||
private static final int THRESHOLD_ZOOM_LEVEL = 7;
|
private static final int THRESHOLD_ZOOM_LEVEL = 7;
|
||||||
|
|
||||||
|
private static final int MIN_ZOOM_LEVEL = 5;
|
||||||
|
|
||||||
|
private LatLng curNortheastBounds;
|
||||||
|
private LatLng curSouthwestBounds;
|
||||||
|
|
||||||
|
|
||||||
|
private boolean markersShown = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
userHasToBeLoggedIn();
|
userHasToBeLoggedIn();
|
||||||
|
|
||||||
|
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.GONE);
|
||||||
|
navDrawer.setSelection(mapAvtivityID, false);
|
||||||
|
|
||||||
|
initMap();
|
||||||
|
handleIntent(getIntent());
|
||||||
|
initClustering();
|
||||||
|
|
||||||
|
findViewById(R.id.fab_reportwf_map).setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initMap() {
|
||||||
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.frag_maps_map)).getMap();
|
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.frag_maps_map)).getMap();
|
||||||
mMap.getUiSettings().setZoomControlsEnabled(true);
|
mMap.getUiSettings().setZoomControlsEnabled(true);
|
||||||
mMap.setMyLocationEnabled(true);
|
mMap.setMyLocationEnabled(true);
|
||||||
|
|
||||||
handleIntent(getIntent());
|
|
||||||
|
|
||||||
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.GONE);
|
|
||||||
|
|
||||||
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
|
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMapClick(LatLng point) {
|
public void onMapClick(LatLng point) {
|
||||||
@@ -104,9 +116,9 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
markedLocation = point;
|
markedLocation = point;
|
||||||
mMarker = mMap.addMarker(new MarkerOptions().position(point));
|
mMarker = mMap.addMarker(new MarkerOptions().position(point));
|
||||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_ZOOM_LEVEL));
|
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_ZOOM_LEVEL));
|
||||||
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.VISIBLE);
|
findViewById(R.id.fab_reportwf_map).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
findViewById(R.id.btn_maps_confirm_position).setOnClickListener(new View.OnClickListener() {
|
findViewById(R.id.fab_reportwf_map).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
gotoReportActivity(markedLocation.latitude + ":" + markedLocation.longitude);
|
gotoReportActivity(markedLocation.latitude + ":" + markedLocation.longitude);
|
||||||
@@ -114,94 +126,261 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setUpClustering();
|
|
||||||
result.setSelection(mapAvtivityID,false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GoogleMap.OnCameraChangeListener getCameraChangeListener()
|
public GoogleMap.OnCameraChangeListener getCameraChangeListener() {
|
||||||
{
|
|
||||||
return new GoogleMap.OnCameraChangeListener()
|
return new GoogleMap.OnCameraChangeListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onCameraChange(CameraPosition position)
|
public void onCameraChange(CameraPosition position)
|
||||||
{
|
{
|
||||||
mClusterManager.onCameraChange(position);
|
mClusterManager.onCameraChange(position);
|
||||||
Log.d("Zoom", "Zoom: " + position.zoom);
|
|
||||||
|
|
||||||
if(position.zoom >= THRESHOLD_ZOOM_LEVEL)
|
if(position.zoom < MIN_ZOOM_LEVEL) {
|
||||||
{
|
mMap.animateCamera(CameraUpdateFactory.zoomTo(MIN_ZOOM_LEVEL));
|
||||||
isMarkerShown = true;
|
return;
|
||||||
} else if (position.zoom < THRESHOLD_ZOOM_LEVEL && (isMarkerShown == true)){
|
|
||||||
mClusterManager.clearItems();
|
|
||||||
visibleMarkers.clear();
|
|
||||||
isMarkerShown = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addMarkersToMap();
|
LatLngBounds bounds = mMap.getProjection().getVisibleRegion().latLngBounds;
|
||||||
|
|
||||||
|
Log.d("OnCameraChangeListener", "Position: "+bounds.getCenter()+" Zoom: "+position.zoom + " Bounds: NE:" + bounds.northeast + " SW: " + bounds.southwest);
|
||||||
|
Log.d("OnCameraChangeListener", "Saved Position - Bounds: NE:" + curNortheastBounds + " SW: " + curSouthwestBounds);
|
||||||
|
|
||||||
|
boolean isOutOfBounds = false;
|
||||||
|
|
||||||
|
double distanceLat = Math.abs(bounds.northeast.latitude - bounds.southwest.latitude);
|
||||||
|
double distanceLon = Math.abs(bounds.northeast.longitude - bounds.southwest.longitude);
|
||||||
|
|
||||||
|
double southwestLat, southwestLng;
|
||||||
|
double northeastLat, northeastLng;
|
||||||
|
|
||||||
|
if(bounds.southwest.latitude < bounds.northeast.latitude){
|
||||||
|
southwestLat = bounds.southwest.latitude - distanceLat * PRELOAD_PERCENTAGE;
|
||||||
|
northeastLat = bounds.northeast.latitude + distanceLat * PRELOAD_PERCENTAGE;
|
||||||
|
|
||||||
|
if((curSouthwestBounds != null) && ((bounds.southwest.latitude < curSouthwestBounds.latitude) || (bounds.northeast.latitude > curNortheastBounds.latitude))){
|
||||||
|
isOutOfBounds = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
southwestLat = bounds.southwest.latitude + distanceLat * PRELOAD_PERCENTAGE;
|
||||||
|
northeastLat = bounds.northeast.latitude - distanceLat * PRELOAD_PERCENTAGE;
|
||||||
|
|
||||||
|
if((curSouthwestBounds != null) && ((bounds.southwest.latitude > curSouthwestBounds.latitude) || (bounds.northeast.latitude < curNortheastBounds.latitude))){
|
||||||
|
isOutOfBounds = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bounds.southwest.longitude < bounds.northeast.longitude){
|
||||||
|
southwestLng = bounds.southwest.longitude - distanceLon * PRELOAD_PERCENTAGE;
|
||||||
|
northeastLng = bounds.northeast.longitude + distanceLon * PRELOAD_PERCENTAGE;
|
||||||
|
|
||||||
|
if((curSouthwestBounds != null) && ((bounds.southwest.longitude < curSouthwestBounds.longitude) || (bounds.northeast.longitude > curNortheastBounds.longitude))){
|
||||||
|
isOutOfBounds = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
southwestLng = bounds.southwest.longitude + distanceLon * PRELOAD_PERCENTAGE;
|
||||||
|
northeastLng = bounds.northeast.longitude - distanceLon * PRELOAD_PERCENTAGE;
|
||||||
|
|
||||||
|
if((curSouthwestBounds != null) && ((bounds.southwest.longitude > curSouthwestBounds.longitude) || (bounds.northeast.longitude < curNortheastBounds.longitude))){
|
||||||
|
isOutOfBounds = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((curSouthwestBounds == null) || isOutOfBounds) {
|
||||||
|
curNortheastBounds = new LatLng(northeastLat, northeastLng);
|
||||||
|
curSouthwestBounds = new LatLng(southwestLat, southwestLng);
|
||||||
|
|
||||||
|
Log.d("OnCameraChangeListener", "isOutOfBounds is true => New Calculated - Bounds: NE:" + curNortheastBounds + " SW: " + curSouthwestBounds);
|
||||||
|
|
||||||
|
if (position.zoom >= THRESHOLD_ZOOM_LEVEL) {
|
||||||
|
refreshIncidentHeatMap(curNortheastBounds, curSouthwestBounds);
|
||||||
|
refreshIncidentMarkers(curNortheastBounds, curSouthwestBounds);
|
||||||
|
markersShown = true;
|
||||||
|
} else if (position.zoom < THRESHOLD_ZOOM_LEVEL) {
|
||||||
|
mClusterManager.clearItems();
|
||||||
|
refreshIncidentHeatMap(curNortheastBounds, curSouthwestBounds);
|
||||||
|
markersShown = false;
|
||||||
|
}
|
||||||
|
} else if((isOutOfBounds == false) && ((position.zoom >= THRESHOLD_ZOOM_LEVEL) && (markersShown == false))){
|
||||||
|
curNortheastBounds = new LatLng(northeastLat, northeastLng);
|
||||||
|
curSouthwestBounds = new LatLng(southwestLat, southwestLng);
|
||||||
|
|
||||||
|
Log.d("OnCameraChangeListener", "zoom threshold passed => New Calculated - Bounds: NE:" + curNortheastBounds + " SW: " + curSouthwestBounds);
|
||||||
|
|
||||||
|
refreshIncidentHeatMap(curNortheastBounds, curSouthwestBounds);
|
||||||
|
refreshIncidentMarkers(curNortheastBounds, curSouthwestBounds);
|
||||||
|
markersShown = true;
|
||||||
|
} else if((isOutOfBounds == false) && ((position.zoom < THRESHOLD_ZOOM_LEVEL) && (markersShown == true))){
|
||||||
|
mClusterManager.clearItems();
|
||||||
|
markersShown = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMarkersToMap(){
|
private void refreshIncidentMarkers(LatLng northeast, LatLng southwest){
|
||||||
LatLngBounds bounds = mMap.getProjection().getVisibleRegion().latLngBounds;
|
String tag_string_req = "getincidentsfrombound";
|
||||||
mHeatMapPositionList.clear();
|
StringRequest strReq = getStringRequestGetAllIncidentsFromBound(northeast,southwest);
|
||||||
Log.d("Zoom", "Bounds: NE:" + bounds.northeast +" SW: " + bounds.southwest);
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addIncidentMarkersOnMap(JSONArray incidents){
|
||||||
|
mClusterManager.clearItems();
|
||||||
|
|
||||||
|
for(int i = 0; i < incidents.length();i++){
|
||||||
|
try {
|
||||||
|
mClusterManager.addItem(new IncidentReport(incidents.getJSONObject(i)));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(IncidentReport item : myMarkers)
|
|
||||||
{
|
|
||||||
if(bounds.contains(item.getPosition()))
|
|
||||||
{
|
|
||||||
mHeatMapPositionList.add(item.getPosition());
|
|
||||||
//If the item isn't already being displayed
|
|
||||||
if(isMarkerShown && !visibleMarkers.containsKey(item.getId()))
|
|
||||||
{
|
|
||||||
mClusterManager.addItem(item);
|
|
||||||
mClusterManager.cluster();
|
mClusterManager.cluster();
|
||||||
|
}
|
||||||
|
|
||||||
visibleMarkers.put(item.getId(),item);
|
private void refreshIncidentHeatMap(LatLng northeast, LatLng southwest){
|
||||||
|
String tag_string_req = "getincidentsforheatmapfrombound";
|
||||||
|
StringRequest strReq = getStringRequestGetAllIncidentsForHeatMapFromBound(northeast, southwest);
|
||||||
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
//If the course was previously on screen
|
|
||||||
if(courseMarkers.containsKey(item.getId()))
|
|
||||||
{
|
|
||||||
//1. Remove the Marker from the GoogleMap
|
|
||||||
courseMarkers.get(item.getId()).remove();
|
|
||||||
|
|
||||||
//2. Remove the reference to the Marker from the HashMap
|
private void addIncidentMarkersOnHeatMap(JSONArray incidents){
|
||||||
courseMarkers.remove(item.getId());
|
ArrayList<WeightedLatLng> heatMapPositions = new ArrayList<>();
|
||||||
}
|
|
||||||
*/
|
for(int i = 0; i < incidents.length();i++){
|
||||||
|
try {
|
||||||
|
heatMapPositions.add(new WeightedLatLng(new LatLng(incidents.getJSONObject(i).getDouble("latitude"), incidents.getJSONObject(i).getDouble("longitude")),1.0));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!mHeatMapPositionList.isEmpty())
|
|
||||||
{
|
if(mProvider == null){
|
||||||
mProvider.setData(mHeatMapPositionList);
|
mProvider = new HeatmapTileProvider.Builder()
|
||||||
|
.radius(50)
|
||||||
|
.weightedData(heatMapPositions)
|
||||||
|
.opacity(0.7)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
mOverlay = mMap.addTileOverlay(new TileOverlayOptions().tileProvider(mProvider));
|
||||||
|
Log.d("HEATMAP", "HeatMap initialized");
|
||||||
|
}else{
|
||||||
|
mProvider.setWeightedData(heatMapPositions);
|
||||||
mOverlay.clearTileCache();
|
mOverlay.clearTileCache();
|
||||||
|
Log.d("HEATMAP", "HeatMap updated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StringRequest getStringRequestGetAllIncidentsForHeatMapFromBound(final LatLng northeast, final LatLng southwest) {
|
||||||
|
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
Log.d(TAG, "Map HeatMap positions response: " + response);
|
||||||
|
|
||||||
private void setUpClustering() {
|
try {
|
||||||
|
JSONObject jObj = new JSONObject(response);
|
||||||
|
boolean error = jObj.getBoolean("error");
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
JSONArray incidents = jObj.getJSONArray("msg");
|
||||||
|
Log.d(TAG, "HeatMap positions response length: " + incidents .length());
|
||||||
|
addIncidentMarkersOnHeatMap(incidents);
|
||||||
|
} else {
|
||||||
|
String errorMsg = jObj.getString("error_msg");
|
||||||
|
Log.e(TAG, "Error getting map heat map positions (server returned error): " + errorMsg);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
Log.e(TAG, "Error getting map positions: " + error.getMessage());
|
||||||
|
showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("tag", "getincidentsforheatmapfrombound");
|
||||||
|
params.put("uid", user.get(SessionManager.KEY_UID));
|
||||||
|
params.put("token", user.get(SessionManager.TOKEN));
|
||||||
|
params.put("nelat", Double.toString(northeast.latitude));
|
||||||
|
params.put("nelng", Double.toString(northeast.longitude));
|
||||||
|
params.put("swlat", Double.toString(southwest.latitude));
|
||||||
|
params.put("swlng", Double.toString(southwest.longitude));
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringRequest getStringRequestGetAllIncidentsFromBound(final LatLng northeast, final LatLng southwest) {
|
||||||
|
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponse(String response) {
|
||||||
|
Log.d(TAG, "Map positions response: " + response);
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jObj = new JSONObject(response);
|
||||||
|
boolean error = jObj.getBoolean("error");
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
JSONArray incidents = jObj.getJSONArray("msg");
|
||||||
|
Log.d(TAG, "Map positions response length: " + incidents.length());
|
||||||
|
addIncidentMarkersOnMap(incidents);
|
||||||
|
} else {
|
||||||
|
String errorMsg = jObj.getString("error_msg");
|
||||||
|
Log.e(TAG, "Error getting map positions (server returned error): " + errorMsg);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
Log.e(TAG, "Error getting map positions: " + error.getMessage());
|
||||||
|
showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("tag", "getincidentsfrombound");
|
||||||
|
params.put("uid", user.get(SessionManager.KEY_UID));
|
||||||
|
params.put("token", user.get(SessionManager.TOKEN));
|
||||||
|
params.put("nelat", Double.toString(northeast.latitude));
|
||||||
|
params.put("nelng", Double.toString(northeast.longitude));
|
||||||
|
params.put("swlat", Double.toString(southwest.latitude));
|
||||||
|
params.put("swlng", Double.toString(southwest.longitude));
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initClustering() {
|
||||||
mClusterManager = new ClusterManager<IncidentReport>(this, mMap);
|
mClusterManager = new ClusterManager<IncidentReport>(this, mMap);
|
||||||
mMap.setOnCameraChangeListener(getCameraChangeListener());
|
mMap.setOnCameraChangeListener(getCameraChangeListener());
|
||||||
|
|
||||||
mClusterManager.setRenderer(new OwnIconRendered(MapsActivity.this,mMap,mClusterManager));
|
mClusterManager.setRenderer(new OwnIconRendered(MapsActivity.this, mMap, mClusterManager));
|
||||||
|
|
||||||
mMap.setOnMarkerClickListener(mClusterManager);
|
mMap.setOnMarkerClickListener(mClusterManager);
|
||||||
mMap.setOnInfoWindowClickListener(mClusterManager);
|
mMap.setOnInfoWindowClickListener(mClusterManager);
|
||||||
mMap.setInfoWindowAdapter(mClusterManager.getMarkerManager());
|
mMap.setInfoWindowAdapter(mClusterManager.getMarkerManager());
|
||||||
|
|
||||||
mClusterManager.setOnClusterItemInfoWindowClickListener(this);
|
mClusterManager.setOnClusterItemInfoWindowClickListener(this);
|
||||||
addClusterMarkers(mClusterManager);
|
|
||||||
|
|
||||||
mClusterManager.setOnClusterClickListener(this);
|
mClusterManager.setOnClusterClickListener(this);
|
||||||
mClusterManager.setOnClusterItemClickListener(this);
|
mClusterManager.setOnClusterItemClickListener(this);
|
||||||
mClusterManager
|
mClusterManager.setOnClusterItemClickListener(new ClusterManager.OnClusterItemClickListener<IncidentReport>() {
|
||||||
.setOnClusterItemClickListener(new ClusterManager.OnClusterItemClickListener<IncidentReport>() {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onClusterItemClick(IncidentReport item) {
|
public boolean onClusterItemClick(IncidentReport item) {
|
||||||
clickedClusterItem = item;
|
clickedClusterItem = item;
|
||||||
@@ -213,14 +392,68 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
new MyCustomAdapterForItems());
|
new MyCustomAdapterForItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void loadInfoWindowInformation(View infoView, String incidentID){
|
||||||
public boolean onClusterItemClick(IncidentReport incidentReport) {
|
String tag_string_req = "getincidentscoreforinfowindow";
|
||||||
return false;
|
StringRequest strReq = getStringRequestGetIncidentScoreForInfoWindow(infoView, incidentID);
|
||||||
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StringRequest getStringRequestGetIncidentScoreForInfoWindow(final View infoView, final String incidentID) {
|
||||||
|
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onClusterClick(Cluster<IncidentReport> cluster) {
|
public void onResponse(String response) {
|
||||||
return false;
|
Log.d(TAG, "Map positions response: " + response);
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSONObject jObj = new JSONObject(response);
|
||||||
|
boolean error = jObj.getBoolean("error");
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
JSONObject incident = jObj.getJSONObject("msg");
|
||||||
|
clickedClusterItem = new IncidentReport(incident);
|
||||||
|
|
||||||
|
TextView tvUsername = ((TextView) infoView.findViewById(R.id.txt_infowindow_fromuser));
|
||||||
|
TextView tvScore = ((TextView) infoView.findViewById(R.id.txt_infowindow_points));
|
||||||
|
RatingBar rbScore = ((RatingBar) infoView.findViewById(R.id.rb_infowindow_rating));
|
||||||
|
|
||||||
|
tvUsername.setText(getString(R.string.lbl_mapsinfowindow_author) + ": " + clickedClusterItem.getFromUsername());
|
||||||
|
tvScore.setText(getString(R.string.lbl_mapsinfowindow_score) + ": " + String.valueOf(clickedClusterItem.getVotedScore()));
|
||||||
|
rbScore.setRating(clickedClusterItem.getScoreStars());
|
||||||
|
|
||||||
|
|
||||||
|
if (markerShowingInfoWindow != null && markerShowingInfoWindow.isInfoWindowShown()) {
|
||||||
|
markerShowingInfoWindow.showInfoWindow();
|
||||||
|
markerShowingInfoWindow = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String errorMsg = jObj.getString("error_msg");
|
||||||
|
Log.e(TAG, "Error getting incident details (server returned error): " + errorMsg);
|
||||||
|
showMessage(errorMsg);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, new Response.ErrorListener() {
|
||||||
|
@Override
|
||||||
|
public void onErrorResponse(VolleyError error) {
|
||||||
|
Log.e(TAG, "Error getting incident details: " + error.getMessage());
|
||||||
|
showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
@Override
|
||||||
|
protected Map<String, String> getParams() {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("tag", "getincidentfromincidentid");
|
||||||
|
params.put("uid", user.get(SessionManager.KEY_UID));
|
||||||
|
params.put("token", user.get(SessionManager.TOKEN));
|
||||||
|
params.put("incidentid", incidentID);
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MyCustomAdapterForItems implements GoogleMap.InfoWindowAdapter {
|
public class MyCustomAdapterForItems implements GoogleMap.InfoWindowAdapter {
|
||||||
@@ -228,17 +461,18 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
private final View myContentsView;
|
private final View myContentsView;
|
||||||
|
|
||||||
MyCustomAdapterForItems() {
|
MyCustomAdapterForItems() {
|
||||||
myContentsView = getLayoutInflater().inflate(
|
myContentsView = getLayoutInflater().inflate(R.layout.map_info_window, null);
|
||||||
R.layout.map_info_window, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getInfoContents(Marker marker) {
|
public View getInfoContents(Marker marker) {
|
||||||
|
markerShowingInfoWindow = marker;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getInfoWindow(Marker marker) {
|
public View getInfoWindow(Marker marker) {
|
||||||
|
markerShowingInfoWindow = marker;
|
||||||
LinearLayout layCategoryColor = ((LinearLayout) myContentsView.findViewById(R.id.lay_infowindow_color));
|
LinearLayout layCategoryColor = ((LinearLayout) myContentsView.findViewById(R.id.lay_infowindow_color));
|
||||||
|
|
||||||
TextView tvCategory = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_category));
|
TextView tvCategory = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_category));
|
||||||
@@ -247,50 +481,22 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
TextView tvSuspect = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_subject));
|
TextView tvSuspect = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_subject));
|
||||||
TextView tvTime = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_time));
|
TextView tvTime = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_time));
|
||||||
|
|
||||||
TextView tvUsername = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_fromuser));
|
|
||||||
TextView tvScore = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_points));
|
|
||||||
RatingBar rbScore = ((RatingBar) myContentsView.findViewById(R.id.rb_infowindow_rating));
|
|
||||||
|
|
||||||
if (clickedClusterItem != null) {
|
if (clickedClusterItem != null) {
|
||||||
|
loadInfoWindowInformation(myContentsView, Integer.toString(clickedClusterItem.getId()));
|
||||||
|
|
||||||
layCategoryColor.setBackgroundColor(clickedClusterItem.getCategoryColor());
|
layCategoryColor.setBackgroundColor(clickedClusterItem.getCategoryColor());
|
||||||
|
|
||||||
tvCategory.setText(clickedClusterItem.getIncidentCategoryName(getApplicationContext()));
|
tvCategory.setText(clickedClusterItem.getIncidentCategoryName(getApplicationContext()));
|
||||||
tvSubcategory.setText(clickedClusterItem.getIncidentSubCategoryName(getApplicationContext()));
|
tvSubcategory.setText(clickedClusterItem.getIncidentSubCategoryName(getApplicationContext()));
|
||||||
tvSuspect.setText(clickedClusterItem.getSuspectString(getApplicationContext()));
|
tvSuspect.setText(clickedClusterItem.getSuspectString(getApplicationContext()));
|
||||||
|
|
||||||
tvUsername.setText(getString(R.string.lbl_mapsinfowindow_author) + ": " + clickedClusterItem.getFromUsername());
|
tvVictim.setText(""); // TODO
|
||||||
//TODO
|
tvTime.setText(clickedClusterItem.getTimeString(getApplicationContext()));
|
||||||
//tvScore.setText(clickedClusterItem.getVotedScore());
|
|
||||||
//tvVictim.setText(clickedClusterItem.getFidVictimCategory());
|
|
||||||
//tvTime.setText(clickedClusterItem.getTimeString(getApplicationContext()));
|
|
||||||
//rbScore.setRating(clickedClusterItem.getScoreStars());
|
|
||||||
}
|
}
|
||||||
return myContentsView;
|
return myContentsView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addClusterMarkers(ClusterManager<IncidentReport> mClusterManager) {
|
|
||||||
|
|
||||||
String tag_string_req = "getincidentswithposition";
|
|
||||||
StringRequest strReq = getStringRequestGetAllIncidentsWithPosition();
|
|
||||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addHeatMap() {
|
|
||||||
mHeatMapPositionList.add(new LatLng(53.252151,10.422109));
|
|
||||||
|
|
||||||
mProvider = new HeatmapTileProvider.Builder()
|
|
||||||
.radius(50)
|
|
||||||
.data(mHeatMapPositionList)
|
|
||||||
.opacity(0.7)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
|
|
||||||
mOverlay = mMap.addTileOverlay(new TileOverlayOptions().tileProvider(mProvider));
|
|
||||||
|
|
||||||
addMarkersToMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleIntent(Intent intent){
|
private void handleIntent(Intent intent){
|
||||||
if(Intent.ACTION_SEARCH.equals(intent.getAction()))
|
if(Intent.ACTION_SEARCH.equals(intent.getAction()))
|
||||||
{
|
{
|
||||||
@@ -308,9 +514,30 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
String longitude = position[1];
|
String longitude = position[1];
|
||||||
|
|
||||||
LatLng point = new LatLng(Double.parseDouble(latitude),Double.parseDouble(longitude));
|
LatLng point = new LatLng(Double.parseDouble(latitude),Double.parseDouble(longitude));
|
||||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, 12.0f));
|
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_ZOOM_LEVEL));
|
||||||
|
} else {
|
||||||
|
myPosition = session.getLocation();
|
||||||
|
if (myPosition != null)
|
||||||
|
{
|
||||||
|
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
|
||||||
|
new LatLng(myPosition.latitude, myPosition.longitude), DEFAULT_ZOOM_LEVEL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onClusterItemClick(IncidentReport incidentReport) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onClusterClick(Cluster<IncidentReport> cluster) { return false; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClusterItemInfoWindowClick(IncidentReport incidentReport) {
|
||||||
|
gotoViewReportActivity(incidentReport.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -335,7 +562,8 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
private void showLocations(Cursor c){
|
private void showLocations(Cursor c){
|
||||||
MarkerOptions markerOptions;
|
MarkerOptions markerOptions;
|
||||||
LatLng position = null;
|
LatLng position = null;
|
||||||
mMap.clear();
|
//mMap.clear();
|
||||||
|
|
||||||
while(c.moveToNext()){
|
while(c.moveToNext()){
|
||||||
markerOptions = new MarkerOptions();
|
markerOptions = new MarkerOptions();
|
||||||
position = new LatLng(Double.parseDouble(c.getString(1)),Double.parseDouble(c.getString(2)));
|
position = new LatLng(Double.parseDouble(c.getString(1)),Double.parseDouble(c.getString(2)));
|
||||||
@@ -350,12 +578,11 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
if (position != null) {
|
if (position != null) {
|
||||||
myLocation = new LatLng(position.latitude,position.longitude);
|
myLocation = new LatLng(position.latitude,position.longitude);
|
||||||
}
|
}
|
||||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(myLocation, 12.0f));
|
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(myLocation, DEFAULT_ZOOM_LEVEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoaderReset(Loader<Cursor> arg0) {
|
public void onLoaderReset(Loader<Cursor> arg0) {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int arg0, Bundle query) {
|
public Loader<Cursor> onCreateLoader(int arg0, Bundle query) {
|
||||||
@@ -391,6 +618,12 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause(){
|
||||||
|
super.onPause();
|
||||||
|
showAd();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
if (mMap != null) {
|
if (mMap != null) {
|
||||||
@@ -400,7 +633,6 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayoutResourceId() {
|
protected int getLayoutResourceId() {
|
||||||
return R.layout.activity_maps;
|
return R.layout.activity_maps;
|
||||||
@@ -410,68 +642,4 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
protected String getActivityName() {
|
protected String getActivityName() {
|
||||||
return mActivityTitle;
|
return mActivityTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringRequest getStringRequestGetAllIncidentsWithPosition() {
|
|
||||||
showDialog();
|
|
||||||
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(String response) {
|
|
||||||
Log.d(TAG, "Map positions response: " + response);
|
|
||||||
|
|
||||||
try {
|
|
||||||
JSONObject jObj = new JSONObject(response);
|
|
||||||
boolean error = jObj.getBoolean("error");
|
|
||||||
|
|
||||||
if (!error) {
|
|
||||||
JSONArray incidents = jObj.getJSONArray("message");
|
|
||||||
|
|
||||||
for(int i=0;i<incidents.length();i++){
|
|
||||||
JSONObject incident = incidents.getJSONObject(i);
|
|
||||||
myMarkers.add(new IncidentReport(incident,new LatLng(incident.getDouble("latitude"),incident.getDouble("longitude"))));
|
|
||||||
}
|
|
||||||
addHeatMap();
|
|
||||||
} else {
|
|
||||||
String errorMsg = jObj.getString("error_msg");
|
|
||||||
Log.e(TAG, "Error getting map positions (server returned error): " + errorMsg);
|
|
||||||
showMessage(errorMsg);
|
|
||||||
}
|
|
||||||
hideDialog();
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
hideDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}, new Response.ErrorListener() {
|
|
||||||
@Override
|
|
||||||
public void onErrorResponse(VolleyError error) {
|
|
||||||
Log.e(TAG, "Error getting map positions: " + error.getMessage());
|
|
||||||
showMessage(getString(R.string.errormsg_couldnotretrieve));
|
|
||||||
hideDialog();
|
|
||||||
}
|
|
||||||
}) {
|
|
||||||
@Override
|
|
||||||
protected Map<String, String> getParams() {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("tag", "getincidentswithpositionandscore");
|
|
||||||
params.put("uid", user.get(SessionManager.KEY_UID));
|
|
||||||
params.put("token", user.get(SessionManager.TOKEN));
|
|
||||||
|
|
||||||
return params;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClusterItemInfoWindowClick(IncidentReport incidentReport) {
|
|
||||||
gotoViewReportActivity(incidentReport.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause(){
|
|
||||||
super.onPause();
|
|
||||||
showAd();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ProfileActivity extends BaseActivity{
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
result.setSelection(userstatsAvtivityID, false);
|
navDrawer.setSelection(userstatsAvtivityID, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
package org.deke.risk.riskahead;
|
package org.deke.risk.riskahead;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.location.Address;
|
import android.location.Address;
|
||||||
import android.location.Geocoder;
|
import android.location.Geocoder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -38,9 +41,9 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragment.OnInputFinishedListener, ReportWF_1_Fragment.OnCallMapListener, ReportWF_2_Fragment.OnInputFinishedListener, ReportWF_3_Fragment.OnInputFinishedListener {
|
public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragment.OnInputFinishedListener, ReportWF_2_Fragment.OnInputFinishedListener, ReportWF_3_Fragment.OnInputFinishedListener {
|
||||||
|
|
||||||
private final static String mActivityTitle = "Report NEW";
|
private final static String mActivityTitle = "Report Incident";
|
||||||
private final static String TAG = ReportWFActivity.class.getSimpleName();
|
private final static String TAG = ReportWFActivity.class.getSimpleName();
|
||||||
|
|
||||||
private List<Fragment> fragList = new ArrayList<Fragment>();
|
private List<Fragment> fragList = new ArrayList<Fragment>();
|
||||||
@@ -51,11 +54,17 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
|
|
||||||
private BootstrapButton btnContinue;
|
private BootstrapButton btnContinue;
|
||||||
private BootstrapButton btnReportNow;
|
private BootstrapButton btnReportNow;
|
||||||
|
private FloatingActionButton btnMap;
|
||||||
|
|
||||||
private IncidentReport incident = new IncidentReport();
|
private IncidentReport incident = new IncidentReport();
|
||||||
|
|
||||||
private int currentState = 0;
|
private int currentState = 0;
|
||||||
|
|
||||||
|
public boolean resetSignal = false;
|
||||||
|
|
||||||
|
SharedPreferences mPrefs;
|
||||||
|
SharedPreferences.Editor prefsEditor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -83,6 +92,22 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
reportIncident(incident);
|
reportIncident(incident);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
btnMap = (FloatingActionButton) findViewById(R.id.fab_reportwf_map);
|
||||||
|
btnMap.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if(incident != null && incident.getPosition() != null){
|
||||||
|
gotoMapActivity(incident.getPosition().latitude+":"+incident.getPosition().longitude);
|
||||||
|
}else {
|
||||||
|
gotoMapActivity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
mPrefs = getPreferences(MODE_PRIVATE);
|
||||||
|
prefsEditor = mPrefs.edit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportIncident(IncidentReport incident){
|
private void reportIncident(IncidentReport incident){
|
||||||
@@ -91,6 +116,16 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resetStateAndIncident(){
|
||||||
|
resetSignal = true;
|
||||||
|
currentState = 0;
|
||||||
|
incident = new IncidentReport();
|
||||||
|
|
||||||
|
prefsEditor.remove("incident");
|
||||||
|
prefsEditor.remove("currentState");
|
||||||
|
prefsEditor.commit();
|
||||||
|
}
|
||||||
|
|
||||||
private void modifiyPos(String pos){
|
private void modifiyPos(String pos){
|
||||||
String[] position = pos.split(":");
|
String[] position = pos.split(":");
|
||||||
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
|
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
|
||||||
@@ -121,8 +156,10 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setIncident(IncidentReport newIncident){
|
public void setIncident(IncidentReport newIncident){
|
||||||
|
if(resetSignal == false){
|
||||||
incident = newIncident;
|
incident = newIncident;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initFragment(int state) {
|
private void initFragment(int state) {
|
||||||
findViewById(R.id.atvStatus).setVisibility(View.INVISIBLE);
|
findViewById(R.id.atvStatus).setVisibility(View.INVISIBLE);
|
||||||
@@ -175,42 +212,33 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause(){
|
public void onStop(){
|
||||||
super.onPause();
|
super.onStop();
|
||||||
|
|
||||||
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
|
if(resetSignal == false){
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
prefsEditor.putString("incident", gson.toJson(incident));
|
||||||
SharedPreferences.Editor prefsEditor = mPrefs.edit();
|
|
||||||
|
|
||||||
prefsEditor.putString("incident",gson.toJson(incident));
|
|
||||||
prefsEditor.putInt("currentState", currentState);
|
prefsEditor.putInt("currentState", currentState);
|
||||||
prefsEditor.commit();
|
prefsEditor.commit();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume(){
|
public void onResume(){
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
if(!mPrefs.getString("incident", "").equals("")) incident = gson.fromJson(mPrefs.getString("incident", ""), IncidentReport.class);
|
if(!mPrefs.getString("incident", "").equals("")) incident = gson.fromJson(mPrefs.getString("incident", ""), IncidentReport.class);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String pos = intent.getStringExtra(EXTRA_MESSAGE);
|
String pos = intent.getStringExtra(EXTRA_MESSAGE);
|
||||||
|
|
||||||
if(pos != null) modifiyPos(pos);
|
if(pos != null) modifiyPos(pos);
|
||||||
|
|
||||||
currentState = mPrefs.getInt("currentState",0);
|
currentState = mPrefs.getInt("currentState",0);
|
||||||
if(currentState != 0) initFragment(currentState);
|
if(currentState != 0) initFragment(currentState);
|
||||||
|
|
||||||
result.setSelection(reportAvtivityID, false);
|
navDrawer.setSelection(reportAvtivityID, false);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCallMap() {
|
|
||||||
gotoMapActivity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -218,12 +246,39 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
|
|
||||||
if((id == R.id.menu_btn_gotostart)){
|
if((id == R.id.menu_btn_gotostart)){
|
||||||
|
new AlertDialog.Builder(ReportWFActivity.this)
|
||||||
|
.setTitle("New Incident?")
|
||||||
|
.setMessage("Reset everything?")
|
||||||
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
resetStateAndIncident();
|
||||||
|
|
||||||
initFragment(0);
|
initFragment(0);
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
|
.show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMapButtonVisibility(boolean isVisible){
|
||||||
|
if(isVisible){
|
||||||
|
btnMap.setVisibility(View.VISIBLE);
|
||||||
|
}else{
|
||||||
|
btnMap.setVisibility(View.INVISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private StringRequest getStringRequestAddIncidentWithPosition(final IncidentReport incident) {
|
private StringRequest getStringRequestAddIncidentWithPosition(final IncidentReport incident) {
|
||||||
showDialog();
|
showDialog();
|
||||||
@@ -239,13 +294,13 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
showMessage("Report added!");
|
showMessage("Report added!");
|
||||||
SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
|
|
||||||
editor.clear().commit();
|
|
||||||
|
|
||||||
|
|
||||||
|
LatLng gotoPosition = new LatLng(incident.getPosition().latitude,incident.getPosition().longitude);
|
||||||
|
resetStateAndIncident();
|
||||||
|
|
||||||
showAd();
|
showAd();
|
||||||
gotoMapActivity(incident.getPosition().latitude+":"+incident.getPosition().longitude);
|
|
||||||
|
gotoMapActivity(gotoPosition.latitude+":"+gotoPosition.longitude);
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error adding incident (Server returned error): " + errorMsg);
|
Log.e(TAG, "Error adding incident (Server returned error): " + errorMsg);
|
||||||
@@ -270,6 +325,33 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
params.put("tag", "addincidentwithposition");
|
params.put("tag", "addincidentwithposition");
|
||||||
params.put("uid", user.get(SessionManager.KEY_UID));
|
params.put("uid", user.get(SessionManager.KEY_UID));
|
||||||
params.put("token", user.get(SessionManager.TOKEN));
|
params.put("token", user.get(SessionManager.TOKEN));
|
||||||
|
params.put("latitude", Double.toString(incident.getPosition().latitude));
|
||||||
|
params.put("longitude", Double.toString(incident.getPosition().longitude));
|
||||||
|
params.put("fid_incident", Integer.toString(incident.getFidIncidentCategory()));
|
||||||
|
params.put("fid_subincident", Integer.toString(incident.getFidIncidentSubCategory()));
|
||||||
|
params.put("etc_incident", incident.getEtcIncidentCategory());
|
||||||
|
params.put("fid_time", Integer.toString(incident.getFidTimeCategory()));
|
||||||
|
params.put("fid_subtime", Integer.toString(incident.getFidTimeSubCategory()));
|
||||||
|
params.put("happened_from_datetime", incident.getFromDate()+" "+incident.getFromTime());
|
||||||
|
params.put("happened_to_datetime", incident.getToDate()+" "+incident.getToTime());
|
||||||
|
params.put("fid_suspect", Integer.toString(incident.getFidSuspectCategory()));
|
||||||
|
params.put("fid_subsuspect", Integer.toString(incident.getFidSuspectSubCategory()));
|
||||||
|
params.put("fid_weapon", Integer.toString(incident.getFidSuspectWeaponCategory()));
|
||||||
|
params.put("fid_subweapon", Integer.toString(incident.getFidSuspectWeaponSubCategory()));
|
||||||
|
params.put("etc_weapon", incident.getEtcSuspectWeaponCategory());
|
||||||
|
params.put("fid_suspectcount", Integer.toString(incident.getFidSuspectCountCategory()));
|
||||||
|
params.put("etc_suspectcount", incident.getEtcSuspectCountCategory());
|
||||||
|
params.put("fid_victim", Integer.toString(incident.getFidVictimCategory()));
|
||||||
|
params.put("fid_victimorigin", Integer.toString(incident.getFidVictimOriginCategory()));
|
||||||
|
params.put("etc_victimorigin", incident.getEtcVictimOriginCategory());
|
||||||
|
params.put("fid_suspecttransportation", Integer.toString(incident.getFidSuspectTransportationCategory()));
|
||||||
|
params.put("etc_suspecttransportation", incident.getEtcSuspectTransportationCategory());
|
||||||
|
params.put("fid_victimbelonging", Integer.toString(incident.getFidVictimBelongingCategory()));
|
||||||
|
params.put("etc_victimbelonging", incident.getEtcVictimBelongingCategory());
|
||||||
|
params.put("fid_suspectcharacteristics", Integer.toString(incident.getFidSuspectCharacteristicsCategory()));
|
||||||
|
params.put("etc_suspectcharacteristics", incident.getEtcSuspectCharacteristicsCategory());
|
||||||
|
params.put("fid_others", Integer.toString(incident.getFidOthersCategory()));
|
||||||
|
params.put("etc_others", incident.getEtcOthersCategory());
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import android.util.Log;
|
|||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.android.volley.Request;
|
import com.android.volley.Request;
|
||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
@@ -144,7 +143,7 @@ public class SettingsActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
result.setSelection(settingsAvtivityID,false);
|
navDrawer.setSelection(settingsAvtivityID,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class SubscriptionsActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
result.setSelection(subscriptionsAvtivityID,false);
|
navDrawer.setSelection(subscriptionsAvtivityID,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.beardedhen.androidbootstrap.BootstrapLabel;
|
|||||||
import org.deke.risk.riskahead.helper.AppConfig;
|
import org.deke.risk.riskahead.helper.AppConfig;
|
||||||
import org.deke.risk.riskahead.helper.AppController;
|
import org.deke.risk.riskahead.helper.AppController;
|
||||||
import org.deke.risk.riskahead.helper.BaseActivity;
|
import org.deke.risk.riskahead.helper.BaseActivity;
|
||||||
|
import org.deke.risk.riskahead.helper.IncidentReport;
|
||||||
import org.deke.risk.riskahead.helper.SessionManager;
|
import org.deke.risk.riskahead.helper.SessionManager;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@@ -35,14 +36,12 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
private final static String mActivityTitle = "ViewReport";
|
private final static String mActivityTitle = "ViewReport";
|
||||||
private final static String TAG = ViewReportActivity.class.getSimpleName();
|
private final static String TAG = ViewReportActivity.class.getSimpleName();
|
||||||
|
|
||||||
private EditText txtTitle;
|
private EditText txtIncidentCategory;
|
||||||
private EditText txtDescription;
|
private EditText txtIncidentSubCategory;
|
||||||
private EditText txtCrimeCategory;
|
private TextView txtPosition;
|
||||||
private EditText txtPosition;
|
|
||||||
private EditText txtDate;
|
|
||||||
private EditText txtTime;
|
|
||||||
private TextView txtPositionDetail;
|
|
||||||
private BootstrapLabel scorelabel;
|
private BootstrapLabel scorelabel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -51,13 +50,9 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
final Integer uid = intent.getIntExtra(BaseActivity.EXTRA_MESSAGE, 0);
|
final Integer uid = intent.getIntExtra(BaseActivity.EXTRA_MESSAGE, 0);
|
||||||
|
|
||||||
txtTitle = (EditText) findViewById(R.id.input_viewreport_short);
|
txtIncidentCategory = (EditText) findViewById(R.id.txt_viewreport_incidentcategory);
|
||||||
txtDescription = (EditText) findViewById(R.id.input_viewreport_long);
|
txtIncidentSubCategory = (EditText) findViewById(R.id.txt_viewreport_incidentsubcategory);
|
||||||
txtCrimeCategory = (EditText) findViewById(R.id.input_viewreport_category);
|
txtPosition = (TextView) findViewById(R.id.txt_viewreport_position);
|
||||||
txtDate = (EditText) findViewById(R.id.input_viewreport_date);
|
|
||||||
txtTime = (EditText) findViewById(R.id.input_viewreport_time);
|
|
||||||
txtPosition = (EditText) findViewById(R.id.input_viewreport_position);
|
|
||||||
txtPositionDetail = (TextView) findViewById(R.id.lbl_viewreport_position_detail);
|
|
||||||
scorelabel = (BootstrapLabel) findViewById(R.id.txt_viewreport_points);
|
scorelabel = (BootstrapLabel) findViewById(R.id.txt_viewreport_points);
|
||||||
|
|
||||||
getIncident(uid);
|
getIncident(uid);
|
||||||
@@ -175,7 +170,6 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private StringRequest getStringRequestGetIncidentWithPositionFromID(final Integer incidentid) {
|
private StringRequest getStringRequestGetIncidentWithPositionFromID(final Integer incidentid) {
|
||||||
showDialog();
|
showDialog();
|
||||||
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||||
@@ -190,54 +184,10 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
boolean error = jObj.getBoolean("error");
|
boolean error = jObj.getBoolean("error");
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
JSONObject incident = jObj.getJSONArray("message").getJSONObject(0);
|
JSONObject jIncident = jObj.getJSONObject("msg");
|
||||||
|
IncidentReport incident = new IncidentReport(jIncident);
|
||||||
|
|
||||||
txtTitle.setText(incident.getString("text_short"));
|
initReport(incident);
|
||||||
txtDescription.setText(incident.getString("text_long"));
|
|
||||||
txtCrimeCategory.setText(incident.getString("cat_name"));
|
|
||||||
|
|
||||||
scorelabel.setText(jObj.getString("score"));
|
|
||||||
|
|
||||||
String[] happened_at = incident.getString("happened_at").split(" ");
|
|
||||||
txtDate.setText(happened_at[0]);
|
|
||||||
txtTime.setText(happened_at[1].substring(0, 5));
|
|
||||||
|
|
||||||
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
|
|
||||||
|
|
||||||
try {
|
|
||||||
List<Address> addressList = geocoder.getFromLocation(incident.getDouble("latitude"), incident.getDouble("longitude"), 1);
|
|
||||||
if (addressList != null && addressList.size() > 0) {
|
|
||||||
Address address = addressList.get(0);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
|
|
||||||
if(address.getAddressLine(i) != null) sb.append(address.getAddressLine(i)).append("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
//if(address.getLocality() != null) sb.append(address.getLocality()).append("\n");
|
|
||||||
//if(address.getPostalCode() != null) sb.append(address.getPostalCode()).append("\n");
|
|
||||||
if(address.getCountryName() != null) sb.append(address.getCountryName());
|
|
||||||
|
|
||||||
txtPosition.setText(address.getLocality());
|
|
||||||
txtPositionDetail.setText(sb.toString());
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
final String latitude = incident.getString("latitude");
|
|
||||||
final String longitude = incident.getString("longitude");
|
|
||||||
|
|
||||||
findViewById(R.id.btn_viewreport_position).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
gotoMapActivity(latitude + ":" + longitude);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if(!incident.getString("fid_user").equals(user.get("uid"))){
|
|
||||||
findViewById(R.id.layoutFooter).setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
@@ -262,7 +212,7 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
protected Map<String, String> getParams() {
|
protected Map<String, String> getParams() {
|
||||||
// Posting parameters to login url
|
// Posting parameters to login url
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("tag", "getincidentfromid");
|
params.put("tag", "getincidentfromincidentid");
|
||||||
params.put("uid", user.get(SessionManager.KEY_UID));
|
params.put("uid", user.get(SessionManager.KEY_UID));
|
||||||
params.put("token", user.get(SessionManager.TOKEN));
|
params.put("token", user.get(SessionManager.TOKEN));
|
||||||
params.put("incidentid", incidentid.toString());
|
params.put("incidentid", incidentid.toString());
|
||||||
@@ -274,6 +224,47 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initReport(IncidentReport incident) {
|
||||||
|
scorelabel.setText(Integer.toString(incident.getVotedScore()));
|
||||||
|
txtIncidentCategory.setText(incident.getIncidentCategoryName(getApplicationContext()));
|
||||||
|
txtIncidentSubCategory.setText(incident.getIncidentSubCategoryName(getApplicationContext()));
|
||||||
|
|
||||||
|
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<Address> addressList = geocoder.getFromLocation(incident.getPosition().latitude,incident.getPosition().longitude, 1);
|
||||||
|
if (addressList != null && addressList.size() > 0) {
|
||||||
|
Address address = addressList.get(0);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
|
||||||
|
if(address.getAddressLine(i) != null) sb.append(address.getAddressLine(i)).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(address.getCountryName() != null) sb.append(address.getCountryName());
|
||||||
|
|
||||||
|
txtPosition.setText(sb.toString());
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
final String latitude = Double.toString(incident.getPosition().latitude);
|
||||||
|
final String longitude = Double.toString(incident.getPosition().longitude);
|
||||||
|
|
||||||
|
findViewById(R.id.btn_viewreport_position).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
gotoMapActivity(latitude + ":" + longitude);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
String test = user.get(SessionManager.KEY_UID);
|
||||||
|
if(incident.getFidFromUser() != Integer.valueOf(test)){
|
||||||
|
findViewById(R.id.layoutFooter).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void makeUpvote(Integer uid) {
|
public void makeUpvote(Integer uid) {
|
||||||
String tag_string_req = "addvote";
|
String tag_string_req = "addvote";
|
||||||
StringRequest strReq = getStringRequestAddVote(uid, "1");
|
StringRequest strReq = getStringRequestAddVote(uid, "1");
|
||||||
@@ -300,10 +291,10 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
showMessage("Voted! Score updated.");
|
showMessage("Voted! Score updated.");
|
||||||
BootstrapLabel scorelabel = (BootstrapLabel) findViewById(R.id.txt_viewreport_points);
|
JSONObject jPoints = jObj.getJSONObject("points");
|
||||||
scorelabel.setText(jObj.getString("points"));
|
|
||||||
showAd();
|
|
||||||
|
|
||||||
|
scorelabel.setText(Integer.toString(jPoints.getInt("upvoted")-jPoints.getInt("downvoted")));
|
||||||
|
showAd();
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error voting incident (Server returned error): " + errorMsg);
|
Log.e(TAG, "Error voting incident (Server returned error): " + errorMsg);
|
||||||
|
|||||||
@@ -35,16 +35,30 @@ public class ProfileStatisticsFragment extends Fragment {
|
|||||||
private View view;
|
private View view;
|
||||||
private ProfileActivity parent;
|
private ProfileActivity parent;
|
||||||
|
|
||||||
|
TextView points ;
|
||||||
|
TextView ranking ;
|
||||||
|
TextView posts ;
|
||||||
|
TextView txtMemberSince ;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
view = inflater.inflate(R.layout.fragment_profile_stats, container, false);
|
view = inflater.inflate(R.layout.fragment_profile_stats, container, false);
|
||||||
parent = (ProfileActivity)getActivity();
|
parent = (ProfileActivity)getActivity();
|
||||||
|
|
||||||
|
points = (TextView) view.findViewById(R.id.txt_profile_points);
|
||||||
|
ranking = (TextView) view.findViewById(R.id.txt_profile_ranking);
|
||||||
|
posts = (TextView) view.findViewById(R.id.txt_profile_numberposts);
|
||||||
|
txtMemberSince = (TextView) view.findViewById(R.id.txt_profile_membersince);
|
||||||
|
|
||||||
|
getProfileStatsForList();
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getProfileStatsForList() {
|
||||||
StringRequest strReq = getStringRequestProfileStats();
|
StringRequest strReq = getStringRequestProfileStats();
|
||||||
String tag_string_req = "req_profilestats";
|
String tag_string_req = "req_profilestats";
|
||||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringRequest getStringRequestProfileStats() {
|
private StringRequest getStringRequestProfileStats() {
|
||||||
@@ -58,15 +72,12 @@ public class ProfileStatisticsFragment extends Fragment {
|
|||||||
JSONObject jObj = new JSONObject(response);
|
JSONObject jObj = new JSONObject(response);
|
||||||
boolean error = jObj.getBoolean("error");
|
boolean error = jObj.getBoolean("error");
|
||||||
if (!error) {
|
if (!error) {
|
||||||
TextView points = (TextView) view.findViewById(R.id.txt_profile_points);
|
|
||||||
TextView ranking = (TextView) view.findViewById(R.id.txt_profile_ranking);
|
|
||||||
TextView posts = (TextView) view.findViewById(R.id.txt_profile_numberposts);
|
|
||||||
TextView txtMemberSince = (TextView) view.findViewById(R.id.txt_profile_membersince);
|
|
||||||
|
|
||||||
|
|
||||||
|
jObj = jObj.getJSONObject("msg");
|
||||||
points.setText(jObj.getString("points"));
|
points.setText(jObj.getString("points"));
|
||||||
ranking.setText(jObj.getString("rank"));
|
ranking.setText(jObj.getString("rank"));
|
||||||
posts.setText(jObj.getString("posts"));
|
posts.setText(jObj.getString("numberOfPosts"));
|
||||||
txtMemberSince.setText(parent.user.get("created_at"));
|
txtMemberSince.setText(parent.user.get("created_at"));
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
@@ -88,7 +99,6 @@ public class ProfileStatisticsFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<String, String> getParams() {
|
protected Map<String, String> getParams() {
|
||||||
// Posting params to register url
|
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("tag", "getuserstats");
|
params.put("tag", "getuserstats");
|
||||||
params.put("uid", parent.user.get(SessionManager.KEY_UID));
|
params.put("uid", parent.user.get(SessionManager.KEY_UID));
|
||||||
|
|||||||
@@ -48,12 +48,10 @@ public class ReportListFragment extends Fragment{
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
view = inflater.inflate(R.layout.fragment_reportlist, container, false);
|
view = inflater.inflate(R.layout.fragment_reportlist, container, false);
|
||||||
parent = (ProfileActivity)getActivity();
|
parent = (ProfileActivity)getActivity();
|
||||||
Log.d(TAG,"ReportListActivated!");
|
|
||||||
myListView = (ListView) view.findViewById(R.id.lv_reportlist_list);
|
myListView = (ListView) view.findViewById(R.id.lv_reportlist_list);
|
||||||
|
|
||||||
String tag_string_req = "getincidentswithpositionfromid";
|
if(resultList == null || resultList.size() == 0) getIncidentsForList();
|
||||||
StringRequest strReq = getStringRequestGetIncidentsWithPositionFromUserID();
|
|
||||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
|
||||||
|
|
||||||
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -65,25 +63,29 @@ public class ReportListFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getIncidentsForList() {
|
||||||
|
String tag_string_req = "getincidentswithpositionfromid";
|
||||||
|
StringRequest strReq = getStringRequestGetIncidentsWithPositionFromUserID();
|
||||||
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
|
}
|
||||||
|
|
||||||
private StringRequest getStringRequestGetIncidentsWithPositionFromUserID() {
|
private StringRequest getStringRequestGetIncidentsWithPositionFromUserID() {
|
||||||
parent.showDialog();
|
|
||||||
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(String response) {
|
public void onResponse(String response) {
|
||||||
Log.d(TAG, "Map positions response with ID: " + response);
|
Log.d(TAG, "Map positions response with ID: " + response);
|
||||||
parent.hideDialog();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject jObj = new JSONObject(response);
|
JSONObject jObj = new JSONObject(response);
|
||||||
boolean error = jObj.getBoolean("error");
|
boolean error = jObj.getBoolean("error");
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
JSONArray incidents = jObj.getJSONArray("message");
|
JSONArray incidents = jObj.getJSONArray("msg");
|
||||||
resultList = new ArrayList<>();
|
resultList = new ArrayList<>();
|
||||||
|
|
||||||
for(int i=0;i<incidents.length();i++){
|
for(int i=0;i<incidents.length();i++){
|
||||||
@@ -113,7 +115,6 @@ public class ReportListFragment extends Fragment{
|
|||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error getting incident list: " + error.getMessage());
|
Log.e(TAG, "Error getting incident list: " + error.getMessage());
|
||||||
parent.showMessage(getString(R.string.errormsg_couldnotretrieve));
|
parent.showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||||
parent.hideDialog();
|
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public class ReportWF_1_Fragment extends Fragment{
|
|||||||
private EditText crimeSubOther;
|
private EditText crimeSubOther;
|
||||||
|
|
||||||
private RelativeLayout timeLayout;
|
private RelativeLayout timeLayout;
|
||||||
private BootstrapButton btnPositionSearch;
|
|
||||||
private TextView txtPositionInformation;
|
private TextView txtPositionInformation;
|
||||||
|
|
||||||
private boolean isMandatoryCategoryFilled;
|
private boolean isMandatoryCategoryFilled;
|
||||||
@@ -47,11 +46,6 @@ public class ReportWF_1_Fragment extends Fragment{
|
|||||||
IncidentReport incident;
|
IncidentReport incident;
|
||||||
|
|
||||||
OnInputFinishedListener mCallbackFinished;
|
OnInputFinishedListener mCallbackFinished;
|
||||||
OnCallMapListener mCallbackMapListener;
|
|
||||||
|
|
||||||
public interface OnCallMapListener {
|
|
||||||
void onCallMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface OnInputFinishedListener {
|
public interface OnInputFinishedListener {
|
||||||
void onInputFinished(boolean finished);
|
void onInputFinished(boolean finished);
|
||||||
@@ -71,6 +65,7 @@ public class ReportWF_1_Fragment extends Fragment{
|
|||||||
initLayerPosition();
|
initLayerPosition();
|
||||||
|
|
||||||
crimeSubOther = (EditText) viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc);
|
crimeSubOther = (EditText) viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc);
|
||||||
|
crimeSubOther.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
return viewFragment;
|
return viewFragment;
|
||||||
}
|
}
|
||||||
@@ -78,7 +73,10 @@ public class ReportWF_1_Fragment extends Fragment{
|
|||||||
private void checkIfFinished(){
|
private void checkIfFinished(){
|
||||||
boolean isFinished = isMandatoryCategoryFilled && (incident != null) && (incident.getPosition() != null);
|
boolean isFinished = isMandatoryCategoryFilled && (incident != null) && (incident.getPosition() != null);
|
||||||
|
|
||||||
if(isMandatoryCategoryFilled) viewFragment.findViewById(R.id.ll_pos).setVisibility(View.VISIBLE);
|
if(isMandatoryCategoryFilled){
|
||||||
|
viewFragment.findViewById(R.id.ll_pos).setVisibility(View.VISIBLE);
|
||||||
|
((ReportWFActivity)getActivity()).setMapButtonVisibility(true);
|
||||||
|
}
|
||||||
|
|
||||||
mCallbackFinished.onInputFinished(isFinished);
|
mCallbackFinished.onInputFinished(isFinished);
|
||||||
}
|
}
|
||||||
@@ -151,7 +149,7 @@ public class ReportWF_1_Fragment extends Fragment{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
int i = 0;
|
int i = 99;
|
||||||
|
|
||||||
switch (((Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_main)).getSelectedItemPosition()) {
|
switch (((Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_main)).getSelectedItemPosition()) {
|
||||||
case VIOLANCE_GENERAL:
|
case VIOLANCE_GENERAL:
|
||||||
@@ -203,16 +201,9 @@ public class ReportWF_1_Fragment extends Fragment{
|
|||||||
private void initLayerPosition(){
|
private void initLayerPosition(){
|
||||||
timeLayout = (RelativeLayout) viewFragment.findViewById(R.id.ll_pos);
|
timeLayout = (RelativeLayout) viewFragment.findViewById(R.id.ll_pos);
|
||||||
timeLayout.setVisibility(View.INVISIBLE);
|
timeLayout.setVisibility(View.INVISIBLE);
|
||||||
|
((ReportWFActivity)getActivity()).setMapButtonVisibility(false);
|
||||||
|
|
||||||
btnPositionSearch = (BootstrapButton) viewFragment.findViewById(R.id.btn_reportwf_position);
|
|
||||||
txtPositionInformation = (TextView) viewFragment.findViewById(R.id.lbl_reportwf_position_detail);
|
txtPositionInformation = (TextView) viewFragment.findViewById(R.id.lbl_reportwf_position_detail);
|
||||||
|
|
||||||
btnPositionSearch.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
mCallbackMapListener.onCallMap();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -225,6 +216,7 @@ public class ReportWF_1_Fragment extends Fragment{
|
|||||||
if(incident.getPosition() != null){
|
if(incident.getPosition() != null){
|
||||||
timeLayout.setVisibility(View.VISIBLE);
|
timeLayout.setVisibility(View.VISIBLE);
|
||||||
txtPositionInformation.setText(incident.getIncidentPositionDescription());
|
txtPositionInformation.setText(incident.getIncidentPositionDescription());
|
||||||
|
((ReportWFActivity)getActivity()).setMapButtonVisibility(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(incident.getFidIncidentCategory() != 0){
|
if(incident.getFidIncidentCategory() != 0){
|
||||||
@@ -235,7 +227,7 @@ public class ReportWF_1_Fragment extends Fragment{
|
|||||||
crimeSubCategory.setSelection(incident.getFidIncidentSubCategory());
|
crimeSubCategory.setSelection(incident.getFidIncidentSubCategory());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(incident.getEtcIncidentCategory() != null){
|
if(!incident.getEtcIncidentCategory().toString().equals("")){
|
||||||
crimeSubOther.setText(incident.getEtcIncidentCategory());
|
crimeSubOther.setText(incident.getEtcIncidentCategory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,7 +253,6 @@ public class ReportWF_1_Fragment extends Fragment{
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mCallbackFinished = (OnInputFinishedListener) activity;
|
mCallbackFinished = (OnInputFinishedListener) activity;
|
||||||
mCallbackMapListener = (OnCallMapListener) activity;
|
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
throw new ClassCastException(activity.toString()
|
throw new ClassCastException(activity.toString()
|
||||||
+ " must implement all Listeners");
|
+ " must implement all Listeners");
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ public class ReportWF_2_Fragment extends Fragment {
|
|||||||
viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.INVISIBLE);
|
viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.INVISIBLE);
|
||||||
viewFragment.findViewById(R.id.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE);
|
viewFragment.findViewById(R.id.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
incident.setFromDate(new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()));
|
inputDateFrom.setText(new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()));
|
||||||
incident.setFromTime(new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
|
inputTimeFrom.setText(new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
|
||||||
|
|
||||||
isMandatoryCategoryFilled = true;
|
isMandatoryCategoryFilled = true;
|
||||||
break;
|
break;
|
||||||
@@ -195,8 +195,6 @@ public class ReportWF_2_Fragment extends Fragment {
|
|||||||
checkIfFinished();
|
checkIfFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
incident.setFidTimeCategory(position);
|
incident.setFidTimeCategory(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,30 +48,33 @@ public class Top10Fragment extends Fragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
view = inflater.inflate(R.layout.fragment_top10list, container, false);
|
view = inflater.inflate(R.layout.fragment_top10list, container, false);
|
||||||
parent = (ProfileActivity)getActivity();
|
parent = (ProfileActivity)getActivity();
|
||||||
Log.d(TAG,"Top10ListActivated!");
|
|
||||||
myListView = (ListView) view.findViewById(R.id.lv_top10list);
|
myListView = (ListView) view.findViewById(R.id.lv_top10list);
|
||||||
|
|
||||||
StringRequest strReq2 = getStringRequestTop10();
|
if(resultList == null || resultList.size() == 0) getTop10ForList();
|
||||||
String tag_string_req2 = "req_top10";
|
|
||||||
AppController.getInstance().addToRequestQueue(strReq2, tag_string_req2);
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getTop10ForList() {
|
||||||
|
StringRequest strReq2 = getStringRequestTop10();
|
||||||
|
String tag_string_req2 = "req_top10";
|
||||||
|
AppController.getInstance().addToRequestQueue(strReq2, tag_string_req2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private StringRequest getStringRequestTop10() {
|
private StringRequest getStringRequestTop10() {
|
||||||
parent.showDialog();
|
|
||||||
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(String response) {
|
public void onResponse(String response) {
|
||||||
Log.d(TAG, "Top 10 stats: " + response);
|
Log.d(TAG, "Top 10 stats: " + response);
|
||||||
parent.hideDialog();
|
|
||||||
try {
|
try {
|
||||||
JSONObject jObj = new JSONObject(response);
|
JSONObject jObj = new JSONObject(response);
|
||||||
boolean error = jObj.getBoolean("error");
|
boolean error = jObj.getBoolean("error");
|
||||||
if (!error) {
|
if (!error) {
|
||||||
JSONArray users = jObj.getJSONArray("top10");
|
JSONArray users = jObj.getJSONArray("msg");
|
||||||
resultList = new ArrayList<>();
|
resultList = new ArrayList<>();
|
||||||
|
|
||||||
for(int i=0;i<users.length();i++){
|
for(int i=0;i<users.length();i++){
|
||||||
@@ -101,7 +104,7 @@ public class Top10Fragment extends Fragment {
|
|||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error getting top 10 stats: " + error.getMessage());
|
Log.e(TAG, "Error getting top 10 stats: " + error.getMessage());
|
||||||
parent.showMessage(getString(R.string.errormsg_couldnotretrieve));
|
parent.showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||||
parent.hideDialog();
|
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
|
|||||||
@@ -5,28 +5,28 @@ import android.app.ProgressDialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.location.LocationListener;
|
||||||
|
import android.location.LocationManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.support.v4.view.LayoutInflaterCompat;
|
import android.support.v4.view.LayoutInflaterCompat;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.google.android.gms.ads.AdListener;
|
import com.google.android.gms.ads.AdListener;
|
||||||
import com.google.android.gms.ads.AdRequest;
|
import com.google.android.gms.ads.AdRequest;
|
||||||
import com.google.android.gms.ads.InterstitialAd;
|
import com.google.android.gms.ads.InterstitialAd;
|
||||||
import com.google.android.gms.common.ConnectionResult;
|
|
||||||
import com.google.android.gms.common.api.GoogleApiClient;
|
import com.google.android.gms.common.api.GoogleApiClient;
|
||||||
import com.google.android.gms.plus.Plus;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||||
import com.mikepenz.iconics.context.IconicsLayoutInflater;
|
import com.mikepenz.iconics.context.IconicsLayoutInflater;
|
||||||
import com.mikepenz.materialdrawer.AccountHeader;
|
import com.mikepenz.materialdrawer.AccountHeader;
|
||||||
@@ -47,7 +47,6 @@ import org.deke.risk.riskahead.ReportWFActivity;
|
|||||||
import org.deke.risk.riskahead.SettingsActivity;
|
import org.deke.risk.riskahead.SettingsActivity;
|
||||||
import org.deke.risk.riskahead.SubscriptionsActivity;
|
import org.deke.risk.riskahead.SubscriptionsActivity;
|
||||||
import org.deke.risk.riskahead.ViewReportActivity;
|
import org.deke.risk.riskahead.ViewReportActivity;
|
||||||
import org.deke.risk.riskahead.fragment.GooglePlusButtonFragment;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@@ -73,9 +72,16 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
InterstitialAd mInterstitialAd;
|
InterstitialAd mInterstitialAd;
|
||||||
|
|
||||||
private AccountHeader headerResult = null;
|
private AccountHeader headerResult = null;
|
||||||
public Drawer result = null;
|
public Drawer navDrawer = null;
|
||||||
public Toolbar mToolbar;
|
public Toolbar mToolbar;
|
||||||
|
|
||||||
|
public Handler mNotifyHandler = new Handler();
|
||||||
|
public final static int INTERVAL_NOTIFICATION = 1000 * 60; //20 seconds
|
||||||
|
|
||||||
|
public LocationManager locationManager;
|
||||||
|
public LatLng myPosition;
|
||||||
|
|
||||||
|
|
||||||
public void userHasToBeLoggedIn(){
|
public void userHasToBeLoggedIn(){
|
||||||
if (!session.isLoggedIn()) {
|
if (!session.isLoggedIn()) {
|
||||||
logout();
|
logout();
|
||||||
@@ -93,6 +99,56 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(getLayoutResourceId());
|
setContentView(getLayoutResourceId());
|
||||||
|
|
||||||
|
initAds();
|
||||||
|
initProgressDialog();
|
||||||
|
|
||||||
|
session = new SessionManager(getApplicationContext());
|
||||||
|
user = session.getUserDetails();
|
||||||
|
|
||||||
|
mToolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||||
|
setSupportActionBar(mToolbar);
|
||||||
|
initNavigationDrawer(savedInstanceState);
|
||||||
|
|
||||||
|
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
LocationListener locationListener = new MyLocationListener();
|
||||||
|
locationManager.requestLocationUpdates(
|
||||||
|
LocationManager.NETWORK_PROVIDER, 5000, 10, locationListener);
|
||||||
|
|
||||||
|
overridePendingTransition(R.anim.fade_in_anim, R.anim.fade_out_anim);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class MyLocationListener implements LocationListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLocationChanged(Location loc) {
|
||||||
|
|
||||||
|
String longitude = "Longitude: " + loc.getLongitude();
|
||||||
|
Log.v(TAG, longitude);
|
||||||
|
String latitude = "Latitude: " + loc.getLatitude();
|
||||||
|
Log.v(TAG, latitude);
|
||||||
|
|
||||||
|
myPosition = new LatLng(loc.getLatitude(),loc.getLongitude());
|
||||||
|
session.setLocation(Double.doubleToRawLongBits(loc.getLatitude()),Double.doubleToRawLongBits(loc.getLongitude()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderDisabled(String provider) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProviderEnabled(String provider) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStatusChanged(String provider, int status, Bundle extras) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initProgressDialog() {
|
||||||
|
pDialog = new ProgressDialog(this);
|
||||||
|
pDialog.setCancelable(false);
|
||||||
|
pDialog.setTitle(getString(R.string.progress_getdata_title));
|
||||||
|
pDialog.setMessage(getString(R.string.progress_getdata_text));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAds() {
|
||||||
mInterstitialAd = new InterstitialAd(getApplicationContext());
|
mInterstitialAd = new InterstitialAd(getApplicationContext());
|
||||||
mInterstitialAd.setAdUnitId(getString(R.string.banner_ad_unit_id));
|
mInterstitialAd.setAdUnitId(getString(R.string.banner_ad_unit_id));
|
||||||
|
|
||||||
@@ -104,24 +160,8 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
requestNewInterstitial();
|
requestNewInterstitial();
|
||||||
|
|
||||||
overridePendingTransition(R.anim.fade_in_anim, R.anim.fade_out_anim);
|
|
||||||
|
|
||||||
pDialog = new ProgressDialog(this);
|
|
||||||
pDialog.setCancelable(false);
|
|
||||||
pDialog.setTitle(getString(R.string.progress_getdata_title));
|
|
||||||
pDialog.setMessage(getString(R.string.progress_getdata_text));
|
|
||||||
|
|
||||||
session = new SessionManager(getApplicationContext());
|
|
||||||
user = session.getUserDetails();
|
|
||||||
|
|
||||||
//initToolbar();
|
|
||||||
mToolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
||||||
setSupportActionBar(mToolbar);
|
|
||||||
initNavigationDrawer(savedInstanceState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initNavigationDrawer(Bundle savedInstanceState) {
|
private void initNavigationDrawer(Bundle savedInstanceState) {
|
||||||
PrimaryDrawerItem item1 = new PrimaryDrawerItem()
|
PrimaryDrawerItem item1 = new PrimaryDrawerItem()
|
||||||
.withName(R.string.navigation_start)
|
.withName(R.string.navigation_start)
|
||||||
@@ -166,7 +206,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
result = new DrawerBuilder()
|
navDrawer = new DrawerBuilder()
|
||||||
.withActivity(this)
|
.withActivity(this)
|
||||||
.withAccountHeader(headerResult)
|
.withAccountHeader(headerResult)
|
||||||
.withTranslucentStatusBar(true)
|
.withTranslucentStatusBar(true)
|
||||||
@@ -284,7 +324,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.menu_common, menu);
|
getMenuInflater().inflate(R.menu.menu_common, menu);
|
||||||
@@ -311,7 +350,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void gotoMapActivity(){
|
public void gotoMapActivity(){
|
||||||
Intent intent;
|
Intent intent;
|
||||||
intent = new Intent(BaseActivity.this, MapsActivity.class);
|
intent = new Intent(BaseActivity.this, MapsActivity.class);
|
||||||
@@ -378,6 +416,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
protected abstract String getActivityName();
|
protected abstract String getActivityName();
|
||||||
|
|
||||||
|
|
||||||
public void showDialog() {
|
public void showDialog() {
|
||||||
if (!pDialog.isShowing())
|
if (!pDialog.isShowing())
|
||||||
pDialog.show();
|
pDialog.show();
|
||||||
|
|||||||
@@ -17,56 +17,56 @@ import org.json.JSONObject;
|
|||||||
*/
|
*/
|
||||||
public class IncidentReport implements ClusterItem {
|
public class IncidentReport implements ClusterItem {
|
||||||
|
|
||||||
private int id;
|
private int id = 0;
|
||||||
private LatLng incidentPosition;
|
private LatLng incidentPosition;
|
||||||
private String incidentPositionDescription;
|
private String incidentPositionDescription = "";
|
||||||
|
|
||||||
private int fidFromUser;
|
private int fidFromUser = 0;
|
||||||
private String fromUsername;
|
private String fromUsername = "";
|
||||||
|
|
||||||
private int votedScore;
|
private int votedScore = 0;
|
||||||
|
|
||||||
private String createdAt;
|
private String createdAt = "";
|
||||||
private String updatedAt;
|
private String updatedAt = "";
|
||||||
|
|
||||||
private int fidIncidentCategory;
|
private int fidIncidentCategory = 0;
|
||||||
private int fidIncidentSubCategory;
|
private int fidIncidentSubCategory = 0;
|
||||||
private String etcIncidentCategory;
|
private String etcIncidentCategory = "";
|
||||||
|
|
||||||
private int fidTimeCategory;
|
private int fidTimeCategory = 0;
|
||||||
private int fidTimeSubCategory;
|
private int fidTimeSubCategory = 0;
|
||||||
private String fromTime;
|
private String fromTime = "";
|
||||||
private String fromDate;
|
private String fromDate = "";
|
||||||
private String toTime;
|
private String toTime = "";
|
||||||
private String toDate;
|
private String toDate = "";
|
||||||
|
|
||||||
private int fidSuspectCategory;
|
private int fidSuspectCategory = 0;
|
||||||
private int fidSuspectSubCategory;
|
private int fidSuspectSubCategory = 0;
|
||||||
private String etcSuspectCategory;
|
private String etcSuspectCategory = "";
|
||||||
|
|
||||||
private int fidSuspectWeaponCategory;
|
private int fidSuspectWeaponCategory = 0;
|
||||||
private int fidSuspectWeaponSubCategory;
|
private int fidSuspectWeaponSubCategory = 0;
|
||||||
private String etcSuspectWeaponCategory;
|
private String etcSuspectWeaponCategory = "";
|
||||||
|
|
||||||
private int fidSuspectCountCategory;
|
private int fidSuspectCountCategory = 0;
|
||||||
private String etcSuspectCountCategory;
|
private String etcSuspectCountCategory = "";
|
||||||
|
|
||||||
private int fidVictimCategory;
|
private int fidVictimCategory = 0;
|
||||||
|
|
||||||
private int fidVictimOriginCategory;
|
private int fidVictimOriginCategory = 0;
|
||||||
private String etcVictimOriginCategory;
|
private String etcVictimOriginCategory = "";
|
||||||
|
|
||||||
private int fidSuspectTransportationCategory;
|
private int fidSuspectTransportationCategory = 0;
|
||||||
private String etcSuspectTransportationCategory;
|
private String etcSuspectTransportationCategory = "";
|
||||||
|
|
||||||
private int fidVictimBelongingCategory;
|
private int fidVictimBelongingCategory = 0;
|
||||||
private String etcVictimBelongingCategory;
|
private String etcVictimBelongingCategory = "";
|
||||||
|
|
||||||
private int fidSuspectCharacteristicsCategory;
|
private int fidSuspectCharacteristicsCategory = 0;
|
||||||
private String etcSuspectCharacteristicsCategory;
|
private String etcSuspectCharacteristicsCategory = "";
|
||||||
|
|
||||||
private int fidOthersCategory;
|
private int fidOthersCategory = 0;
|
||||||
private String etcOthersCategory;
|
private String etcOthersCategory = "";
|
||||||
|
|
||||||
public IncidentReport(JSONObject mIncident, LatLng position) {
|
public IncidentReport(JSONObject mIncident, LatLng position) {
|
||||||
setAllAttributes(mIncident, position);
|
setAllAttributes(mIncident, position);
|
||||||
@@ -90,47 +90,46 @@ public class IncidentReport implements ClusterItem {
|
|||||||
this.incidentPosition = new LatLng(mIncident.getDouble("latitude"),mIncident.getDouble("longitude"));
|
this.incidentPosition = new LatLng(mIncident.getDouble("latitude"),mIncident.getDouble("longitude"));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.votedScore = mIncident.getInt("score");
|
if(mIncident.has("created_at")) this.createdAt = mIncident.getString("created_at");
|
||||||
this.createdAt = mIncident.getString("created_at");
|
if(mIncident.has("updated_at")) this.updatedAt = mIncident.getString("updated_at");
|
||||||
this.updatedAt = mIncident.getString("updated_at");
|
|
||||||
this.fromUsername = mIncident.getString("username");
|
|
||||||
|
|
||||||
this.fidFromUser = mIncident.getInt("fid_user");
|
if(mIncident.has("upvoted") && mIncident.has("downvoted")) this.votedScore = mIncident.getInt("upvoted") - mIncident.getInt("downvoted");
|
||||||
|
if(mIncident.has("username")) this.fromUsername = mIncident.getString("username");
|
||||||
|
|
||||||
|
if(mIncident.has("fid_user")) this.fidFromUser = mIncident.getInt("fid_user");
|
||||||
this.fidIncidentCategory = mIncident.getInt("fid_incident");
|
this.fidIncidentCategory = mIncident.getInt("fid_incident");
|
||||||
this.fidIncidentSubCategory = mIncident.getInt("fid_subincident");
|
this.fidIncidentSubCategory = mIncident.getInt("fid_subincident");
|
||||||
this.etcIncidentCategory = mIncident.getString("etc_incident");
|
if(mIncident.has("etc_incident")) this.etcIncidentCategory = mIncident.getString("etc_incident");
|
||||||
this.fidTimeCategory = mIncident.getInt("fid_time");
|
this.fidTimeCategory = mIncident.getInt("fid_time");
|
||||||
this.fidTimeSubCategory = mIncident.getInt("fid_subtime");
|
this.fidTimeSubCategory = mIncident.getInt("fid_subtime");
|
||||||
this.fromTime = mIncident.getString("happened_from_datetime").split(" ")[1];
|
this.fromTime = mIncident.getString("happened_from_datetime").split(" ")[1];
|
||||||
this.fromDate = mIncident.getString("happened_from_datetime").split(" ")[0];
|
this.fromDate = mIncident.getString("happened_from_datetime").split(" ")[0];
|
||||||
this.toTime = mIncident.getString("happened_to_datetime").split(" ")[1];
|
this.toTime = mIncident.getString("happened_to_datetime").split(" ")[1];
|
||||||
this.toDate = mIncident.getString("happened_to_datetime").split(" ")[0];
|
this.toDate = mIncident.getString("happened_to_datetime").split(" ")[0];
|
||||||
this.fidSuspectCategory = mIncident.getInt("fid_suspect");
|
if(mIncident.has("fid_suspect")) this.fidSuspectCategory = mIncident.getInt("fid_suspect");
|
||||||
this.fidSuspectSubCategory = mIncident.getInt("fid_subsuspect");
|
if(mIncident.has("fid_subsuspect")) this.fidSuspectSubCategory = mIncident.getInt("fid_subsuspect");
|
||||||
this.etcSuspectCategory = mIncident.getString("etc_suspect");
|
if(mIncident.has("etc_suspect")) this.etcSuspectCategory = mIncident.getString("etc_suspect");
|
||||||
this.fidSuspectWeaponCategory = mIncident.getInt("fid_weapon");
|
if(mIncident.has("fid_weapon")) this.fidSuspectWeaponCategory = mIncident.getInt("fid_weapon");
|
||||||
this.fidSuspectWeaponSubCategory = mIncident.getInt("fid_subweapon");
|
if(mIncident.has("fid_subweapon")) this.fidSuspectWeaponSubCategory = mIncident.getInt("fid_subweapon");
|
||||||
this.etcSuspectWeaponCategory = mIncident.getString("etc_weapon");
|
if(mIncident.has("etc_weapon")) this.etcSuspectWeaponCategory = mIncident.getString("etc_weapon");
|
||||||
this.fidSuspectCountCategory = mIncident.getInt("fid_suspectcount");
|
if(mIncident.has("fid_suspectcount")) this.fidSuspectCountCategory = mIncident.getInt("fid_suspectcount");
|
||||||
this.etcSuspectCountCategory = mIncident.getString("etc_suspectcount");
|
if(mIncident.has("etc_suspectcount")) this.etcSuspectCountCategory = mIncident.getString("etc_suspectcount");
|
||||||
this.fidVictimCategory = mIncident.getInt("fid_victim");
|
if(mIncident.has("fid_victim")) this.fidVictimCategory = mIncident.getInt("fid_victim");
|
||||||
this.fidVictimOriginCategory = mIncident.getInt("fid_victimorigin");
|
if(mIncident.has("fid_victimorigin")) this.fidVictimOriginCategory = mIncident.getInt("fid_victimorigin");
|
||||||
this.etcVictimOriginCategory = mIncident.getString("etc_victimorigin");
|
if(mIncident.has("etc_victimorigin")) this.etcVictimOriginCategory = mIncident.getString("etc_victimorigin");
|
||||||
this.fidSuspectTransportationCategory = mIncident.getInt("fid_suspecttransportation");
|
if(mIncident.has("fid_suspecttransportation")) this.fidSuspectTransportationCategory = mIncident.getInt("fid_suspecttransportation");
|
||||||
this.etcSuspectTransportationCategory = mIncident.getString("etc_suspecttransportation");
|
if(mIncident.has("etc_suspecttransportation")) this.etcSuspectTransportationCategory = mIncident.getString("etc_suspecttransportation");
|
||||||
this.fidVictimBelongingCategory = mIncident.getInt("fid_victimbelonging");
|
if(mIncident.has("fid_victimbelonging")) this.fidVictimBelongingCategory = mIncident.getInt("fid_victimbelonging");
|
||||||
this.etcVictimBelongingCategory = mIncident.getString("etc_victimbelonging");
|
if(mIncident.has("etc_victimbelonging")) this.etcVictimBelongingCategory = mIncident.getString("etc_victimbelonging");
|
||||||
this.fidSuspectCharacteristicsCategory = mIncident.getInt("fid_suspectcharacteristics");
|
if(mIncident.has("fid_suspectcharacteristics")) this.fidSuspectCharacteristicsCategory = mIncident.getInt("fid_suspectcharacteristics");
|
||||||
this.etcSuspectCharacteristicsCategory = mIncident.getString("etc_suspectcharacteristics");
|
if(mIncident.has("etc_suspectcharacteristics")) this.etcSuspectCharacteristicsCategory = mIncident.getString("etc_suspectcharacteristics");
|
||||||
this.fidOthersCategory = mIncident.getInt("fid_others");
|
if(mIncident.has("fid_others")) this.fidOthersCategory = mIncident.getInt("fid_others");
|
||||||
this.etcOthersCategory = mIncident.getString("etc_others");
|
if(mIncident.has("etc_others")) this.etcOthersCategory = mIncident.getString("etc_others");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public BitmapDescriptor getIcon() {
|
public BitmapDescriptor getIcon() {
|
||||||
BitmapDescriptor mIcon;
|
BitmapDescriptor mIcon;
|
||||||
|
|
||||||
@@ -191,28 +190,28 @@ public class IncidentReport implements ClusterItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getScoreStars() {
|
public float getScoreStars() {
|
||||||
if(this.votedScore > 0){
|
if(this.votedScore < 0){
|
||||||
|
return 0.0f;
|
||||||
|
}else if(this.votedScore < 1){
|
||||||
return 0.5f;
|
return 0.5f;
|
||||||
}else if(this.votedScore > 1){
|
}else if(this.votedScore < 2){
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}else if(this.votedScore > 2){
|
}else if(this.votedScore < 3){
|
||||||
return 1.5f;
|
return 1.5f;
|
||||||
}else if(this.votedScore > 3){
|
}else if(this.votedScore < 4){
|
||||||
return 2.0f;
|
return 2.0f;
|
||||||
}else if(this.votedScore > 4){
|
}else if(this.votedScore < 5){
|
||||||
return 2.5f;
|
return 2.5f;
|
||||||
}else if(this.votedScore > 5){
|
}else if(this.votedScore < 6){
|
||||||
return 3.0f;
|
return 3.0f;
|
||||||
}else if(this.votedScore > 6){
|
}else if(this.votedScore < 7){
|
||||||
return 3.5f;
|
return 3.5f;
|
||||||
}else if(this.votedScore > 7){
|
}else if(this.votedScore < 8){
|
||||||
return 4.0f;
|
return 4.0f;
|
||||||
}else if(this.votedScore > 8){
|
}else if(this.votedScore < 9){
|
||||||
return 4.5f;
|
return 4.5f;
|
||||||
}else if(this.votedScore > 9){
|
|
||||||
return 5.0f;
|
|
||||||
}else{
|
}else{
|
||||||
return 0f;
|
return 5.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +288,11 @@ public class IncidentReport implements ClusterItem {
|
|||||||
String returnString = "";
|
String returnString = "";
|
||||||
switch (this.fidTimeCategory){
|
switch (this.fidTimeCategory){
|
||||||
case 1:
|
case 1:
|
||||||
|
if((this.fromDate != null) && !(this.fromDate.equals("0000-00-00"))){
|
||||||
|
returnString = this.fromDate+" "+this.fromTime;
|
||||||
|
}else{
|
||||||
returnString = context.getResources().getStringArray(R.array.cat_time_main)[this.fidTimeCategory-1];
|
returnString = context.getResources().getStringArray(R.array.cat_time_main)[this.fidTimeCategory-1];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
returnString = context.getResources().getStringArray(R.array.cat_time_sub_periodical)[this.fidTimeSubCategory-1];
|
returnString = context.getResources().getStringArray(R.array.cat_time_sub_periodical)[this.fidTimeSubCategory-1];
|
||||||
@@ -316,7 +319,12 @@ public class IncidentReport implements ClusterItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getSuspectString(Context context){
|
public String getSuspectString(Context context){
|
||||||
|
if(this.fidSuspectCategory > 0){
|
||||||
return context.getResources().getStringArray(R.array.cat_suspect_main)[this.fidSuspectCategory-1];
|
return context.getResources().getStringArray(R.array.cat_suspect_main)[this.fidSuspectCategory-1];
|
||||||
|
}else{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCategoryColor(){
|
public int getCategoryColor(){
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class SessionManager {
|
public class SessionManager {
|
||||||
@@ -35,6 +37,11 @@ public class SessionManager {
|
|||||||
public static final String TOKEN = "accesskey";
|
public static final String TOKEN = "accesskey";
|
||||||
public static final String KEY_IS_LOGGEDIN = "isLoggedIn";
|
public static final String KEY_IS_LOGGEDIN = "isLoggedIn";
|
||||||
|
|
||||||
|
public static final String KEY_LOCATION_LAT = "location_latitude";
|
||||||
|
public static final String KEY_LOCATION_LNG = "location_longitude";
|
||||||
|
|
||||||
|
public static final String KEY_LAST_NOTIFICATION = "lastNotificationTime";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public SessionManager(Context context) {
|
public SessionManager(Context context) {
|
||||||
@@ -54,6 +61,25 @@ public class SessionManager {
|
|||||||
return status.getBoolean(KEY_IS_LOGGEDIN, false);
|
return status.getBoolean(KEY_IS_LOGGEDIN, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLocation(Long latitude, Long longitude){
|
||||||
|
statusEditor.putLong(KEY_LOCATION_LAT, latitude);
|
||||||
|
statusEditor.putLong(KEY_LOCATION_LNG, longitude);
|
||||||
|
statusEditor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LatLng getLocation(){
|
||||||
|
return new LatLng(Double.longBitsToDouble(status.getLong(KEY_LOCATION_LAT, 0)), Double.longBitsToDouble(status.getLong(KEY_LOCATION_LNG, 0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastNotification(String time){
|
||||||
|
statusEditor.putString(KEY_LAST_NOTIFICATION, time);
|
||||||
|
statusEditor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLastNotification(){
|
||||||
|
return status.getString(KEY_LAST_NOTIFICATION, "");
|
||||||
|
}
|
||||||
|
|
||||||
public void addUser(String uid, String username, String name, String surname, String email, String status, String provider_type, String created_at, String updated_at, String lastlogin_at, String token) {
|
public void addUser(String uid, String username, String name, String surname, String email, String status, String provider_type, String created_at, String updated_at, String lastlogin_at, String token) {
|
||||||
|
|
||||||
userDataEditor.putString(KEY_UID, uid); //UID
|
userDataEditor.putString(KEY_UID, uid); //UID
|
||||||
|
|||||||
@@ -8,6 +8,6 @@
|
|||||||
android:repeatCount="0" />
|
android:repeatCount="0" />
|
||||||
</set>-->
|
</set>-->
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="@android:integer/config_shortAnimTime"/>
|
<translate android:fromXDelta="100%p" android:toXDelta="0" android:duration="@android:integer/config_mediumAnimTime"/>
|
||||||
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="@android:integer/config_shortAnimTime" />
|
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="@android:integer/config_mediumAnimTime" />
|
||||||
</set>
|
</set>
|
||||||
@@ -8,6 +8,6 @@
|
|||||||
android:repeatCount="0" />
|
android:repeatCount="0" />
|
||||||
</set>-->
|
</set>-->
|
||||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="@android:integer/config_shortAnimTime"/>
|
<translate android:fromXDelta="0" android:toXDelta="-100%p" android:duration="@android:integer/config_mediumAnimTime"/>
|
||||||
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="@android:integer/config_shortAnimTime" />
|
<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="@android:integer/config_mediumAnimTime" />
|
||||||
</set>
|
</set>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 167 KiB After Width: | Height: | Size: 87 KiB |
@@ -1,6 +1,7 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:bootstrap="http://schemas.android.com/apk/res-auto"
|
xmlns:bootstrap="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/main_layout"
|
android:id="@+id/main_layout"
|
||||||
android:background="@drawable/layout_bg_gradient"
|
android:background="@drawable/layout_bg_gradient"
|
||||||
@@ -22,13 +23,26 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
<fragment
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:id="@+id/frag_maps_map"
|
android:id="@+id/frag_maps_map"
|
||||||
android:name="com.google.android.gms.maps.SupportMapFragment"
|
android:name="com.google.android.gms.maps.SupportMapFragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".MapsActivity" />
|
tools:context=".MapsActivity" >
|
||||||
|
</fragment>
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab_reportwf_map"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:tint="@color/white"
|
||||||
|
android:src="@android:drawable/ic_input_add"
|
||||||
|
app:layout_anchor="@+id/frag_maps_map"
|
||||||
|
android:layout_marginLeft="15dp"
|
||||||
|
android:layout_marginBottom="50dp"
|
||||||
|
app:layout_anchorGravity="bottom|left|end"
|
||||||
|
android:layout_alignParentBottom="true"/>
|
||||||
|
|
||||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||||
android:id="@+id/btn_maps_confirm_position"
|
android:id="@+id/btn_maps_confirm_position"
|
||||||
@@ -40,8 +54,11 @@
|
|||||||
bootstrap:bootstrapBrand="danger"
|
bootstrap:bootstrapBrand="danger"
|
||||||
bootstrap:bootstrapText="@string/btn_maps_confirm_position"
|
bootstrap:bootstrapText="@string/btn_maps_confirm_position"
|
||||||
bootstrap:roundedCorners="true" />
|
bootstrap:roundedCorners="true" />
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:bootstrap="http://schemas.android.com/apk/res-auto"
|
xmlns:bootstrap="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
@@ -34,14 +35,26 @@
|
|||||||
android:id="@+id/fragment_reportwf"
|
android:id="@+id/fragment_reportwf"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center_horizontal" >
|
||||||
|
|
||||||
|
<android.support.design.widget.FloatingActionButton
|
||||||
|
android:id="@+id/fab_reportwf_map"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="16dp"
|
||||||
|
android:clickable="true"
|
||||||
|
android:src="@android:drawable/ic_dialog_map"
|
||||||
|
app:layout_anchor="@+id/layoutStatus"
|
||||||
|
app:layout_anchorGravity="top|right|end"
|
||||||
|
android:layout_gravity="right|bottom" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<com.beardedhen.androidbootstrap.AwesomeTextView
|
<com.beardedhen.androidbootstrap.AwesomeTextView
|
||||||
android:id="@+id/atvStatus"
|
android:id="@+id/atvStatus"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_centerInParent="true"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:textSize="50dp"
|
android:textSize="50dp"
|
||||||
bootstrap:bootstrapBrand="success"
|
bootstrap:bootstrapBrand="success"
|
||||||
|
|||||||
@@ -37,103 +37,37 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/lbl_viewreport_short"
|
android:id="@+id/til_viewreport_incidentcategory"
|
||||||
android:text="@string/lbl_report_short"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignLeft="@+id/input_viewreport_short"
|
|
||||||
android:layout_alignStart="@+id/input_viewreport_short" />
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/input_viewreport_short"
|
android:id="@+id/txt_viewreport_incidentcategory"
|
||||||
android:inputType="text"
|
android:hint="@string/lbl_viewreport_incidentcategory"
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:layout_marginTop="20dp" />
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<TextView
|
</android.support.design.widget.TextInputLayout>
|
||||||
android:id="@+id/lbl_viewreport_long"
|
|
||||||
android:text="@string/lbl_report_long"
|
<android.support.design.widget.TextInputLayout
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/til_viewreport_incidentsubcategory"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_below="@+id/til_viewreport_incidentcategory">
|
||||||
android:layout_below="@+id/input_viewreport_short" />
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/input_viewreport_long"
|
android:id="@+id/txt_viewreport_incidentsubcategory"
|
||||||
android:inputType="textMultiLine"
|
android:hint="@string/lbl_viewreport_incidentsubcategory"
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="top|left"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:layout_below="@+id/lbl_viewreport_long"
|
|
||||||
android:scrollbars="vertical"
|
|
||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
android:minLines="1"
|
android:layout_width="match_parent"
|
||||||
android:lines="4"
|
android:layout_height="wrap_content" />
|
||||||
android:maxLines="4" />
|
|
||||||
|
|
||||||
<TextView
|
</android.support.design.widget.TextInputLayout>
|
||||||
android:id="@+id/lbl_viewreport_category"
|
|
||||||
android:text="@string/lbl_report_category"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_below="@+id/input_viewreport_long" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/input_viewreport_category"
|
|
||||||
android:enabled="false"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/lbl_viewreport_category" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/lbl_viewreport_date"
|
|
||||||
android:text="@string/lbl_report_date"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_below="@+id/input_viewreport_category" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/lbl_viewreport_time"
|
|
||||||
android:text="@string/lbl_report_time"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_above="@+id/input_viewreport_time"
|
|
||||||
android:layout_alignLeft="@+id/input_viewreport_time"
|
|
||||||
android:layout_alignStart="@+id/input_viewreport_time" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/input_viewreport_date"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:inputType="date"
|
|
||||||
android:enabled="false"
|
|
||||||
android:ems="10"
|
|
||||||
android:layout_below="@+id/lbl_viewreport_date"
|
|
||||||
android:layout_alignLeft="@+id/lbl_viewreport_date"
|
|
||||||
android:layout_alignStart="@+id/lbl_viewreport_date"
|
|
||||||
android:focusable="false" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/input_viewreport_time"
|
|
||||||
android:enabled="false"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:inputType="time"
|
|
||||||
android:ems="10"
|
|
||||||
android:layout_alignBottom="@+id/input_viewreport_date"
|
|
||||||
android:layout_toRightOf="@+id/input_viewreport_date"
|
|
||||||
android:layout_toEndOf="@+id/input_viewreport_date"
|
|
||||||
android:focusable="false" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/lbl_viewreport_position"
|
android:id="@+id/lbl_viewreport_position"
|
||||||
@@ -141,21 +75,9 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:layout_below="@+id/input_viewreport_date"
|
android:layout_below="@+id/til_viewreport_incidentsubcategory" />
|
||||||
android:layout_alignLeft="@+id/input_viewreport_date"
|
|
||||||
android:layout_alignStart="@+id/input_viewreport_time" />
|
|
||||||
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/input_viewreport_position"
|
|
||||||
android:enabled="false"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/lbl_viewreport_position"
|
|
||||||
android:layout_toRightOf="@+id/lbl_viewreport_category"
|
|
||||||
android:layout_toEndOf="@+id/lbl_viewreport_category"
|
|
||||||
android:editable="false" />
|
|
||||||
|
|
||||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||||
android:id="@+id/btn_viewreport_position"
|
android:id="@+id/btn_viewreport_position"
|
||||||
android:layout_marginTop="3dp"
|
android:layout_marginTop="3dp"
|
||||||
@@ -169,15 +91,17 @@
|
|||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentStart="true" />
|
android:layout_alignParentStart="true" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/txt_viewreport_position"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:layout_marginLeft="31dp"
|
||||||
android:id="@+id/lbl_viewreport_position_detail"
|
android:layout_alignBaseline="@+id/btn_viewreport_position"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignBottom="@+id/btn_viewreport_position"
|
||||||
android:layout_below="@+id/input_viewreport_position"
|
android:layout_toRightOf="@+id/lbl_viewreport_position"
|
||||||
android:layout_alignLeft="@+id/input_viewreport_position"
|
android:layout_toEndOf="@+id/lbl_viewreport_position"
|
||||||
android:layout_alignStart="@+id/input_viewreport_position" />
|
android:layout_marginStart="31dp" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
|
|||||||
@@ -57,7 +57,6 @@
|
|||||||
<EditText
|
<EditText
|
||||||
android:layout_width="300dp"
|
android:layout_width="300dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="invisible"
|
|
||||||
android:hint="Please enter your info here"
|
android:hint="Please enter your info here"
|
||||||
android:id="@+id/txt_reportwf_1_cat_etc"
|
android:id="@+id/txt_reportwf_1_cat_etc"
|
||||||
android:layout_below="@id/dd_reportwf_1_cat_sub" />
|
android:layout_below="@id/dd_reportwf_1_cat_sub" />
|
||||||
@@ -80,28 +79,17 @@
|
|||||||
android:textColor="@color/bg_common" />
|
android:textColor="@color/bg_common" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="200dp"
|
android:layout_width="250dp"
|
||||||
android:layout_height="70dp"
|
android:layout_height="70dp"
|
||||||
android:background="@drawable/layout_bg"
|
android:background="@drawable/layout_bg"
|
||||||
android:hint="No position choosen yet"
|
android:hint="No position choosen yet"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:id="@+id/lbl_reportwf_position_detail"
|
android:id="@+id/lbl_reportwf_position_detail"
|
||||||
android:layout_alignTop="@+id/btn_reportwf_position"
|
android:layout_below="@+id/lbl_reportwf_1_question_2"
|
||||||
android:layout_toRightOf="@+id/btn_reportwf_position"
|
android:layout_centerInParent="true"
|
||||||
android:layout_marginLeft="20dp" />
|
android:layout_marginLeft="20dp" />
|
||||||
|
|
||||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
|
||||||
android:id="@+id/btn_reportwf_position"
|
|
||||||
android:layout_marginTop="3dp"
|
|
||||||
bootstrap:bootstrapText="@string/btn_report_position"
|
|
||||||
android:layout_below="@+id/lbl_reportwf_1_question_2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
bootstrap:bootstrapBrand="primary"
|
|
||||||
bootstrap:roundedCorners="true"
|
|
||||||
bootstrap:bootstrapSize="lg"
|
|
||||||
android:layout_alignParentLeft="true"
|
|
||||||
android:layout_alignParentStart="true" />
|
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
@@ -63,7 +63,6 @@
|
|||||||
android:id="@+id/lbl_report_from_date"
|
android:id="@+id/lbl_report_from_date"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/dd_report_category"
|
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:text="@string/lbl_report_from_date" />
|
android:text="@string/lbl_report_from_date" />
|
||||||
|
|
||||||
@@ -111,7 +110,6 @@
|
|||||||
android:id="@+id/lbl_report_to_date"
|
android:id="@+id/lbl_report_to_date"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/dd_report_category"
|
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:text="@string/lbl_report_to_date" />
|
android:text="@string/lbl_report_to_date" />
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,6 @@
|
|||||||
<EditText
|
<EditText
|
||||||
android:layout_width="300dp"
|
android:layout_width="300dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="invisible"
|
|
||||||
android:hint="Please enter your info here"
|
android:hint="Please enter your info here"
|
||||||
android:id="@+id/txt_reportwf_3_suspect_etc"
|
android:id="@+id/txt_reportwf_3_suspect_etc"
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center_horizontal" />
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
android:textColor="#a6000000"
|
android:textColor="#a6000000"
|
||||||
android:id="@+id/txt_infowindow_category"
|
android:id="@+id/txt_infowindow_category"
|
||||||
android:text="Headerfffffffffffffffffffffffffffffffff"
|
android:text="Loading Header..."
|
||||||
android:textSize="18dp"
|
android:textSize="18dp"
|
||||||
android:paddingLeft="30dp"
|
android:paddingLeft="30dp"
|
||||||
android:typeface="serif"
|
android:typeface="serif"
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:typeface="serif"
|
android:typeface="serif"
|
||||||
android:textColor="#b9000000"
|
android:textColor="#b9000000"
|
||||||
android:text="subcategory"
|
android:text="Loading subcategory..."
|
||||||
android:paddingTop="10dp"
|
android:paddingTop="10dp"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:id="@+id/txt_infowindow_subcategory"
|
android:id="@+id/txt_infowindow_subcategory"
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#b9000000"
|
android:textColor="#b9000000"
|
||||||
android:text="subject"
|
android:text="Loading subject..."
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:id="@+id/txt_infowindow_subject"
|
android:id="@+id/txt_infowindow_subject"
|
||||||
android:typeface="serif" />
|
android:typeface="serif" />
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#b9000000"
|
android:textColor="#b9000000"
|
||||||
android:text="victim"
|
android:text="Loading victim..."
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:id="@+id/txt_infowindow_victim"
|
android:id="@+id/txt_infowindow_victim"
|
||||||
android:typeface="serif" />
|
android:typeface="serif" />
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#b9000000"
|
android:textColor="#b9000000"
|
||||||
android:text="time"
|
android:text="Loading time..."
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
android:id="@+id/txt_infowindow_time"
|
android:id="@+id/txt_infowindow_time"
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#b9000000"
|
android:textColor="#b9000000"
|
||||||
android:text="username"
|
android:text="Loading username..."
|
||||||
android:id="@+id/txt_infowindow_fromuser"
|
android:id="@+id/txt_infowindow_fromuser"
|
||||||
android:typeface="serif" />
|
android:typeface="serif" />
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor="#b9000000"
|
android:textColor="#b9000000"
|
||||||
android:text="points:"
|
android:text="Loading points..."
|
||||||
android:id="@+id/txt_infowindow_points"
|
android:id="@+id/txt_infowindow_points"
|
||||||
android:typeface="serif" />
|
android:typeface="serif" />
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,8 @@
|
|||||||
<string name="lbl_report_from_time">From time</string>
|
<string name="lbl_report_from_time">From time</string>
|
||||||
<string name="lbl_report_to_date">To date (yyyy-MM-dd)</string>
|
<string name="lbl_report_to_date">To date (yyyy-MM-dd)</string>
|
||||||
<string name="lbl_report_to_time">To time</string>
|
<string name="lbl_report_to_time">To time</string>
|
||||||
|
<string name="lbl_viewreport_incidentcategory">Incident Category</string>
|
||||||
|
<string name="lbl_viewreport_incidentsubcategory">Incident Subcategory</string>
|
||||||
|
|
||||||
<string-array name="cat_situation_main">
|
<string-array name="cat_situation_main">
|
||||||
<item>Allgemeiner Vorfall/Situation</item>
|
<item>Allgemeiner Vorfall/Situation</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user