Exemplo n.º 1
0
 @Override
 protected void onResume() {
   super.onResume();
   Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
   Application.getInstance().addUIListener(OnContactChangedListener.class, this);
   update();
 }
  @Override
  protected void onResume() {
    super.onResume();
    barPainter.setDefaultColor();
    rebuildAccountToggle();
    Application.getInstance().addUIListener(OnAccountChangedListener.class, this);

    if (action != null) {
      switch (action) {
        case ContactList.ACTION_ROOM_INVITE:
        case Intent.ACTION_SEND:
        case Intent.ACTION_CREATE_SHORTCUT:
          if (Intent.ACTION_SEND.equals(action)) {
            sendText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
          }
          Toast.makeText(this, getString(R.string.select_contact), Toast.LENGTH_LONG).show();
          break;
        case Intent.ACTION_VIEW:
          {
            action = null;
            Uri data = getIntent().getData();
            if (data != null && "xmpp".equals(data.getScheme())) {
              XMPPUri xmppUri;
              try {
                xmppUri = XMPPUri.parse(data);
              } catch (IllegalArgumentException e) {
                xmppUri = null;
              }
              if (xmppUri != null && "message".equals(xmppUri.getQueryType())) {
                ArrayList<String> texts = xmppUri.getValues("body");
                String text = null;
                if (texts != null && !texts.isEmpty()) {
                  text = texts.get(0);
                }
                openChat(xmppUri.getPath(), text);
              }
            }
            break;
          }
        case Intent.ACTION_SENDTO:
          {
            action = null;
            Uri data = getIntent().getData();
            if (data != null) {
              String path = data.getPath();
              if (path != null && path.startsWith("/")) {
                openChat(path.substring(1), null);
              }
            }
            break;
          }
      }
    }

    if (Application.getInstance().doNotify()) {
      if (!SettingsManager.isTranslationSuggested()) {
        Locale currentLocale = getResources().getConfiguration().locale;
        if (!currentLocale.getLanguage().equals("en")
            && !getResources().getBoolean(R.bool.is_translated)) {
          new TranslationDialog().show(getFragmentManager(), "TRANSLATION_DIALOG");
          SettingsManager.setTranslationSuggested();
        }
      }

      if (SettingsManager.bootCount() > 2
          && !SettingsManager.connectionStartAtBoot()
          && !SettingsManager.startAtBootSuggested()) {
        StartAtBootDialogFragment.newInstance().show(getFragmentManager(), "START_AT_BOOT");
      }
      if (!SettingsManager.contactIntegrationSuggested()
          && Application.getInstance().isContactsSupported()) {
        if (AccountManager.getInstance().getAllAccounts().isEmpty()) {
          SettingsManager.setContactIntegrationSuggested();
        } else {
          ContactIntegrationDialogFragment.newInstance()
              .show(getFragmentManager(), "CONTACT_INTEGRATION");
        }
      }
    }
  }