From ab905a5316b7d3632acfd492c89f2cceb9ca3a88 Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 1 Nov 2017 15:05:42 +0100 Subject: [PATCH] Started menu creation --- .../android/comunic/client/MainActivity.java | 34 +++++++++++++++++++ app/src/main/res/menu/main_menu.xml | 11 ++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 46 insertions(+) create mode 100644 app/src/main/res/menu/main_menu.xml 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 @@ The connexion couldn\'t be etablished. Please check your credentials ! No Internet connexion ! The server sent an unexcepted response… + Sign out