Updated String resources and provided context
This commit is contained in:
parent
83a02ba6ed
commit
13cd391af0
|
|
@ -227,7 +227,7 @@ public class AddNewPlaceActivity extends AppCompatActivity implements View.OnCli
|
|||
|
||||
private void onClickBtnSubmit() {
|
||||
View[] views = {etPlaceName, etLatitude, etLongitude, etAddress, etPlaceDescription};
|
||||
if (Helper.isEmptyFieldValidation(views)) {
|
||||
if (Helper.isEmptyFieldValidation(context, views)) {
|
||||
setInputDataToEntity();
|
||||
|
||||
if (place_uuid != null && !place_uuid.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.example.acloc.activity;
|
|||
|
||||
import static com.example.acloc.utility.Constants.BASE_URL;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
|
|
@ -273,7 +272,7 @@ public class AddReportActivity extends AppCompatActivity implements View.OnClick
|
|||
|
||||
private void onClickBtnSubmit() {
|
||||
View[] views = {etPlaceName, etDescription};
|
||||
if (Helper.isEmptyFieldValidation(views) && isValidateRating()) {
|
||||
if (Helper.isEmptyFieldValidation(context, views) && isValidateRating()) {
|
||||
setInputDataToEntity();
|
||||
|
||||
if (report_uuid != null && !report_uuid.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||
Helper.goTo(this, MainActivity.class);
|
||||
finish();
|
||||
} else {
|
||||
// Optionally force logout if token expired
|
||||
// force logout if token expired
|
||||
SharedPref.setIsLoggedIn(this, false);
|
||||
SharedPref.setAccessToken(this, ""); // clear token
|
||||
setContentView(R.layout.activity_login);
|
||||
|
|
@ -112,7 +112,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList
|
|||
|
||||
private void onClickBtnLogin() {
|
||||
View[] views = {etUsername, etPassword};
|
||||
if (Helper.isEmptyFieldValidation(views)) {
|
||||
if (Helper.isEmptyFieldValidation(context, views)) {
|
||||
setInputDataToEntity();
|
||||
loginUserWithRetrofit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class PlaceDetailActivity extends AppCompatActivity implements View.OnCli
|
|||
super.onResume();
|
||||
if (adapter != null) {
|
||||
setDataVisibility(false);
|
||||
adapter.clearReports(); // Safe way to clear and notify
|
||||
adapter.clearReports(); // clear and notify
|
||||
}
|
||||
|
||||
if (context != null) loadData();
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class AlertChangePasswordDialog implements View.OnClickListener {
|
|||
|
||||
private void onClickBtnUpdate() {
|
||||
View[] views = {etOldPassword, etNewPassword};
|
||||
if (Helper.isEmptyFieldValidation(views) && Helper.isPasswordValid(etNewPassword)) {
|
||||
if (Helper.isEmptyFieldValidation(context, views) && Helper.isPasswordValid(context, etNewPassword)) {
|
||||
String username = SharedPref.getUserName(context);
|
||||
String oldPassword = Helper.getStringFromInput(etOldPassword);
|
||||
String newPassword = Helper.getStringFromInput(etNewPassword);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class AlertViewAddNewPlaceDialog implements View.OnClickListener {
|
|||
|
||||
private void onClickBtnSubmit() {
|
||||
View[] views = {etPlaceName, etLatitude, etLongitude, etAddress, etPlaceDescription};
|
||||
if (Helper.isEmptyFieldValidation(views)) {
|
||||
if (Helper.isEmptyFieldValidation(context, views)) {
|
||||
setInputDataToEntity();
|
||||
|
||||
if (place_uuid != null && !place_uuid.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class AlertViewOrUpdateProfileDialog implements View.OnClickListener {
|
|||
|
||||
private void onClickBtnUpdate() {
|
||||
View[] views = {etUsername, etEmail};
|
||||
if (Helper.isEmptyFieldValidation(views) && Helper.isEmailValid(etEmail)) {
|
||||
if (Helper.isEmptyFieldValidation(context, views) && Helper.isEmailValid(context, etEmail)) {
|
||||
setInputDataToEntity();
|
||||
String uuid = SharedPref.getUserUid(context);
|
||||
updateUserWithRetrofit(uuid, entity.getUsername(), entity.getEmail());
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import com.google.android.material.snackbar.Snackbar;
|
|||
import com.google.android.material.textfield.MaterialAutoCompleteTextView;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.ieslamar.acloc.R;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -49,17 +50,6 @@ public class Helper {
|
|||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
context.startActivity(intent);
|
||||
|
||||
// No need to finish explicitly here, flags handle it
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).finish();
|
||||
}
|
||||
}
|
||||
|
||||
public static void goToAndFinish(Context context, Class<?> activity, String key, Serializable object) {
|
||||
Intent intent = new Intent(context, activity);
|
||||
intent.putExtra(key, object);
|
||||
context.startActivity(intent);
|
||||
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).finish();
|
||||
}
|
||||
|
|
@ -75,6 +65,16 @@ public class Helper {
|
|||
// }
|
||||
}
|
||||
|
||||
public static void goToAndFinish(Context context, Class<?> activity, String key, Serializable object) {
|
||||
Intent intent = new Intent(context, activity);
|
||||
intent.putExtra(key, object);
|
||||
context.startActivity(intent);
|
||||
|
||||
if (context instanceof Activity) {
|
||||
((Activity) context).finish();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getIntValueFromString(String value) {
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
|
|
@ -137,7 +137,7 @@ public class Helper {
|
|||
return isValidate;
|
||||
}
|
||||
|
||||
public static boolean isEmptyFieldValidation(View[] inputFields) {
|
||||
public static boolean isEmptyFieldValidation(Context context, View[] inputFields) {
|
||||
boolean isValidate = true;
|
||||
try {
|
||||
for (View view : inputFields) {
|
||||
|
|
@ -156,13 +156,13 @@ public class Helper {
|
|||
|
||||
if (inputText.isEmpty()) {
|
||||
if (textInputLayout != null) {
|
||||
textInputLayout.setError("Please " + textInputLayout.getHint());
|
||||
textInputLayout.setError(context.getString(R.string.please) +" "+ textInputLayout.getHint());
|
||||
textInputLayout.setErrorEnabled(true);
|
||||
} else {
|
||||
if (view instanceof TextInputEditText) {
|
||||
((TextInputEditText) view).setError("Empty");
|
||||
((TextInputEditText) view).setError(context.getString(R.string.empty));
|
||||
} else if (view instanceof MaterialAutoCompleteTextView) {
|
||||
((MaterialAutoCompleteTextView) view).setError("Empty");
|
||||
((MaterialAutoCompleteTextView) view).setError(context.getString(R.string.empty));
|
||||
}
|
||||
}
|
||||
isValidate = false;
|
||||
|
|
@ -185,7 +185,7 @@ public class Helper {
|
|||
return isValidate;
|
||||
}
|
||||
|
||||
public static boolean isEmailValid(View emailView) {
|
||||
public static boolean isEmailValid(Context context, View emailView) {
|
||||
boolean isValidate = true;
|
||||
try {
|
||||
TextInputLayout textInputLayout = null;
|
||||
|
|
@ -204,13 +204,13 @@ public class Helper {
|
|||
// Regex for email validation
|
||||
if (!emailText.matches("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,6}$")) {
|
||||
if (textInputLayout != null) {
|
||||
textInputLayout.setError("Invalid Email Address");
|
||||
textInputLayout.setError(context.getString(R.string.invalid_email_address));
|
||||
textInputLayout.setErrorEnabled(true);
|
||||
} else {
|
||||
if (emailView instanceof TextInputEditText) {
|
||||
((TextInputEditText) emailView).setError("Invalid Email Address");
|
||||
((TextInputEditText) emailView).setError(context.getString(R.string.invalid_email_address));
|
||||
} else if (emailView instanceof MaterialAutoCompleteTextView) {
|
||||
((MaterialAutoCompleteTextView) emailView).setError("Invalid Email Address");
|
||||
((MaterialAutoCompleteTextView) emailView).setError(context.getString(R.string.invalid_email_address));
|
||||
}
|
||||
}
|
||||
isValidate = false;
|
||||
|
|
@ -232,7 +232,7 @@ public class Helper {
|
|||
return isValidate;
|
||||
}
|
||||
|
||||
public static boolean isPasswordValid(View passwordView) {
|
||||
public static boolean isPasswordValid(Context context, View passwordView) {
|
||||
boolean isValidate = true;
|
||||
try {
|
||||
TextInputLayout textInputLayout = null;
|
||||
|
|
@ -253,13 +253,13 @@ public class Helper {
|
|||
|
||||
if (!passwordText.matches(passwordPattern)) {
|
||||
if (textInputLayout != null) {
|
||||
textInputLayout.setError("Password must be at least 6 characters, include 1 uppercase, 1 lowercase, 1 digit, and 1 special character.");
|
||||
textInputLayout.setError(context.getString(R.string.password_validation_requirement));
|
||||
textInputLayout.setErrorEnabled(true);
|
||||
} else {
|
||||
if (passwordView instanceof TextInputEditText) {
|
||||
((TextInputEditText) passwordView).setError("Password must be at least 6 characters, include 1 uppercase, 1 lowercase, 1 digit, and 1 special character.");
|
||||
((TextInputEditText) passwordView).setError(context.getString(R.string.password_validation_requirement));
|
||||
} else if (passwordView instanceof MaterialAutoCompleteTextView) {
|
||||
((MaterialAutoCompleteTextView) passwordView).setError("Password must be at least 6 characters, include 1 uppercase, 1 lowercase, 1 digit, and 1 special character.");
|
||||
((MaterialAutoCompleteTextView) passwordView).setError(context.getString(R.string.password_validation_requirement));
|
||||
}
|
||||
}
|
||||
isValidate = false;
|
||||
|
|
|
|||
|
|
@ -170,6 +170,10 @@
|
|||
<string name="response_parsing_error">Error de análisis</string>
|
||||
<string name="no_places_found_near_this_location">Ningún lugar encontrado cerca de esta dirección</string>
|
||||
<string name="location_not_found">Lugar no encontrado</string>
|
||||
<string name="invalid_email_address">Dirección de correo no válida</string>
|
||||
<string name="please">Por favor</string>
|
||||
<string name="empty">Vacío</string>
|
||||
<string name="password_validation_requirement">La contraseña debe tener al menos 6 caracteres, incluir 1 mayúscula, 1 minúscula, 1 dígito y 1 carácter especial.</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
@ -173,6 +173,10 @@
|
|||
<string name="response_parsing_error">Response parsing error</string>
|
||||
<string name="no_places_found_near_this_location">No places found near this location</string>
|
||||
<string name="location_not_found">Location not found</string>
|
||||
<string name="invalid_email_address">Invalid email address</string>
|
||||
<string name="please">Please</string>
|
||||
<string name="empty">Empty</string>
|
||||
<string name="password_validation_requirement">Password must be at least 6 characters, include 1 uppercase, 1 lowercase, 1 digit, and 1 special character.</string>
|
||||
|
||||
|
||||
</resources>
|
||||
Loading…
Reference in New Issue