diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-28 22:21:08 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-01-28 22:21:08 +0100 |
commit | efba73ffd012cede18b6d50fe32b3077bb866741 (patch) | |
tree | 8e01e09304a0b9d5d249ae965e93ea1f75d828da | |
parent | 52da0fe7c9c68d4545f068fb84efbf0854c37392 (diff) |
refactored newconversationactivty to use array adapter
-rw-r--r-- | gen/de/gultsch/chat/R.java | 86 | ||||
-rw-r--r-- | res/layout/activity_new_conversation.xml | 82 | ||||
-rw-r--r-- | res/layout/contact.xml | 13 | ||||
-rw-r--r-- | src/de/gultsch/chat/ui/ConversationActivity.java | 2 | ||||
-rw-r--r-- | src/de/gultsch/chat/ui/ConversationFragment.java | 6 | ||||
-rw-r--r-- | src/de/gultsch/chat/ui/NewConversationActivity.java | 290 |
6 files changed, 220 insertions, 259 deletions
diff --git a/gen/de/gultsch/chat/R.java b/gen/de/gultsch/chat/R.java index 68890a5c..b7dde8f4 100644 --- a/gen/de/gultsch/chat/R.java +++ b/gen/de/gultsch/chat/R.java @@ -38,56 +38,50 @@ public final class R { public static final int section_header=0x7f02000a; } public static final class id { - public static final int account_confirm_password_desc=0x7f0a0017; + public static final int account_confirm_password_desc=0x7f0a0011; public static final int account_jid=0x7f0a0000; - public static final int account_list=0x7f0a0027; - public static final int account_password=0x7f0a0015; - public static final int account_password_confirm2=0x7f0a0018; - public static final int account_server=0x7f0a001d; - public static final int account_show_advanced=0x7f0a0019; + public static final int account_list=0x7f0a0021; + public static final int account_password=0x7f0a000f; + public static final int account_password_confirm2=0x7f0a0012; + public static final int account_server=0x7f0a0017; + public static final int account_show_advanced=0x7f0a0013; public static final int account_status=0x7f0a0002; - public static final int account_username=0x7f0a0013; - public static final int action_accounts=0x7f0a002f; - public static final int action_add=0x7f0a002b; - public static final int action_add_account=0x7f0a0031; - public static final int action_archive=0x7f0a002e; - public static final int action_details=0x7f0a002d; - public static final int action_security=0x7f0a002c; - public static final int action_settings=0x7f0a0030; - public static final int advanced_options=0x7f0a001a; - public static final int contact_display_name=0x7f0a000c; - public static final int contact_divider=0x7f0a000e; - public static final int contact_jid=0x7f0a000d; - public static final int contact_photo=0x7f0a000b; - public static final int conversation_image=0x7f0a000f; - public static final int conversation_lastmsg=0x7f0a0011; - public static final int conversation_lastupdate=0x7f0a0012; - public static final int conversation_name=0x7f0a0010; - public static final int create_new_contact=0x7f0a000a; - public static final int editText3=0x7f0a001f; - public static final int edit_account_register_new=0x7f0a0016; - public static final int jabber_contacts=0x7f0a0008; - public static final int jabber_contacts_header=0x7f0a0007; - public static final int list=0x7f0a0025; - public static final int message_body=0x7f0a0029; - public static final int message_photo=0x7f0a0028; - public static final int message_time=0x7f0a002a; - public static final int messages_view=0x7f0a0023; - public static final int new_contact_header=0x7f0a0009; + public static final int account_username=0x7f0a000d; + public static final int action_accounts=0x7f0a0029; + public static final int action_add=0x7f0a0025; + public static final int action_add_account=0x7f0a002b; + public static final int action_archive=0x7f0a0028; + public static final int action_details=0x7f0a0027; + public static final int action_security=0x7f0a0026; + public static final int action_settings=0x7f0a002a; + public static final int advanced_options=0x7f0a0014; + public static final int contactList=0x7f0a0005; + public static final int contact_display_name=0x7f0a0007; + public static final int contact_jid=0x7f0a0008; + public static final int contact_photo=0x7f0a0006; + public static final int contacts_header=0x7f0a0004; + public static final int conversation_image=0x7f0a0009; + public static final int conversation_lastmsg=0x7f0a000b; + public static final int conversation_lastupdate=0x7f0a000c; + public static final int conversation_name=0x7f0a000a; + public static final int editText3=0x7f0a0019; + public static final int edit_account_register_new=0x7f0a0010; + public static final int list=0x7f0a001f; + public static final int message_body=0x7f0a0023; + public static final int message_photo=0x7f0a0022; + public static final int message_time=0x7f0a0024; + public static final int messages_view=0x7f0a001d; public static final int new_conversation_search=0x7f0a0003; - public static final int phone_contacts=0x7f0a0006; - public static final int phone_contacts_header=0x7f0a0005; - public static final int scrollView1=0x7f0a0004; - public static final int selected_conversation=0x7f0a0026; - public static final int server_input_layout=0x7f0a001b; - public static final int slidingpanelayout=0x7f0a0024; - public static final int textSendButton=0x7f0a0022; - public static final int textView1=0x7f0a0014; + public static final int selected_conversation=0x7f0a0020; + public static final int server_input_layout=0x7f0a0015; + public static final int slidingpanelayout=0x7f0a001e; + public static final int textSendButton=0x7f0a001c; + public static final int textView1=0x7f0a000e; public static final int textView2=0x7f0a0001; - public static final int textView3=0x7f0a001c; - public static final int textView4=0x7f0a001e; - public static final int textinput=0x7f0a0021; - public static final int textsend=0x7f0a0020; + public static final int textView3=0x7f0a0016; + public static final int textView4=0x7f0a0018; + public static final int textinput=0x7f0a001b; + public static final int textsend=0x7f0a001a; } public static final class layout { public static final int account_row=0x7f030000; diff --git a/res/layout/activity_new_conversation.xml b/res/layout/activity_new_conversation.xml index 68836761..c993ce49 100644 --- a/res/layout/activity_new_conversation.xml +++ b/res/layout/activity_new_conversation.xml @@ -2,7 +2,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="#f9f9f9"> + android:background="#e5e5e5" > <EditText android:id="@+id/new_conversation_search" @@ -11,72 +11,36 @@ android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentTop="true" + android:background="#eee" android:ems="10" - android:inputType="textEmailAddress" android:hint="Search or enter Jabber ID" - android:background="#ffffff" - android:layout_marginTop="12dp" - android:layout_marginBottom="12dp" - android:layout_marginLeft="8dp" - android:layout_marginRight="8dp"/> + android:inputType="textEmailAddress" + android:paddingBottom="12dp" + android:paddingLeft="8dp" + android:paddingRight="8dp" + android:paddingTop="12dp" /> + + <TextView + android:id="@+id/contacts_header" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Contacts" + style="@style/sectionHeader" + android:layout_below="@+id/new_conversation_search" + android:paddingLeft="8dp" + android:paddingTop="8dp" + android:paddingRight="8dp"/> - <ScrollView - android:id="@+id/scrollView1" + <ListView + android:id="@+id/contactList" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" - android:layout_below="@+id/new_conversation_search" - android:background="#e5e5e5" > + android:layout_below="@+id/contacts_header" + tools:listitem="@layout/contact" > - <LinearLayout - android:layout_width="match_parent" - android:layout_height="380dp" - android:orientation="vertical" - android:padding="8dp" > + </ListView> - <TextView - android:id="@+id/phone_contacts_header" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Phone Contacts" - style="@style/sectionHeader"/> - <LinearLayout - android:id="@+id/phone_contacts" - android:layout_height="fill_parent" - android:layout_width="fill_parent" - android:orientation="vertical"> - - </LinearLayout> - <TextView - android:id="@+id/jabber_contacts_header" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Jabber Contacts" - style="@style/sectionHeader"/> - <LinearLayout - android:id="@+id/jabber_contacts" - android:layout_height="fill_parent" - android:layout_width="fill_parent" - android:orientation="vertical"> - - </LinearLayout> - <TextView - android:id="@+id/new_contact_header" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="create new contact" - style="@style/sectionHeader" - android:visibility="gone"/> - <LinearLayout - android:id="@+id/create_new_contact" - android:layout_height="fill_parent" - android:layout_width="fill_parent" - android:orientation="vertical" - android:visibility="gone"> - - </LinearLayout> - </LinearLayout> - </ScrollView> </RelativeLayout>
\ No newline at end of file diff --git a/res/layout/contact.xml b/res/layout/contact.xml index 1b11f0fc..ec985fcf 100644 --- a/res/layout/contact.xml +++ b/res/layout/contact.xml @@ -1,12 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" - android:layout_width="fill_parent" - android:layout_height="wrap_content"> -<RelativeLayout +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:paddingTop="8dp" + android:padding="8dp" android:paddingBottom="8dp"> <ImageView @@ -38,7 +34,4 @@ /> </LinearLayout> -</RelativeLayout> - <View style="@style/Divider" - android:id="@+id/contact_divider"/> -</LinearLayout>
\ No newline at end of file +</RelativeLayout>
\ No newline at end of file diff --git a/src/de/gultsch/chat/ui/ConversationActivity.java b/src/de/gultsch/chat/ui/ConversationActivity.java index 959e39a9..90fc1d40 100644 --- a/src/de/gultsch/chat/ui/ConversationActivity.java +++ b/src/de/gultsch/chat/ui/ConversationActivity.java @@ -129,7 +129,6 @@ public class ConversationActivity extends XmppActivity { }); spl = (SlidingPaneLayout) findViewById(id.slidingpanelayout); spl.setParallaxDistance(150); - spl.openPane(); spl.setShadowResource(R.drawable.es_slidingpane_shadow); spl.setSliderFadeColor(0); spl.setPanelSlideListener(new PanelSlideListener() { @@ -286,6 +285,7 @@ public class ConversationActivity extends XmppActivity { startActivity(new Intent(this, NewConversationActivity.class)); finish(); } else { + spl.openPane(); //find currently loaded fragment ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager().findFragmentByTag("conversation"); if (selectedFragment!=null) { diff --git a/src/de/gultsch/chat/ui/ConversationFragment.java b/src/de/gultsch/chat/ui/ConversationFragment.java index 1ae04ce9..c3b73ac5 100644 --- a/src/de/gultsch/chat/ui/ConversationFragment.java +++ b/src/de/gultsch/chat/ui/ConversationFragment.java @@ -157,6 +157,9 @@ public class ConversationFragment extends Fragment { // rendering complete. now go tell activity to close pane if (!activity.shouldPaneBeOpen()) { activity.getSlidingPaneLayout().closePane(); + activity.getActionBar().setDisplayHomeAsUpEnabled(true); + activity.getActionBar().setTitle(conversation.getName()); + activity.invalidateOptionsMenu(); } int size = this.messageList.size(); @@ -173,6 +176,9 @@ public class ConversationFragment extends Fragment { // rendering complete. now go tell activity to close pane if (!activity.shouldPaneBeOpen()) { activity.getSlidingPaneLayout().closePane(); + activity.getActionBar().setDisplayHomeAsUpEnabled(true); + activity.getActionBar().setTitle(conversation.getName()); + activity.invalidateOptionsMenu(); } } } diff --git a/src/de/gultsch/chat/ui/NewConversationActivity.java b/src/de/gultsch/chat/ui/NewConversationActivity.java index e30fcbb8..2725178d 100644 --- a/src/de/gultsch/chat/ui/NewConversationActivity.java +++ b/src/de/gultsch/chat/ui/NewConversationActivity.java @@ -1,13 +1,14 @@ package de.gultsch.chat.ui; -import java.util.LinkedHashMap; -import java.util.Map.Entry; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; import de.gultsch.chat.R; import de.gultsch.chat.entities.Account; import de.gultsch.chat.entities.Contact; import de.gultsch.chat.entities.Conversation; -import de.gultsch.chat.persistance.DatabaseBackend; import de.gultsch.chat.utils.Validator; import android.os.Bundle; import android.provider.ContactsContract; @@ -18,8 +19,12 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.view.View.OnClickListener; -import android.widget.LinearLayout; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ArrayAdapter; +import android.widget.EditText; +import android.widget.ListView; import android.widget.TextView; import android.widget.ImageView; import android.content.Context; @@ -31,10 +36,53 @@ import android.database.Cursor; public class NewConversationActivity extends XmppActivity { - final protected LinkedHashMap<Contact, View> availablePhoneContacts = new LinkedHashMap<Contact, View>(); - final protected LinkedHashMap<Contact, View> availableJabberContacts = new LinkedHashMap<Contact, View>(); - protected View newContactView; - protected Contact newContact; + protected List<Contact> phoneContacts = new ArrayList<Contact>(); + protected List<Contact> rosterContacts = new ArrayList<Contact>(); + protected List<Contact> aggregatedContacts = new ArrayList<Contact>(); + protected ListView contactsView; + protected ArrayAdapter<Contact> contactsAdapter; + + protected EditText search; + protected String searchString = ""; + private TextView contactsHeader; + + protected void updateAggregatedContacts() { + + aggregatedContacts.clear(); + for (Contact contact : phoneContacts) { + if (contact.match(searchString)) + aggregatedContacts.add(contact); + } + for (Contact contact : rosterContacts) { + if (contact.match(searchString)) + aggregatedContacts.add(contact); + } + + Collections.sort(aggregatedContacts, new Comparator<Contact>() { + + @Override + public int compare(Contact lhs, Contact rhs) { + return lhs.getDisplayName().compareTo(rhs.getDisplayName()); + } + }); + + if (aggregatedContacts.size() == 0) { + + if (Validator.isValidJid(searchString)) { + String name = searchString.split("@")[0]; + Contact newContact = new Contact(name, searchString, + DEFAULT_PROFILE_PHOTO); + aggregatedContacts.add(newContact); + contactsHeader.setText("Create new contact"); + } else { + contactsHeader.setText("Contacts"); + } + } else { + contactsHeader.setText("Contacts"); + } + + contactsAdapter.notifyDataSetChanged(); + } static final String[] PROJECTION = new String[] { ContactsContract.Data.CONTACT_ID, @@ -48,63 +96,95 @@ public class NewConversationActivity extends XmppActivity { + "\") AND (" + ContactsContract.CommonDataKinds.Im.PROTOCOL + "=\"" + ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER + "\")"; - protected static final String DEFAULT_PROFILE_PHOTO = "android.resource://de.gultsch.chat/" + R.drawable.ic_profile; - - protected View getViewForContact(Contact contact) { - LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View view = (View) inflater.inflate(R.layout.contact,null); - ((TextView) view.findViewById(R.id.contact_display_name)).setText(contact.getDisplayName()); - ((TextView) view.findViewById(R.id.contact_jid)).setText(contact.getJid()); - ((ImageView) view.findViewById(R.id.contact_photo)).setImageURI(contact.getProfilePhoto()); - view.setOnClickListener(new OnClickListener() { - + protected static final String DEFAULT_PROFILE_PHOTO = "android.resource://de.gultsch.chat/" + + R.drawable.ic_profile; + + @Override + protected void onCreate(Bundle savedInstanceState) { + + super.onCreate(savedInstanceState); + + setContentView(R.layout.activity_new_conversation); + + contactsHeader = (TextView) findViewById(R.id.contacts_header); + + search = (EditText) findViewById(R.id.new_conversation_search); + search.addTextChangedListener(new TextWatcher() { + @Override - public void onClick(View v) { - Contact clickedContact = null; - for(Entry<Contact, View> entry : availablePhoneContacts.entrySet()) { - if (entry.getValue() == v) { - clickedContact = entry.getKey(); - break; - } - } - for(Entry<Contact, View> entry : availableJabberContacts.entrySet()) { - if (entry.getValue() == v) { - clickedContact = entry.getKey(); - break; - } - } - if (newContactView==v) { - clickedContact = newContact; + public void onTextChanged(CharSequence s, int start, int before, + int count) { + searchString = search.getText().toString(); + updateAggregatedContacts(); + } + + @Override + public void afterTextChanged(Editable s) { + // TODO Auto-generated method stub + + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, + int after) { + // TODO Auto-generated method stub + + } + }); + + contactsView = (ListView) findViewById(R.id.contactList); + contactsAdapter = new ArrayAdapter<Contact>(getApplicationContext(), + R.layout.contact, aggregatedContacts) { + @Override + public View getView(int position, View view, ViewGroup parent) { + LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); + if (view == null) { + view = (View) inflater.inflate(R.layout.contact, null); } - Log.d("gultsch","clicked on "+clickedContact.getDisplayName()); - - + + ((TextView) view.findViewById(R.id.contact_display_name)) + .setText(getItem(position).getDisplayName()); + ((TextView) view.findViewById(R.id.contact_jid)) + .setText(getItem(position).getJid()); + ((ImageView) view.findViewById(R.id.contact_photo)) + .setImageURI(getItem(position).getProfilePhoto()); + return view; + } + }; + contactsView.setAdapter(contactsAdapter); + contactsView.setOnItemClickListener(new OnItemClickListener() { + + @Override + public void onItemClick(AdapterView<?> arg0, View view, int pos, + long arg3) { + Contact clickedContact = aggregatedContacts.get(pos); + Log.d("gultsch", + "clicked on " + clickedContact.getDisplayName()); + Account account = new Account(); - - Conversation conversation = xmppConnectionService.findOrCreateConversation(account, clickedContact); - - Intent viewConversationIntent = new Intent(v.getContext(),ConversationActivity.class); + + Conversation conversation = xmppConnectionService + .findOrCreateConversation(account, clickedContact); + + Intent viewConversationIntent = new Intent(view.getContext(), + ConversationActivity.class); viewConversationIntent.setAction(Intent.ACTION_VIEW); - viewConversationIntent.putExtra(ConversationActivity.CONVERSATION, conversation.getUuid()); - viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION); - viewConversationIntent.setFlags(viewConversationIntent.getFlags() | Intent.FLAG_ACTIVITY_CLEAR_TOP); + viewConversationIntent.putExtra( + ConversationActivity.CONVERSATION, + conversation.getUuid()); + viewConversationIntent + .setType(ConversationActivity.VIEW_CONVERSATION); + viewConversationIntent.setFlags(viewConversationIntent + .getFlags() | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(viewConversationIntent); } }); - return view; } - + @Override - protected void onCreate(Bundle savedInstanceState) { - - super.onCreate(savedInstanceState); - - if (DatabaseBackend.getInstance(this).getConversationCount() < 1) { - getActionBar().setDisplayHomeAsUpEnabled(false); - getActionBar().setHomeButtonEnabled(false); - } - - setContentView(R.layout.activity_new_conversation); + public void onStart() { + super.onStart(); + CursorLoader mCursorLoader = new CursorLoader(this, ContactsContract.Data.CONTENT_URI, PROJECTION, SELECTION, null, null); @@ -112,8 +192,10 @@ public class NewConversationActivity extends XmppActivity { @Override public void onLoadComplete(Loader<Cursor> arg0, Cursor cursor) { + phoneContacts.clear(); while (cursor.moveToNext()) { - String profilePhoto = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.PHOTO_THUMBNAIL_URI)); + String profilePhoto = cursor.getString(cursor + .getColumnIndex(ContactsContract.Data.PHOTO_THUMBNAIL_URI)); if (profilePhoto == null) { profilePhoto = DEFAULT_PROFILE_PHOTO; } @@ -122,109 +204,31 @@ public class NewConversationActivity extends XmppActivity { .getColumnIndex(ContactsContract.Data.DISPLAY_NAME)), cursor.getString(cursor .getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA)), - profilePhoto - ); - View contactView = getViewForContact(contact); - availablePhoneContacts.put(contact, getViewForContact(contact)); - ((LinearLayout) findViewById(R.id.phone_contacts)).addView(contactView); + profilePhoto); + phoneContacts.add(contact); } - updateAvailableContacts(); + updateAggregatedContacts(); } }); mCursorLoader.startLoading(); - ((TextView) findViewById(R.id.new_conversation_search)).addTextChangedListener(new TextWatcher() { - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - updateAvailableContacts(); - } - - @Override - public void afterTextChanged(Editable s) { - // TODO Auto-generated method stub - - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, - int after) { - // TODO Auto-generated method stub - - } - }); - - } - - protected void updateAvailableContacts() { - String search = ((TextView) findViewById(R.id.new_conversation_search)).getText().toString(); - - LinearLayout phoneContacts = (LinearLayout) findViewById(R.id.phone_contacts); - filterAvailableContacts(phoneContacts,this.availablePhoneContacts,search); - - if (phoneContacts.getChildCount() == 0) { - findViewById(R.id.phone_contacts_header).setVisibility(View.GONE); - } else { - findViewById(R.id.phone_contacts_header).setVisibility(View.VISIBLE); - } - - LinearLayout jabberContacts = (LinearLayout) findViewById(R.id.jabber_contacts); - filterAvailableContacts(jabberContacts,this.availableJabberContacts,search); - if (jabberContacts.getChildCount() == 0) { - findViewById(R.id.jabber_contacts_header).setVisibility(View.GONE); - } else { - findViewById(R.id.jabber_contacts_header).setVisibility(View.VISIBLE); - } - - LinearLayout createNewContact = (LinearLayout) findViewById(R.id.create_new_contact); - if (Validator.isValidJid(search)) { - createNewContact.removeAllViews(); - String name = search.split("@")[0]; - newContact = new Contact(name,search,DEFAULT_PROFILE_PHOTO); - newContactView = getViewForContact(newContact); - newContactView.findViewById(R.id.contact_divider).setVisibility(View.GONE); - createNewContact.addView(newContactView); - createNewContact.setVisibility(View.VISIBLE); - ((TextView) findViewById(R.id.new_contact_header)).setVisibility(View.VISIBLE); - } else { - createNewContact.setVisibility(View.GONE); - ((TextView) findViewById(R.id.new_contact_header)).setVisibility(View.GONE); - } - } - - private void filterAvailableContacts( - LinearLayout layout, LinkedHashMap<Contact, View> contacts, String search) { - layout.removeAllViews(); - for(Entry<Contact, View> entry : contacts.entrySet()) { - - if (entry.getKey().match(search)) { - entry.getValue().setVisibility(View.VISIBLE); - entry.getValue().findViewById(R.id.contact_divider).setVisibility(View.VISIBLE); - layout.addView(entry.getValue()); - } - } - int contactsCount = layout.getChildCount(); - if (contactsCount>=1) { - View lastContact = layout.getChildAt(contactsCount - 1); - lastContact.findViewById(R.id.contact_divider).setVisibility(View.GONE); - } } @Override void onBackendConnected() { - if (xmppConnectionService.getConversationCount()==0) { + if (xmppConnectionService.getConversationCount() == 0) { getActionBar().setDisplayHomeAsUpEnabled(false); getActionBar().setHomeButtonEnabled(false); } } - + @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.newconversation, menu); return true; } - + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { @@ -239,5 +243,5 @@ public class NewConversationActivity extends XmppActivity { } return super.onOptionsItemSelected(item); } - + } |