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);
    }
  }
  private TextView initStatusBar(long providerId, boolean showEdit) {

    EditText statusEdit = (EditText) findViewById(R.id.statusEdit);
    statusEdit.setVisibility(View.GONE);
    TextView statusView = (TextView) findViewById(R.id.statusView);
    statusView.setVisibility(View.GONE);

    if (showEdit) {

      statusEdit.setVisibility(View.VISIBLE);
      statusEdit.setOnKeyListener(
          new OnKeyListener() {
            public boolean onKey(View v, int keyCode, KeyEvent event) {
              if (KeyEvent.ACTION_DOWN == event.getAction()) {
                switch (keyCode) {
                  case KeyEvent.KEYCODE_DPAD_CENTER:
                  case KeyEvent.KEYCODE_ENTER:
                    updateStatusText();
                    return true;
                }
              }
              return false;
            }
          });

      statusEdit.setOnFocusChangeListener(
          new View.OnFocusChangeListener() {
            public void onFocusChange(View v, boolean hasFocus) {
              if (!hasFocus) {
                updateStatusText();
              }
            }
          });

      return statusEdit;
    } else {
      if (mPresence != null) {
        statusView.setText(mPresence.getStatusText());
      }

      statusView.setVisibility(View.VISIBLE);

      statusView.setOnClickListener(
          new OnClickListener() {

            @Override
            public void onClick(View v) {
              mStatusBar = initStatusBar(mProviderId, true);
            }
          });

      return statusView;
    }
  }