Add a disconnect entry on the contact list menu.
authorDa Risk <darisk972@gmail.com>
Thu, 06 May 2010 21:10:22 +0200
changeset 729 a24a98c1e019
parent 728 13d204a5c6fe
child 730 e80061686da5
Add a disconnect entry on the contact list menu. Fix #261
res/drawable/ic_menu_add.png
res/drawable/ic_menu_close_clear_cancel.png
res/drawable/ic_menu_manage.png
res/menu/contact_list.xml
res/values-fr/strings.xml
res/values/strings.xml
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/ui/ChangeStatus.java
src/com/beem/project/beem/ui/ContactList.java
Binary file res/drawable/ic_menu_add.png has changed
Binary file res/drawable/ic_menu_close_clear_cancel.png has changed
Binary file res/drawable/ic_menu_manage.png has changed
--- a/res/menu/contact_list.xml	Thu May 06 20:22:03 2010 +0200
+++ b/res/menu/contact_list.xml	Thu May 06 21:10:22 2010 +0200
@@ -2,9 +2,13 @@
 	<item android:id="@+id/contact_list_menu_add_contact"
 		android:visible="true"
 		android:title="@string/contact_list_menu_add_contact"
-		android:icon="@android:drawable/ic_menu_add" />
+		android:icon="@drawable/ic_menu_add" />
 	<item android:id="@+id/contact_list_menu_settings"
 		android:visible="true"
 		android:title="@string/contact_list_menu_settings"
-		android:icon="@android:drawable/ic_menu_manage" />
+		android:icon="@drawable/ic_menu_manage" />
+	<item android:id="@+id/menu_disconnect"
+		android:visible="true"
+		android:title="@string/contact_list_menu_disconnect"
+		android:icon="@drawable/ic_menu_close_clear_cancel" />
 </menu>
--- a/res/values-fr/strings.xml	Thu May 06 20:22:03 2010 +0200
+++ b/res/values-fr/strings.xml	Thu May 06 21:10:22 2010 +0200
@@ -243,6 +243,7 @@
 	 -->
 	<string name="contact_list_menu_add_contact">Ajouter un contact</string>
 	<string name="contact_list_menu_settings">Param├Ętres</string>
+	<string name="contact_list_menu_disconnect">Se d├ęconnecter</string>
 	<string name="contact_list_all_contact">Tous les contacts</string>
 	<string name="contact_list_no_group">Aucun groupe</string>
 
--- a/res/values/strings.xml	Thu May 06 20:22:03 2010 +0200
+++ b/res/values/strings.xml	Thu May 06 21:10:22 2010 +0200
@@ -231,6 +231,7 @@
 	<!-- ContactList Activity  -->
 	<string name="contact_list_menu_add_contact">Add a contact</string>
 	<string name="contact_list_menu_settings">Settings</string>
+	<string name="contact_list_menu_disconnect">Disconnect</string>
 	<string name="contact_list_all_contact">All contacts</string>
 	<string name="contact_list_no_group">No group</string>
 
--- a/src/com/beem/project/beem/BeemService.java	Thu May 06 20:22:03 2010 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Thu May 06 21:10:22 2010 +0200
@@ -221,6 +221,7 @@
     public void onDestroy() {
 	super.onDestroy();
 	Log.d("Service", "onDestroy");
+	resetStatus();
 	mNotificationManager.cancelAll();
 	unregisterReceiver(mReceiver);
 	mSettings.unregisterOnSharedPreferenceChangeListener(mPreferenceListener);
--- a/src/com/beem/project/beem/ui/ChangeStatus.java	Thu May 06 20:22:03 2010 +0200
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java	Thu May 06 21:10:22 2010 +0200
@@ -277,7 +277,6 @@
 		edit.putString(BeemApplication.STATUS_TEXT_KEY, msg);
 		if (status == Status.CONTACT_STATUS_DISCONNECT) {
 		    stopService(new Intent(ChangeStatus.this, BeemService.class));
-		    edit.putInt(BeemApplication.STATUS_KEY, AVAILABLE_IDX);
 		} else {
 		    try {
 			mXmppFacade.changeStatus(status, msg.toString());
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu May 06 20:22:03 2010 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Thu May 06 21:10:22 2010 +0200
@@ -148,11 +148,6 @@
 	return true;
     }
 
-    /**
-     * Callback for menu item selected.
-     * @param item the item selected
-     * @return true on success, false otherwise
-     */
     @Override
     public final boolean onOptionsItemSelected(MenuItem item) {
 	switch (item.getItemId()) {
@@ -162,6 +157,10 @@
 	    case R.id.contact_list_menu_add_contact:
 		startActivity(new Intent(ContactList.this, AddContact.class));
 		return true;
+	    case R.id.menu_disconnect:
+		    stopService(SERVICE_INTENT);
+		    finish();
+		return true;
 	    default:
 		return false;
 	}