DT @24.09.2015: Report button implemented, settings change password added
This commit is contained in:
@@ -11,6 +11,7 @@ import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.view.Menu;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.gms.maps.CameraUpdate;
|
||||
import com.google.android.gms.maps.CameraUpdateFactory;
|
||||
@@ -30,6 +31,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
|
||||
private static GoogleMap mMap;
|
||||
private LatLng myLocation;
|
||||
private LatLng markedLocation;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -39,7 +41,27 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
||||
mMap.getUiSettings().setZoomControlsEnabled(true);
|
||||
handleIntent(getIntent());
|
||||
|
||||
setUpMap();
|
||||
//setUpMap();
|
||||
|
||||
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.GONE);
|
||||
|
||||
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(LatLng point) {
|
||||
markedLocation = point;
|
||||
mMap.clear();
|
||||
mMap.addMarker(new MarkerOptions().position(point));
|
||||
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.VISIBLE);
|
||||
|
||||
findViewById(R.id.btn_maps_confirm_position).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
gotoReportActivity(markedLocation.latitude+":"+markedLocation.longitude);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void handleIntent(Intent intent){
|
||||
|
||||
@@ -3,6 +3,9 @@ package org.deke.risk.riskahead;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.Intent;
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
@@ -11,9 +14,14 @@ import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
import org.deke.risk.riskahead.helper.BaseActivity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ReportActivity extends BaseActivity {
|
||||
|
||||
@@ -76,6 +84,22 @@ public class ReportActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
|
||||
Intent intent = getIntent();
|
||||
String pos = intent.getStringExtra(EXTRA_MESSAGE);
|
||||
|
||||
if(pos != null) {
|
||||
txtPosition.setText(pos);
|
||||
String[] position = pos.split(":");
|
||||
|
||||
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
|
||||
try {
|
||||
List<Address> addresses = geocoder.getFromLocation(Double.parseDouble(position[0]), Double.parseDouble(position[1]), 1);
|
||||
txtPosition.setText(addresses.get(0).getLocality());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
txtDay.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
@@ -1,9 +1,26 @@
|
||||
package org.deke.risk.riskahead;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
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 org.deke.risk.riskahead.helper.AppConfig;
|
||||
import org.deke.risk.riskahead.helper.AppController;
|
||||
import org.deke.risk.riskahead.helper.BaseActivity;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SettingsActivity extends BaseActivity {
|
||||
|
||||
@@ -15,7 +32,6 @@ public class SettingsActivity extends BaseActivity {
|
||||
private TextView txtName;
|
||||
private TextView txtEmail;
|
||||
private TextView txtPassword;
|
||||
private TextView txtPassword2;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -26,7 +42,54 @@ public class SettingsActivity extends BaseActivity {
|
||||
txtSurname = (TextView) findViewById(R.id.txt_settings_surname);
|
||||
txtEmail = (TextView) findViewById(R.id.txt_settings_email);
|
||||
txtPassword = (TextView) findViewById(R.id.txt_settings_password);
|
||||
txtPassword2 = (TextView) findViewById(R.id.txt_settings_retype_password);
|
||||
|
||||
findViewById(R.id.btn_settings_req_password).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new AlertDialog.Builder(SettingsActivity.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.")
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String tag_string_req = "requestpwreset";
|
||||
StringRequest strReq = getStringRequestResetPW(txtEmail.getText().toString());
|
||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||
|
||||
showMessage("E-Mail was sent to your address");
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.btn_settings_change).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new AlertDialog.Builder(getApplicationContext())
|
||||
.setTitle("Confirm changes")
|
||||
.setMessage("Do you really want to confirm changes? ")
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
|
||||
showMessage("Has to be implemented :)");
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// do nothing
|
||||
}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
txtUsername.setText(user.get("username"));
|
||||
txtName.setText(user.get("name"));
|
||||
@@ -41,4 +104,51 @@ public class SettingsActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
protected String getActivityName() { return mActivityTitle; }
|
||||
|
||||
private StringRequest getStringRequestResetPW(final String email) {
|
||||
return new StringRequest(Request.Method.POST, AppConfig.URL_REGISTER, new Response.Listener<String>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
Log.d(TAG, "Resend E-Mail Response: " + response);
|
||||
|
||||
try {
|
||||
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();
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
Log.e(TAG, "E-Mail pw resend Error: " + error.getMessage());
|
||||
Toast.makeText(getApplicationContext(),
|
||||
error.getMessage(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}) {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> getParams() {
|
||||
// Posting params to register url
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("tag", "requestpwreset");
|
||||
params.put("email", email);
|
||||
|
||||
return params;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
|
||||
import org.deke.risk.riskahead.LoginActivity;
|
||||
import org.deke.risk.riskahead.MainActivity;
|
||||
@@ -29,7 +32,7 @@ import java.util.HashMap;
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
private final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
||||
public final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
||||
private final static String TAG = BaseActivity.class.getSimpleName();
|
||||
|
||||
private ActionBarDrawerToggle mDrawerToggle;
|
||||
@@ -181,6 +184,13 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void gotoReportActivity(String position){
|
||||
Intent intent;
|
||||
intent = new Intent(getApplicationContext(), ReportActivity.class);
|
||||
intent.putExtra(EXTRA_MESSAGE, position);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
public void gotoMapActivity(){
|
||||
Intent intent;
|
||||
intent = new Intent(getApplicationContext(), MapsActivity.class);
|
||||
@@ -233,6 +243,10 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void showMessage(String statusText){
|
||||
Toast.makeText(this, statusText, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void setShareIntent() {
|
||||
if (mShareActionProvider != null) {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:bootstrap="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@@ -17,7 +18,19 @@
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/frag_maps_map"
|
||||
tools:context=".MapsActivity"
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment" />
|
||||
android:name="com.google.android.gms.maps.SupportMapFragment"
|
||||
/>
|
||||
|
||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||
android:id="@+id/btn_maps_confirm_position"
|
||||
android:text="@string/btn_maps_confirm_position"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
bootstrap:bb_icon_left="fa-paint-brush"
|
||||
bootstrap:bb_type="primary"
|
||||
bootstrap:bb_roundedCorners="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ListView
|
||||
|
||||
@@ -104,21 +104,6 @@
|
||||
android:ems="7"
|
||||
android:layout_below="@+id/lbl_settings_password"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lbl_settings_retype_password"
|
||||
android:text="@string/lbl_settings_retype_password"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_below="@+id/txt_settings_password"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/txt_settings_retype_password"
|
||||
android:inputType="textPassword"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="7"
|
||||
android:layout_below="@+id/lbl_settings_retype_password"/>
|
||||
|
||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||
android:id="@+id/btn_settings_change"
|
||||
@@ -129,9 +114,21 @@
|
||||
bootstrap:bb_icon_left="fa-paint-brush"
|
||||
bootstrap:bb_type="primary"
|
||||
bootstrap:bb_roundedCorners="true"
|
||||
android:layout_marginTop="46dp"
|
||||
android:layout_below="@+id/txt_settings_retype_password"
|
||||
android:layout_centerHorizontal="true" />
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginBottom="33dp" />
|
||||
|
||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||
android:id="@+id/btn_settings_req_password"
|
||||
android:text="@string/btn_settings_req_password"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
bootstrap:bb_icon_left="fa-paint-brush"
|
||||
bootstrap:bb_type="primary"
|
||||
bootstrap:bb_roundedCorners="true"
|
||||
android:layout_alignTop="@+id/lbl_settings_password"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
@@ -80,13 +80,15 @@
|
||||
<string name="lbl_profile_ranking">ranking</string>
|
||||
<string name="lbl_profile_numberposts">number of posts</string>
|
||||
<string name="btn_profile_viewposts">View posts</string>
|
||||
<string name="lbl_settings_password">Password</string>
|
||||
<string name="lbl_settings_password">Confirm Password</string>
|
||||
<string name="btn_settings_req_password">Change 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">Position</string>
|
||||
<string name="btn_maps_confirm_position">Report this position!</string>
|
||||
|
||||
<string-array name="incident_categories">
|
||||
<item>Personal</item>
|
||||
|
||||
Reference in New Issue
Block a user