diff --git a/app/src/main/java/com/mapps/seproject/UserActivity.java b/app/src/main/java/com/mapps/seproject/UserActivity.java index 2cc718255a11ce0f05151fbc8899f91441fcdb93..674f1ccfb7ad99eb3db9f1a5c19a54c1a75e2c08 100644 --- a/app/src/main/java/com/mapps/seproject/UserActivity.java +++ b/app/src/main/java/com/mapps/seproject/UserActivity.java @@ -1,11 +1,14 @@ package com.mapps.seproject; import android.content.Intent; +import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.TextView; +import android.widget.Toast; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; @@ -13,7 +16,8 @@ import com.google.firebase.auth.FirebaseUser; public class UserActivity extends AppCompatActivity implements View.OnClickListener { FirebaseAuth firebaseAuth; - Button button; + Button bSignOut; + Button bComposeMail; TextView welcome; @Override @@ -22,7 +26,9 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe setContentView(R.layout.activity_user); welcome = (TextView) findViewById(R.id.tvWelcome); - button = (Button) findViewById(R.id.bSignOut); + bSignOut = (Button) findViewById(R.id.bSignOut); + bComposeMail = (Button) findViewById(R.id.bComposeMail); + firebaseAuth = FirebaseAuth.getInstance(); @@ -37,20 +43,59 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe welcome.setText("Welcome "+user.getEmail()); // Get Email - button.setOnClickListener(this); // Start listener on Button + bSignOut.setOnClickListener(this); // Start listener on Button + bComposeMail.setOnClickListener(this); + + + } + + + public void composeEmail() { + + Log.i("Sending Email",""); + String [] TO = {""}; + String [] CC = {""}; + + 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"); + + try { + + startActivity(Intent.createChooser(emailIntent,"Send Mail...")); + Log.i("Finished",""); + + } + + catch (android.content.ActivityNotFoundException ex) { + Toast.makeText(getApplicationContext(), "There is no email client installed.", Toast.LENGTH_SHORT).show(); + } + catch (Exception e) { + e.printStackTrace(); + } } + + + + + + @Override public void onClick(View v) { - if(v == button) { + if(v == bSignOut) { firebaseAuth.signOut(); // sign out finish(); @@ -58,6 +103,15 @@ public class UserActivity extends AppCompatActivity implements View.OnClickListe } + if(v == bComposeMail) { + + + Log.i("Clicked","Compose"); + composeEmail(); + + + } + diff --git a/app/src/main/res/layout/activity_user.xml b/app/src/main/res/layout/activity_user.xml index 59ddcc095725186d20165ca455d69303ca08bca3..f846daae524d3308277e5734aa4dfa01ee10bacf 100644 --- a/app/src/main/res/layout/activity_user.xml +++ b/app/src/main/res/layout/activity_user.xml @@ -10,21 +10,30 @@ android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.mapps.seproject.UserActivity"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="28dp" + android:id="@+id/tvWelcome" + android:textSize="24sp" + android:layout_alignParentTop="true" + android:layout_centerHorizontal="true" /> + <Button android:text="Sign Out" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + android:id="@+id/bSignOut" android:layout_alignParentBottom="true" - android:layout_centerHorizontal="true" - android:layout_marginBottom="98dp" - android:id="@+id/bSignOut" /> + android:layout_centerHorizontal="true" /> - <TextView + <Button + android:text="Compose Email" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentTop="true" + android:layout_below="@+id/tvWelcome" android:layout_centerHorizontal="true" - android:layout_marginTop="102dp" - android:id="@+id/tvWelcome" - android:textSize="24sp" /> + android:layout_marginTop="27dp" + android:id="@+id/bComposeMail" /> </RelativeLayout>