Skip to content
Snippets Groups Projects
Commit fc426a66 authored by melvinabraham's avatar melvinabraham
Browse files

Add Background Image, Complaint to Db and Removed Redundancies

parent ef338ac7
No related branches found
No related tags found
No related merge requests found
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintDuplicateIds" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="AndroidLintGradleCompatible" 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" />
......
......@@ -76,7 +76,7 @@ public class CameraFragment extends Fragment {
mStorageRef = FirebaseStorage.getInstance().getReference();
btnCapturePicture = (Button) view.findViewById(R.id.btnCapturePicture);
signOut = (Button) view.findViewById(R.id.button3);
signOut = (Button) view.findViewById(R.id.bSignOut);
choose_image = (Button) view.findViewById(R.id.choose_image);
btnCapturePicture.setOnClickListener(new View.OnClickListener() {
......@@ -110,7 +110,7 @@ public class CameraFragment extends Fragment {
@Override
public void onViewCreated(View view,Bundle savedInstanceState){
super.onViewCreated(view,savedInstanceState);
getActivity().setTitle("Menu1");
getActivity().setTitle("Camera Utilities");
}
private boolean isDeviceSupportCamera() {
......
......@@ -29,6 +29,12 @@ import android.widget.Toast;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.OnProgressListener;
import com.google.firebase.storage.StorageReference;
......@@ -51,9 +57,10 @@ public class ComposeFragment extends Fragment implements View.OnClickListener{
Button bComposeMail;
Spinner dropdown;
TextView emailText;
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
final String data = firebaseAuth.getCurrentUser().getEmail();
String UserEmail = null;
private Uri imageUri = CameraFragment.images;
......@@ -62,12 +69,14 @@ public class ComposeFragment extends Fragment implements View.OnClickListener{
Button upload;
//private static int RESULT_LOAD_IMAGE = 1;
private Button b_get;
private com.mapps.seproject.TrackGPS gps;
double longitude;
double latitude;
String city;
String postalCode;
final DatabaseReference mDatabase = FirebaseDatabase.getInstance().getReference("users");
......@@ -82,12 +91,12 @@ public class ComposeFragment extends Fragment implements View.OnClickListener{
bComposeMail = (Button) view.findViewById(R.id.bComposeMail);
emailText = (TextView) view.findViewById(R.id.tvEmailMessage);
b_get = (Button) view.findViewById(R.id.button2);
//b_get = (Button) view.findViewById(R.id.button2);
bComposeMail.setOnClickListener(this);
b_get.setOnClickListener(this);
//b_get.setOnClickListener(this);
return view;
}
......@@ -101,6 +110,7 @@ public class ComposeFragment extends Fragment implements View.OnClickListener{
public void composeEmail() {
Log.i("Sending Email","");
String[] TO;
if (flag == 0) {
......@@ -113,7 +123,7 @@ public class ComposeFragment extends Fragment implements View.OnClickListener{
}
String [] CC = {""};
String mailText = emailText.getText().toString();
final String mailText = emailText.getText().toString();
Intent emailIntent = new Intent(Intent.ACTION_SEND);
......@@ -136,10 +146,35 @@ public class ComposeFragment extends Fragment implements View.OnClickListener{
startActivityForResult(Intent.createChooser(emailIntent,"Send Mail..."),2);
mDatabase.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for(DataSnapshot snapshot : dataSnapshot.getChildren()){
UserEmail = snapshot.child("email").toString().split("value =")[1].split(" ")[1].replaceAll("\\s+","");
if(UserEmail.equals(data)) {
snapshot.getRef().child("complaint").setValue(mailText);
break;
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Log.i("Finished","");
}
catch (android.content.ActivityNotFoundException ex) {
catch (android.content.ActivityNotFoundException e) {
Toast.makeText(getActivity().getBaseContext(), "There is no email client installed.", Toast.LENGTH_SHORT).show();
......@@ -168,26 +203,7 @@ public class ComposeFragment extends Fragment implements View.OnClickListener{
//Location
if(v == b_get){
gps = new TrackGPS(getActivity());
if(gps.canGetLocation()){
longitude = gps.getLongitude();
latitude = gps .getLatitude();
city = gps.getCity();
postalCode = gps.getPostalCode();
Toast.makeText(getActivity(),"Longitude:"+Double.toString(longitude)+"\nLatitude:"+Double.toString(latitude)+"\nCity:"+city+"\nPostal:"+postalCode,Toast.LENGTH_SHORT).show();
}
else
{
gps.showSettingsAlert();
}
}
......
......@@ -3,12 +3,16 @@ package com.mapps.seproject;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.support.annotation.IdRes;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.Toast;
......@@ -36,6 +40,29 @@ public class MainActivity extends AppCompatActivity {
String userId;
String UserEmail = null;
static String location = "Not Updated";
static String complaint = "Not Updated";
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.sign_out:
firebaseAuth.signOut();
startActivity(new Intent(this,StartActivty.class));
}
return true;
}
@Override
......@@ -84,7 +111,7 @@ public class MainActivity extends AppCompatActivity {
if(flag == 0) {
userId = mDatabase.push().getKey();
User user = new User(data,getname.getText().toString(),location);
User user = new User(data,getname.getText().toString(),location,complaint);
mDatabase.child(userId).setValue(user);
Log.e("E","new");
}
......
......@@ -9,6 +9,7 @@ public class User {
public String name;
public String email;
public String location;
public String complaint;
public User() {
......@@ -16,11 +17,12 @@ public class User {
}
public User(String email,String name,String location) {
public User(String email,String name,String location,String complaint) {
this.email = email;
this.name = name;
this.location = location;
this.complaint = complaint;
}
......
app/src/main/res/drawable/indflag.png

207 KiB

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/indflag"
android:orientation="vertical">
<Button
android:id="@+id/btnCapturePicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Take Image"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="114dp"
android:layout_marginStart="53dp"
android:text="Take Image" />
android:layout_marginStart="26dp"
android:layout_marginBottom="149dp" />
<Button
android:id="@+id/choose_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Choose Image"
android:layout_alignBaseline="@+id/btnCapturePicture"
android:layout_alignBottom="@+id/btnCapturePicture"
android:layout_alignParentEnd="true"
android:layout_alignTop="@+id/btnCapturePicture"
android:layout_marginEnd="42dp"
android:text="Choose Image" />
android:layout_marginEnd="36dp" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="108dp"
android:text="Button" />
</RelativeLayout>
\ No newline at end of file
......@@ -4,58 +4,45 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mapps.seproject.ComposeFragment">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<RelativeLayout
android:id="@+id/activity_compose_mail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
>
android:paddingTop="@dimen/activity_vertical_margin">
<Spinner
android:id="@+id/spSelectCitiy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/spSelectCitiy"
android:layout_marginTop="11dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
android:layout_marginTop="11dp" />
<Button
android:text="Compose Email"
android:id="@+id/bComposeMail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/bComposeMail"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true" />
android:layout_alignParentStart="true"
android:text="Compose Email" />
<EditText
android:layout_width="match_parent"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/tvEmailMessage"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="280dp"
android:layout_above="@+id/bComposeMail"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="19dp"
android:ems="10"
android:hint="Enter your complaint here"
android:layout_alignParentEnd="true" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Location"
android:layout_above="@+id/tvEmailMessage"
android:layout_centerHorizontal="true"
android:layout_marginBottom="19dp" />
android:inputType="textPersonName"
android:visibility="visible" />
</RelativeLayout>
......
......@@ -2,9 +2,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
app:showAsAction="never"
android:title="settings"/>
android:id="@+id/sign_out"
android:title="Sign Out">
</item>
</menu>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment