diff --git a/app/src/main/java/com/mapps/seproject/UserActivity.java b/app/src/main/java/com/mapps/seproject/UserActivity.java index 762fedb218ce3f18bb3447f8e045a1cad548fa9b..7cb77fccb293d533949dbb3f277b233ab6394375 100644 --- a/app/src/main/java/com/mapps/seproject/UserActivity.java +++ b/app/src/main/java/com/mapps/seproject/UserActivity.java @@ -23,15 +23,23 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe Button bComposeMail; TextView welcome; Spinner dropdown; + TextView emailText; + int flag =0; + + @Override protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); setContentView(R.layout.activity_user); + welcome = (TextView) findViewById(R.id.tvWelcome); bSignOut = (Button) findViewById(R.id.bSignOut); bComposeMail = (Button) findViewById(R.id.bComposeMail); + emailText = (TextView) findViewById(R.id.tvEmailMessage); + firebaseAuth = FirebaseAuth.getInstance(); @@ -44,7 +52,7 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe } 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); String [] items = new String[]{"Coimbatore","Chennai"}; @@ -54,6 +62,8 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe + + bSignOut.setOnClickListener(this); // Start listener on Button bComposeMail.setOnClickListener(this); dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @@ -65,11 +75,13 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe case 0: // setCityCoimbatore(); Log.i("City: ","Coimbatore"); + flag =0; break; case 1: // setCityChennai(); Log.i("City:","Chennai"); + flag = 1; break; } @@ -90,16 +102,33 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe public void composeEmail() { Log.i("Sending Email",""); - String [] TO = {""}; - String [] CC = {""}; + String[] TO; + if (flag == 0) { + + TO = new String[]{"commr.coimbatore@tn.gov.in"}; + + } + else { + TO = new String[]{"mayor@chennaicorporation.gov.in"}; + } + String [] CC = {""}; + + String mailText = emailText.getText().toString(); + Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setData(Uri.parse("mailto")); emailIntent.setType("text/plain"); - emailIntent.putExtra(Intent.EXTRA_EMAIL,TO); - emailIntent.putExtra(Intent.EXTRA_SUBJECT,"Your Subject"); - emailIntent.putExtra(Intent.EXTRA_TEXT,"Type your text here"); + emailIntent.putExtra(Intent.EXTRA_EMAIL, TO); + if ( flag == 0) { + 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 { diff --git a/app/src/main/res/layout/activity_user.xml b/app/src/main/res/layout/activity_user.xml index 5422032f1417d4eb223676c837af43d35af161f0..b7617f1014b88775ffbc6936b458f5dd928fe9a5 100644 --- a/app/src/main/res/layout/activity_user.xml +++ b/app/src/main/res/layout/activity_user.xml @@ -26,6 +26,23 @@ android:layout_alignParentTop="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 android:text="Compose Email" android:layout_width="wrap_content" @@ -34,12 +51,14 @@ android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" /> - <Spinner + <EditText 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" /> + android:layout_height="250dp" + android:inputType="textPersonName" + android:ems="10" + android:layout_centerVertical="true" + android:layout_centerHorizontal="true" + android:id="@+id/tvEmailMessage" + android:hint="Enter your complaint here" /> </RelativeLayout>