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

Added Field for adding the complaint and linked with Mail API

parent c218a861
No related branches found
No related tags found
No related merge requests found
...@@ -23,15 +23,23 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe ...@@ -23,15 +23,23 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe
Button bComposeMail; Button bComposeMail;
TextView welcome; TextView welcome;
Spinner dropdown; Spinner dropdown;
TextView emailText;
int flag =0;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user); setContentView(R.layout.activity_user);
welcome = (TextView) findViewById(R.id.tvWelcome); welcome = (TextView) findViewById(R.id.tvWelcome);
bSignOut = (Button) findViewById(R.id.bSignOut); bSignOut = (Button) findViewById(R.id.bSignOut);
bComposeMail = (Button) findViewById(R.id.bComposeMail); bComposeMail = (Button) findViewById(R.id.bComposeMail);
emailText = (TextView) findViewById(R.id.tvEmailMessage);
firebaseAuth = FirebaseAuth.getInstance(); firebaseAuth = FirebaseAuth.getInstance();
...@@ -44,7 +52,7 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe ...@@ -44,7 +52,7 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe
} }
FirebaseUser user = firebaseAuth.getCurrentUser(); // Get user FirebaseUser user = firebaseAuth.getCurrentUser(); // Get user
welcome.setText("Welcome "+user.getEmail());// Get Emailx welcome.setText("Welcome "+user.getEmail()); // Get Email
dropdown = (Spinner) findViewById(R.id.spSelectCitiy); dropdown = (Spinner) findViewById(R.id.spSelectCitiy);
String [] items = new String[]{"Coimbatore","Chennai"}; String [] items = new String[]{"Coimbatore","Chennai"};
...@@ -54,6 +62,8 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe ...@@ -54,6 +62,8 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe
bSignOut.setOnClickListener(this); // Start listener on Button bSignOut.setOnClickListener(this); // Start listener on Button
bComposeMail.setOnClickListener(this); bComposeMail.setOnClickListener(this);
dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
...@@ -65,11 +75,13 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe ...@@ -65,11 +75,13 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe
case 0: case 0:
// setCityCoimbatore(); // setCityCoimbatore();
Log.i("City: ","Coimbatore"); Log.i("City: ","Coimbatore");
flag =0;
break; break;
case 1: case 1:
// setCityChennai(); // setCityChennai();
Log.i("City:","Chennai"); Log.i("City:","Chennai");
flag = 1;
break; break;
} }
...@@ -90,16 +102,33 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe ...@@ -90,16 +102,33 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe
public void composeEmail() { public void composeEmail() {
Log.i("Sending Email",""); Log.i("Sending Email","");
String [] TO = {""}; String[] TO;
if (flag == 0) {
TO = new String[]{"commr.coimbatore@tn.gov.in"};
}
else {
TO = new String[]{"mayor@chennaicorporation.gov.in"};
}
String [] CC = {""}; String [] CC = {""};
String mailText = emailText.getText().toString();
Intent emailIntent = new Intent(Intent.ACTION_SEND); Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto")); emailIntent.setData(Uri.parse("mailto"));
emailIntent.setType("text/plain"); emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO); emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
emailIntent.putExtra(Intent.EXTRA_SUBJECT,"Your Subject"); if ( flag == 0) {
emailIntent.putExtra(Intent.EXTRA_TEXT,"Type your text here"); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Regarding cleanliness in Coimbatore");
}
else {
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Regarding cleanliness in Chennai");
}
emailIntent.putExtra(Intent.EXTRA_TEXT,mailText);
try { try {
......
...@@ -26,6 +26,23 @@ ...@@ -26,6 +26,23 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" /> android:layout_alignParentEnd="true" />
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/spSelectCitiy"
android:layout_marginTop="31dp"
android:layout_below="@+id/bSignOut"
android:layout_alignParentStart="true" />
<Button
android:text="Add Image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bAddImage"
android:layout_above="@+id/bComposeMail"
android:layout_alignEnd="@+id/bComposeMail"
android:layout_alignStart="@+id/bComposeMail" />
<Button <Button
android:text="Compose Email" android:text="Compose Email"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -34,12 +51,14 @@ ...@@ -34,12 +51,14 @@
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" /> android:layout_centerHorizontal="true" />
<Spinner <EditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="250dp"
android:id="@+id/spSelectCitiy" android:inputType="textPersonName"
android:layout_marginTop="31dp" android:ems="10"
android:layout_below="@+id/bSignOut" android:layout_centerVertical="true"
android:layout_alignParentStart="true" /> android:layout_centerHorizontal="true"
android:id="@+id/tvEmailMessage"
android:hint="Enter your complaint here" />
</RelativeLayout> </RelativeLayout>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment