diff --git a/app/src/main/java/com/mobilecomputing/sahayak/Activities/UserDashboard.java b/app/src/main/java/com/mobilecomputing/sahayak/Activities/UserDashboard.java index e93cb3a..923c608 100644 --- a/app/src/main/java/com/mobilecomputing/sahayak/Activities/UserDashboard.java +++ b/app/src/main/java/com/mobilecomputing/sahayak/Activities/UserDashboard.java @@ -3,12 +3,16 @@ import android.content.Intent; import android.os.Bundle; import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.widget.Button; +import android.widget.SearchView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import androidx.cardview.widget.CardView; +import androidx.core.view.MenuItemCompat; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; @@ -118,4 +122,22 @@ else if(url!=null){ } ); } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_dashboard, menu); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + int id = item.getItemId(); + + if (id == R.id.action_logout) { + FirebaseAuth.getInstance().signOut(); + Intent signOutIntent = new Intent(this, SignInActivity.class); + startActivity(signOutIntent); + finish(); + } + return super.onOptionsItemSelected(item); + } } diff --git a/app/src/main/res/menu/menu_dashboard.xml b/app/src/main/res/menu/menu_dashboard.xml new file mode 100644 index 0000000..a3c84b7 --- /dev/null +++ b/app/src/main/res/menu/menu_dashboard.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file