DT @25.11.2015: General refactoring, improved errortext show up, better position detail when reporting, added german language file (but english at the moment), cleaned strings res

This commit is contained in:
Dennis Thießen
2015-11-25 21:59:00 +01:00
parent 666fa60512
commit 1a358128c4
15 changed files with 315 additions and 222 deletions

View File

@@ -2,6 +2,7 @@
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintRtlCompat" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="AndroidLintValidFragment" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="LoggerInitializedWithForeignClass" enabled="false" level="WARNING" enabled_by_default="false">
<option name="loggerClassName" value="org.apache.log4j.Logger,org.slf4j.LoggerFactory,org.apache.commons.logging.LogFactory,java.util.logging.Logger" />
<option name="loggerFactoryMethodName" value="getLogger,getLogger,getLog,getLogger" />

View File

@@ -41,7 +41,7 @@
<activity
android:name=".StartActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_start" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -51,7 +51,7 @@
<activity
android:name=".LoginActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/app_name"
android:parentActivityName=".StartActivity" >
<meta-data
@@ -70,14 +70,14 @@
<activity
android:name=".MainActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_entrance"
android:parentActivityName=".LoginActivity" >
</activity>
<activity
android:name=".MapsActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_maps"
android:parentActivityName=".MainActivity" >
<intent-filter>
@@ -99,32 +99,32 @@
<activity
android:name=".ProfileActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_user_config"
android:parentActivityName=".MainActivity" >
</activity>
<activity
android:name=".ReportActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_report" >
</activity>
<activity
android:name=".SettingsActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_settings" >
</activity>
<activity
android:name=".SubscriptionsActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_subscriptions" >
</activity>
<activity
android:name=".ReportlistActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_reportlist"
android:parentActivityName=".ProfileActivity" >
<meta-data
@@ -134,7 +134,7 @@
<activity
android:name=".ViewReportActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:label="@string/title_activity_view_report" >
</activity>
</application>

View File

@@ -70,12 +70,11 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
setContentView(R.layout.activity_register);
input_username = (TextView) findViewById(R.id.input_register_name);
input_username.addTextChangedListener(new TextValidator(input_username) {
input_username.addTextChangedListener(new TextValidator(input_username,getApplicationContext()) {
@Override
public void validate(TextView textView, String text) {
if (text.length() < 5) {
textView.setError("Your username must be at least\n" +
"5 characters in length.");
textView.setError(getString(R.string.error_anytext));
}
}
});
@@ -84,22 +83,20 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
input_email = (TextView) findViewById(R.id.input_register_email);
input_password = (TextView) findViewById(R.id.input_register_password);
input_email.addTextChangedListener(new TextValidator(input_email) {
input_email.addTextChangedListener(new TextValidator(input_email,getApplicationContext()) {
@Override
public void validate(TextView textView, String text) {
if(!Patterns.EMAIL_ADDRESS.matcher(text).matches()){
textView.setError("Please enter a valid email address\n" +
"e.g.: text@abc.de");
textView.setError(getString(R.string.error_email));
}
}
});
input_password.addTextChangedListener(new TextValidator(input_password) {
input_password.addTextChangedListener(new TextValidator(input_password,getApplicationContext()) {
@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.");
textView.setError(getString(R.string.error_password));
}
}
});
@@ -126,8 +123,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
if (msg_intent.equals("login")) {
if (input_password.getError() != null || input_email.getError() != null) {
showMessage("Entered fields not valid\n" +
"Please check errors first.");
showMessage(getString(R.string.error_validation));
} else {
showDialog();
checkLogin(email, password);
@@ -135,8 +131,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
} else if (msg_intent.equals("register")) {
String name = input_username.getText().toString();
if (input_password.getError() != null || input_email.getError() != null || input_username.getError() != null) {
showMessage("Entered fields not valid\n" +
"Please check errors first.");
showMessage(getString(R.string.error_validation));
} else {
showDialog();
registerUser(name, email, password);
@@ -212,20 +207,20 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
public void onClick(View view){
if(input_email.getText() != null && input_email.getText().toString().isEmpty()){
showMessage("Enter your E-Mail to reset your password");
showMessage(getString(R.string.message_enteremail));
return;
}
new AlertDialog.Builder(this)
.setTitle("Send password reset E-Mail")
.setMessage("Do you really want to reset your password? An E-Mail will be send to your address. Please follow the instructions to reset your password.")
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) {
String tag_string_req = "requestpwreset";
StringRequest strReq = getStringRequestResetPW(input_email.getText().toString());
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
showMessage("E-Mail was sent to your address");
showMessage(getString(R.string.alert_passwordreset_confirmation));
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@@ -238,8 +233,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.URL_REGISTER, new Response.Listener<String>() {
return new StringRequest(Method.POST,AppConfig.URL_REGISTER, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
@@ -250,12 +244,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (!error) {
// user successfully logged in
// Create login session
session.setLogin(true);
// User successfully stored in MySQL
// Now store the user in sqlite
String uid = jObj.getString("uid");
JSONObject user = jObj.getJSONObject("user");
String username = user.getString("username");
@@ -268,10 +258,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
String providerType = user.getString("providerType");
String token = user.getString("token");
// Inserting row in users table
session.addUser(uid, username, name, surname, email, status, providerType, created_at, updated_at, token);
// Launch login activity
Intent intent = new Intent(
LoginActivity.this,
MainActivity.class);
@@ -279,10 +267,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
startActivity(intent);
finish();
} else {
// Error occurred in registration. Get the error message
String errorMsg = jObj.getString("error_msg");
Toast.makeText(getApplicationContext(),
errorMsg, Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(),errorMsg, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
@@ -344,8 +330,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
if(status.equals("0")){
new AlertDialog.Builder(LoginActivity.this)
.setTitle("Activate your account")
.setMessage("Your account is not activated yet. Please follow the instructions in your E-Mail. Do you want to resent the E-Mail?")
.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) {
String tag_string_req = "resendactivationusermail";
@@ -353,7 +339,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
StringRequest strReq = getStringRequestActivationLinkUser(input_email.getText().toString());
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
showMessage("E-Mail was sent to your address");
showMessage(getString(R.string.alert_accactivation_confirmation));
}
})
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@@ -363,36 +349,30 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
}else {
// Inserting row in users table
session.addUser(uid, username, name, surname, email, status, providerType, created_at, updated_at, token);
// user successfully logged in
// Create login session
session.setLogin(true);
hideDialog();
// Launch main activity
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
} else {
// Error in login. Get the error message
String errorMsg = jObj.getString("error_msg");
Toast.makeText(getApplicationContext(), errorMsg, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
// JSON error
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e(TAG, "Login Error: " + error.getMessage());
Toast.makeText(getApplicationContext(),
error.getMessage(), Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
hideDialog();
}
}) {
@@ -407,7 +387,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
return params;
}
};
}
@@ -423,28 +402,22 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (!error) {
new AlertDialog.Builder(getApplicationContext())
.setTitle("Activation Link")
.setMessage("An activation link was send to your e-mail address. Please follow the instructions to activate your account. Thank you!")
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) {
//do nothing
Intent intent = new Intent(
LoginActivity.this,
LoginActivity.class);
intent.putExtra(EXTRA_MESSAGE, "login");
startActivity(intent);
finish();
}
})
.setIcon(android.R.drawable.ic_dialog_alert)
.show();
// Launch login activity
Intent intent = new Intent(
LoginActivity.this,
LoginActivity.class);
intent.putExtra(EXTRA_MESSAGE, "login");
startActivity(intent);
finish();
} else {
// Error occurred in registration. Get the error
// message
String errorMsg = jObj.getString("error_msg");
Toast.makeText(getApplicationContext(),
errorMsg, Toast.LENGTH_LONG).show();
@@ -452,7 +425,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@@ -567,7 +539,6 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
};
}
public void showMessage(String statusText){
Toast.makeText(this, statusText, Toast.LENGTH_LONG).show();
}

View File

@@ -256,13 +256,14 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
@Override
public void onDestroy() {
super.onDestroy();
if (mMap != null) {
getSupportFragmentManager().beginTransaction().remove(getSupportFragmentManager().findFragmentById(R.id.frag_maps_map)).commitAllowingStateLoss();
mMap = null;
}
super.onDestroy();
}
@Override
protected int getLayoutResourceId() {
return R.layout.activity_maps;

View File

@@ -52,6 +52,7 @@ public class ReportActivity extends BaseActivity {
private static final String SAVED_DATE_INCIDENT = "804";
private static final String SAVED_DATE_TIME = "805";
private static final String SAVED_POSITION = "806";
private static final String SAVED_POSITION_DETAIL = "807";
private EditText txtTitle;
private EditText txtDescription;
@@ -111,40 +112,6 @@ public class ReportActivity extends BaseActivity {
}
});
if(pos != null) {
txtPosition.setText(pos);
String[] position = pos.split(":");
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
try {
List<Address> addressList = geocoder.getFromLocation(Double.parseDouble(position[0]), Double.parseDouble(position[1]), 1);
if (addressList != null && addressList.size() > 0) {
Address address = addressList.get(0);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
if(txtPosition.getText().equals("") && address.getAddressLine(i) != null) txtPosition.setText(address.getAddressLine(i));
if(address.getAddressLine(i) != null) sb.append(address.getAddressLine(i)).append("\n");
}
//if(address.getLocality() != null) sb.append(address.getLocality()).append("\n");
//if(address.getPostalCode() != null) sb.append(address.getPostalCode()).append("\n");
if(address.getCountryName() != null) sb.append(address.getCountryName());
txtPositionDetail.setText(sb.toString());
}
latitude = position[0];
longitude = position[1];
} catch (IOException e) {
e.printStackTrace();
}
}
findViewById(R.id.btn_report_report).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -171,7 +138,39 @@ public class ReportActivity extends BaseActivity {
restoreSharedPreferences();
txtTitle.addTextChangedListener(new TextValidator(txtTitle) {
if(pos != null) {
String[] position = pos.split(":");
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
try {
List<Address> addressList = geocoder.getFromLocation(Double.parseDouble(position[0]), Double.parseDouble(position[1]), 1);
if (addressList != null && addressList.size() > 0) {
Address address = addressList.get(0);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
if(address.getAddressLine(i) != null) sb.append(address.getAddressLine(i)).append("\n");
}
//if(address.getLocality() != null) sb.append(address.getLocality()).append("\n");
//if(address.getPostalCode() != null) sb.append(address.getPostalCode()).append("\n");
if(address.getCountryName() != null) sb.append(address.getCountryName());
txtPosition.setText(address.getLocality());
txtPositionDetail.setText(sb.toString());
}
latitude = position[0];
longitude = position[1];
} catch (IOException e) {
e.printStackTrace();
}
}
txtTitle.addTextChangedListener(new TextValidator(txtTitle,getApplicationContext()) {
@Override
public void validate(TextView textView, String text) {
if (text.length() < 5) {
@@ -181,7 +180,7 @@ public class ReportActivity extends BaseActivity {
}
});
txtDescription.addTextChangedListener(new TextValidator(txtDescription) {
txtDescription.addTextChangedListener(new TextValidator(txtDescription,getApplicationContext()) {
@Override
public void validate(TextView textView, String text) {
if (text.length() < 5) {
@@ -258,7 +257,6 @@ public class ReportActivity extends BaseActivity {
return params;
}
};
}
@@ -318,6 +316,7 @@ public class ReportActivity extends BaseActivity {
editor.putString(SAVED_DATE_INCIDENT, txtDay.getText().toString());
editor.putString(SAVED_DATE_TIME, txtTime.getText().toString());
editor.putString(SAVED_POSITION, txtPosition.getText().toString());
editor.putString(SAVED_POSITION_DETAIL, txtPositionDetail.getText().toString());
editor.putString("latitude", latitude);
editor.putString("longitude", longitude);
editor.apply();
@@ -336,8 +335,8 @@ public class ReportActivity extends BaseActivity {
txtTime.setText(prefs.getString(SAVED_DATE_TIME, new StringBuilder().append(hour)
.append(":").append(minute).append(" ").toString()));
txtPosition.setText(prefs.getString(SAVED_POSITION, "0:0"));
txtPosition.setText(prefs.getString(SAVED_POSITION, ""));
txtPositionDetail.setText(prefs.getString(SAVED_POSITION_DETAIL, ""));
latitude = prefs.getString("latitude","0");
longitude = prefs.getString("longitude","0");

View File

@@ -46,26 +46,6 @@ 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
public void onClick(View v) {
@@ -130,6 +110,26 @@ public class SettingsActivity extends BaseActivity {
txtSurname.setText(user.get("surname"));
txtEmail.setText(user.get("email"));
txtUsername.addTextChangedListener(new TextValidator(txtUsername, getApplicationContext()) {
@Override
public void validate(TextView textView, String text) {
if (text.length() < 5) {
textView.setError("Your username must be at least\n" +
"5 characters in length.");
}
}
});
txtEmail.addTextChangedListener(new TextValidator(txtEmail, getApplicationContext()) {
@Override
public void validate(TextView textView, String text) {
if (!Patterns.EMAIL_ADDRESS.matcher(text).matches()) {
textView.setError("Please enter a valid email address\n" +
"e.g.: text@abc.de");
}
}
});
if(user.get("providerType") != null && user.get("providerType").equals("local")){
findViewById(R.id.rl_main_content_2).setVisibility(View.VISIBLE);
}else{
@@ -212,10 +212,7 @@ public class SettingsActivity extends BaseActivity {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (!error) {
// do nothing actually
} else {
// Error occurred in registration. Get the error
// message
String errorMsg = jObj.getString("error_msg");
Toast.makeText(getApplicationContext(),
errorMsg, Toast.LENGTH_LONG).show();

View File

@@ -9,7 +9,6 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
@@ -22,12 +21,10 @@ import com.beardedhen.androidbootstrap.BootstrapLabel;
import org.deke.risk.riskahead.helper.AppConfig;
import org.deke.risk.riskahead.helper.AppController;
import org.deke.risk.riskahead.helper.BaseActivity;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -208,16 +205,28 @@ public class ViewReportActivity extends BaseActivity {
txtTime.setText(happened_at[1].substring(0, 5));
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(incident.getDouble("latitude"), incident.getDouble("longitude"), 1);
try{
txtPosition.setText(addresses.get(0).getLocality());
txtPositionDetail.setText(addresses.get(0).getAddressLine(0));
} catch (Exception e) {
//do nothing
try {
List<Address> addressList = geocoder.getFromLocation(incident.getDouble("latitude"), incident.getDouble("longitude"), 1);
if (addressList != null && addressList.size() > 0) {
Address address = addressList.get(0);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
if(address.getAddressLine(i) != null) sb.append(address.getAddressLine(i)).append("\n");
}
//if(address.getLocality() != null) sb.append(address.getLocality()).append("\n");
//if(address.getPostalCode() != null) sb.append(address.getPostalCode()).append("\n");
if(address.getCountryName() != null) sb.append(address.getCountryName());
txtPosition.setText(address.getLocality());
txtPositionDetail.setText(sb.toString());
}
} catch (IOException e) {
e.printStackTrace();
}
final String latitude = incident.getString("latitude");
final String longitude = incident.getString("longitude");
@@ -241,8 +250,6 @@ public class ViewReportActivity extends BaseActivity {
}
} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e2) {
e2.printStackTrace();
}
}
}, new Response.ErrorListener() {

View File

@@ -3,7 +3,6 @@ package org.deke.risk.riskahead.helper;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.res.Configuration;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.os.Bundle;
import android.support.v7.app.ActionBarDrawerToggle;
@@ -14,7 +13,6 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
@@ -66,13 +64,13 @@ public abstract class BaseActivity extends AppCompatActivity {
user = session.getUserDetails();
ObjectDrawerItem[] drawerItem = new ObjectDrawerItem[7];
drawerItem[0] = new ObjectDrawerItem(R.drawable.ic_action_web_site, "Start");
drawerItem[1] = new ObjectDrawerItem(R.drawable.ic_action_flash_on, "Report");
drawerItem[2] = new ObjectDrawerItem(R.drawable.ic_action_map, "Incident Map");
drawerItem[3] = new ObjectDrawerItem(R.drawable.ic_action_about, "User Statistics");
drawerItem[4] = new ObjectDrawerItem(R.drawable.ic_action_settings, "Account Settings");
drawerItem[5] = new ObjectDrawerItem(R.drawable.ic_action_important, "Subscriptions");
drawerItem[6] = new ObjectDrawerItem(R.drawable.ic_action_back, "Logout");
drawerItem[0] = new ObjectDrawerItem(R.drawable.ic_action_web_site, getString(R.string.navigation_start));
drawerItem[1] = new ObjectDrawerItem(R.drawable.ic_action_flash_on, getString(R.string.navigation_report));
drawerItem[2] = new ObjectDrawerItem(R.drawable.ic_action_map, getString(R.string.navigation_incident_map));
drawerItem[3] = new ObjectDrawerItem(R.drawable.ic_action_about, getString(R.string.navigation_user_stats));
drawerItem[4] = new ObjectDrawerItem(R.drawable.ic_action_settings, getString(R.string.navigation_acc_settings));
drawerItem[5] = new ObjectDrawerItem(R.drawable.ic_action_important, getString(R.string.navigation_settings));
drawerItem[6] = new ObjectDrawerItem(R.drawable.ic_action_back, getString(R.string.navigation_logout));
mCustomDrawerAdapter = new DrawerItemCustomAdapter(this, R.layout.listview_item_row, drawerItem);
@@ -281,15 +279,11 @@ public abstract class BaseActivity extends AppCompatActivity {
private void setShareIntent() {
if (mShareActionProvider != null) {
// create an Intent with the contents of the TextView
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Android Development");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Ich empfehle RiskAhead!");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_item_title));
shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_item_text));
// Make sure the provider knows
// it should work with that Intent
mShareActionProvider.setShareIntent(shareIntent);
}
}

View File

@@ -28,7 +28,6 @@ public class PlaceProvider extends ContentProvider {
public static final String AUTHORITY = "org.deke.risk.riskahead.helper.PlaceProvider";
public static final Uri SEARCH_URI = Uri.parse("content://"+AUTHORITY+"/search");
public static final Uri DETAILS_URI = Uri.parse("content://"+AUTHORITY+"/details");
private static final int SEARCH = 1;

View File

@@ -1,18 +1,24 @@
package org.deke.risk.riskahead.helper;
import android.content.Context;
import android.content.res.Resources;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.TextView;
import org.deke.risk.riskahead.R;
import static android.provider.Settings.Global.getString;
/**
* Created by Dennis on 17.11.2015.
*/
public abstract class TextValidator implements TextWatcher {
private final TextView textView;
public TextValidator(TextView textView) {
public TextValidator(TextView textView, Context context) {
this.textView = textView;
if(this.textView.getText().equals("")) this.textView.setError("Please enter a value");
if(this.textView.getText().length() == 0) this.textView.setError(context.getResources().getString(R.string.error_enter_value));
}
public abstract void validate(TextView textView, String text);

View File

@@ -143,7 +143,6 @@
android:id="@+id/input_report_position"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="City"
android:editable="false"
android:layout_below="@+id/lbl_report_position"
android:layout_toRightOf="@+id/lbl_report_category"

View File

@@ -136,15 +136,16 @@
android:layout_alignLeft="@+id/input_viewreport_date"
android:layout_alignStart="@+id/input_viewreport_time"/>
<EditText
android:id="@+id/input_viewreport_position"
android:enabled="false"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:layout_below="@+id/lbl_viewreport_position"
android:layout_alignLeft="@+id/lbl_viewreport_position"
android:layout_alignStart="@+id/lbl_viewreport_position"
android:layout_toRightOf="@+id/lbl_viewreport_category"
android:layout_toEndOf="@+id/lbl_viewreport_category"
android:editable="false"/>
<com.beardedhen.androidbootstrap.BootstrapButton
@@ -154,19 +155,21 @@
android:layout_height="wrap_content"
bootstrap:bootstrapBrand="primary"
bootstrap:roundedCorners="true"
android:layout_marginTop="7dp"
android:layout_alignTop="@+id/lbl_viewreport_position"
android:layout_alignRight="@+id/input_viewreport_time"
android:layout_alignEnd="@+id/input_viewreport_time" />
bootstrap:bootstrapSize="lg"
android:layout_marginTop="3dp"
android:layout_below="@+id/lbl_viewreport_position"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/lbl_viewreport_position_detail"
android:layout_alignParentRight="true"
android:layout_below="@+id/input_viewreport_position"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
android:layout_alignParentLeft="@+id/input_viewreport_position"
android:layout_alignParentStart="@+id/input_viewreport_position" />
</RelativeLayout>
<RelativeLayout

View File

@@ -8,7 +8,7 @@
android:id="@+id/btn_login_gp"
android:layout_width="225dp"
android:layout_height="50dp"
bootstrap:bootstrapText="{fa_google_plus} Google+"
bootstrap:bootstrapText="{fa_google} Google+"
android:layout_above="@+id/btn_login_gp"
bootstrap:bootstrapBrand="danger"
bootstrap:roundedCorners="true"

View File

@@ -0,0 +1,113 @@
<resources>
<string name="app_name">RiskAhead</string>
<string name="facebook_app_id">658657714234846</string>
<string name="btn_start_login">Login</string>
<string name="btn_start_register">Register</string>
<string name="lbl_login_title">Log-in to RiskAhead</string>
<string name="lbl_login_resendPW">Forgot your password?\nClick here</string>
<string name="lbl_login_policy"><a href="https://www.riskahead.de/terms/">Terms of Service</a> and\n<a href="https://www.riskahead.de/privacy/">Privacy Policy</a></string>
<string name="lbl_login_usesocialnet">Or use following social networks to sign in</string>
<string name="lbl_register_title">Register to RiskAhead</string>
<string name="input_register_name_hint">Username</string>
<string name="input_register_email_hint">E-Mail</string>
<string name="input_register_password_hint">Password</string>
<string name="status_signing_in">Signing in...</string>
<string name="status_signing_out">Signing out...</string>
<string name="title_activity_start">RiskAhead</string>
<string name="title_activity_entrance">RiskAhead</string>
<string name="btn_settings_change">{fa_pencil} Confirm changes</string>
<string name="drawer_open">Open navigation drawer</string>
<string name="drawer_close">Close navigation drawer</string>
<string name="find">Find</string>
<string name="hint">Enter Place</string>
<string name="search_hint">Location</string>
<string name="search_settings">Search Settings</string>
<string name="title_activity_base">Base</string>
<string name="title_activity_user_config">User Profile</string>
<string name="title_activity_maps">Risk Map</string>
<string name="title_activity_report">Report Incident</string>
<string name="title_activity_settings">User Settings</string>
<string name="title_activity_subscriptions">Subscriptions</string>
<string name="title_activity_view_report">View Report</string>
<string name="title_activity_reportlist">Report List</string>
<string name="menu_action_about">About</string>
<string name="menu_action_language">Language</string>
<string name="menu_action_help">Help &amp; Contact</string>
<string name="menu_action_exit">Exit</string>
<string name="menu_action_refresh">Refresh Map</string>
<string name="lbl_main_txt1">We have currently ...</string>
<string name="lbl_main_txt2">... reported incidents</string>
<string name="btn_main_report">{fa_map_marker} Report</string>
<string name="btn_main_viewmap">{fa_info} View Map</string>
<string name="input_report_short_hint">Short Description</string>
<string name="input_report_long_hint">Long Descpription</string>
<string name="lbl_report_short">Title</string>
<string name="lbl_report_long">Description</string>
<string name="lbl_report_category">Crime Category</string>
<string name="lbl_report_time">Time </string>
<string name="lbl_report_date">Date (yyyy-MM-dd)</string>
<string name="lbl_report_position">Position</string>
<string name="btn_report_position">{fa_search}</string>
<string name="btn_viewreport_delete">Delete Report</string>
<string name="lbl_settings_name">Name</string>
<string name="lbl_settings_surname">Surname</string>
<string name="lbl_settings_email">E-Mail</string>
<string name="lbl_settings_username">Username</string>
<string name="lbl_profile_stats">Profile Stats</string>
<string name="lbl_profile_member_since">Member Since</string>
<string name="lbl_profile_points">Points</string>
<string name="lbl_profile_ranking">Ranking</string>
<string name="lbl_profile_numberposts">Number of Posts</string>
<string name="btn_profile_viewposts">{fa_search} View Posts</string>
<string name="lbl_profile_top10">Top 10</string>
<string name="lbl_settings_password">Confirm Password</string>
<string name="btn_settings_req_password">{fa_envelope} Request New Password</string>
<string name="lbl_settings_retype_password">Retype Password</string>
<string name="btn_maps_confirm_position">{fa_paint_brush} Report this position!</string>
<string name="navigation_start">Start</string>
<string name="navigation_report">Report</string>
<string name="navigation_incident_map">Incident Map</string>
<string name="navigation_user_stats">User Statistics</string>
<string name="navigation_acc_settings">Account Settings</string>
<string name="navigation_settings">Settings</string>
<string name="navigation_logout">Logout</string>
<string name="share_item_text">I recommend RiskAhead!</string>
<string name="share_item_title">RiskAhead</string>
<string name="error_enter_value">Please enter a value</string>
<string name="error_anytext">Your username must be at least \n 5 characters in length.</string>
<string name="error_email">Please enter a valid email address\ne.g.: text@abc.de</string>
<string name="error_password">Your password must be at least\n5 characters in length.</string>
<string name="error_validation">Entered fields not valid\nPlease check errors first.</string>
<string name="message_enteremail">Enter your E-Mail to reset your password</string>
<string name="alert_passwordreset_title">Send Password Reset E-Mail</string>
<string name="alert_passwordreset_text">Do you really want to reset your password? An E-Mail will be send to your address. Please follow the instructions to reset your password.</string>
<string name="alert_passwordreset_confirmation">E-Mail was sent to your e-mail address</string>
<string name="alert_accactivation_title">Activate your account</string>
<string name="alert_accactivation_text">Your account is not activated yet. Please follow the instructions in your E-Mail. Do you want to resent the E-Mail?</string>
<string name="alert_accactivation_confirmation">E-Mail was sent to your e-mail address</string>
<string name="alert_accregistration_title">Activation E-Mail</string>
<string name="alert_accregistration_text">An activation link was send to your e-mail address. Please follow the instructions to activate your account. Thank you!</string>
</resources>

View File

@@ -7,7 +7,7 @@
<string name="lbl_login_title">Log-in to RiskAhead</string>
<string name="lbl_login_resendPW">Forgot your password?\nClick here</string>
<string name="lbl_login_policy"><a href="test.com">Terms of Service</a> and\n<a href="test.com">Privacy Policy</a></string>
<string name="lbl_login_policy"><a href="https://www.riskahead.de/terms/">Terms of Service</a> and\n<a href="https://www.riskahead.de/privacy/">Privacy Policy</a></string>
<string name="lbl_login_usesocialnet">Or use following social networks to sign in</string>
<string name="lbl_register_title">Register to RiskAhead</string>
@@ -15,96 +15,99 @@
<string name="input_register_email_hint">E-Mail</string>
<string name="input_register_password_hint">Password</string>
<string name="action_about">About</string>
<string name="status_signing_in">Signing in...</string>
<string name="status_signing_out">Signing out...</string>
<string name="title_activity_start">RiskAhead</string>
<string name="title_activity_entrance">Risk Ahead</string>
<string name="title_activity_entrance">RiskAhead</string>
<string name="btn_profile_logout">Logout</string>
<string name="btn_settings_change">{fa_pencil} Confirm changes</string>
<string name="lbl_profile_title">Welcome</string>
<string name="drawer_open">Open navigation drawer</string>
<string name="drawer_close">Close navigation drawer</string>
<string name="settings_user">Account</string>
<string name="settings_logout">Logout</string>
<string name="find">Find</string>
<string name="hint">Enter Place</string>
<string name="action_search">Search</string>
<string name="menu_action_refresh">Refresh page</string>
<string name="action_help">Help &amp; Feedback</string>
<string name="search_hint">Location</string>
<string name="search_settings">Search Settings</string>
<string name="title_activity_base">Base</string>
<string name="title_activity_user_config">User Profile</string>
<string name="title_activity_maps">Risk Map</string>
<string name="title_activity_report">Report Incident</string>
<string name="title_activity_settings">User Settings</string>
<string name="app_label">Label</string>
<string name="search_hint">Location</string>
<string name="search_settings">search settings</string>
<string name="title_activity_subscriptions">Subscriptions</string>
<string name="title_activity_view_report">View Report</string>
<string name="title_activity_reportlist">Report List</string>
<string name="menu_action_about">About</string>
<string name="menu_action_language">Language</string>
<string name="menu_action_help">Help &amp; Contact</string>
<string name="menu_action_exit">Exit</string>
<string name="menu_action_refresh">Refresh Map</string>
<string name="lbl_main_txt1">We have currently ...</string>
<string name="lbl_main_txt2">... reported incidents</string>
<string name="lbl_main_share">Contribute and share your information</string>
<string name="btn_main_report">{fa_map_marker} Report</string>
<string name="btn_main_viewmap">{fa_info} View Map</string>
<string name="input_report_short_hint">short description</string>
<string name="input_report_long_hint">long descpription</string>
<string name="input_report_short_hint">Short Description</string>
<string name="input_report_long_hint">Long Descpription</string>
<string name="lbl_report_short">Title</string>
<string name="lbl_report_long">Description</string>
<string name="lbl_report_category">Crime Category</string>
<string name="lbl_report_time">Time </string>
<string name="lbl_report_date">Date (yyyy-mm-dd)</string>
<string name="lbl_report_date">Date (yyyy-MM-dd)</string>
<string name="lbl_report_position">Position</string>
<string name="btn_report_position">{fa_search}</string>
<string name="btn_viewreport_delete">Delete Report</string>
<string name="lbl_settings_name">Name</string>
<string name="lbl_settings_surname">Surname</string>
<string name="lbl_settings_email">E-Mail</string>
<string name="lbl_settings_username">Username</string>
<string name="lbl_profile_stats">Profile stats</string>
<string name="lbl_profile_member_since">member since</string>
<string name="lbl_profile_points">points</string>
<string name="lbl_profile_ranking">ranking</string>
<string name="lbl_profile_numberposts">number of posts</string>
<string name="btn_profile_viewposts">{fa_search} View posts</string>
<string name="lbl_profile_top10">Top10</string>
<string name="lbl_profile_stats">Profile Stats</string>
<string name="lbl_profile_member_since">Member Since</string>
<string name="lbl_profile_points">Points</string>
<string name="lbl_profile_ranking">Ranking</string>
<string name="lbl_profile_numberposts">Number of Posts</string>
<string name="btn_profile_viewposts">{fa_search} View Posts</string>
<string name="lbl_profile_top10">Top 10</string>
<string name="lbl_settings_password">Confirm Password</string>
<string name="btn_settings_req_password">{fa_envelope} Request new password</string>
<string name="btn_settings_req_password">{fa_envelope} Request New Password</string>
<string name="lbl_settings_retype_password">Retype Password</string>
<string name="menu_action_about">About</string>
<string name="menu_action_help">Help</string>
<string name="menu_action_exit">Exit</string>
<string name="lbl_report_position">Position</string>
<string name="btn_report_position">{fa_search}</string>
<string name="btn_maps_confirm_position">{fa_paint_brush} Report this position!</string>
<string name="title_activity_reportlist">Report List</string>
<string name="navigation_start">Start</string>
<string name="navigation_report">Report</string>
<string name="navigation_incident_map">Incident Map</string>
<string name="navigation_user_stats">User Statistics</string>
<string name="navigation_acc_settings">Account Settings</string>
<string name="navigation_settings">Settings</string>
<string name="navigation_logout">Logout</string>
<string name="share_item_text">I recommend RiskAhead!</string>
<string name="share_item_title">RiskAhead</string>
<string name="action_settings">Settings</string>
<string name="title_activity_view_report">View Report</string>
<string name="error_enter_value">Please enter a value</string>
<string name="error_anytext">Your username must be at least \n 5 characters in length.</string>
<string name="error_email">Please enter a valid email address\ne.g.: text@abc.de</string>
<string name="error_password">Your password must be at least\n5 characters in length.</string>
<string name="error_validation">Entered fields not valid\nPlease check errors first.</string>
<string-array name="navigation_drawer_items_array">
<item>Start</item>
<item>Report</item>
<item>Incident Map</item>
<item>User Statistics</item>
<item>Account Settings</item>
<item>Subscriptions</item>
<item>Logout</item>
</string-array>
<string name="message_enteremail">Enter your E-Mail to reset your password</string>
<string name="alert_passwordreset_title">Send Password Reset E-Mail</string>
<string name="alert_passwordreset_text">Do you really want to reset your password? An E-Mail will be send to your address. Please follow the instructions to reset your password.</string>
<string name="alert_passwordreset_confirmation">E-Mail was sent to your e-mail address</string>
<string name="alert_accactivation_title">Activate your account</string>
<string name="alert_accactivation_text">Your account is not activated yet. Please follow the instructions in your E-Mail. Do you want to resent the E-Mail?</string>
<string name="alert_accactivation_confirmation">E-Mail was sent to your e-mail address</string>
<string name="alert_accregistration_title">Activation E-Mail</string>
<string name="alert_accregistration_text">An activation link was send to your e-mail address. Please follow the instructions to activate your account. Thank you!</string>
</resources>