/** * Adds the user interface related to the given protocol provider. * * @param protocolProvider the protocol provider for which we add the user interface */ public void addProtocolProviderUI(ProtocolProviderService protocolProvider) { OperationSetBasicTelephony<?> telOpSet = protocolProvider.getOperationSet(OperationSetBasicTelephony.class); if (telOpSet != null) { telOpSet.addCallListener(androidCallListener); } OperationSetPresence presenceOpSet = protocolProvider.getOperationSet(OperationSetPresence.class); if (presenceOpSet != null) { presenceOpSet.addProviderPresenceStatusListener(androidPresenceListener); } }
/** * Removes the user interface related to the given protocol provider. * * @param protocolProvider the protocol provider to remove */ public void removeProtocolProviderUI(ProtocolProviderService protocolProvider) { OperationSetBasicTelephony<?> telOpSet = protocolProvider.getOperationSet(OperationSetBasicTelephony.class); if (telOpSet != null) { telOpSet.removeCallListener(androidCallListener); } OperationSetPresence presenceOpSet = protocolProvider.getOperationSet(OperationSetPresence.class); if (presenceOpSet != null) { presenceOpSet.removeProviderPresenceStatusListener(androidPresenceListener); } // Removes all chat session for unregistered provider ChatSessionManager.removeAllChatsForProvider(protocolProvider); }
/** Initializes "select account" spinner with existing accounts. */ private void initAccountSpinner() { Spinner accountsSpiner = (Spinner) findViewById(R.id.selectAccountSpinner); Iterator<ProtocolProviderService> providers = AccountUtils.getRegisteredProviders().iterator(); List<AccountID> accounts = new ArrayList<AccountID>(); int selectedIdx = -1; int idx = 0; while (providers.hasNext()) { ProtocolProviderService provider = providers.next(); OperationSet opSet = provider.getOperationSet(OperationSetPresence.class); if (opSet == null) continue; AccountID account = provider.getAccountID(); accounts.add(account); idx++; if (account.isPreferredProvider()) { selectedIdx = idx; } } AccountsListAdapter accountsAdapter = new AccountsListAdapter( this, R.layout.select_account_row, R.layout.select_account_dropdown, accounts, true); accountsSpiner.setAdapter(accountsAdapter); // if we have only select account option and only one account // select the available account if (accounts.size() == 1) accountsSpiner.setSelection(0); else accountsSpiner.setSelection(selectedIdx); }