Skip to content

Commit

Permalink
added disconnect button in action bar menu
Browse files Browse the repository at this point in the history
  • Loading branch information
romainpiel committed Jan 12, 2014
1 parent 812791b commit e8e75de
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
30 changes: 17 additions & 13 deletions Meatspace/src/main/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@

<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
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_switch_camera"
android:title="@string/menu_main_switch_camera"
android:icon="@drawable/ic_action_switch_camera"
android:showAsAction="ifRoom" />
<item
android:id="@+id/menu_main_unmute_all"
android:title="@string/menu_main_unmute_all"
android:showAsAction="never"/>
android:id="@+id/menu_main_disconnect"
android:title="@string/menu_main_disconnect"
android:showAsAction="never" />
<item
android:id="@+id/menu_main_settings"
android:title="@string/menu_main_settings"
android:showAsAction="never"/>
android:id="@+id/menu_main_unmute_all"
android:title="@string/menu_main_unmute_all"
android:showAsAction="never" />
<item
android:id="@+id/menu_main_about"
android:title="@string/menu_main_about"
android:showAsAction="never"/>
android:id="@+id/menu_main_settings"
android:title="@string/menu_main_settings"
android:showAsAction="never" />
<item
android:id="@+id/menu_main_about"
android:title="@string/menu_main_about"
android:showAsAction="never" />
</menu>
1 change: 1 addition & 0 deletions Meatspace/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<resources>
<string name="app_name">Meatspace</string>
<string name="menu_main_switch_camera">Switch camera</string>
<string name="menu_main_disconnect">Disconnect</string>
<string name="menu_main_unmute_all">Unmute</string>
<string name="menu_main_about">About</string>
<string name="menu_main_settings">Settings</string>
Expand Down

0 comments on commit e8e75de

Please sign in to comment.