private void updateView() { ImApp app = ImApp.getApplication((Activity) mContext); BrandingResources brandingRes = app.getBrandingResource(mProviderId); int status = PresenceUtils.convertStatus(mPresence.getStatus()); mStatusDialogButton.setImageDrawable( brandingRes.getDrawable(PresenceUtils.getStatusIconId(status))); String statusText = mPresence.getStatusText(); if (TextUtils.isEmpty(statusText)) { statusText = brandingRes.getString(PresenceUtils.getStatusStringRes(status)); } mLastStatusText = statusText; if (mStatusBar == null) { mStatusBar = initStatusBar(mProviderId, false); } mStatusBar.setText(statusText); // Disable the user to edit the custom status text because // the AIM and MSN server don't support it now. ProviderDef provider = app.getProvider(mProviderId); String providerName = provider == null ? null : provider.mName; if (Imps.ProviderNames.AIM.equals(providerName) || Imps.ProviderNames.MSN.equals(providerName)) { mStatusBar.setFocusable(false); } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { AdapterView.AdapterContextMenuInfo info; try { info = (AdapterView.AdapterContextMenuInfo) menuInfo; } catch (ClassCastException e) { Log.e(TAG, "bad menuInfo", e); return; } Cursor providerCursor = (Cursor) getListAdapter().getItem(info.position); menu.setHeaderTitle(providerCursor.getString(PROVIDER_FULLNAME_COLUMN)); if (providerCursor.isNull(ACTIVE_ACCOUNT_ID_COLUMN)) { menu.add(0, ID_ADD_ACCOUNT, 0, R.string.menu_edit_account); menu.add(0, ID_REMOVE_ACCOUNT, 0, R.string.menu_remove_account) .setIcon(android.R.drawable.ic_menu_delete); return; } long providerId = providerCursor.getLong(PROVIDER_ID_COLUMN); boolean isLoggingIn = isSigningIn(providerCursor); boolean isLoggedIn = isSignedIn(providerCursor); BrandingResources brandingRes = mApp.getBrandingResource(providerId); menu.add( 0, ID_VIEW_CONTACT_LIST, 0, brandingRes.getString(BrandingResourceIDs.STRING_MENU_CONTACT_LIST)); if (isLoggedIn) { menu.add(0, ID_SIGN_OUT, 0, R.string.menu_sign_out) .setIcon(android.R.drawable.ic_menu_close_clear_cancel); } else if (isLoggingIn) { menu.add(0, ID_SIGN_OUT, 0, R.string.menu_cancel_signin) .setIcon(android.R.drawable.ic_menu_close_clear_cancel); } else { menu.add(0, ID_SIGN_IN, 0, R.string.sign_in) // TODO .setIcon(info.guardianproject.otr.app.internal.R.drawable.ic_menu_login) ; } boolean isAccountEditable = providerCursor.getInt(ACTIVE_ACCOUNT_LOCKED) == 0; if (isAccountEditable && !isLoggingIn && !isLoggedIn) { menu.add(0, ID_EDIT_ACCOUNT, 0, R.string.menu_edit_account) .setIcon(android.R.drawable.ic_menu_edit); menu.add(0, ID_REMOVE_ACCOUNT, 0, R.string.menu_remove_account) .setIcon(android.R.drawable.ic_menu_delete); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mApp = ImApp.getApplication(this); mHandler = new SimpleAlertHandler(this); resolveIntent(getIntent()); setContentView(R.layout.add_contact_activity); BrandingResources brandingRes = mApp.getBrandingResource(mProviderId); setTitle(brandingRes.getString(BrandingResourceIDs.STRING_ADD_CONTACT_TITLE)); BhoTextView label = (BhoTextView) findViewById(R.id.input_contact_label); label.setText(brandingRes.getString(BrandingResourceIDs.STRING_LABEL_INPUT_CONTACT)); mAddressList = (MultiAutoCompleteTextView) findViewById(R.id.email); mAddressList.setAdapter(new EmailAddressAdapter(this)); mAddressList.setTokenizer(new Rfc822Tokenizer()); mAddressList.addTextChangedListener(mTextWatcher); mListSpinner = (Spinner) findViewById(R.id.choose_list); Cursor c = queryContactLists(); int initSelection = searchInitListPos(c, getIntent().getStringExtra(ImServiceConstants.EXTRA_INTENT_LIST_NAME)); SimpleCursorAdapter adapter = new SimpleCursorAdapter( this, android.R.layout.simple_spinner_item, c, new String[] {Imps.ContactList.NAME}, new int[] {android.R.id.text1}); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mListSpinner.setAdapter(adapter); mListSpinner.setSelection(initSelection); mInviteButton = (BhoButton) findViewById(R.id.invite); mInviteButton.setText(brandingRes.getString(BrandingResourceIDs.STRING_BUTTON_ADD_CONTACT)); mInviteButton.setOnClickListener(mButtonHandler); mInviteButton.setEnabled(false); }
private StatusIconAdapter getStatusAdapter() { try { mStatusItems.clear(); int[] supportedStatus = mConn.getSupportedPresenceStatus(); for (int i = 0; i < supportedStatus.length; i++) { int s = PresenceUtils.convertStatus(supportedStatus[i]); if (s == Imps.Presence.OFFLINE) { s = Imps.Presence.INVISIBLE; } ImApp app = ImApp.getApplication((Activity) mContext); BrandingResources brandingRes = app.getBrandingResource(mProviderId); Drawable icon = brandingRes.getDrawable(PresenceUtils.getStatusIconId(s)); String text = brandingRes.getString(PresenceUtils.getStatusStringRes(s)); mStatusItems.add(new StatusItem(supportedStatus[i], icon, text)); } } catch (RemoteException e) { mHandler.showServiceErrorAlert(); } return new StatusIconAdapter(mContext, mStatusItems); }