diff --git a/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java b/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java index 1eb8096..92a149f 100644 --- a/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java +++ b/app/src/main/java/org/communiquons/android/comunic/client/MainActivity.java @@ -3,6 +3,8 @@ package org.communiquons.android.comunic.client; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @@ -33,4 +35,36 @@ public class MainActivity extends AppCompatActivity { startActivity(intent); } } + + /** + * Menu creation + */ + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.main_menu, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + + //Get action id + int id = item.getItemId(); + + //Check for logout request + if(id == R.id.action_logout){ + confirmUserLogout(); + return true; + } + + return super.onOptionsItemSelected(item); + + } + + /** + * Ask user to confirm if he really what to sign out or not + */ + void confirmUserLogout(){ + Toast.makeText(this, "Do you really want to signout ???", Toast.LENGTH_SHORT).show(); + } } diff --git a/app/src/main/res/menu/main_menu.xml b/app/src/main/res/menu/main_menu.xml new file mode 100644 index 0000000..85d8de7 --- /dev/null +++ b/app/src/main/res/menu/main_menu.xml @@ -0,0 +1,11 @@ + +
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 79489dd..678d6ad 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -9,4 +9,5 @@