diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java | 174 |
1 files changed, 78 insertions, 96 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 2b357d0d1..191e0b82a 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -66,59 +66,25 @@ import eu.siacs.conversations.utils.Validator; import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; -public class StartConversationActivity extends XmppActivity { +public class StartConversationActivity extends XmppActivity implements OnRosterUpdate { + public int conference_context_id; + public int contact_context_id; private Tab mContactsTab; private Tab mConferencesTab; private ViewPager mViewPager; - private MyListFragment mContactsListFragment = new MyListFragment(); private List<ListItem> contacts = new ArrayList<>(); private ArrayAdapter<ListItem> mContactsAdapter; - private MyListFragment mConferenceListFragment = new MyListFragment(); private List<ListItem> conferences = new ArrayList<ListItem>(); private ArrayAdapter<ListItem> mConferenceAdapter; - private List<String> mActivatedAccounts = new ArrayList<String>(); private List<String> mKnownHosts; private List<String> mKnownConferenceHosts; - private Invite mPendingInvite = null; - private Menu mOptionsMenu; private EditText mSearchEditText; - - public int conference_context_id; - public int contact_context_id; - - private TabListener mTabListener = new TabListener() { - - @Override - public void onTabUnselected(Tab tab, FragmentTransaction ft) { - return; - } - - @Override - public void onTabSelected(Tab tab, FragmentTransaction ft) { - mViewPager.setCurrentItem(tab.getPosition()); - onTabChanged(); - } - - @Override - public void onTabReselected(Tab tab, FragmentTransaction ft) { - return; - } - }; - - private ViewPager.SimpleOnPageChangeListener mOnPageChangeListener = new ViewPager.SimpleOnPageChangeListener() { - @Override - public void onPageSelected(int position) { - getActionBar().setSelectedNavigationItem(position); - onTabChanged(); - } - }; - private MenuItem.OnActionExpandListener mOnActionExpandListener = new MenuItem.OnActionExpandListener() { @Override @@ -147,6 +113,31 @@ public class StartConversationActivity extends XmppActivity { return true; } }; + private TabListener mTabListener = new TabListener() { + + @Override + public void onTabUnselected(Tab tab, FragmentTransaction ft) { + return; + } + + @Override + public void onTabSelected(Tab tab, FragmentTransaction ft) { + mViewPager.setCurrentItem(tab.getPosition()); + onTabChanged(); + } + + @Override + public void onTabReselected(Tab tab, FragmentTransaction ft) { + return; + } + }; + private ViewPager.SimpleOnPageChangeListener mOnPageChangeListener = new ViewPager.SimpleOnPageChangeListener() { + @Override + public void onPageSelected(int position) { + getActionBar().setSelectedNavigationItem(position); + onTabChanged(); + } + }; private TextWatcher mSearchTextWatcher = new TextWatcher() { @Override @@ -164,23 +155,21 @@ public class StartConversationActivity extends XmppActivity { int count) { } }; - private OnRosterUpdate onRosterUpdate = new OnRosterUpdate() { + private MenuItem mMenuSearchView; + private String mInitialJid; - @Override - public void onRosterUpdate() { - runOnUiThread(new Runnable() { + @Override + public void onRosterUpdate() { + runOnUiThread(new Runnable() { - @Override - public void run() { - if (mSearchEditText != null) { - filter(mSearchEditText.getText().toString()); - } + @Override + public void run() { + if (mSearchEditText != null) { + filter(mSearchEditText.getText().toString()); } - }); - } - }; - private MenuItem mMenuSearchView; - private String mInitialJid; + } + }); + } @Override public void onCreate(Bundle savedInstanceState) { @@ -243,12 +232,6 @@ public class StartConversationActivity extends XmppActivity { } - @Override - public void onStop() { - super.onStop(); - xmppConnectionService.removeOnRosterUpdateListener(); - } - protected void openConversationForContact(int position) { Contact contact = (Contact) contacts.get(position); Conversation conversation = xmppConnectionService @@ -361,20 +344,20 @@ public class StartConversationActivity extends XmppActivity { return; } if (Validator.isValidJid(jid.getText().toString())) { - final Jid accountJid; - try { - accountJid = Jid.fromString((String) spinner - .getSelectedItem()); - } catch (final InvalidJidException e) { - return; - } - final Jid contactJid; - try { - contactJid = Jid.fromString(jid.getText().toString()); - } catch (final InvalidJidException e) { - return; - } - Account account = xmppConnectionService + final Jid accountJid; + try { + accountJid = Jid.fromString((String) spinner + .getSelectedItem()); + } catch (final InvalidJidException e) { + return; + } + final Jid contactJid; + try { + contactJid = Jid.fromString(jid.getText().toString()); + } catch (final InvalidJidException e) { + return; + } + Account account = xmppConnectionService .findAccountByJid(accountJid); if (account == null) { dialog.dismiss(); @@ -427,19 +410,19 @@ public class StartConversationActivity extends XmppActivity { return; } if (Validator.isValidJid(jid.getText().toString())) { - final Jid accountJid; - try { - accountJid = Jid.fromString((String) spinner.getSelectedItem()); - } catch (final InvalidJidException e) { - return; - } - final Jid conferenceJid; - try { - conferenceJid = Jid.fromString(jid.getText().toString()); - } catch (final InvalidJidException e) { - return; // TODO: Do some error handling... - } - Account account = xmppConnectionService + final Jid accountJid; + try { + accountJid = Jid.fromString((String) spinner.getSelectedItem()); + } catch (final InvalidJidException e) { + return; + } + final Jid conferenceJid; + try { + conferenceJid = Jid.fromString(jid.getText().toString()); + } catch (final InvalidJidException e) { + return; // TODO: Do some error handling... + } + Account account = xmppConnectionService .findAccountByJid(accountJid); if (account == null) { dialog.dismiss(); @@ -570,7 +553,6 @@ public class StartConversationActivity extends XmppActivity { @Override protected void onBackendConnected() { - xmppConnectionService.setOnRosterUpdateListener(this.onRosterUpdate); this.mActivatedAccounts.clear(); for (Account account : xmppConnectionService.getAccounts()) { if (account.getStatus() != Account.STATUS_DISABLED) { @@ -611,20 +593,20 @@ public class StartConversationActivity extends XmppActivity { for (Parcelable message : getIntent().getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)) { if (message instanceof NdefMessage) { Log.d(Config.LOGTAG, "received message=" + message); - for (NdefRecord record : ((NdefMessage)message).getRecords()) { + for (NdefRecord record : ((NdefMessage) message).getRecords()) { switch (record.getTnf()) { - case NdefRecord.TNF_WELL_KNOWN: - if (Arrays.equals(record.getType(), NdefRecord.RTD_URI)) { - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - return getInviteJellyBean(record).invite(); - } else { - byte[] payload = record.getPayload(); - if (payload[0] == 0) { - return new Invite(Uri.parse(new String(Arrays.copyOfRange( - payload, 1, payload.length)))).invite(); + case NdefRecord.TNF_WELL_KNOWN: + if (Arrays.equals(record.getType(), NdefRecord.RTD_URI)) { + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + return getInviteJellyBean(record).invite(); + } else { + byte[] payload = record.getPayload(); + if (payload[0] == 0) { + return new Invite(Uri.parse(new String(Arrays.copyOfRange( + payload, 1, payload.length)))).invite(); + } } } - } } } } |