From e8e75deb4344d8d2dca10976227d88569034331f Mon Sep 17 00:00:00 2001 From: Romain Piel Date: Sun, 12 Jan 2014 16:49:09 +0000 Subject: [PATCH] added disconnect button in action bar menu --- .../meatspace/activity/MainActivity.java | 9 +++++- Meatspace/src/main/res/menu/main.xml | 30 +++++++++++-------- Meatspace/src/main/res/values/strings.xml | 1 + 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Meatspace/src/main/java/com/romainpiel/meatspace/activity/MainActivity.java b/Meatspace/src/main/java/com/romainpiel/meatspace/activity/MainActivity.java index 039e998..0b920c5 100644 --- a/Meatspace/src/main/java/com/romainpiel/meatspace/activity/MainActivity.java +++ b/Meatspace/src/main/java/com/romainpiel/meatspace/activity/MainActivity.java @@ -4,6 +4,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.app.FragmentManager; +import android.content.Intent; import android.hardware.Camera; import android.os.Bundle; import android.text.Html; @@ -16,6 +17,7 @@ import com.bugsense.trace.BugSenseHandler; import com.google.analytics.tracking.android.EasyTracker; +import com.romainpiel.Constants; import com.romainpiel.lib.bus.BusManager; import com.romainpiel.lib.bus.MuteEvent; import com.romainpiel.lib.bus.UIEvent; @@ -73,7 +75,12 @@ public boolean onMenuItemSelected(int featureId, MenuItem item) { switch (item.getItemId()) { case R.id.menu_main_switch_camera: ChatFragment fragment = (ChatFragment) getFragmentManager().findFragmentById(R.id.main_fragment); - fragment.switchCamera(); + if (fragment != null) { + fragment.switchCamera(); + } + break; + case R.id.menu_main_disconnect: + sendBroadcast(new Intent(Constants.FILTER_CHAT_CLOSE)); break; case R.id.menu_main_unmute_all: BusManager.get().getChatBus().post(new MuteEvent(false, null)); diff --git a/Meatspace/src/main/res/menu/main.xml b/Meatspace/src/main/res/menu/main.xml index fe9d4eb..dca8691 100644 --- a/Meatspace/src/main/res/menu/main.xml +++ b/Meatspace/src/main/res/menu/main.xml @@ -2,20 +2,24 @@ + android:id="@+id/menu_main_switch_camera" + android:title="@string/menu_main_switch_camera" + android:icon="@drawable/ic_action_switch_camera" + android:showAsAction="ifRoom" /> + android:id="@+id/menu_main_disconnect" + android:title="@string/menu_main_disconnect" + android:showAsAction="never" /> + android:id="@+id/menu_main_unmute_all" + android:title="@string/menu_main_unmute_all" + android:showAsAction="never" /> + android:id="@+id/menu_main_settings" + android:title="@string/menu_main_settings" + android:showAsAction="never" /> + \ No newline at end of file diff --git a/Meatspace/src/main/res/values/strings.xml b/Meatspace/src/main/res/values/strings.xml index c68ac76..b02e10b 100644 --- a/Meatspace/src/main/res/values/strings.xml +++ b/Meatspace/src/main/res/values/strings.xml @@ -1,6 +1,7 @@ Meatspace Switch camera + Disconnect Unmute About Settings