DT @10.01.2016: Icons verändert, Subscription hinzugefügt, Profile von anderen Usern einsehbar. Release 1.3

This commit is contained in:
Dennis Thießen
2016-01-10 22:26:32 +01:00
parent bdcef68772
commit f44042efa8
125 changed files with 1384 additions and 814 deletions

View File

@@ -1,6 +1,7 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintCommitPrefEdits" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="AndroidLintRtlCompat" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="AndroidLintValidFragment" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">

2
.idea/modules.xml generated
View File

@@ -2,8 +2,8 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/RiskAhead.iml" filepath="$PROJECT_DIR$/RiskAhead.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/riskAhead.iml" filepath="$PROJECT_DIR$/riskAhead.iml" />
</modules>
</component>
</project>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="riskAhead" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id="RiskAhead" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>

Binary file not shown.

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="riskAhead" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="RiskAhead" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
@@ -96,6 +96,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/release" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />

View File

@@ -19,8 +19,8 @@ android {
applicationId "org.deke.risk.riskahead"
minSdkVersion 15
targetSdkVersion 22
versionCode 3
versionName "1.2"
versionCode 4
versionName "1.3"
}
buildTypes {
release {

View File

@@ -25,6 +25,7 @@ import org.deke.risk.riskahead.helper.AppConfig;
import org.deke.risk.riskahead.helper.AppController;
import org.deke.risk.riskahead.helper.SessionManager;
import org.deke.risk.riskahead.helper.TextValidator;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -40,13 +41,9 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
private final static String TAG = LoginActivity.class.getSimpleName();
private String msg_intent;
private Button btn_login;
private TextView input_email;
private TextView input_username;
private TextView input_password;
private TextView btn_requestPW;
private ProgressDialog pDialog;
private SessionManager session;
@@ -58,17 +55,17 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
session = new SessionManager(getApplicationContext());
initProgressDialog();
handleIntentAndInitView();
initSocialLoginButtons();
initMyLoginButton();
}
private void handleIntentAndInitView() {
Intent intent = getIntent();
msg_intent = intent.getStringExtra(AppConfig.EXTRA_MESSAGE);
String msg_intent = intent.getStringExtra(AppConfig.EXTRA_MESSAGE);
if(msg_intent.equals(AppConfig.INTENT_NORMALLOGIN)){
if(msg_intent.equals(AppConfig.INTENT_LOGIN)){
initLoginView();
}else if(msg_intent.equals(AppConfig.INTENT_REGISTER)){
initRegisterView();
@@ -86,7 +83,24 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
input_email = (TextView) findViewById(R.id.input_register_email);
input_password = (TextView) findViewById(R.id.input_register_password);
btn_requestPW = (TextView) findViewById(R.id.lbl_login_resendPW);
TextView btn_requestPW = (TextView) findViewById(R.id.lbl_login_resendPW);
Button btn_login = (Button) findViewById(R.id.btn_login);
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = input_email.getText().toString();
String password = input_password.getText().toString();
if (input_password.getError() != null || input_email.getError() != null) {
showMessage(getString(R.string.error_validation));
} else {
showDialog();
performLogin(email, password);
}
}
});
input_email.addTextChangedListener(new TextValidator(input_email, getApplicationContext()) {
@Override
@@ -120,6 +134,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
input_username = (TextView) findViewById(R.id.input_register_name);
input_email = (TextView) findViewById(R.id.input_register_email);
input_password = (TextView) findViewById(R.id.input_register_password);
Button btn_login = (Button) findViewById(R.id.btn_register);
input_username.addTextChangedListener(new TextValidator(input_username,getApplicationContext()) {
@Override
@@ -147,11 +162,28 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
}
}
});
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String email = input_email.getText().toString();
String password = input_password.getText().toString();
String name = input_username.getText().toString();
if (input_password.getError() != null || input_email.getError() != null || input_username.getError() != null) {
showMessage(getString(R.string.error_validation));
} else {
showDialog();
performRegistration(name, email, password);
}
}
});
}
private void initSocialLoginButtons() {
FragmentManager fragmentManager = getSupportFragmentManager();
FacebookButtonFragment fragmentFB = new FacebookButtonFragment();
//FacebookButtonFragment fragmentFB = new FacebookButtonFragment();
new FacebookButtonFragment();
GooglePlusButtonFragment fragmentGP = new GooglePlusButtonFragment();
FragmentTransaction transaction = fragmentManager.beginTransaction();
@@ -159,36 +191,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
transaction.commit();
}
private void initMyLoginButton() {
btn_login = (Button) findViewById(R.id.btn_register);
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (v.getId() == R.id.btn_register) {
String email = input_email.getText().toString();
String password = input_password.getText().toString();
if (msg_intent.equals("login")) {
if (input_password.getError() != null || input_email.getError() != null) {
showMessage(getString(R.string.error_validation));
} else {
showDialog();
performLogin(email, password);
}
} else if (msg_intent.equals("register")) {
String name = input_username.getText().toString();
if (input_password.getError() != null || input_email.getError() != null || input_username.getError() != null) {
showMessage(getString(R.string.error_validation));
} else {
showDialog();
performRegistration(name, email, password);
}
}
}
}
});
}
private void performLogin(final String email, final String password) {
String tag_string_req = "req_login";
StringRequest strReq = getStringRequestLogin(email, password);
@@ -220,7 +222,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
}
public void onRequestNewPasswordClick(View view){
if(input_email.getText() != null && input_email.getText().toString().isEmpty()){
if((input_email.getText() != null && input_email.getText().toString().isEmpty()) || (input_email.getError() != null)){
showMessage(getString(R.string.message_enteremail));
return;
}
@@ -275,7 +277,23 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
String providerType = user.getString("providerType");
String token = user.getString("accesskey");
session.addUser(id, username, name, surname, email, status, providerType, created_at, updated_at, lastlogin_at, token);
JSONArray jSubs = jObj.getJSONArray("subs");
boolean isPremium = false;
boolean isAdFree = false;
if(jSubs.length() > 0){
for(int i = 0; i < jSubs.length();i++) {
if(jSubs.getJSONObject(i).getString("productId").contains("extra_functions")){
isPremium = true;
}
if(jSubs.getJSONObject(i).getString("productId").contains("no_ads")){
isAdFree = true;
}
}
}
session.addUser(id, username, name, surname, email, status, providerType, created_at, updated_at, lastlogin_at, token,isPremium,isAdFree);
Intent intent = new Intent(
LoginActivity.this,
@@ -308,7 +326,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
protected Map<String, String> getParams() {
// Posting params to register url
Map<String, String> params = new HashMap<>();
params.put("tag", "sociallogin");
params.put("tag", AppConfig.REST_LOGIN_SOCIAL);
params.put("key", key);
params.put("providerType", providerType);
params.put("username", username);
@@ -346,6 +364,22 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
String token = user.getString("accesskey");
String providerType = "local";
JSONArray jSubs = user.getJSONArray("subs");
boolean isPremium = false;
boolean isAdFree = false;
if(jSubs.length() > 0){
for(int i = 0; i < jSubs.length();i++) {
if(jSubs.getJSONObject(i).getString("productId").contains("extra_functions")){
isPremium = true;
}
if(jSubs.getJSONObject(i).getString("productId").contains("no_ads")){
isAdFree = true;
}
}
}
if(status.equals("0")){
new AlertDialog.Builder(LoginActivity.this)
.setTitle(getString(R.string.alert_accactivation_title))
@@ -367,7 +401,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}else {
session.addUser(id, username, name, surname, email, status, providerType, created_at, updated_at, lastlogin_at, token);
session.addUser(id, username, name, surname, email, status, providerType, created_at, updated_at, lastlogin_at, token, isPremium, isAdFree);
session.setLogin(true);
hideDialog();
@@ -399,7 +433,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
protected Map<String, String> getParams() {
// Posting parameters to login url
Map<String, String> params = new HashMap<>();
params.put("tag", "login");
params.put("tag", AppConfig.REST_LOGIN);
params.put("email", email);
params.put("password", password);
@@ -457,9 +491,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
@Override
protected Map<String, String> getParams() {
// Posting params to register url
Map<String, String> params = new HashMap<>();
params.put("tag", "register");
params.put("tag", AppConfig.REST_REGISTER);
params.put("username", username);
params.put("email", email);
params.put("password", password);
@@ -505,9 +538,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
@Override
protected Map<String, String> getParams() {
// Posting params to register url
Map<String, String> params = new HashMap<>();
params.put("tag", "requestpwreset");
params.put("tag", AppConfig.REST_REQUESTPWRESET);
params.put("email", email);
return params;
@@ -550,7 +582,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "resendactivationusermail");
params.put("tag", AppConfig.REST_RESENDACTIVATIONMAIL);
params.put("email", email);
return params;
@@ -591,10 +623,10 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}else if((id == R.id.menu_action_about)){
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.riskahead.net/about/"));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(AppConfig.URL_ABOUT));
startActivity(browserIntent);
}else if((id == R.id.menu_action_help)){
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.riskahead.net/contact/"));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(AppConfig.URL_CONTACT));
startActivity(browserIntent);
}
@@ -620,6 +652,5 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
facebook_fragment.onActivityResult(requestCode, resultCode, data);
}
Log.d("Test", "GOT ACTIVITY RESULT!!!:" + requestCode + " : " + resultCode);
}
}

View File

@@ -1,10 +1,9 @@
package org.deke.risk.riskahead;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.widget.Button;
@@ -33,31 +32,18 @@ public class MainActivity extends BaseActivity{
private final static String mActivityTitle = "RiskAhead";
private final static String TAG = MainActivity.class.getSimpleName();
public String msg_input;
public static FragmentManager fragmentManager;
Handler mHandler = new Handler();
private final static int INTERVAL = 1000 * 20; //20 seconds
private TextView count;
private Button report;
private Button map;
private Handler mHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
userHasToBeLoggedIn();
count = (TextView) findViewById(R.id.txt_main_incidents);
initButtons();
}
Intent intent = getIntent();
msg_input = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
fragmentManager = getSupportFragmentManager();
report = (Button) findViewById(R.id.btn_main_report);
private void initButtons() {
Button report = (Button) findViewById(R.id.btn_main_report);
report.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -67,12 +53,12 @@ public class MainActivity extends BaseActivity{
Drawable reportIcon = new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_room)
.color(getResources().getColor(R.color.white))
.color(ContextCompat.getColor(getApplicationContext(),R.color.white))
.sizeDp(24);
report.setCompoundDrawables(reportIcon, null, null, null);
map = (Button) findViewById(R.id.btn_main_viewmap);
Button map = (Button) findViewById(R.id.btn_main_viewmap);
map.setOnClickListener(new View.OnClickListener() {
@Override
@@ -83,64 +69,27 @@ public class MainActivity extends BaseActivity{
Drawable mapIcon = new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_map)
.color(getResources().getColor(R.color.white))
.color(ContextCompat.getColor(getApplicationContext(), R.color.white))
.sizeDp(24);
map.setCompoundDrawables(null, null, mapIcon, null);
}
@Override
protected int getLayoutResourceId() {
return R.layout.activity_main;
}
@Override
protected String getActivityName() {
return mActivityTitle;
}
@Override
protected void onPause(){
super.onPause();
stopRepeatingTask();
}
@Override
protected void onDestroy(){
super.onDestroy();
}
@Override
protected void onResume(){
super.onResume();
navDrawer.setSelection(mainAvtivityID,false);
startRepeatingTask();
}
Runnable mHandlerTask = new Runnable()
{
@Override
public void run() {
StringRequest strReq = getStringRequestIncidentCount();
String tag_string_req = "req_incidents";
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
mHandler.postDelayed(mHandlerTask, INTERVAL);
requestNumberOfIncidents();
mHandler.postDelayed(mHandlerTask, AppConfig.UPDATE_COUNT_INTERVAL);
}
};
void startRepeatingTask()
{
mHandlerTask.run();
private void requestNumberOfIncidents() {
StringRequest strReq = getStringRequestIncidentCount();
String tag_string_req = "req_incidents";
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
void stopRepeatingTask()
{
mHandler.removeCallbacks(mHandlerTask);
}
private StringRequest getStringRequestIncidentCount() {
return new StringRequest(Request.Method.POST, AppConfig.URL_DEFAULT, new Response.Listener<String>() {
@@ -155,9 +104,8 @@ public class MainActivity extends BaseActivity{
if (!error) {
JSONObject jCount = jObj.getJSONObject("msg");
DecimalFormat nf = new DecimalFormat();
String decimalNumber = nf.format(jCount.getInt("total"));
count.setText(decimalNumber);
displayNumberOfIncidents(jCount);
} else {
String errorMsg = jObj.getString("error_msg");
Log.e(TAG, "Error getting incident count (server returned error): " + errorMsg);
@@ -180,11 +128,51 @@ public class MainActivity extends BaseActivity{
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "getincidentcount");
params.put("tag", AppConfig.REST_GET_NUMOFINCIDENTS);
params.put("uid", user.get(SessionManager.KEY_UID));
params.put("token", user.get(SessionManager.TOKEN));
return params;
}
};
}
private void displayNumberOfIncidents(JSONObject jCount) throws JSONException {
TextView count = (TextView) findViewById(R.id.txt_main_incidents);
DecimalFormat nf = new DecimalFormat();
String decimalNumber = nf.format(jCount.getInt("total"));
count.setText(decimalNumber);
}
void startRepeatingTask()
{
mHandlerTask.run();
}
void stopRepeatingTask()
{
mHandler.removeCallbacks(mHandlerTask);
}
@Override
protected void onResume(){
super.onResume();
navDrawer.setSelection(mainAvtivityID, false);
startRepeatingTask();
}
@Override
protected void onPause(){
super.onPause();
stopRepeatingTask();
}
@Override
protected int getLayoutResourceId() {
return R.layout.activity_main;
}
@Override
protected String getActivityName() {
return mActivityTitle;
}
}

View File

@@ -26,7 +26,8 @@ import com.android.volley.toolbox.StringRequest;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
@@ -57,34 +58,31 @@ import java.util.Map;
public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCallbacks<Cursor>,
ClusterManager.OnClusterItemInfoWindowClickListener<IncidentReport>, ClusterManager.OnClusterClickListener<IncidentReport>, ClusterManager.OnClusterItemClickListener<IncidentReport>{
ClusterManager.OnClusterItemInfoWindowClickListener<IncidentReport>, ClusterManager.OnClusterClickListener<IncidentReport>, ClusterManager.OnClusterItemClickListener<IncidentReport>, OnMapReadyCallback {
private final static String mActivityTitle = "Risk Map";
private static final String TAG = MapsActivity.class.getSimpleName();
private static final Double PRELOAD_PERCENTAGE = 0.3;
private static final int DEFAULT_ZOOM_LEVEL = 14;
private static final int THRESHOLD_ZOOM_LEVEL = 10;
private int MIN_ZOOM_LEVEL = 9;
private static GoogleMap mMap;
private Marker mMarker;
private Marker markerShowingInfoWindow;
private GoogleMap mMap;
private IncidentReport clickedClusterItem;
private ClusterManager<IncidentReport> mClusterManager;
private TileOverlay mOverlay;
private HeatmapTileProvider mProvider;
private Marker mMarker;
private Marker markerShowingInfoWindow;
private IncidentReport clickedClusterItem;
private LatLng myLocation;
private LatLng markedLocation;
private static final int DEFAULT_ZOOM_LEVEL = 14;
private static final int THRESHOLD_ZOOM_LEVEL = 10;
private static final int MIN_ZOOM_LEVEL = 7;
private LatLng curNortheastBounds;
private LatLng curSouthwestBounds;
private boolean markersShown = false;
@Override
@@ -92,19 +90,32 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
super.onCreate(savedInstanceState);
userHasToBeLoggedIn();
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.GONE);
navDrawer.setSelection(mapAvtivityID, false);
System.gc();
if(session.getSubsPremium()){
MIN_ZOOM_LEVEL = 7;
}else{
MIN_ZOOM_LEVEL = 9;
}
initMap();
handleIntent(getIntent());
initClustering();
MapFragment mapFragment = (MapFragment) getFragmentManager()
.findFragmentById(R.id.frag_maps_map);
mapFragment.getMapAsync(this);
findViewById(R.id.fab_reportwf_map).setVisibility(View.INVISIBLE);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
initMap();
handleIntent(getIntent());
initClustering();
}
@Override
public void onLowMemory() {
super.onLowMemory();
@@ -112,7 +123,6 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
}
private void initMap() {
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.frag_maps_map)).getMap();
mMap.getUiSettings().setZoomControlsEnabled(true);
mMap.setMyLocationEnabled(true);
@@ -127,7 +137,6 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_ZOOM_LEVEL));
findViewById(R.id.fab_reportwf_map).setVisibility(View.VISIBLE);
String intentMessage = getIntent().getStringExtra(EXTRA_MESSAGE);
if(session.getNotificationPositionRequest()){
findViewById(R.id.fab_reportwf_map).setOnClickListener(new View.OnClickListener() {
@Override
@@ -390,7 +399,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
}
private void initClustering() {
mClusterManager = new ClusterManager<IncidentReport>(this, mMap);
mClusterManager = new ClusterManager<>(this, mMap);
mMap.setOnCameraChangeListener(getCameraChangeListener());
mClusterManager.setRenderer(new OwnIconRendered(MapsActivity.this, mMap, mClusterManager));
@@ -476,12 +485,13 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
};
}
public class MyCustomAdapterForItems implements GoogleMap.InfoWindowAdapter {
private final View myContentsView;
MyCustomAdapterForItems() {
myContentsView = getLayoutInflater().inflate(R.layout.map_info_window, null);
myContentsView = View.inflate(getApplicationContext(), R.layout.map_info_window, null);
}
@Override
@@ -501,6 +511,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
TextView tvSuspect = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_subject));
TextView tvTime = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_time));
if (clickedClusterItem != null) {
loadInfoWindowInformation(myContentsView, Integer.toString(clickedClusterItem.getId()));
@@ -545,15 +556,19 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
}else{
String sDefSystemLanguage = Locale.getDefault().getLanguage();
if(sDefSystemLanguage.equals("en")){
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(51.507351, -0.127758), DEFAULT_ZOOM_LEVEL));
} else if (sDefSystemLanguage.equals("de")){
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(52.518594, 13.376188), DEFAULT_ZOOM_LEVEL));
} else {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(19.410704, -99.132385), DEFAULT_ZOOM_LEVEL));
switch (sDefSystemLanguage) {
case "en":
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(51.507351, -0.127758), DEFAULT_ZOOM_LEVEL));
break;
case "de":
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(52.518594, 13.376188), DEFAULT_ZOOM_LEVEL));
break;
default:
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(19.410704, -99.132385), DEFAULT_ZOOM_LEVEL));
break;
}
}
}

View File

@@ -1,11 +1,15 @@
package org.deke.risk.riskahead;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import org.deke.risk.riskahead.helper.AppConfig;
import org.deke.risk.riskahead.helper.BaseActivity;
import org.deke.risk.riskahead.adapter.ProfilePagerAdapter;
import org.deke.risk.riskahead.helper.SessionManager;
public class ProfileActivity extends BaseActivity{
@@ -17,6 +21,48 @@ public class ProfileActivity extends BaseActivity{
super.onCreate(savedInstanceState);
userHasToBeLoggedIn();
Intent intent = getIntent();
String msg_intent = intent.getStringExtra(AppConfig.EXTRA_MESSAGE);
if(msg_intent != null){
initProfileFromUserID(msg_intent);
}else{
initOwnProfileView();
}
}
private void initProfileFromUserID(String msg_intent) {
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Statistics"));
tabLayout.addTab(tabLayout.newTab().setText("Reports"));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final PagerAdapter adapter = new ProfilePagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount(), msg_intent);
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
private void initOwnProfileView() {
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Statistics"));
@@ -26,7 +72,7 @@ public class ProfileActivity extends BaseActivity{
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
final PagerAdapter adapter = new ProfilePagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
final PagerAdapter adapter = new ProfilePagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount(), user.get(SessionManager.KEY_UID));
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
@@ -46,8 +92,6 @@ public class ProfileActivity extends BaseActivity{
}
});
}
@Override

View File

@@ -85,6 +85,14 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initFragments();
initButtonsAndElements();
mPrefs = getPreferences(MODE_PRIVATE);
prefsEditor = mPrefs.edit();
}
private void initFragments() {
fragList.add(frag_report_1);
fragList.add(frag_report_2);
fragList.add(frag_report_3);
@@ -94,7 +102,9 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
fragList.add(frag_report_7);
fragList.add(frag_report_8);
fragList.add(frag_report_finish);
}
private void initButtonsAndElements() {
btnContinue = (BootstrapButton) findViewById(R.id.btn_reportwf_next);
btnContinue.setVisibility(View.INVISIBLE);
btnContinue.setOnClickListener(new View.OnClickListener() {
@@ -109,7 +119,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
btnReportNow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
reportIncident();
sendReport();
}
});
@@ -119,22 +129,35 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
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 {
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(){
String tag_string_req = "addincidentwithposition";
StringRequest strReq = getStringRequestAddIncidentWithPosition(incident);
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
private void initFragment(int state) {
findViewById(R.id.atvStatus).setVisibility(View.INVISIBLE);
currentState = state;
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_reportwf, fragList.get(state));
transaction.commit();
if(state > 1) btnReportNow.setVisibility(View.VISIBLE);
if(state == (fragList.size()-1)){
btnContinue.setVisibility(View.INVISIBLE);
btnReportNow.setVisibility(View.INVISIBLE);
siteIndicator.setVisibility(View.INVISIBLE);
}else{
siteIndicator.setVisibility(View.VISIBLE);
}
String currentSite = (currentState+1)+"/"+(fragList.size()-1);
siteIndicator.setText(currentSite);
}
private void resetStateAndIncident(){
@@ -172,8 +195,11 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
}
}
public IncidentReport getIncident(){
return incident;
@Override
public void sendReport() {
String tag_string_req = "addincidentwithposition";
StringRequest strReq = getStringRequestAddIncidentWithPosition(incident);
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
public void setIncident(IncidentReport newIncident){
@@ -184,34 +210,8 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
}
}
private void initFragment(int state) {
findViewById(R.id.atvStatus).setVisibility(View.INVISIBLE);
currentState = state;
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_reportwf, fragList.get(state));
transaction.commit();
if(state > 1) btnReportNow.setVisibility(View.VISIBLE);
if(state == (fragList.size()-1)){
btnContinue.setVisibility(View.INVISIBLE);
btnReportNow.setVisibility(View.INVISIBLE);
siteIndicator.setVisibility(View.INVISIBLE);
}else{
siteIndicator.setVisibility(View.VISIBLE);
}
String currentSite = (currentState+1)+"/"+(fragList.size()-1);
siteIndicator.setText(currentSite);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_reportwf, menu);
getMenuInflater().inflate(R.menu.menu_common, menu);
return true;
public IncidentReport getIncident(){
return incident;
}
@Override
@@ -233,36 +233,6 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
}
}
@Override
public void onStop(){
super.onStop();
if(!resetSignal){
Gson gson = new Gson();
prefsEditor.putString("incident", gson.toJson(incident));
prefsEditor.putInt("currentState", currentState);
prefsEditor.commit();
}
}
@Override
public void onResume(){
super.onResume();
Gson gson = new Gson();
if(!mPrefs.getString("incident", "").equals("")) incident = gson.fromJson(mPrefs.getString("incident", ""), IncidentReport.class);
Intent intent = getIntent();
String pos = intent.getStringExtra(EXTRA_MESSAGE);
if(pos != null) modifyPos(pos);
currentState = mPrefs.getInt("currentState",0);
initFragment(currentState);
navDrawer.setSelection(reportAvtivityID, false);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
@@ -298,6 +268,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
}
}
@Override
public void onBackPressed(){
if(currentState > 0) {
initFragment(currentState - 1);
@@ -348,7 +319,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "addincidentwithposition");
params.put("tag", AppConfig.REST_ADD_INCIDENT_WITHPOSITION);
params.put("uid", user.get(SessionManager.KEY_UID));
params.put("token", user.get(SessionManager.TOKEN));
params.put("latitude", Double.toString(incident.getPosition().latitude));
@@ -384,6 +355,45 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
};
}
@Override
public void onResume(){
super.onResume();
Gson gson = new Gson();
if(!mPrefs.getString("incident", "").equals("")) incident = gson.fromJson(mPrefs.getString("incident", ""), IncidentReport.class);
Intent intent = getIntent();
String pos = intent.getStringExtra(EXTRA_MESSAGE);
if(pos != null) modifyPos(pos);
currentState = mPrefs.getInt("currentState",0);
initFragment(currentState);
navDrawer.setSelection(reportAvtivityID, false);
}
@Override
public void onStop(){
super.onStop();
if(!resetSignal){
Gson gson = new Gson();
prefsEditor.putString("incident", gson.toJson(incident));
prefsEditor.putInt("currentState", currentState);
prefsEditor.commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_reportwf, menu);
getMenuInflater().inflate(R.menu.menu_common, menu);
return true;
}
@Override
protected int getLayoutResourceId() {
return R.layout.activity_report_wf;
@@ -393,9 +403,4 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
protected String getActivityName() {
return mActivityTitle;
}
@Override
public void sendReport() {
reportIncident();
}
}

View File

@@ -1,29 +1,41 @@
package org.deke.risk.riskahead;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import com.android.vending.billing.IInAppBillingService;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.beardedhen.androidbootstrap.BootstrapButton;
import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
import org.deke.risk.riskahead.helper.AppConfig;
import org.deke.risk.riskahead.helper.AppController;
import org.deke.risk.riskahead.helper.BaseActivity;
import org.deke.risk.riskahead.helper.SessionManager;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class SubscriptionsActivity extends BaseActivity{
@@ -37,12 +49,17 @@ public class SubscriptionsActivity extends BaseActivity{
ServiceConnection mServiceConn;
Bundle querySkus;
HashMap<String,JSONObject> purchaseMap = new HashMap<>();
HashMap<String,String> dbItems = new HashMap<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
userHasToBeLoggedIn();
tblBillings = (TableLayout) findViewById(R.id.tbl_billing);
getSubscriptions(user.get(SessionManager.KEY_UID));
ServiceConnection mServiceConn = new ServiceConnection() {
@Override
@@ -58,6 +75,7 @@ public class SubscriptionsActivity extends BaseActivity{
Log.d(TAG,"Connected to InApp Billing Service");
initBillingOptions();
getAlreadyPurchasedItems();
}
};
@@ -65,61 +83,100 @@ public class SubscriptionsActivity extends BaseActivity{
serviceIntent.setPackage("com.android.vending");
bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
ArrayList<String> skuList = new ArrayList<String>();
ArrayList<String> skuList = new ArrayList<>();
skuList.add("no_ads_01");
skuList.add("no_ads_02");
skuList.add("extra_functions_01");
skuList.add("extra_functions_02");
querySkus = new Bundle();
querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
}
private void getAlreadyPurchasedItems() {
try {
Bundle activeSubs = mService.getPurchases(3, getPackageName(),"subs", null);
int response = activeSubs.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList<String> ownedSkus = activeSubs.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
ArrayList<String> purchaseDataList = activeSubs.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
ArrayList<String> signatureList = activeSubs.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
String continuationToken = activeSubs.getString("INAPP_CONTINUATION_TOKEN");
for (int i = 0; i < purchaseDataList.size(); ++i) {
String purchaseData = purchaseDataList.get(i);
String signature = signatureList.get(i);
String sku = ownedSkus.get(i);
Log.d(TAG, "Already purchased: " + sku + " : " + purchaseData + " : " + signature);
}
syncWithDatabase(ownedSkus);
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
private void syncWithDatabase(ArrayList<String> ownedSkus) {
boolean itemFound = false;
if(dbItems.containsKey("extra_functions_01")){
for(String sku : ownedSkus){
itemFound = itemFound || sku.equals("extra_functions_01");
}
if(itemFound == false){
deactivateSubscriptions(dbItems.get("extra_functions_01"));
}
}
if(dbItems.containsKey("extra_functions_02")){
for(String sku : ownedSkus){
itemFound = itemFound || sku.equals("extra_functions_02");
}
if(itemFound == false){
deactivateSubscriptions(dbItems.get("extra_functions_02"));
}
}
if(dbItems.containsKey("no_ads_01")){
for(String sku : ownedSkus){
itemFound = itemFound || sku.equals("no_ads_01");
}
if(itemFound == false){
deactivateSubscriptions(dbItems.get("no_ads_01"));
}
}
if(dbItems.containsKey("no_ads_02")){
for(String sku : ownedSkus){
itemFound = itemFound || sku.equals("no_ads_02");
}
if(itemFound == false){
deactivateSubscriptions(dbItems.get("no_ads_02"));
}
}
}
private void initBillingOptions() {
try {
Bundle skuDetails = mService.getSkuDetails(3,
getPackageName(), "subs", querySkus);
Bundle skuDetails = mService.getSkuDetails(3, getPackageName(), "subs", querySkus);
int response = skuDetails.getInt("RESPONSE_CODE");
Log.d(TAG, "InApp Response_Code: " + response);
if (response == 0) {
ArrayList<String> responseList
= skuDetails.getStringArrayList("DETAILS_LIST");
ArrayList<String> responseList= skuDetails.getStringArrayList("DETAILS_LIST");
TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
for (String thisResponse : responseList) {
JSONObject object = new JSONObject(thisResponse);
TableRow tableRow = new TableRow(getApplicationContext());
tableRow.setLayoutParams(rowParams);
TextView textView = new TextView(getApplicationContext());
textView.setLayoutParams(rowParams);
textView.setText(object.getString("title"));
BootstrapButton btnPurchase = new BootstrapButton(getApplicationContext());
btnPurchase.setText(object.getString("price"));
btnPurchase.setLayoutParams(rowParams);
btnPurchase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG,"Purchase item");
}
});
tableRow.addView(textView);
tableRow.addView(btnPurchase);
tblBillings.addView(tableRow);
String sku = object.getString("productId");
String price = object.getString("price");
Log.d(TAG,"Product: "+sku+" Price: "+price);
}
initPurchaseTable(responseList);
}
@@ -130,14 +187,249 @@ public class SubscriptionsActivity extends BaseActivity{
}
}
private void initPurchaseTable(ArrayList<String> responseList) throws JSONException {
TableRow.LayoutParams rowParamsDescription = new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 0.7f);
rowParamsDescription.weight = 1.0f;
rowParamsDescription.gravity = Gravity.CENTER;
TableRow.LayoutParams rowParamsButton = new TableRow.LayoutParams(0, TableRow.LayoutParams.WRAP_CONTENT, 0.3f);
rowParamsDescription.setMargins(10,10,0,20);
rowParamsButton.setMargins(10,10,10,20);
for (String thisResponse : responseList) {
JSONObject object = new JSONObject(thisResponse);
final String sku = object.getString("productId");
String price = object.getString("price");
String title = object.getString("title");
purchaseMap.put(sku,object);
TableRow tableRow = new TableRow(getApplicationContext());
TextView textView = new TextView(getApplicationContext());
textView.setLayoutParams(rowParamsDescription);
textView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.md_black_1000));
textView.setText(title);
BootstrapButton btnPurchase = new BootstrapButton(getApplicationContext());
btnPurchase.setText(price);
btnPurchase.setLayoutParams(rowParamsButton);
btnPurchase.setRounded(true);
btnPurchase.setBootstrapBrand(DefaultBootstrapBrand.SUCCESS);
btnPurchase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "Purchase item: " + sku);
buyProduct(sku);
}
});
tableRow.addView(textView);
tableRow.addView(btnPurchase);
tblBillings.addView(tableRow);
Log.d(TAG,"Product: "+sku+" Price: "+price);
}
}
private void buyProduct(String sku) {
try {
Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "subs", user.get(SessionManager.KEY_UID));
PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
startIntentSenderForResult(pendingIntent.getIntentSender(),
1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0),
Integer.valueOf(0));
} catch (RemoteException e) {
e.printStackTrace();
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1001) {
int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
if (resultCode == RESULT_OK) {
try {
JSONObject jo = new JSONObject(purchaseData);
String sku = jo.getString("productId");
showMessage("You have bought the " + sku + ". Thank you for your support!");
addSubscription(purchaseMap.get(sku).getString("productId"),purchaseMap.get(sku).getString("type"),purchaseMap.get(sku).getString("price_amount_micros"),purchaseMap.get(sku).getString("price_currency_code"));
}
catch (JSONException e) {
showMessage("Failed to parse purchase data.");
e.printStackTrace();
}
}
}
}
private void addSubscription(String productId, String type, String price, String currency) {
String tag_string_req = "requestaddsubscription";
StringRequest strReq = getStringAddSubscription(productId, type, price, price);
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
private StringRequest getStringAddSubscription(final String productId, final String type, final String price, final String currency) {
return new StringRequest(Request.Method.POST, AppConfig.URL_DEFAULT, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (error) {
String errorMsg = jObj.getString("error_msg");
Log.e(TAG, "Error adding subscription (Server returned error): " + errorMsg);
} else {
getSubscriptions(user.get(SessionManager.KEY_UID));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Error adding subscription: " + error.getMessage());
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "addsubscription");
params.put("uid", user.get(SessionManager.KEY_UID));
params.put("token", user.get(SessionManager.TOKEN));
params.put("productid", productId);
params.put("type", type);
params.put("pricemicros", price);
params.put("currencycode", currency);
return params;
}
};
}
private void getSubscriptions(String userId) {
String tag_string_req = "requestgetsubscription";
StringRequest strReq = getStringGetSubscriptions(userId);
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
private StringRequest getStringGetSubscriptions(final String userId) {
return new StringRequest(Request.Method.POST, AppConfig.URL_DEFAULT, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (error) {
String errorMsg = jObj.getString("error_msg");
Log.e(TAG, "Error getting subscription (Server returned error): " + errorMsg);
dbItems = null;
}else{
JSONArray subs = jObj.getJSONArray("msg");
for(int i = 0;i < subs.length();i++){
dbItems.put(subs.getJSONObject(i).getString("productId"),subs.getJSONObject(i).getString("id"));
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Error getting subscription: " + error.getMessage());
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "getsubscriptions");
params.put("uid", user.get(SessionManager.KEY_UID));
params.put("token", user.get(SessionManager.TOKEN));
params.put("userid", userId);
return params;
}
};
}
private void deactivateSubscriptions(String subscriptionId) {
String tag_string_req = "requestdeactivatesubscription";
StringRequest strReq = getStringDeactivateSubscriptions(subscriptionId);
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
private StringRequest getStringDeactivateSubscriptions(final String subscriptionId) {
return new StringRequest(Request.Method.POST, AppConfig.URL_DEFAULT, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (error) {
String errorMsg = jObj.getString("error_msg");
Log.e(TAG, "Error deactivating subscription (Server returned error): " + errorMsg);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Error deactivating subscription: " + error.getMessage());
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "deactivatesubscription");
params.put("uid", user.get(SessionManager.KEY_UID));
params.put("token", user.get(SessionManager.TOKEN));
params.put("subid", subscriptionId);
return params;
}
};
}
@Override
protected void onResume() {
super.onResume();
navDrawer.setSelection(subscriptionsAvtivityID, false);
}
@Override
protected int getLayoutResourceId() {
return R.layout.activity_subscriptions;
@@ -149,7 +441,7 @@ public class SubscriptionsActivity extends BaseActivity{
@Override
public void onDestroy() {
super.onDestroy();
if (mService != null) {
if (mService != null && mServiceConn != null) {
unbindService(mServiceConn);
}
}

View File

@@ -4,9 +4,12 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
@@ -16,6 +19,8 @@ import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.beardedhen.androidbootstrap.BootstrapLabel;
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import org.deke.risk.riskahead.helper.AppConfig;
import org.deke.risk.riskahead.helper.AppController;
@@ -49,7 +54,7 @@ public class ViewReportActivity extends BaseActivity {
private EditText txtVictimAffiliation;
private EditText txtSuspectRecognition;
private EditText txtEtcEtc;
private EditText txtReportedFrom;
private BootstrapLabel scorelabel;
private IncidentReport incident;
@@ -73,6 +78,7 @@ public class ViewReportActivity extends BaseActivity {
txtVictimAffiliation = (EditText) findViewById(R.id.txt_viewreport_victimaff);
txtSuspectRecognition = (EditText) findViewById(R.id.txt_viewreport_suspectrecon);
txtEtcEtc = (EditText) findViewById(R.id.txt_viewreport_etcetc);
txtReportedFrom = (EditText) findViewById(R.id.txt_viewreport_reportedfrom);
Intent intent = getIntent();
final Integer id = intent.getIntExtra(BaseActivity.EXTRA_MESSAGE, 0);
@@ -269,6 +275,7 @@ public class ViewReportActivity extends BaseActivity {
txtVictimAffiliation.setText(checkIfTextEmptyAndReturnString(incident.getVictimAffiliationString(tmpContext)));
txtSuspectRecognition.setText(checkIfTextEmptyAndReturnString(incident.getSuspectRecognitionString(tmpContext)));
txtEtcEtc.setText(checkIfTextEmptyAndReturnString(incident.getEtcOthersCategory()));
txtReportedFrom.setText(incident.getFromUsername());
this.incident = incident;
@@ -294,6 +301,21 @@ public class ViewReportActivity extends BaseActivity {
final String latitude = Double.toString(incident.getPosition().latitude);
final String longitude = Double.toString(incident.getPosition().longitude);
final String fromUid = Integer.toString(incident.getFidFromUser());
Drawable identityIcon = new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_perm_identity)
.color(ContextCompat.getColor(getApplicationContext(), R.color.white))
.sizeDp(24);
((FloatingActionButton)findViewById(R.id.btn_viewreport_user)).setImageDrawable(identityIcon);
findViewById(R.id.btn_viewreport_user).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
gotoProfileActivity(fromUid);
}
});
findViewById(R.id.btn_viewreport_position).setOnClickListener(new View.OnClickListener() {
@Override

View File

@@ -1,8 +1,10 @@
package org.deke.risk.riskahead.adapter;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.util.Log;
import org.deke.risk.riskahead.fragment.ProfileStatisticsFragment;
import org.deke.risk.riskahead.fragment.ReportListFragment;
@@ -10,31 +12,69 @@ import org.deke.risk.riskahead.fragment.Top10Fragment;
public class ProfilePagerAdapter extends FragmentStatePagerAdapter {
int mNumOfTabs;
String userID;
public ProfilePagerAdapter(FragmentManager fm, int NumOfTabs) {
public ProfilePagerAdapter(FragmentManager fm, int NumOfTabs, String userID) {
super(fm);
this.mNumOfTabs = NumOfTabs;
this.userID = userID;
}
@Override
public Fragment getItem(int position) {
Fragment returnFragment;
switch (position) {
case 0:
returnFragment = new ProfileStatisticsFragment();
break;
case 1:
returnFragment = new Top10Fragment();
break;
case 2:
returnFragment = new ReportListFragment();
break;
default:
return null;
Fragment returnFragment = null;
if(mNumOfTabs == 2){
switch (position) {
case 0:
returnFragment = newProfileStatisticsInstance(userID);
break;
case 1:
returnFragment = newReportListInstance(userID);
break;
default:
return null;
}
}else if(mNumOfTabs == 3){
switch (position) {
case 0:
returnFragment = newProfileStatisticsInstance(userID);
break;
case 1:
returnFragment = new Top10Fragment();
break;
case 2:
returnFragment = newReportListInstance(userID);
break;
default:
return null;
}
}
return returnFragment;
}
public static Fragment newProfileStatisticsInstance(String uid) {
ProfileStatisticsFragment myFragment = new ProfileStatisticsFragment();
Bundle args = new Bundle();
args.putString("uid", uid);
myFragment.setArguments(args);
return myFragment;
}
public static Fragment newReportListInstance(String uid) {
ReportListFragment myFragment = new ReportListFragment();
Bundle args = new Bundle();
args.putString("uid", uid);
myFragment.setArguments(args);
return myFragment;
}
@Override
public int getCount() {
return mNumOfTabs;

View File

@@ -12,12 +12,16 @@ import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.beardedhen.androidbootstrap.BootstrapButton;
import com.beardedhen.androidbootstrap.api.attributes.BootstrapBrand;
import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
import org.deke.risk.riskahead.ProfileActivity;
import org.deke.risk.riskahead.R;
import org.deke.risk.riskahead.helper.AppConfig;
import org.deke.risk.riskahead.helper.AppController;
import org.deke.risk.riskahead.helper.SessionManager;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -35,11 +39,20 @@ public class ProfileStatisticsFragment extends Fragment {
private View view;
private ProfileActivity parent;
private String uid = "";
TextView points ;
TextView ranking ;
TextView posts ;
TextView txtMemberSince ;
TextView lblPoints;
TextView lblPosts;
TextView lblRanking;
TextView lblMemberSince;
BootstrapButton btnMembershipType;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_profile_stats, container, false);
@@ -50,6 +63,15 @@ public class ProfileStatisticsFragment extends Fragment {
posts = (TextView) view.findViewById(R.id.txt_profile_numberposts);
txtMemberSince = (TextView) view.findViewById(R.id.txt_profile_membersince);
lblPoints = (TextView) view.findViewById(R.id.lbl_profile_points);
lblRanking = (TextView) view.findViewById(R.id.lbl_profile_ranking);
lblPosts = (TextView) view.findViewById(R.id.lbl_profile_numberposts);
lblMemberSince = (TextView) view.findViewById(R.id.lbl_profile_membersince);
btnMembershipType = (BootstrapButton) view.findViewById(R.id.btn_profile_membershiptype);
uid = getArguments().getString("uid",parent.user.get(SessionManager.KEY_UID));
getProfileStatsForList();
return view;
@@ -72,13 +94,45 @@ public class ProfileStatisticsFragment extends Fragment {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (!error) {
jObj = jObj.getJSONObject("msg");
points.setText(jObj.getString("points"));
ranking.setText(jObj.getString("rank"));
posts.setText(jObj.getString("numberOfPosts"));
txtMemberSince.setText(parent.user.get("created_at"));
JSONArray jSubs = jObj.getJSONArray("subs");
boolean isPremium = false;
boolean isAdFree = false;
if(jSubs.length() == 0){
btnMembershipType.setBootstrapBrand(DefaultBootstrapBrand.SUCCESS);
btnMembershipType.setText(getResources().getString(R.string.lbl_membershiptype_free));
}else{
for(int i = 0; i < jSubs.length();i++) {
if(jSubs.getJSONObject(i).getString("productId").contains("extra_functions")){
isPremium = true;
}
if(jSubs.getJSONObject(i).getString("productId").contains("no_ads")){
isAdFree = true;
}
}
if(isPremium){
btnMembershipType.setBootstrapBrand(DefaultBootstrapBrand.WARNING);
btnMembershipType.setText(getResources().getString(R.string.lbl_membershiptype_premium));
}else if(isAdFree){
btnMembershipType.setBootstrapBrand(DefaultBootstrapBrand.PRIMARY);
btnMembershipType.setText(getResources().getString(R.string.lbl_membershiptype_addfree));
}
}
if(uid != parent.user.get(SessionManager.KEY_UID)){
lblPoints.setText(jObj.getString("username")+" "+getResources().getString(R.string.lbl_profile_points_someone));
lblPosts.setText(getResources().getString(R.string.lbl_profile_numofposts_me));
lblRanking.setText(getResources().getString(R.string.lbl_profile_ranking_someone));
lblMemberSince.setText(jObj.getString("username")+" "+getResources().getString(R.string.lbl_profile_membersince_someone));
}
} else {
String errorMsg = jObj.getString("error_msg");
Log.e(TAG, "Error getting user stats (server returned error): " + errorMsg);
@@ -100,9 +154,10 @@ public class ProfileStatisticsFragment extends Fragment {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "getuserstats");
params.put("tag", AppConfig.REST_GET_USERSTATS);
params.put("uid", parent.user.get(SessionManager.KEY_UID));
params.put("token", parent.user.get(SessionManager.TOKEN));
params.put("userstatsid", uid);
return params;
}

View File

@@ -44,11 +44,15 @@ public class ReportListFragment extends Fragment{
ListAdapter myListAdapter;
List<JSONObject> resultList;
private String uid = "";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_reportlist, container, false);
parent = (ProfileActivity)getActivity();
uid = getArguments().getString("uid",parent.user.get(SessionManager.KEY_UID));
myListView = (ListView) view.findViewById(R.id.lv_reportlist_list);
if(resultList == null || resultList.size() == 0) getIncidentsForList();
@@ -121,9 +125,10 @@ public class ReportListFragment extends Fragment{
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tag", "getincidentsfromuserid");
params.put("tag", AppConfig.REST_GET_INCIDENTS_FROMUSERID);
params.put("uid", parent.user.get(SessionManager.KEY_UID));
params.put("token", parent.user.get(SessionManager.TOKEN));
params.put("userincidentid", uid);
return params;
}

View File

@@ -281,8 +281,8 @@ public class ReportWF_8_Fragment extends Fragment {
public void onPause() {
super.onPause();
incident.setFidVictimOriginCategory(suspectVehicle.getSelectedItemPosition());
incident.setEtcVictimOriginCategory(suspectVehicleEtcInput.getText().toString());
incident.setFidSuspectTransportationCategory(suspectVehicle.getSelectedItemPosition());
incident.setEtcSuspectTransportationCategory(suspectVehicleEtcInput.getText().toString());
incident.setFidVictimBelongingCategory(victimAffiliation.getSelectedItemPosition());
incident.setEtcVictimBelongingCategory(victimAffiliationEtcInput.getText().toString());

View File

@@ -21,6 +21,7 @@ import org.deke.risk.riskahead.helper.AppConfig;
import org.deke.risk.riskahead.helper.AppController;
import org.deke.risk.riskahead.helper.SessionManager;
import org.deke.risk.riskahead.helper.ValidatedEditTextPreference;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -122,6 +123,14 @@ public class SettingsFragment extends PreferenceFragment {
return true;
}
});
if(!session.getSubsPremium()){
prefGPSENabled.setEnabled(false);
prefLocation.setEnabled(false);
prefGPSENabled.setTitle(prefGPSENabled.getTitle()+" (Only Premium)");
prefLocation.setTitle(prefLocation.getTitle()+" (Only Premium)");
}
}
private void initAccountPrefs() {
@@ -131,27 +140,6 @@ public class SettingsFragment extends PreferenceFragment {
prefEmail = (ValidatedEditTextPreference) getPreferenceManager().findPreference("emailPref");
btnRequestPW = getPreferenceManager().findPreference("resetPassword");
/*
prefUsername.getEditText().addTextChangedListener(new TextValidator(prefUsername.getEditText(), getActivity().getApplicationContext()) {
@Override
public void validate(TextView textView, String text) {
if (text.length() < 5) {
textView.setError("Your username must be at least\n" +
"5 characters in length.");
}
}
});
prefEmail.getEditText().addTextChangedListener(new TextValidator(prefEmail.getEditText(), getActivity().getApplicationContext()) {
@Override
public void validate(TextView textView, String text) {
if (!Patterns.EMAIL_ADDRESS.matcher(text).matches()) {
textView.setError("Please enter a valid email address\n" +
"e.g.: text@abc.de");
}
}
});
*/
Preference.OnPreferenceChangeListener changeListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
@@ -310,7 +298,24 @@ public class SettingsFragment extends PreferenceFragment {
if (!error) {
((SettingsActivity) getActivity()).showMessage(jObj.getString("msg"));
JSONObject tmpuser = jObj.getJSONObject("user");
((SettingsActivity) getActivity()).session.addUser(tmpuser.getString("id"), tmpuser.getString("username"), tmpuser.getString("name"), tmpuser.getString("surname"), tmpuser.getString("email"), tmpuser.getString("status"), user.get("providerType"), tmpuser.getString("created_at"), tmpuser.getString("updated_at"), tmpuser.getString("lastlogin_at"), tmpuser.getString("accesskey"));
JSONArray jSubs = tmpuser.getJSONArray("subs");
boolean isPremium = false;
boolean isAdFree = false;
if(jSubs.length() > 0){
for(int i = 0; i < jSubs.length();i++) {
if(jSubs.getJSONObject(i).getString("productId").contains("extra_functions")){
isPremium = true;
}
if(jSubs.getJSONObject(i).getString("productId").contains("no_ads")){
isAdFree = true;
}
}
}
((SettingsActivity) getActivity()).session.addUser(tmpuser.getString("id"), tmpuser.getString("username"), tmpuser.getString("name"), tmpuser.getString("surname"), tmpuser.getString("email"), tmpuser.getString("status"), user.get("providerType"), tmpuser.getString("created_at"), tmpuser.getString("updated_at"), tmpuser.getString("lastlogin_at"), tmpuser.getString("accesskey"),isPremium,isAdFree);
} else {
String errorMsg = jObj.getString("error_msg");

View File

@@ -6,6 +6,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListAdapter;
import android.widget.ListView;
@@ -51,6 +52,17 @@ public class Top10Fragment extends Fragment {
myListView = (ListView) view.findViewById(R.id.lv_top10list);
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parentview, View view, int position, long id) {
try {
parent.gotoProfileActivity(resultList.get(position).getString("id"));
} catch (JSONException e) {
e.printStackTrace();
}
}
});
if(resultList == null || resultList.size() == 0) getTop10ForList();
return view;

View File

@@ -4,13 +4,44 @@ package org.deke.risk.riskahead.helper;
* Created by Dennis on 09.08.2015.
*/
public class AppConfig {
public static String URL_ENCRYPTED = "https://www.riskahead.de/helper/rest/";
/** URLs **/
public final static String URL_ENCRYPTED = "https://www.riskahead.de/helper/rest/";
public final static String URL_DEFAULT = "http://www.riskahead.de/helper/rest/";
public static String URL_DEFAULT = "http://www.riskahead.de/helper/rest/";
public final static String URL_ABOUT = "http://www.riskahead.de/en/about/";
public final static String URL_CONTACT = "http://www.riskahead.de/en/contact-2/";
/** INTENT MESSAGES **/
public final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
public final static String INTENT_LOGIN = "login";
public final static String INTENT_REGISTER = "register";
public final static String INTENT_NORMALLOGIN = "normallogin";
public final static String INTENT_SOCIALMEDIALOGIN = "socialmedialogin";
/** HANDLER INTERVALS **/
public final static int UPDATE_COUNT_INTERVAL = 1000 * 30; //30 seconds
/** REST WEBSERVICE **/
public final static String REST_LOGIN = "login";
public final static String REST_LOGIN_SOCIAL = "sociallogin";
public final static String REST_REGISTER = "register";
public final static String REST_RESENDACTIVATIONMAIL = "resendactivationusermail";
public final static String REST_ACTIVATEUSER = "activateuser";
public final static String REST_REQUESTPWRESET = "requestpwreset";
public final static String REST_PERFORMPWRESET = "performpwreset";
public final static String REST_GET_NUMOFINCIDENTS = "getincidentcount";
public final static String REST_GET_ALLACTIVEINCIDENTS = "getallactiveincidents";
public final static String REST_GET_INCIDENTS_FROMBOUND = "getincidentsfrombound";
public final static String REST_GET_INCIDENTS_FROMBOUND_FORHEATMAP = "getincidentsforheatmapfrombound";
public final static String REST_GET_INCIDENTS_FROMUSERID = "getincidentsfromuserid";
public final static String REST_GET_INCIDENTS_FROMINCIDENTID = "getincidentfromincidentid";
public final static String REST_ADD_INCIDENT_WITHPOSITION = "addincidentwithposition";
public final static String REST_UPDATE_USER = "updateuser";
public final static String REST_GET_USERSTATS = "getuserstats";
public final static String REST_GET_INCIDENTS_FROMAREATIME = "getincidentsinareaandtime";
public final static String REST_GET_TOP10 = "gettop10";
public final static String REST_GET_VOTETYPES = "getvotetypes";
public final static String REST_ADD_VOTE = "addvote";
public final static String REST_DEACTIVATE_INCIDENT = "deactivateincident";
}

View File

@@ -13,7 +13,6 @@ import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.view.LayoutInflaterCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
@@ -224,7 +223,6 @@ public abstract class BaseActivity extends AppCompatActivity {
.withOnDrawerListener(new Drawer.OnDrawerListener() {
@Override
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle("Navigate to...");
}
@Override
@@ -298,8 +296,9 @@ public abstract class BaseActivity extends AppCompatActivity {
public void showAd(){
if (mInterstitialAd.isLoaded()) {
//TODO: ACTIVATE WHEN NEEDED
//mInterstitialAd.show();
if(!session.getSubsNoAds()){
mInterstitialAd.show();
}
}
}
@@ -379,6 +378,13 @@ public abstract class BaseActivity extends AppCompatActivity {
startActivity(intent);
}
public void gotoProfileActivity(String uid){
Intent intent;
intent = new Intent(getApplicationContext(), ProfileActivity.class);
intent.putExtra(EXTRA_MESSAGE, uid);
startActivity(intent);
}
public void gotoSettingsActivity(){
Intent intent;
intent = new Intent(getApplicationContext(), SettingsActivity.class);

View File

@@ -298,28 +298,55 @@ public class IncidentReport implements ClusterItem {
}
public String getIncidentSubCategoryName(Context context){
String returnName = "";
String returnValue = "";
String[] stringArray;
switch(this.fidIncidentCategory){
case 1:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_general)[this.fidIncidentSubCategory-1];
stringArray = context.getResources().getStringArray(R.array.cat_situation_sub_general);
returnValue = stringArray[this.fidIncidentSubCategory-1];
break;
case 2:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_verbal)[this.fidIncidentSubCategory-1];
stringArray = context.getResources().getStringArray(R.array.cat_situation_sub_verbal);
returnValue = stringArray[this.fidIncidentSubCategory-1];
break;
case 3:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_force)[this.fidIncidentSubCategory-1];
stringArray = context.getResources().getStringArray(R.array.cat_situation_sub_force);
returnValue = stringArray[this.fidIncidentSubCategory-1];
break;
case 4:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_force_serious)[this.fidIncidentSubCategory-1];
stringArray = context.getResources().getStringArray(R.array.cat_situation_sub_force_serious);
returnValue = stringArray[this.fidIncidentSubCategory-1];
break;
case 5:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_nature)[this.fidIncidentSubCategory-1];
stringArray = context.getResources().getStringArray(R.array.cat_situation_sub_nature);
returnValue = stringArray[this.fidIncidentSubCategory-1];
break;
case 6:
returnName = context.getResources().getStringArray(R.array.cat_situation_sub_infrastructure)[this.fidIncidentSubCategory-1];
stringArray = context.getResources().getStringArray(R.array.cat_situation_sub_infrastructure);
returnValue = stringArray[this.fidIncidentSubCategory-1];
break;
default:
stringArray = null;
returnValue = "";
break;
}
return returnName;
if(stringArray != null && (stringArray.length == this.fidIncidentSubCategory)){
returnValue = getEtcIncidentCategory();
}else if(stringArray != null){
returnValue = stringArray[this.fidIncidentSubCategory-1];
}
return returnValue;
}
public String getTimeString(Context context){
@@ -359,19 +386,39 @@ public class IncidentReport implements ClusterItem {
}
public String getSuspectString(Context context){
String returnValue = "";
String[] stringArray;
if(this.fidSuspectCategory > 0){
return context.getResources().getStringArray(R.array.cat_suspect_main)[this.fidSuspectCategory-1];
stringArray = context.getResources().getStringArray(R.array.cat_suspect_main);
returnValue = stringArray[this.fidSuspectCategory-1];
}else{
return "";
stringArray = null;
returnValue = "";
}
if(stringArray != null && (stringArray.length == this.fidIncidentSubCategory)){
returnValue = getEtcSuspectCategory();
}else if(stringArray != null){
returnValue = stringArray[this.fidIncidentSubCategory-1];
}
return returnValue;
}
public String getVictimString(Context context){
String returnValue = "";
String[] stringArray;
if(this.fidVictimCategory > 0){
return context.getResources().getStringArray(R.array.cat_victim)[this.fidVictimCategory-1];
stringArray = context.getResources().getStringArray(R.array.cat_victim);
returnValue = stringArray[this.fidVictimCategory-1];
}else{
return "";
stringArray = null;
returnValue = "";
}
return returnValue;
}
public int getCategoryColor(){
@@ -401,54 +448,126 @@ public class IncidentReport implements ClusterItem {
public String getSuspectWeaponsString(Context context) {
String returnValue = "";
String[] stringArray;
if(fidSuspectWeaponCategory != 0) returnValue = context.getResources().getStringArray(R.array.cat_suspect_weapons)[fidSuspectWeaponCategory-1];
if(!etcSuspectWeaponCategory.equals("")) returnValue += "\n"+etcSuspectWeaponCategory;
if(this.fidSuspectWeaponCategory > 0){
stringArray = context.getResources().getStringArray(R.array.cat_suspect_weapons);
returnValue = stringArray[this.fidSuspectWeaponCategory-1];
}else{
stringArray = null;
returnValue = "";
}
if(stringArray != null && (stringArray.length == this.fidSuspectWeaponCategory)){
returnValue = etcSuspectWeaponCategory;
}else if(stringArray != null){
returnValue = stringArray[this.fidSuspectWeaponCategory-1];
}
return returnValue;
}
public String getSuspectNoOfString(Context context) {
String returnValue = "";
String[] stringArray;
if(fidSuspectCountCategory != 0) returnValue = context.getResources().getStringArray(R.array.cat_suspect_count)[fidSuspectCountCategory-1];
if(!etcSuspectCountCategory.equals("")) returnValue += "\n"+etcSuspectCountCategory;
if(this.fidSuspectCountCategory > 0){
stringArray = context.getResources().getStringArray(R.array.cat_suspect_count);
returnValue = stringArray[this.fidSuspectCountCategory-1];
}else{
stringArray = null;
returnValue = "";
}
if(stringArray != null && (stringArray.length == this.fidSuspectCountCategory)){
returnValue = etcSuspectCountCategory;
}else if(stringArray != null){
returnValue = stringArray[this.fidSuspectCountCategory-1];
}
return returnValue;
}
public String getVictimOriginString(Context context) {
String returnValue = "";
String[] stringArray;
if(fidVictimOriginCategory != 0) returnValue = context.getResources().getStringArray(R.array.cat_victim_origin)[fidVictimOriginCategory-1];
if(!etcVictimOriginCategory.equals("")) returnValue += "\n"+etcVictimOriginCategory;
if(this.fidVictimOriginCategory > 0){
stringArray = context.getResources().getStringArray(R.array.cat_victim_origin);
returnValue = stringArray[this.fidVictimOriginCategory-1];
}else{
stringArray = null;
returnValue = "";
}
if(stringArray != null && (stringArray.length == this.fidVictimOriginCategory)){
returnValue = etcVictimOriginCategory;
}else if(stringArray != null){
returnValue = stringArray[this.fidVictimOriginCategory-1];
}
return returnValue;
}
public String getSuspectTransportString(Context context) {
String returnValue = "";
String[] stringArray;
if(fidSuspectTransportationCategory != 0) returnValue = context.getResources().getStringArray(R.array.cat_details_vehicle)[fidSuspectTransportationCategory-1];
if(!etcSuspectTransportationCategory.equals("")) returnValue += "\n"+etcSuspectTransportationCategory;
if(this.fidSuspectTransportationCategory > 0){
stringArray = context.getResources().getStringArray(R.array.cat_details_vehicle);
returnValue = stringArray[this.fidSuspectTransportationCategory-1];
}else{
stringArray = null;
returnValue = "";
}
if(stringArray != null && (stringArray.length == this.fidSuspectTransportationCategory)){
returnValue = etcSuspectTransportationCategory;
}else if(stringArray != null){
returnValue = stringArray[this.fidSuspectTransportationCategory-1];
}
return returnValue;
}
public String getVictimAffiliationString(Context context) {
String returnValue = "";
String[] stringArray;
if(fidVictimBelongingCategory != 0) returnValue = context.getResources().getStringArray(R.array.cat_details_victimaff)[fidVictimBelongingCategory-1];
if(!etcVictimBelongingCategory.equals("")) returnValue += "\n"+etcVictimBelongingCategory;
if(this.fidVictimBelongingCategory > 0){
stringArray = context.getResources().getStringArray(R.array.cat_details_victimaff);
returnValue = stringArray[this.fidVictimBelongingCategory-1];
}else{
stringArray = null;
returnValue = "";
}
if(stringArray != null && (stringArray.length == this.fidVictimBelongingCategory)){
returnValue = etcVictimBelongingCategory;
}else if(stringArray != null){
returnValue = stringArray[this.fidVictimBelongingCategory-1];
}
return returnValue;
}
public String getSuspectRecognitionString(Context context) {
String returnValue = "";
String[] stringArray;
if(fidSuspectCharacteristicsCategory != 0) returnValue = context.getResources().getStringArray(R.array.cat_details_suspect_recon)[fidSuspectCharacteristicsCategory-1];
if(!etcSuspectCharacteristicsCategory.equals("")) returnValue += "\n"+etcSuspectCharacteristicsCategory;
if(this.fidSuspectCharacteristicsCategory > 0){
stringArray = context.getResources().getStringArray(R.array.cat_details_suspect_recon);
returnValue = stringArray[this.fidSuspectCharacteristicsCategory-1];
}else{
stringArray = null;
returnValue = "";
}
if(stringArray != null && (stringArray.length == this.fidSuspectCharacteristicsCategory)){
returnValue = etcSuspectCharacteristicsCategory;
}else if(stringArray != null){
returnValue = stringArray[this.fidSuspectCharacteristicsCategory-1];
}
return returnValue;
}

View File

@@ -49,6 +49,9 @@ public class SessionManager {
public static final String KEY_NOTIFY_GPS = "notifyGPSEnabled";
public static final String KEY_NOTIFY_REQUEST_POS = "notifyGPSPositionRequest";
public static final String KEY_SUBS_NOADS = "subs_noads";
public static final String KEY_SUBS_PREMIUM = "subs_premium";
public SessionManager(Context context) {
@@ -123,7 +126,25 @@ public class SessionManager {
}
public Boolean getNotificationPositionRequest(){
return status.getBoolean(KEY_NOTIFY_REQUEST_POS, false);
return status.getBoolean(KEY_NOTIFY_REQUEST_POS, true);
}
public void setSubsNoAds(boolean isEnabled){
statusEditor.putBoolean(KEY_SUBS_NOADS, isEnabled);
statusEditor.apply();
}
public Boolean getSubsNoAds(){
return status.getBoolean(KEY_SUBS_NOADS, false);
}
public void setSubsPremium(boolean isEnabled){
statusEditor.putBoolean(KEY_SUBS_PREMIUM, isEnabled);
statusEditor.apply();
}
public Boolean getSubsPremium(){
return status.getBoolean(KEY_SUBS_PREMIUM, false);
}
public int getNotificationRadius(){
@@ -134,8 +155,7 @@ public class SessionManager {
return status.getInt(KEY_NOTIFY_POLLINGFREQ, 5);
}
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, boolean premium, boolean addfree) {
userDataEditor.putString(KEY_UID, uid); //UID
userDataEditor.putString(KEY_USERNAME, username); // Username
@@ -149,6 +169,9 @@ public class SessionManager {
userDataEditor.putString(KEY_LASTLOGIN_AT, lastlogin_at); // Last Login
userDataEditor.putString(TOKEN, token); // TOKEN
setSubsNoAds(true);
setSubsPremium(true);
userDataEditor.apply();
Log.d(TAG, "New user written to sharedPreferences: " + uid);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -1,7 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/btn_report" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/btn_report_pressed" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/btn_report_pressed" />
<item android:drawable="@drawable/btn_report" />
<item android:state_pressed="false">
<shape android:shape="oval">
<solid android:color="#cc3b55"/>
</shape>
</item>
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="#7e0f2b"/>
</shape>
</item>
</selector>

View File

@@ -1,6 +1,4 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
xmlns:fontawesometext="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
@@ -53,7 +51,7 @@
android:textColorHint="@color/input_login_hint" />
<Button
android:id="@+id/btn_register"
android:id="@+id/btn_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
@@ -66,16 +64,32 @@
android:text="@string/btn_start_login"
android:textColor="@color/white" />
<TextView
android:id="@+id/lbl_login_policy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/lbl_login_resendPW"
android:gravity="end"
android:text="@string/lbl_login_policy"
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:layout_width="match_parent"
android:layout_below="@+id/btn_login"
android:orientation="horizontal"
android:layout_height="wrap_content">
<TextView
android:id="@+id/lbl_login_resendPW"
android:layout_width="0dp"
android:ellipsize="end"
android:layout_height="wrap_content"
android:text="@string/lbl_login_resendPW"
android:layout_weight=".5"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/lbl_login_policy"
android:ellipsize="end"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="end"
android:layout_weight=".45"
android:text="@string/lbl_login_policy"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<TextView
android:id="@+id/lbl_login_usesocialnet"
@@ -117,14 +131,6 @@
android:layout_marginTop="5dp"
tools:layout="@layout/fragment_facebook_button" />
<TextView
android:id="@+id/lbl_login_resendPW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/btn_register"
android:text="@string/lbl_login_resendPW"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>

Some files were not shown because too many files have changed in this diff Show More