DT @22.11.2015: Implemented some text checks
This commit is contained in:
11
app/app.iml
11
app/app.iml
@@ -66,12 +66,10 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/debug" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/mediarouter-v7/22.0.0/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
|
||||
@@ -102,17 +100,12 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.twitter.sdk.android/twitter-core/1.4.1/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/io.fabric.sdk.android/fabric/1.3.4/jars" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
|
||||
</content>
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.DatePicker;
|
||||
@@ -26,6 +27,7 @@ import com.android.volley.toolbox.StringRequest;
|
||||
import org.deke.risk.riskahead.helper.AppConfig;
|
||||
import org.deke.risk.riskahead.helper.AppController;
|
||||
import org.deke.risk.riskahead.helper.BaseActivity;
|
||||
import org.deke.risk.riskahead.helper.TextValidator;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
@@ -152,6 +154,26 @@ public class ReportActivity extends BaseActivity {
|
||||
showDialog(TIME_DIALOG_ID);
|
||||
}
|
||||
});
|
||||
|
||||
txtTitle.addTextChangedListener(new TextValidator(txtTitle) {
|
||||
@Override
|
||||
public void validate(TextView textView, String text) {
|
||||
if (text.length() < 5) {
|
||||
textView.setError("Your password must be at least\n" +
|
||||
"5 characters in length.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
txtDescription.addTextChangedListener(new TextValidator(txtDescription) {
|
||||
@Override
|
||||
public void validate(TextView textView, String text) {
|
||||
if (text.length() < 5) {
|
||||
textView.setError("Your password must be at least\n" +
|
||||
"5 characters in length.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void restoreSharedPreferences() {
|
||||
@@ -194,7 +216,7 @@ public class ReportActivity extends BaseActivity {
|
||||
SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
|
||||
editor.clear();
|
||||
editor.apply();
|
||||
gotoMapActivity();
|
||||
gotoMapActivity(latitude+":"+longitude);
|
||||
} else {
|
||||
String errorMsg = jObj.getString("error_msg");
|
||||
Toast.makeText(getApplicationContext(), errorMsg, Toast.LENGTH_LONG).show();
|
||||
|
||||
@@ -4,8 +4,8 @@ import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.util.Patterns;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.android.volley.toolbox.StringRequest;
|
||||
import org.deke.risk.riskahead.helper.AppConfig;
|
||||
import org.deke.risk.riskahead.helper.AppController;
|
||||
import org.deke.risk.riskahead.helper.BaseActivity;
|
||||
import org.deke.risk.riskahead.helper.TextValidator;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -45,7 +46,25 @@ public class SettingsActivity extends BaseActivity {
|
||||
txtEmail = (TextView) findViewById(R.id.txt_settings_email);
|
||||
txtPassword = (TextView) findViewById(R.id.txt_settings_password);
|
||||
|
||||
txtUsername.addTextChangedListener(new TextValidator(txtUsername) {
|
||||
@Override
|
||||
public void validate(TextView textView, String text) {
|
||||
if (text.length() < 5) {
|
||||
textView.setError("Your username must be at least\n" +
|
||||
"5 characters in length.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
txtEmail.addTextChangedListener(new TextValidator(txtEmail) {
|
||||
@Override
|
||||
public void validate(TextView textView, String text) {
|
||||
if (!Patterns.EMAIL_ADDRESS.matcher(text).matches()) {
|
||||
textView.setError("Please enter a valid email address\n" +
|
||||
"e.g.: text@abc.de");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btn_settings_req_password).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -80,6 +99,11 @@ public class SettingsActivity extends BaseActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
if (txtUsername.getError() != null || txtEmail.getError() != null) {
|
||||
showMessage("Entered fields not valid\n" +
|
||||
"Please check errors first.");
|
||||
} else {
|
||||
|
||||
new AlertDialog.Builder(SettingsActivity.this)
|
||||
.setTitle("Confirm changes")
|
||||
.setMessage("Do you really want to confirm changes? ")
|
||||
@@ -98,6 +122,7 @@ public class SettingsActivity extends BaseActivity {
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
txtUsername.setText(user.get("username"));
|
||||
|
||||
@@ -290,12 +290,10 @@ public class ViewReportActivity extends BaseActivity {
|
||||
JSONObject jObj = new JSONObject(response);
|
||||
boolean error = jObj.getBoolean("error");
|
||||
|
||||
// Check for error node in json
|
||||
if (!error) {
|
||||
BootstrapLabel scorelabel = (BootstrapLabel) findViewById(R.id.txt_viewreport_points);
|
||||
scorelabel.setText(jObj.getString("points"));
|
||||
} else {
|
||||
// Error in login. Get the error message
|
||||
String errorMsg = jObj.getString("error_msg");
|
||||
Toast.makeText(getApplicationContext(), errorMsg, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
@@ -316,17 +314,14 @@ public class ViewReportActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
// Posting parameters to login url
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("tag", "getincidentvotescore");
|
||||
params.put("uid", user.get("uid"));
|
||||
params.put("token", user.get("token"));
|
||||
params.put("incidentid", incidentid);
|
||||
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -380,7 +375,6 @@ public class ViewReportActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
// Posting parameters to login url
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("tag", "addvote");
|
||||
params.put("uid", user.get("uid"));
|
||||
@@ -388,10 +382,8 @@ public class ViewReportActivity extends BaseActivity {
|
||||
params.put("incidentid", incidentid);
|
||||
params.put("votetype", votetype);
|
||||
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ public abstract class TextValidator implements TextWatcher {
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 102 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 46 KiB |
Reference in New Issue
Block a user