Refactored to lambda expressions and fixe some minor bugs
This commit is contained in:
@@ -98,13 +98,13 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-verifier" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-apk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-main-apk-res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-resources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifest-checker" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged-not-compiled-resources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/processing-tools" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
|
||||
@@ -9,8 +9,8 @@ android {
|
||||
applicationId "org.deke.risk.riskahead"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 26
|
||||
versionCode 48
|
||||
versionName "3.1.4"
|
||||
versionCode 49
|
||||
versionName "3.1.5"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":48,"versionName":"3.1.4","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":49,"versionName":"3.1.5","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||
@@ -3,14 +3,11 @@ package org.deke.risk.riskahead;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@@ -23,7 +20,6 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@@ -40,8 +36,6 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import com.android.volley.Request.Method;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
@@ -95,7 +89,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void isNetworkAvailable() {
|
||||
@@ -113,10 +106,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
.setTitle(getString(R.string.alert_internetconnection_title))
|
||||
.setMessage(getString(R.string.alert_internetconnection_text))
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setNeutralButton(android.R.string.yes, (dialog, which) -> {
|
||||
//todo What to do when no internet connection is available?
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
@@ -152,18 +143,10 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
TextView btn_requestPW = findViewById(R.id.lbl_login_resendPW);
|
||||
|
||||
BootstrapButton btn_gotoregistration = findViewById(R.id.btn_switchtoregistration);
|
||||
btn_gotoregistration.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoRegister(v);
|
||||
}
|
||||
});
|
||||
btn_gotoregistration.setOnClickListener(this::gotoRegister);
|
||||
|
||||
BootstrapButton btn_login = findViewById(R.id.btn_login);
|
||||
btn_login.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
btn_login.setOnClickListener((View v) -> {
|
||||
String email = input_email.getText().toString();
|
||||
String password = input_password.getText().toString();
|
||||
|
||||
@@ -173,7 +156,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
showDialog();
|
||||
performLogin(email, password);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
input_email.addTextChangedListener(new TextValidator(input_email, inputLayoutEmail, getApplicationContext()) {
|
||||
@@ -198,12 +180,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
});
|
||||
|
||||
btn_requestPW.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onRequestNewPasswordClick(v);
|
||||
}
|
||||
});
|
||||
btn_requestPW.setOnClickListener(this::onRequestNewPasswordClick);
|
||||
}
|
||||
|
||||
private void initRegisterView() {
|
||||
@@ -251,9 +228,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
});
|
||||
|
||||
btn_login.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btn_login.setOnClickListener(v -> {
|
||||
String email = input_email.getText().toString();
|
||||
String password = input_password.getText().toString();
|
||||
|
||||
@@ -264,25 +239,14 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
showDialog();
|
||||
checkForUserAndPerformRegistration(name, email, password);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
btn_switchtologin.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoLogin(v);
|
||||
}
|
||||
});
|
||||
btn_switchtologin.setOnClickListener(this::gotoLogin);
|
||||
}
|
||||
|
||||
private void initSocialLoginButtons() {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
new FacebookButtonFragment();
|
||||
GooglePlusButtonFragment fragmentGP = new GooglePlusButtonFragment();
|
||||
|
||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
transaction.add(R.id.frag_login_btnGP, fragmentGP);
|
||||
transaction.commit();
|
||||
new GooglePlusButtonFragment();
|
||||
}
|
||||
|
||||
private void checkForMaintenance() {
|
||||
@@ -292,10 +256,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestCheckForMaintenance() {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_CHECK_MAINTENANCE, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_CHECK_MAINTENANCE, response -> {
|
||||
Log.d(TAG, "Check for Maintenance Response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -312,12 +273,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}
|
||||
}, error -> {
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -346,10 +302,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestCheckIfVersionSupported() {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_CHECK_VERSION, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_CHECK_VERSION, response -> {
|
||||
Log.d(TAG, "Check Version Response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -368,12 +321,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}
|
||||
}, error -> {
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -399,18 +347,12 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
.setTitle(getString(R.string.alert_notsupported_title))
|
||||
.setMessage(getString(R.string.alert_notsupported_text))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.update, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())));
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(R.string.update, (dialog, which) -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()))))
|
||||
.setNegativeButton(R.string.exit, (dialog, which) -> {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addCategory(Intent.CATEGORY_HOME);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
@@ -421,15 +363,9 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
.setTitle(getString(R.string.alert_notrecommended_title))
|
||||
.setMessage(getString(R.string.alert_notrecommended_text))
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.update, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName())));
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.later, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(R.string.update, (dialog, which) -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getPackageName()))))
|
||||
.setNegativeButton(R.string.later, (dialog, which) -> {
|
||||
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
@@ -480,15 +416,9 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
new AlertDialog.Builder(LoginActivity.this)
|
||||
.setTitle(getString(R.string.alert_passwordreset_title))
|
||||
.setMessage(getString(R.string.alert_passwordreset_text))
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
performRequestNewPassword();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> performRequestNewPassword())
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
@@ -507,10 +437,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestSocialMediaLogin(final String key, final String providerType, final String username, final String email) {
|
||||
return new StringRequest(Method.POST,AppConfig.REST_LOGIN_SOCIAL, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Method.POST,AppConfig.REST_LOGIN_SOCIAL, response -> {
|
||||
Log.d(TAG, "Social Media Login Response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -522,15 +449,15 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
|
||||
JSONObject user = jObj.getJSONObject("user");
|
||||
String id = user.getString("id");
|
||||
String username = user.getString("username");
|
||||
String username1 = user.getString("username");
|
||||
String name = user.getString("name");
|
||||
String surname = user.getString("surname");
|
||||
String email = user.getString("email");
|
||||
String email1 = user.getString("email");
|
||||
String status = user.getString("status");
|
||||
String created_at = user.getString("created_at");
|
||||
String updated_at = user.getString("updated_at");
|
||||
String lastlogin_at = user.getString("lastlogin_at");
|
||||
String providerType = user.getString("providerType");
|
||||
String providerType1 = user.getString("providerType");
|
||||
String token = user.getString("accesskey");
|
||||
|
||||
JSONArray jSubs = user.getJSONArray("subs");
|
||||
@@ -549,7 +476,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
}
|
||||
|
||||
session.addUser(id, username, name, surname, email, status, providerType, created_at, updated_at, lastlogin_at, token,isPremium,isAdFree);
|
||||
session.addUser(id, username1, name, surname, email1, status, providerType1, created_at, updated_at, lastlogin_at, token,isPremium,isAdFree);
|
||||
|
||||
Intent intent = new Intent(
|
||||
LoginActivity.this,
|
||||
@@ -567,15 +494,10 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Social Media Login Error: " + error.getMessage());
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login)+getResources().getString(R.string.txt_errormsg_suffix), Toast.LENGTH_LONG).show();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -593,10 +515,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestLogin(final String email, final String password) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_LOGIN, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_LOGIN, response -> {
|
||||
Log.d(TAG, "Login Response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -610,7 +529,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
String username = user.getString("username");
|
||||
String name = user.getString("name");
|
||||
String surname = user.getString("surname");
|
||||
String email = user.getString("email");
|
||||
String email1 = user.getString("email");
|
||||
String status = user.getString("status");
|
||||
String created_at = user.getString("created_at");
|
||||
String updated_at = user.getString("updated_at");
|
||||
@@ -638,24 +557,20 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
new AlertDialog.Builder(LoginActivity.this)
|
||||
.setTitle(getString(R.string.alert_accactivation_title))
|
||||
.setMessage(getString(R.string.alert_accactivation_text))
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
||||
String tag_string_req = "resendactivationusermail";
|
||||
|
||||
StringRequest strReq = getStringRequestActivationLinkUser(input_email.getText().toString());
|
||||
|
||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||
showMessage(getString(R.string.alert_accactivation_confirmation));
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
}
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
})
|
||||
.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, isPremium, isAdFree);
|
||||
session.addUser(id, username, name, surname, email1, status, providerType, created_at, updated_at, lastlogin_at, token, isPremium, isAdFree);
|
||||
session.setLogin(true);
|
||||
|
||||
hideDialog();
|
||||
@@ -673,15 +588,10 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Login Error: " + error.getMessage());
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login), Toast.LENGTH_LONG).show();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -696,10 +606,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestCheckUserExists(final String username, final String email, final String password) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_USEREXISTS, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_USEREXISTS, response -> {
|
||||
Log.d(TAG, "Check User Exists Response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -725,16 +632,11 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Crashlytics.log(Log.ERROR, TAG, "Exception caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Registration Error: " + error.getMessage());
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -748,10 +650,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestCheckSocialUserExists(final String key, final String providerType, final String username, final String email) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_USEREXISTS, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_USEREXISTS, response -> {
|
||||
Log.d(TAG, "Check Social User Exists Response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -775,16 +674,11 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Registration Error: " + error.getMessage());
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -827,28 +721,19 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this)
|
||||
.setTitle(R.string.txt_register_privacy_title)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
performSocialMediaLogin(key, providerType, username, email);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
}
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> performSocialMediaLogin(key, providerType, username, email))
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
})
|
||||
.setIcon(R.drawable.logo_380);
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
|
||||
privacyCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
privacyCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (isChecked) {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
|
||||
} else {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dialog.setView(layout, 30, 30, 30, 30);
|
||||
@@ -888,28 +773,19 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this)
|
||||
.setTitle(R.string.txt_register_privacy_title)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
performRegistration(username, email, password);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
}
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> performRegistration(username, email, password))
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
})
|
||||
.setIcon(R.drawable.logo_380);
|
||||
|
||||
final AlertDialog dialog = builder.create();
|
||||
|
||||
privacyCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
privacyCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
if (isChecked) {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true);
|
||||
} else {
|
||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dialog.setView(layout, 30, 30, 30, 30);
|
||||
@@ -919,10 +795,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestResetPW(final String email) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_REQUESTPWRESET, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_REQUESTPWRESET, response -> {
|
||||
Log.d(TAG, "Resend E-Mail Response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -942,16 +815,11 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "E-Mail pw resend Error: " + error.getMessage());
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getResources().getString(R.string.txt_errormsg_getpwreset), Toast.LENGTH_LONG).show();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -965,10 +833,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestActivationLinkUser(final String email) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_SENDACTIVATIONMAIL, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_SENDACTIVATIONMAIL, response -> {
|
||||
Log.d(TAG, "Resend E-Mail Response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -986,16 +851,11 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "E-Mail pw resend error: " + error.getMessage());
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getResources().getString(R.string.txt_errormsg_getactivationlink), Toast.LENGTH_LONG).show();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -1009,10 +869,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestRegisterUser(final String username, final String email, final String password) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_REGISTER, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Method.POST, AppConfig.REST_REGISTER, response -> {
|
||||
Log.d(TAG, "Register Response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -1023,15 +880,13 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
new AlertDialog.Builder(LoginActivity.this)
|
||||
.setTitle(getString(R.string.alert_accregistration_title))
|
||||
.setMessage(getString(R.string.alert_accregistration_text))
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
||||
Intent intent = new Intent(
|
||||
LoginActivity.this,
|
||||
LoginActivity.class);
|
||||
intent.putExtra(AppConfig.EXTRA_MESSAGE, AppConfig.INTENT_LOGIN);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
@@ -1044,16 +899,11 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Registration Error: " + error.getMessage());
|
||||
Toast.makeText(getApplicationContext(),
|
||||
getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.deke.risk.riskahead;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.SearchManager;
|
||||
import android.app.SearchableInfo;
|
||||
import android.content.Context;
|
||||
@@ -11,7 +12,9 @@ import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.location.Location;
|
||||
import android.location.LocationManager;
|
||||
import android.location.LocationListener;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
@@ -20,10 +23,9 @@ import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RatingBar;
|
||||
@@ -33,11 +35,6 @@ import android.widget.TextView;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
|
||||
import android.location.LocationListener;
|
||||
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.google.android.gms.maps.CameraUpdate;
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
@@ -155,14 +152,14 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
Log.d(TAG, "Getting permission results...");
|
||||
switch (requestCode) {
|
||||
case MY_PERMISSIONS_REQUEST_LOCATION: {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
Log.d(TAG, "Permission was granted by user");
|
||||
enableMyLocationButton();
|
||||
getLocation();
|
||||
gotoMyLocation();
|
||||
|
||||
} else {
|
||||
Log.d(TAG, "Permission was not granted by user");
|
||||
@@ -192,19 +189,22 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
Log.d(TAG, "Init Map");
|
||||
mMap.getUiSettings().setZoomControlsEnabled(true);
|
||||
mMap.setMinZoomPreference(MIN_ZOOM_LEVEL);
|
||||
mMap.setOnMyLocationButtonClickListener(new GoogleMap.OnMyLocationButtonClickListener() {
|
||||
@Override
|
||||
public boolean onMyLocationButtonClick() {
|
||||
getLocation();
|
||||
mMap.setOnMyLocationButtonClickListener(() -> {
|
||||
gotoMyLocation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Retrieve height of action bar and modify map padding
|
||||
TypedValue tv = new TypedValue();
|
||||
if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true))
|
||||
{
|
||||
int actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics());
|
||||
mMap.setPadding(0, actionBarHeight,0,0);
|
||||
}
|
||||
|
||||
enableMyLocationButton();
|
||||
|
||||
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(LatLng point) {
|
||||
mMap.setOnMapClickListener(point -> {
|
||||
if (mMarker != null) {
|
||||
mMarker.remove();
|
||||
}
|
||||
@@ -232,12 +232,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
|
||||
addButton.setImageDrawable(identityIcon);
|
||||
|
||||
addButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoReportActivity(markedLocation.latitude + ":" + markedLocation.longitude);
|
||||
}
|
||||
});
|
||||
addButton.setOnClickListener(v -> gotoReportActivity(markedLocation.latitude + ":" + markedLocation.longitude));
|
||||
} else if (getIntent().getStringExtra(AppConfig.EXTRA_MAP_TYPE).equals(AppConfig.INTENT_MAP_GETNOTIFY)) {
|
||||
addButton.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(getApplicationContext(), R.color.md_green_400)));
|
||||
showAdd = false;
|
||||
@@ -248,34 +243,25 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
|
||||
addButton.setImageDrawable(identityIcon);
|
||||
|
||||
addButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
addButton.setOnClickListener(v -> {
|
||||
session.setManualLocation(Double.doubleToRawLongBits(markedLocation.latitude), Double.doubleToRawLongBits(markedLocation.longitude));
|
||||
Log.d(TAG, "MARKED LOCATION: " + markedLocation.latitude + " " + markedLocation.longitude);
|
||||
gotoSettingsActivity();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
addButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
addButton.setOnClickListener(v -> {
|
||||
Log.d(TAG, "MARKED LOCATION: " + markedLocation.latitude + " " + markedLocation.longitude);
|
||||
showAdd = false;
|
||||
gotoReportActivity(markedLocation.latitude + ":" + markedLocation.longitude);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public GoogleMap.OnCameraIdleListener getCameraChangeListener() {
|
||||
return new GoogleMap.OnCameraIdleListener() {
|
||||
@Override
|
||||
public void onCameraIdle() {
|
||||
return () -> {
|
||||
mClusterManager.onCameraIdle();
|
||||
CameraPosition position = mMap.getCameraPosition();
|
||||
current_zoom_level = position.zoom;
|
||||
@@ -359,7 +345,6 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
mClusterManager.clearItems();
|
||||
markersShown = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -421,10 +406,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestGetAllIncidentsForHeatMapFromBound(final LatLng northeast, final LatLng southwest) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENTS_FROMBOUND_FORHEATMAP, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENTS_FROMBOUND_FORHEATMAP, response -> {
|
||||
Log.d(TAG, "Map HeatMap positions response: " + response);
|
||||
hideProgress();
|
||||
try {
|
||||
@@ -446,14 +428,10 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
hideProgress();
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error getting map positions: " + error.getMessage());
|
||||
handleVolleyErrorResponse();
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
@@ -471,10 +449,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestGetAllIncidentsFromBound(final LatLng northeast, final LatLng southwest) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENTS_FROMBOUND, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENTS_FROMBOUND, response -> {
|
||||
Log.d(TAG, "Map positions response: " + response);
|
||||
hideProgress();
|
||||
try {
|
||||
@@ -494,14 +469,10 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
hideProgress();
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error getting map positions: " + error.getMessage());
|
||||
showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
@@ -532,12 +503,9 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
|
||||
mClusterManager.setOnClusterClickListener(this);
|
||||
mClusterManager.setOnClusterItemClickListener(this);
|
||||
mClusterManager.setOnClusterItemClickListener(new ClusterManager.OnClusterItemClickListener<IncidentReport>() {
|
||||
@Override
|
||||
public boolean onClusterItemClick(IncidentReport item) {
|
||||
mClusterManager.setOnClusterItemClickListener(item -> {
|
||||
clickedClusterItem = item;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mClusterManager.getMarkerCollection().setOnInfoWindowAdapter(
|
||||
@@ -553,10 +521,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestGetIncidentScoreForInfoWindow(final View infoView, final String incidentID) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENT, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENT, response -> {
|
||||
Log.d(TAG, "Map positions response: " + response);
|
||||
hideProgress();
|
||||
try {
|
||||
@@ -587,14 +552,10 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
hideProgress();
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error getting incident details: " + error.getMessage());
|
||||
handleVolleyErrorResponse();
|
||||
}
|
||||
}) {
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
@@ -674,7 +635,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
if ((myPosition != null) && (myPosition.latitude != 0.0) && (myPosition.longitude != 0.0)) {
|
||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(myPosition.latitude, myPosition.longitude), DEFAULT_ZOOM_LEVEL));
|
||||
} else {
|
||||
getLocation();
|
||||
gotoMyLocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -714,7 +675,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
getSupportLoaderManager().restartLoader(1, data, this);
|
||||
}
|
||||
|
||||
private void showLocations(Cursor c) {
|
||||
private void showLocation(Cursor c) {
|
||||
MarkerOptions markerOptions;
|
||||
LatLng position = null;
|
||||
|
||||
@@ -736,16 +697,17 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> arg0) {
|
||||
public void onLoaderReset(@NonNull Loader<Cursor> arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Loader<Cursor> onCreateLoader(int arg0, Bundle query) {
|
||||
CursorLoader cLoader;
|
||||
|
||||
if (arg0 == 0)
|
||||
cLoader = new CursorLoader(getBaseContext(), PlaceProvider.SEARCH_URI, null, null, new String[]{query.getString("query")}, null);
|
||||
else //if (arg0 == 1)
|
||||
else
|
||||
cLoader = new CursorLoader(getBaseContext(), PlaceProvider.DETAILS_URI, null, null, new String[]{query.getString("query")}, null);
|
||||
|
||||
return cLoader;
|
||||
@@ -785,7 +747,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
public void gotoMyLocation() {
|
||||
//check for permission
|
||||
Log.d(TAG, "Permission for GPS not granted yet - ask for permission now");
|
||||
if (ActivityCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||
@@ -841,25 +803,22 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
private void enableMyLocationButton() {
|
||||
try{
|
||||
mMap.setMyLocationEnabled(true);
|
||||
MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.frag_maps_map);
|
||||
View locationButton = ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).getParent()).findViewById(Integer.parseInt("2"));
|
||||
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
|
||||
rlp.setMargins(0, 250, 30, 30);
|
||||
}catch(SecurityException se){
|
||||
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION}, MY_PERMISSIONS_REQUEST_LOCATION);
|
||||
}catch(AssertionError ae){
|
||||
Crashlytics.log(Log.ERROR, TAG, "Could not find mapFragment view");
|
||||
Crashlytics.logException(ae);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> arg0, Cursor c) {
|
||||
showLocations(c);
|
||||
public void onLoadFinished(@NonNull Loader<Cursor> arg0, Cursor c) {
|
||||
showLocation(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.location.Address;
|
||||
@@ -24,8 +23,6 @@ import android.widget.TextView;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
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;
|
||||
@@ -124,37 +121,28 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
||||
private void initButtonsAndElements() {
|
||||
btnContinue = findViewById(R.id.btn_reportwf_next);
|
||||
btnContinue.setEnabled(false);
|
||||
btnContinue.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnContinue.setOnClickListener(v -> {
|
||||
incident = fragList.get(currentState).getCurrentInput();
|
||||
initFragment(currentState + 1);
|
||||
}
|
||||
});
|
||||
|
||||
btnReportNow = findViewById(R.id.btn_reportwf_reportnow);
|
||||
btnReportNow.setEnabled(false);
|
||||
btnReportNow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnReportNow.setOnClickListener(v -> {
|
||||
incident = fragList.get(currentState).getCurrentInput();
|
||||
sendReport();
|
||||
}
|
||||
});
|
||||
|
||||
siteIndicator = findViewById(R.id.lbl_reportwf_site);
|
||||
|
||||
btnMap = findViewById(R.id.fab_reportwf_map);
|
||||
btnMap.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnMap.setOnClickListener(v -> {
|
||||
incident = fragList.get(currentState).getCurrentInput();
|
||||
if (incident != null && incident.getPosition() != null) {
|
||||
getIncidentLocationFromMapActivity(incident.getPosition().latitude + ":" + incident.getPosition().longitude);
|
||||
} else {
|
||||
getIncidentLocationFromMapActivity();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -196,7 +184,9 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
||||
private void modifyPos(String pos){
|
||||
String[] position = pos.split(":");
|
||||
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
|
||||
LatLng latlngpos = new LatLng(Double.parseDouble(position[0]), Double.parseDouble(position[1]));
|
||||
LatLng latlngpos = new LatLng(
|
||||
Double.parseDouble(position[0]),
|
||||
Double.parseDouble(position[1]));
|
||||
incident.setPosition(latlngpos);
|
||||
|
||||
try {
|
||||
@@ -204,16 +194,12 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
||||
|
||||
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.getAddressLine(0) != null){
|
||||
incident.setIncidentPositionDescription(
|
||||
address.getAddressLine(0).replace(", ", "\n"));
|
||||
}
|
||||
|
||||
if(address.getCountryName() != null) sb.append(address.getCountryName());
|
||||
incident.setIncidentPositionDescription(sb.toString());
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
@@ -275,20 +261,16 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
||||
new AlertDialog.Builder(ReportWFActivity.this)
|
||||
.setTitle(getResources().getString(R.string.txt_reportwf_newincidenttitle))
|
||||
.setMessage(getResources().getString(R.string.txt_reportwf_newincidenttext))
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
||||
resetStateAndIncident();
|
||||
initFragment(0);
|
||||
|
||||
if(currentState == 0){
|
||||
gotoReportActivity();
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
@@ -316,10 +298,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
||||
|
||||
private StringRequest getStringRequestAddIncidentWithPosition(final IncidentReport incident) {
|
||||
showDialog();
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_ADD_INCIDENT_WITHPOSITION, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_ADD_INCIDENT_WITHPOSITION, response -> {
|
||||
Log.d(TAG, "Report response: " + response);
|
||||
|
||||
try {
|
||||
@@ -340,14 +319,10 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
||||
}
|
||||
|
||||
hideDialog();
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error adding incident: " + error.getMessage());
|
||||
handleVolleyErrorResponse();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -410,16 +385,8 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
||||
new AlertDialog.Builder(ReportWFActivity.this)
|
||||
.setTitle(R.string.txt_share_title)
|
||||
.setMessage(R.string.txt_share_message)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startShareIncidentIntent(incident);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
finishReportAndGotoMap(incident);
|
||||
}
|
||||
})
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> startShareIncidentIntent(incident))
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> finishReportAndGotoMap(incident))
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
|
||||
@@ -432,11 +399,9 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
||||
alertDialog.setTitle("Request Permission");
|
||||
alertDialog.setMessage("If you want to use the sharing feature in the future we need storage permission to generate the message which should be shared.");
|
||||
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
(dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
requestPermission();
|
||||
}
|
||||
});
|
||||
alertDialog.show();
|
||||
|
||||
@@ -447,10 +412,22 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
||||
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
|
||||
Bitmap icon = BitmapFactory.decodeResource(getApplicationContext().getResources(),
|
||||
R.drawable.ra_qrcode);
|
||||
|
||||
String[] posDesc = incident.getIncidentPositionDescription().split("\\n");
|
||||
String locationText = "";
|
||||
|
||||
if(posDesc.length > 1){
|
||||
locationText = posDesc[0] + " - " +posDesc[1];
|
||||
}else if(posDesc.length == 1){
|
||||
locationText = posDesc[0];
|
||||
}else{
|
||||
Log.e(TAG, "Could not find location desciption");
|
||||
}
|
||||
|
||||
String text = getString(R.string.txt_share_hint)
|
||||
+getString(R.string.txt_share_hint2)+": "+ incident.getIncidentCategoryName(getApplicationContext())
|
||||
+" - "+incident.getIncidentSubCategoryName(getApplicationContext())+"\n"
|
||||
+getString(R.string.txt_share_hint3)+": "+ incident.getIncidentPositionDescription().split("\\n")[0] + " - " + incident.getIncidentPositionDescription().split("\\n")[1] + "\n"
|
||||
+getString(R.string.txt_share_hint3)+": "+ locationText + "\n"
|
||||
+getString(R.string.txt_share_page);
|
||||
|
||||
sharingIntent.putExtra(Intent.EXTRA_TEXT, text);
|
||||
|
||||
@@ -18,8 +18,6 @@ import android.widget.LinearLayout;
|
||||
|
||||
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.crashlytics.android.Crashlytics;
|
||||
|
||||
@@ -317,10 +315,7 @@ public class SubscriptionsActivity extends BaseActivity{
|
||||
}
|
||||
|
||||
private StringRequest getStringAddSubscription(final String productId, final String type, final String price, final String currency) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_ADD_SUBSCRIPTIONS, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_ADD_SUBSCRIPTIONS, response -> {
|
||||
|
||||
try {
|
||||
JSONObject jObj = new JSONObject(response);
|
||||
@@ -340,15 +335,10 @@ public class SubscriptionsActivity extends BaseActivity{
|
||||
}
|
||||
|
||||
hideDialog();
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error adding subscription: " + error.getMessage());
|
||||
showMessage(getResources().getString(R.string.txt_errormsg_subs));
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -373,10 +363,7 @@ public class SubscriptionsActivity extends BaseActivity{
|
||||
}
|
||||
|
||||
private StringRequest getStringGetSubscriptions(final String userId) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_SUBSCRIPTIONS, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_SUBSCRIPTIONS, response -> {
|
||||
|
||||
try {
|
||||
JSONObject jObj = new JSONObject(response);
|
||||
@@ -403,14 +390,9 @@ public class SubscriptionsActivity extends BaseActivity{
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error getting subscription: " + error.getMessage());
|
||||
handleVolleyErrorResponse();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -434,10 +416,7 @@ public class SubscriptionsActivity extends BaseActivity{
|
||||
}
|
||||
|
||||
private StringRequest getStringDeactivateSubscriptions(final String subscriptionId) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_DEACTIVATE_SUBSCRIPTIONS, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_DEACTIVATE_SUBSCRIPTIONS, response -> {
|
||||
|
||||
try {
|
||||
JSONObject jObj = new JSONObject(response);
|
||||
@@ -454,14 +433,7 @@ public class SubscriptionsActivity extends BaseActivity{
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error deactivating subscription: " + error.getMessage());
|
||||
}
|
||||
}) {
|
||||
}, error -> Crashlytics.log(Log.ERROR, TAG, "Error deactivating subscription: " + error.getMessage())) {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.deke.risk.riskahead;
|
||||
|
||||
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;
|
||||
@@ -15,8 +14,6 @@ import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
||||
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.AwesomeTextView;
|
||||
import com.beardedhen.androidbootstrap.BootstrapLabel;
|
||||
@@ -101,41 +98,19 @@ public class ViewReportActivity extends BaseActivity {
|
||||
final Integer id = intent.getIntExtra(BaseActivity.EXTRA_MESSAGE, 0);
|
||||
getIncident(id);
|
||||
|
||||
btnUpvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
makeUpvote(id);
|
||||
}
|
||||
});
|
||||
btnUpvote.setOnClickListener(v -> makeUpvote(id));
|
||||
findViewById(R.id.layoutFooter).setVisibility(View.GONE);
|
||||
btnDownvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
makeDownvote(id);
|
||||
}
|
||||
});
|
||||
btnDownvote.setOnClickListener(v -> makeDownvote(id));
|
||||
|
||||
findViewById(R.id.btn_viewreport_delete).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new AlertDialog.Builder(ViewReportActivity.this)
|
||||
findViewById(R.id.btn_viewreport_delete).setOnClickListener(v -> new AlertDialog.Builder(ViewReportActivity.this)
|
||||
.setTitle(getResources().getString(R.string.txt_viewreport_deletetitle))
|
||||
.setMessage(getResources().getString(R.string.txt_viewreport_deletetext))
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
deleteReport(id);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> deleteReport(id))
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
//do nothing
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
|
||||
}
|
||||
});
|
||||
.show());
|
||||
|
||||
Drawable identityIcon = new IconicsDrawable(this)
|
||||
.icon(GoogleMaterial.Icon.gmd_account_circle)
|
||||
@@ -158,10 +133,7 @@ public class ViewReportActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestDeleteIncident(final Integer incidentid) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_DEACTIVATE_INCIDENT, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_DEACTIVATE_INCIDENT, response -> {
|
||||
Log.d(TAG, "Delete Incident with ID response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -181,15 +153,10 @@ public class ViewReportActivity extends BaseActivity {
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error deleting incident: " + error.getMessage());
|
||||
handleVolleyErrorResponse();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -213,10 +180,7 @@ public class ViewReportActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestGetIncidentWithPositionFromID(final Integer incidentid) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENT, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENT, response -> {
|
||||
Log.d(TAG, "Incident with ID response: " + response);
|
||||
hideDialog();
|
||||
|
||||
@@ -239,15 +203,10 @@ public class ViewReportActivity extends BaseActivity {
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error get incident: " + error.getMessage());
|
||||
handleVolleyErrorResponse();
|
||||
hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -277,74 +236,38 @@ public class ViewReportActivity extends BaseActivity {
|
||||
btnUpvote.startFlashing(true, AwesomeTextView.AnimationSpeed.MEDIUM);
|
||||
btnDownvote.startFlashing(false, AwesomeTextView.AnimationSpeed.MEDIUM);
|
||||
|
||||
btnUpvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
deleteVote(incident.getId());
|
||||
}
|
||||
});
|
||||
btnUpvote.setOnClickListener(v -> deleteVote(incident.getId()));
|
||||
|
||||
btnDownvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnDownvote.setOnClickListener(v -> {
|
||||
deleteVote(incident.getId());
|
||||
makeDownvote(incident.getId());
|
||||
}
|
||||
});
|
||||
} else if (hasvoted.getInt("fid_votetype") == AppConfig.VOTETYPE_DOWNVOTE) {
|
||||
btnUpvote.startFlashing(false, AwesomeTextView.AnimationSpeed.MEDIUM);
|
||||
btnDownvote.startFlashing(true, AwesomeTextView.AnimationSpeed.MEDIUM);
|
||||
|
||||
btnUpvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnUpvote.setOnClickListener(v -> {
|
||||
deleteVote(incident.getId());
|
||||
makeUpvote(incident.getId());
|
||||
}
|
||||
});
|
||||
|
||||
btnDownvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
deleteVote(incident.getId());
|
||||
}
|
||||
});
|
||||
btnDownvote.setOnClickListener(v -> deleteVote(incident.getId()));
|
||||
} else {
|
||||
btnUpvote.startFlashing(false, AwesomeTextView.AnimationSpeed.MEDIUM);
|
||||
btnDownvote.startFlashing(false, AwesomeTextView.AnimationSpeed.MEDIUM);
|
||||
|
||||
btnUpvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
makeUpvote(incident.getId());
|
||||
}
|
||||
});
|
||||
btnUpvote.setOnClickListener(v -> makeUpvote(incident.getId()));
|
||||
|
||||
btnDownvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
makeDownvote(incident.getId());
|
||||
}
|
||||
});
|
||||
btnDownvote.setOnClickListener(v -> makeDownvote(incident.getId()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
btnUpvote.startFlashing(false, AwesomeTextView.AnimationSpeed.MEDIUM);
|
||||
btnDownvote.startFlashing(false, AwesomeTextView.AnimationSpeed.MEDIUM);
|
||||
|
||||
btnUpvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
makeUpvote(incident.getId());
|
||||
}
|
||||
});
|
||||
btnUpvote.setOnClickListener(v -> makeUpvote(incident.getId()));
|
||||
|
||||
btnDownvote.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
makeDownvote(incident.getId());
|
||||
}
|
||||
});
|
||||
btnDownvote.setOnClickListener(v -> makeDownvote(incident.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -405,19 +328,9 @@ public class ViewReportActivity extends BaseActivity {
|
||||
final String longitude = Double.toString(incident.getPosition().longitude);
|
||||
final String fromUid = Integer.toString(incident.getFidFromUser());
|
||||
|
||||
findViewById(R.id.btn_viewreport_user).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoProfileActivity(fromUid);
|
||||
}
|
||||
});
|
||||
findViewById(R.id.btn_viewreport_user).setOnClickListener(v -> gotoProfileActivity(fromUid));
|
||||
|
||||
findViewById(R.id.btn_viewreport_position).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoMapActivity(latitude + ":" + longitude);
|
||||
}
|
||||
});
|
||||
findViewById(R.id.btn_viewreport_position).setOnClickListener(v -> gotoMapActivity(latitude + ":" + longitude));
|
||||
|
||||
String uid = user.get(SessionManager.KEY_UID);
|
||||
if (incident.getFidFromUser() != Integer.valueOf(uid)) {
|
||||
@@ -448,10 +361,7 @@ public class ViewReportActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestAddVote(final Integer incidentid, final String votetype) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_ADD_VOTE, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_ADD_VOTE, response -> {
|
||||
Log.d(TAG, "MadeVote: " + response);
|
||||
|
||||
try {
|
||||
@@ -462,7 +372,7 @@ public class ViewReportActivity extends BaseActivity {
|
||||
showMessage(getString(R.string.txt_success_voted));
|
||||
JSONObject jPoints = jObj.getJSONObject("points");
|
||||
|
||||
scorelabel.setText(String.format("%d",jPoints.getInt("upvoted") - jPoints.getInt("downvoted")));
|
||||
scorelabel.setText(String.format(Locale.US, "%d",jPoints.getInt("upvoted") - jPoints.getInt("downvoted")));
|
||||
checkVotetypeAndSetVoteButtons(jPoints);
|
||||
} else {
|
||||
String errorMsg = jObj.getString("error_msg");
|
||||
@@ -473,14 +383,9 @@ public class ViewReportActivity extends BaseActivity {
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error voting incident: " + error.getMessage());
|
||||
handleVolleyErrorResponse();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -503,10 +408,7 @@ public class ViewReportActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestDeleteVote(final Integer incidentid) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_DELETE_VOTE, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_DELETE_VOTE, response -> {
|
||||
Log.d(TAG, "Delete Vote: " + response);
|
||||
|
||||
try {
|
||||
@@ -516,7 +418,7 @@ public class ViewReportActivity extends BaseActivity {
|
||||
if (!error) {
|
||||
JSONObject jPoints = jObj.getJSONObject("points");
|
||||
|
||||
scorelabel.setText(String.format("%d", jPoints.getInt("upvoted") - jPoints.getInt("downvoted")));
|
||||
scorelabel.setText(String.format(Locale.US, "%d", jPoints.getInt("upvoted") - jPoints.getInt("downvoted")));
|
||||
checkVotetypeAndSetVoteButtons(jPoints);
|
||||
} else {
|
||||
String errorMsg = jObj.getString("error_msg");
|
||||
@@ -526,14 +428,9 @@ public class ViewReportActivity extends BaseActivity {
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error deleting voting incident: " + error.getMessage());
|
||||
handleVolleyErrorResponse();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ReportListAdapter extends BaseAdapter {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View vi = convertView;
|
||||
if (vi == null) vi = inflater.inflate(R.layout.fragment_reportlist_row, null);
|
||||
if (vi == null) vi = inflater.inflate(R.layout.fragment_reportlist_row, parent, false);
|
||||
|
||||
TextView itemText = vi.findViewById(R.id.txt_reportlist_lvrow_text);
|
||||
TextView titleText = vi.findViewById(R.id.txt_reportlist_lvrow_title);
|
||||
@@ -99,7 +99,7 @@ public class ReportListAdapter extends BaseAdapter {
|
||||
IncidentReport item = new IncidentReport(data.get(position));
|
||||
titleText.setText(item.getIncidentCategoryName(vi.getContext()));
|
||||
itemText.setText(item.getIncidentSubCategoryName(vi.getContext()));
|
||||
itemText.setGravity(Gravity.LEFT);
|
||||
itemText.setGravity(Gravity.START);
|
||||
itemText.setPadding(0,0,0,0);
|
||||
categoryText.setText(item.getTimeString(vi.getContext()));
|
||||
|
||||
@@ -111,8 +111,9 @@ public class ReportListAdapter extends BaseAdapter {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
iv.setBackground(parent.getContext().getDrawable(item.getIconDrawable()));
|
||||
} else {
|
||||
iv.setBackgroundDrawable(parent.getResources().getDrawable(item.getIconDrawable()));
|
||||
iv.setBackground(parent.getResources().getDrawable(item.getIconDrawable()));
|
||||
}
|
||||
|
||||
}
|
||||
return vi;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Top10ListAdapter extends BaseAdapter {
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View vi = convertView;
|
||||
if (vi == null) vi = inflater.inflate(R.layout.fragment_top10list_row, null);
|
||||
if (vi == null) vi = inflater.inflate(R.layout.fragment_top10list_row, parent, false);
|
||||
|
||||
TextView rank = vi.findViewById(R.id.txt_top10_rank);
|
||||
TextView name = vi.findViewById(R.id.txt_top10_name);
|
||||
@@ -66,13 +66,20 @@ public class Top10ListAdapter extends BaseAdapter {
|
||||
TextView points = vi.findViewById(R.id.txt_top10_points);
|
||||
|
||||
try {
|
||||
rank.setText("#"+data.get(position).getString("rank"));
|
||||
rank.setText(String.format("#%s",
|
||||
data.get(position).getString("rank")));
|
||||
|
||||
name.setText(data.get(position).getString("username"));
|
||||
name.setTypeface(null, Typeface.BOLD);
|
||||
points.setText(data.get(position).getString("points"));
|
||||
|
||||
numberOfIncidents.setText(data.get(position).getString("numberOfPosts")+" "+context.getResources().getString(R.string.txt_top10_reportedinc));
|
||||
memberSince.setText(context.getResources().getString(R.string.txt_top10_membersince)+" "+data.get(position).getString("created_at").split(" ")[0]);
|
||||
numberOfIncidents.setText(String.format("%s %s",
|
||||
data.get(position).getString("numberOfPosts"),
|
||||
context.getResources().getString(R.string.txt_top10_reportedinc)));
|
||||
|
||||
memberSince.setText(String.format("%s %s",
|
||||
context.getResources().getString(R.string.txt_top10_membersince),
|
||||
data.get(position).getString("created_at").split(" ")[0]));
|
||||
} catch (JSONException e) {
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.deke.risk.riskahead.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
@@ -9,7 +9,6 @@ import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
@@ -19,7 +18,6 @@ import com.facebook.CallbackManager;
|
||||
import com.facebook.FacebookCallback;
|
||||
import com.facebook.FacebookException;
|
||||
import com.facebook.GraphRequest;
|
||||
import com.facebook.GraphResponse;
|
||||
import com.facebook.login.LoginBehavior;
|
||||
import com.facebook.login.LoginManager;
|
||||
import com.facebook.login.LoginResult;
|
||||
@@ -27,7 +25,6 @@ import com.facebook.login.LoginResult;
|
||||
import org.deke.risk.riskahead.LoginActivity;
|
||||
import org.deke.risk.riskahead.R;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -84,16 +81,10 @@ public class FacebookButtonFragment extends Fragment {
|
||||
mListener = null;
|
||||
}
|
||||
|
||||
public interface OnFragmentInteractionListener {
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
|
||||
private void initFacebookButton() {
|
||||
BootstrapButton btnLoginFB = view.findViewById(R.id.btn_login_fb);
|
||||
|
||||
btnLoginFB.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnLoginFB.setOnClickListener(v -> {
|
||||
LoginManager.getInstance().setLoginBehavior(LoginBehavior.WEB_ONLY);
|
||||
Activity activity = getActivity();
|
||||
if(activity != null){
|
||||
@@ -101,7 +92,6 @@ public class FacebookButtonFragment extends Fragment {
|
||||
}else{
|
||||
Crashlytics.log(Log.ERROR, TAG, "Could not get activity when initializing the facebook button");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
LoginManager.getInstance().registerCallback(callbackManager,
|
||||
@@ -136,9 +126,7 @@ public class FacebookButtonFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void getUserMailAndLogin(AccessToken accesstoken){
|
||||
GraphRequest request = GraphRequest.newMeRequest(accesstoken, new GraphRequest.GraphJSONObjectCallback() {
|
||||
@Override
|
||||
public void onCompleted(JSONObject objects, GraphResponse response) {
|
||||
GraphRequest request = GraphRequest.newMeRequest(accesstoken, (objects, response) -> {
|
||||
try {
|
||||
LoginActivity activity = (LoginActivity) getActivity();
|
||||
if(activity != null){
|
||||
@@ -150,11 +138,14 @@ public class FacebookButtonFragment extends Fragment {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Exception caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
Bundle parameters = new Bundle();
|
||||
parameters.putString("fields", "id,first_name,last_name,email");
|
||||
request.setParameters(parameters);
|
||||
request.executeAsync();
|
||||
}
|
||||
|
||||
public interface OnFragmentInteractionListener {
|
||||
void onFragmentInteraction(Uri uri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -51,16 +52,11 @@ public class GooglePlusButtonFragment extends Fragment{
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_googleplus_button,container, false);
|
||||
|
||||
BootstrapButton btnSignIn = view.findViewById(R.id.btn_login_gp);
|
||||
btnSignIn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
performClickAction();
|
||||
}
|
||||
});
|
||||
btnSignIn.setOnClickListener(v -> performClickAction());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.deke.risk.riskahead.fragment;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -9,13 +10,10 @@ import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
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 com.crashlytics.android.Crashlytics;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import org.deke.risk.riskahead.ProfileActivity;
|
||||
import org.deke.risk.riskahead.R;
|
||||
@@ -56,7 +54,7 @@ public class ProfileStatisticsFragment extends Fragment {
|
||||
private BootstrapButton btnMembershipType;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_profile_stats, container, false);
|
||||
parent = (ProfileActivity)getActivity();
|
||||
|
||||
@@ -97,16 +95,13 @@ public class ProfileStatisticsFragment extends Fragment {
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestProfileStats() {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_USERSTATS, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_USERSTATS, response -> {
|
||||
Log.d(TAG, "User stats: " + response);
|
||||
|
||||
try {
|
||||
JSONObject jObj = new JSONObject(response);
|
||||
boolean error = jObj.getBoolean("error");
|
||||
if (!error) {
|
||||
if (!error && isAdded()) {
|
||||
posts.setText(jObj.getString("numberOfPosts"));
|
||||
|
||||
JSONObject subJObj = jObj.getJSONObject("msg");
|
||||
@@ -155,10 +150,10 @@ public class ProfileStatisticsFragment extends Fragment {
|
||||
}
|
||||
|
||||
if(!parent.user.get(SessionManager.KEY_UID).equals(uid) ){
|
||||
lblPoints.setText(jObj.getString("username")+" "+getResources().getString(R.string.lbl_profile_points_someone));
|
||||
lblPoints.setText(String.format("%s %s", 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));
|
||||
lblMemberSince.setText(String.format("%s %s",jObj.getString("username"), getResources().getString(R.string.lbl_profile_membersince_someone)));
|
||||
}
|
||||
} else {
|
||||
String errorMsg = jObj.getString("error_msg");
|
||||
@@ -172,11 +167,7 @@ public class ProfileStatisticsFragment extends Fragment {
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error getting user stats: " + error.getMessage());
|
||||
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||
if(activity != null){
|
||||
@@ -185,7 +176,6 @@ public class ProfileStatisticsFragment extends Fragment {
|
||||
}else {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Could not retrieve activity for onErrorResponse");
|
||||
}
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
package org.deke.risk.riskahead.fragment;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
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;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
|
||||
import org.deke.risk.riskahead.ProfileActivity;
|
||||
import org.deke.risk.riskahead.R;
|
||||
@@ -51,7 +48,7 @@ public class ReportListFragment extends Fragment{
|
||||
private String uid;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_reportlist, container, false);
|
||||
|
||||
parent = (ProfileActivity)getActivity();
|
||||
@@ -66,9 +63,7 @@ public class ReportListFragment extends Fragment{
|
||||
|
||||
if(resultList == null || resultList.size() == 0) getIncidentsForList();
|
||||
|
||||
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parentview, View view, int position, long id) {
|
||||
myListView.setOnItemClickListener((parentview, view1, position, id) -> {
|
||||
try {
|
||||
if(resultList.get(position).getInt("status") == 1){
|
||||
parent.gotoViewReportActivity(resultList.get(position).getInt("id"));
|
||||
@@ -77,7 +72,6 @@ public class ReportListFragment extends Fragment{
|
||||
Crashlytics.log(Log.ERROR, TAG, "Catched JSONException");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
@@ -97,10 +91,7 @@ public class ReportListFragment extends Fragment{
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestGetIncidentsWithPositionFromUserID() {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENTS_FROMUSERID, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENTS_FROMUSERID, response -> {
|
||||
Log.d(TAG, "Map positions response with ID: " + response);
|
||||
|
||||
try {
|
||||
@@ -138,15 +129,10 @@ public class ReportListFragment extends Fragment{
|
||||
Crashlytics.log(Log.ERROR, TAG, "Catched JSONException");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error getting incident list: " + error.getMessage());
|
||||
parent.handleVolleyErrorResponse();
|
||||
parent.hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -160,5 +146,4 @@ public class ReportListFragment extends Fragment{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.deke.risk.riskahead.fragment;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Dialog;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.Context;
|
||||
@@ -205,9 +206,7 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
||||
inputDateFrom = viewFragment.findViewById(R.id.input_report_from_date);
|
||||
inputTimeFrom = viewFragment.findViewById(R.id.input_report_from_time);
|
||||
|
||||
inputDateFrom.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
inputDateFrom.setOnClickListener(v -> {
|
||||
tmpInput = inputDateFrom;
|
||||
tmpInput.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
@@ -226,12 +225,9 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
||||
}
|
||||
});
|
||||
showDatePickerDialog();
|
||||
}
|
||||
});
|
||||
|
||||
inputTimeFrom.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
inputTimeFrom.setOnClickListener(v -> {
|
||||
tmpInput = inputTimeFrom;
|
||||
tmpInput.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
@@ -250,7 +246,6 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
||||
}
|
||||
});
|
||||
showTimePickerDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -261,28 +256,23 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
||||
inputDateTo = viewFragment.findViewById(R.id.input_report_to_date);
|
||||
inputTimeTo = viewFragment.findViewById(R.id.input_report_to_time);
|
||||
|
||||
inputDateTo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
inputDateTo.setOnClickListener(v -> {
|
||||
tmpInput = inputDateTo;
|
||||
tmpIsToDate = true;
|
||||
showDatePickerDialog();
|
||||
}
|
||||
});
|
||||
|
||||
inputTimeTo.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
inputTimeTo.setOnClickListener(v -> {
|
||||
tmpInput = inputTimeTo;
|
||||
tmpIsToTime = true;
|
||||
showTimePickerDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int hour = c.get(Calendar.HOUR_OF_DAY);
|
||||
@@ -314,6 +304,7 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
||||
public static class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final Calendar c = Calendar.getInstance();
|
||||
int year = c.get(Calendar.YEAR);
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.deke.risk.riskahead.helper.IncidentReport;
|
||||
*
|
||||
*/
|
||||
public class ReportWF_Finish_Fragment extends BaseReportWFFragment {
|
||||
|
||||
private final static String TAG = ReportWF_Finish_Fragment.class.getSimpleName();
|
||||
|
||||
private SendReportListener mCallback;
|
||||
@@ -33,12 +32,7 @@ public class ReportWF_Finish_Fragment extends BaseReportWFFragment {
|
||||
View viewFragment = inflater.inflate(R.layout.fragment_reportwf_finish, container, false);
|
||||
|
||||
Button btnSendReport = viewFragment.findViewById(R.id.btn_reportwf_finish_send);
|
||||
btnSendReport.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mCallback.sendReport();
|
||||
}
|
||||
});
|
||||
btnSendReport.setOnClickListener(v -> mCallback.sendReport());
|
||||
|
||||
return viewFragment;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.deke.risk.riskahead.fragment;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.EditTextPreference;
|
||||
import android.preference.ListPreference;
|
||||
@@ -11,8 +10,6 @@ import android.support.v7.app.AlertDialog;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
|
||||
@@ -76,18 +73,13 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
prefGPSENabled = (SwitchPreference) getPreferenceManager().findPreference("notifyEnableGPS");
|
||||
prefLocation = getPreferenceManager().findPreference("notifyChooseLocation");
|
||||
|
||||
prefNotifications.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
prefNotifications.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
String newStringValue = newValue.toString();
|
||||
session.setNotificationEnabled(Boolean.valueOf(newStringValue));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
prefRadius.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
prefRadius.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
String newStringValue = newValue.toString();
|
||||
|
||||
if(session.getSubsPremium() || Integer.valueOf(newStringValue) < 25){
|
||||
@@ -100,34 +92,25 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
prefFrequency.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
prefFrequency.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
String newStringValue = newValue.toString();
|
||||
session.setNotificationPollFreq(Integer.valueOf(newStringValue));
|
||||
((ListPreference) preference).setValue(newValue.toString());
|
||||
preference.setSummary(prefFrequency.getEntry());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
prefGPSENabled.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
prefGPSENabled.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
String newStringValue = newValue.toString();
|
||||
session.setGPSForNotificationsEnabled(Boolean.valueOf(newStringValue));
|
||||
updatePrefs();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
prefLocation.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
prefLocation.setOnPreferenceClickListener(preference -> {
|
||||
if (session.getManualLocation().longitude != 0.0 && session.getManualLocation().latitude != 0.0) {
|
||||
((SettingsActivity) getActivity()).getNotifyLocationFromMapActivity(Double.toString(session.getManualLocation().latitude) + " : " + Double.toString(session.getManualLocation().longitude));
|
||||
} else if(session.getLocation().longitude != 0.0 && session.getLocation().latitude != 0.0){
|
||||
@@ -137,7 +120,6 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if(!session.getSubsPremium()){
|
||||
@@ -158,12 +140,9 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
prefEmail = (ValidatedEditTextPreference) getPreferenceManager().findPreference("emailPref");
|
||||
Preference btnRequestPW = getPreferenceManager().findPreference("resetPassword");
|
||||
|
||||
Preference.OnPreferenceChangeListener changeListener = new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
Preference.OnPreferenceChangeListener changeListener = (preference, newValue) -> {
|
||||
requestUpdateUserSettings(preference,newValue.toString());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
prefUsername.setOnPreferenceChangeListener(changeListener);
|
||||
@@ -172,27 +151,18 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
prefEmail.setOnPreferenceChangeListener(changeListener);
|
||||
|
||||
if(btnRequestPW != null){
|
||||
btnRequestPW.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
btnRequestPW.setOnPreferenceClickListener(preference -> {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setTitle(getResources().getString(R.string.txt_settings_resetpwtitle))
|
||||
.setMessage(getResources().getString(R.string.txt_settings_resetpwtext))
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
requestPasswordReset();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> requestPasswordReset())
|
||||
.setNegativeButton(android.R.string.no, (dialog, which) -> {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if(!user.get(SessionManager.PROVIDER_TYPE).equals("local")){
|
||||
@@ -243,10 +213,7 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
|
||||
private StringRequest getStringRequestResetPW(final String email) {
|
||||
((SettingsActivity) getActivity()).showDialog();
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_REQUESTPWRESET, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_REQUESTPWRESET, response -> {
|
||||
Log.d(TAG, "Resend E-Mail Response: " + response);
|
||||
((SettingsActivity) getActivity()).hideDialog();
|
||||
|
||||
@@ -266,15 +233,10 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error request email reset: " + error.getMessage());
|
||||
((SettingsActivity) getActivity()).showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||
((SettingsActivity) getActivity()).hideDialog();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
@@ -291,27 +253,28 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
((SettingsActivity) getActivity()).showDialog();
|
||||
String username = prefUsername.getText(),name = prefName.getText(),surname = prefSurname.getText(),email = prefEmail.getText();
|
||||
|
||||
if(pref.getKey().equals("usernamePref")){
|
||||
switch (pref.getKey()){
|
||||
case "usernamePref":
|
||||
username = newValue;
|
||||
}else if(pref.getKey().equals("namePref")){
|
||||
break;
|
||||
case "namePref":
|
||||
name = newValue;
|
||||
}else if(pref.getKey().equals("surnamePref")){
|
||||
break;
|
||||
case "surnamePref":
|
||||
surname = newValue;
|
||||
}else if(pref.getKey().equals("emailPref")){
|
||||
break;
|
||||
case "emailPref":
|
||||
email = newValue;
|
||||
break;
|
||||
}
|
||||
|
||||
String tag_string_req = "updateuser";
|
||||
StringRequest strReq = getStringChangeUserSettings(username,name,surname,email);
|
||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||
|
||||
}
|
||||
|
||||
private StringRequest getStringChangeUserSettings(final String username, final String name, final String surname, final String email) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_UPDATE_USER, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_UPDATE_USER, response -> {
|
||||
Log.d(TAG, "Change user settings: " + response);
|
||||
|
||||
try {
|
||||
@@ -354,16 +317,11 @@ public class SettingsFragment extends PreferenceFragment {
|
||||
|
||||
((SettingsActivity) getActivity()).hideDialog();
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error getting user settings: " + error.getMessage());
|
||||
((SettingsActivity) getActivity()).showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||
((SettingsActivity) getActivity()).hideDialog();
|
||||
updatePrefs();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.deke.risk.riskahead.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -37,7 +38,7 @@ public class SubscriptionItemFragment extends Fragment {
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_subscriptionitem, container, false);
|
||||
parent = (SubscriptionsActivity)getActivity();
|
||||
|
||||
@@ -81,12 +82,9 @@ public class SubscriptionItemFragment extends Fragment {
|
||||
txtDescription.setText(description);
|
||||
btnPurchase.setText(price);
|
||||
|
||||
btnPurchase.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnPurchase.setOnClickListener(v -> {
|
||||
Log.d(TAG, "PURCHASE: " + id);
|
||||
parent.buyProduct(id);
|
||||
}
|
||||
});
|
||||
|
||||
txtTitle.setVisibility(View.VISIBLE);
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package org.deke.risk.riskahead.fragment;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
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;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
|
||||
@@ -48,22 +46,19 @@ public class Top10Fragment extends Fragment {
|
||||
List<JSONObject> resultList;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_top10list, container, false);
|
||||
parent = (ProfileActivity)getActivity();
|
||||
|
||||
myListView = view.findViewById(R.id.lv_top10list);
|
||||
|
||||
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parentview, View view, int position, long id) {
|
||||
myListView.setOnItemClickListener((parentview, view1, position, id) -> {
|
||||
try {
|
||||
parent.gotoProfileActivity(resultList.get(position).getString("id"));
|
||||
} catch (JSONException e) {
|
||||
Crashlytics.log(Log.ERROR, TAG, "JSONException caught");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(resultList == null || resultList.size() == 0) getTop10ForList();
|
||||
@@ -85,10 +80,7 @@ public class Top10Fragment extends Fragment {
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestTop10() {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_TOP10, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_TOP10, response -> {
|
||||
Log.d(TAG, "Top 10 stats: " + response);
|
||||
|
||||
try {
|
||||
@@ -127,11 +119,7 @@ public class Top10Fragment extends Fragment {
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
}, error -> {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error getting top 10 stats: " + error.getMessage());
|
||||
|
||||
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||
@@ -141,7 +129,6 @@ public class Top10Fragment extends Fragment {
|
||||
}else{
|
||||
Crashlytics.log(Log.ERROR, TAG, "Could not get parent Activity");
|
||||
}
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -12,15 +13,12 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.twitter.sdk.android.core.Callback;
|
||||
import com.twitter.sdk.android.core.DefaultLogger;
|
||||
import com.twitter.sdk.android.core.Result;
|
||||
import com.twitter.sdk.android.core.Twitter;
|
||||
import com.twitter.sdk.android.core.TwitterAuthToken;
|
||||
import com.twitter.sdk.android.core.TwitterConfig;
|
||||
import com.twitter.sdk.android.core.TwitterCore;
|
||||
import com.twitter.sdk.android.core.TwitterAuthConfig;
|
||||
@@ -66,8 +64,16 @@ public class TwitterButtonFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
||||
mContext = getActivity().getApplicationContext();
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
try{
|
||||
Activity mActivity = getActivity();
|
||||
assert mActivity != null;
|
||||
mContext = mActivity.getApplicationContext();
|
||||
}catch(Exception e){
|
||||
Crashlytics.log(Log.ERROR, TAG, "Could not get activity for TwitterButton");
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
TwitterConfig config = new TwitterConfig.Builder(mContext)
|
||||
.logger(new DefaultLogger(Log.INFO))
|
||||
.twitterAuthConfig(new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET))
|
||||
@@ -85,10 +91,6 @@ public class TwitterButtonFragment extends Fragment {
|
||||
public void success(Result<TwitterSession> result) {
|
||||
Log.e("Debug", "onSuccess wird ausgeführt");
|
||||
session = result.data;
|
||||
TwitterAuthToken authToken = session.getAuthToken();
|
||||
String token = authToken.token;
|
||||
String secret = authToken.secret;
|
||||
|
||||
((LoginActivity) getActivity()).handleSocialMediaLogin((Long.toString(session.getUserId())), "twitter", session.getUserName(), "");
|
||||
}
|
||||
|
||||
@@ -100,24 +102,14 @@ public class TwitterButtonFragment extends Fragment {
|
||||
})
|
||||
);
|
||||
|
||||
if(isAuthed()){
|
||||
// log out
|
||||
}else{
|
||||
// log in
|
||||
}
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void setUpSignOut() {
|
||||
btnLoginTW.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
btnLoginTW.setOnClickListener(v -> {
|
||||
TwitterCore.getInstance().getSessionManager().clearActiveSession();
|
||||
|
||||
Toast.makeText(mContext, "All accounts are cleared",Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -146,11 +138,6 @@ public class TwitterButtonFragment extends Fragment {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.deke.risk.riskahead.helper;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
@@ -19,11 +18,12 @@ import org.deke.risk.riskahead.R;
|
||||
public class AppRater {
|
||||
|
||||
private final static int DAYS_UNTIL_PROMPT = 1;
|
||||
private final static int MILLIS_UNTIL_PROMPT = DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000;
|
||||
private final static int LAUNCHES_UNTIL_PROMPT = 10;
|
||||
|
||||
public static boolean app_launched(Context mContext) {
|
||||
public static void startAppRater(Context mContext) {
|
||||
SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);
|
||||
if (prefs.getBoolean("dontshowagain", false)) { return false ; }
|
||||
if (prefs.getBoolean("dontshowagain", false)) { return; }
|
||||
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
|
||||
@@ -39,16 +39,12 @@ public class AppRater {
|
||||
}
|
||||
|
||||
// Wait at least n days before opening
|
||||
if (launch_count >= LAUNCHES_UNTIL_PROMPT) {
|
||||
if (System.currentTimeMillis() >= date_firstLaunch +
|
||||
(DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000)) {
|
||||
if (launch_count >= LAUNCHES_UNTIL_PROMPT &&
|
||||
System.currentTimeMillis() >= MILLIS_UNTIL_PROMPT) {
|
||||
showRateDialog(mContext, editor);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
editor.apply();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showRateDialog(final Context mContext, final SharedPreferences.Editor editor) {
|
||||
@@ -59,33 +55,22 @@ public class AppRater {
|
||||
alert.setIcon(R.drawable.logo_380);
|
||||
alert.setCancelable(true);
|
||||
alert.setPositiveButton(R.string.txt_rate_retenowbtn,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + AppConfig.APP_PNAME)));
|
||||
}
|
||||
});
|
||||
(dialog, which) -> mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + AppConfig.APP_PNAME))));
|
||||
alert.setNeutralButton(R.string.txt_rate_laterbtn,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
(dialog, which) -> {
|
||||
SharedPreferences prefs = mContext.getSharedPreferences("apprater", 0);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
SharedPreferences.Editor editor1 = prefs.edit();
|
||||
|
||||
Long date_firstLaunch = System.currentTimeMillis();
|
||||
editor.putLong("date_firstlaunch", date_firstLaunch);
|
||||
editor.apply();
|
||||
}
|
||||
editor1.putLong("date_firstlaunch", date_firstLaunch);
|
||||
editor1.apply();
|
||||
});
|
||||
alert.setNegativeButton(R.string.txt_rate_neverbtn,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
(dialog, which) -> {
|
||||
if (editor != null) {
|
||||
editor.putBoolean("dontshowagain", true);
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog ad = alert.create();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.deke.risk.riskahead.helper;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.AlertDialog;
|
||||
@@ -7,7 +8,6 @@ import android.app.Dialog;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -37,8 +37,6 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.google.android.gms.ads.AdListener;
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
@@ -52,7 +50,6 @@ import com.mikepenz.materialdrawer.DrawerBuilder;
|
||||
import com.mikepenz.materialdrawer.model.DividerDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.PrimaryDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.ProfileDrawerItem;
|
||||
import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
|
||||
|
||||
import org.deke.risk.riskahead.LoginActivity;
|
||||
import org.deke.risk.riskahead.MapsActivity;
|
||||
@@ -69,8 +66,6 @@ import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import io.fabric.sdk.android.Fabric;
|
||||
|
||||
/**
|
||||
* (C) Copyright 2016 RiskAhead (http://www.riskahead.net)
|
||||
* Developer & Contributor: Dennis Thießen (dennis.thiessen@riskahead.net)
|
||||
@@ -177,7 +172,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
Log.d(TAG, "onCreate: NotificationService already running. Not starting more services.");
|
||||
}
|
||||
|
||||
AppRater.app_launched(BaseActivity.this);
|
||||
AppRater.startAppRater(BaseActivity.this);
|
||||
}
|
||||
|
||||
class LogoutReceiver extends BroadcastReceiver {
|
||||
@@ -313,9 +308,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
item5,
|
||||
new DividerDrawerItem(),
|
||||
item6,
|
||||
item7).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
|
||||
@Override
|
||||
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
|
||||
item7).withOnDrawerItemClickListener((view, position, drawerItem) -> {
|
||||
|
||||
switch ((int) drawerItem.getIdentifier()) {
|
||||
case 2:
|
||||
@@ -343,7 +336,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}).build();
|
||||
|
||||
|
||||
@@ -394,11 +386,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
.setTitle(getString(R.string.alert_internetconnection_title))
|
||||
.setMessage(getString(R.string.alert_internetconnection_text))
|
||||
.setCancelable(false)
|
||||
.setNeutralButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
logoutUser();
|
||||
}
|
||||
})
|
||||
.setNeutralButton(android.R.string.yes, (dialog, which) -> logoutUser())
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
}
|
||||
@@ -559,10 +547,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(this);
|
||||
b.setTitle(R.string.txt_language_title);
|
||||
String[] types = {"ar - العربية", "de - Deutsch", "en - English", "es - Español", "et - Eesti keel", "fi - Suomi", "fr - Français", "lv - Latviešu valoda", "mn - Монгол хэл", "nl - Nederlands", "pl - Polszczyzna", "pt - Português do Brasil", "ru - Pусский", "tr - Türkçe"};
|
||||
b.setItems(types, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
b.setItems(types, (dialog, which) -> {
|
||||
|
||||
dialog.dismiss();
|
||||
switch (which) {
|
||||
@@ -609,8 +594,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
setLocale("tr");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
b.show();
|
||||
@@ -628,6 +611,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
finish();
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
private void showAboutInfoDialog() {
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
View dialoglayout = inflater.inflate(R.layout.dialog_about, null);
|
||||
@@ -644,10 +628,8 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(BaseActivity.this)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
||||
//do nothing
|
||||
}
|
||||
});
|
||||
|
||||
builder.setView(dialoglayout);
|
||||
@@ -674,18 +656,10 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
alert.setIcon(R.drawable.logo_380);
|
||||
alert.setCancelable(true);
|
||||
alert.setPositiveButton(R.string.txt_feedback_sendbtn,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
sendFeedback(input.getText().toString());
|
||||
}
|
||||
});
|
||||
(dialog, which) -> sendFeedback(input.getText().toString()));
|
||||
alert.setNegativeButton(R.string.txt_feedback_cancelbtn,
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
(dialog, which) -> {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog ad = alert.create();
|
||||
@@ -711,10 +685,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private StringRequest getStringRequestSendFeedback(final String feedback, final String sysprop) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_SEND_FEEDBACK, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_SEND_FEEDBACK, response -> {
|
||||
Log.d(TAG, "Send Feedback: " + response);
|
||||
|
||||
try {
|
||||
@@ -732,14 +703,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error sending feedback: " + error.getMessage());
|
||||
}
|
||||
}) {
|
||||
}, error -> Crashlytics.log(Log.ERROR, TAG, "Error sending feedback: " + error.getMessage())) {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
@@ -802,7 +766,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
public void dropBreadCumb(String category, String action, String label, long value) {
|
||||
public void dropBreadCrumb(String category, String action, String label, long value) {
|
||||
String breadCrumb = String.format("%s|%s|%s|%s", category, action, label, value);
|
||||
Crashlytics.log(breadCrumb);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ import android.support.v4.app.TaskStackBuilder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.StringRequest;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
@@ -208,10 +206,7 @@ public class NotificationService extends Service {
|
||||
};
|
||||
|
||||
private StringRequest getStringRequestIncidentsFromAreaAndTime(final Double latitude, final Double longitude, final int radius, final String time) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENTS_FROMAREATIME, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_INCIDENTS_FROMAREATIME, response -> {
|
||||
Log.d(TAG, "Incident notifications: " + response);
|
||||
|
||||
try {
|
||||
@@ -231,14 +226,7 @@ public class NotificationService extends Service {
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Crashlytics.log(Log.ERROR, TAG, "Error getting incident notification: " + error.getMessage());
|
||||
}
|
||||
}) {
|
||||
}, error -> Crashlytics.log(Log.ERROR, TAG, "Error getting incident notification: " + error.getMessage())) {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
@@ -184,17 +185,17 @@ public class PlaceProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Uri uri, String selection, String[] selectionArgs) {
|
||||
public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(Uri uri) {
|
||||
public String getType(@NonNull Uri uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(Uri uri, ContentValues values) {
|
||||
public Uri insert(@NonNull Uri uri, ContentValues values) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -204,7 +205,7 @@ public class PlaceProvider extends ContentProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri uri, ContentValues values, String selection,String[] selectionArgs) {
|
||||
public int update(@NonNull Uri uri, ContentValues values, String selection,String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -227,15 +228,15 @@ public class PlaceProvider extends ContentProvider {
|
||||
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(iStream));
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line = "";
|
||||
String line;
|
||||
while( ( line = br.readLine()) != null){
|
||||
sb.append(line);
|
||||
}
|
||||
|
||||
data = sb.toString();
|
||||
System.out.println("DATA:"+data);
|
||||
Log.d(TAG,"DATA:"+data);
|
||||
br.close();
|
||||
|
||||
}catch(Exception e){
|
||||
@@ -264,7 +265,7 @@ public class PlaceProvider extends ContentProvider {
|
||||
|
||||
// Building the url to the web service
|
||||
String url = "https://maps.googleapis.com/maps/api/place/details/"+output+"?"+parameters;
|
||||
System.out.println("URL: "+url);
|
||||
Log.d(TAG,"URL: "+url);
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -290,7 +291,7 @@ public class PlaceProvider extends ContentProvider {
|
||||
// Building the url to the web service
|
||||
String url = "https://maps.googleapis.com/maps/api/place/autocomplete/"+output+"?"+parameters;
|
||||
|
||||
System.out.println("URL: "+url);
|
||||
Log.d(TAG,"URL: "+url);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
Reference in New Issue
Block a user