@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isFinishing()) return;

    setContentView(R.layout.fingerprint_viewer);
    integrator = new IntentIntegrator(this);
    Intent intent = getIntent();
    account = getAccount(intent);
    user = getUser(intent);
    if (AccountManager.getInstance().getAccount(account) == null || user == null) {
      Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
      finish();
      return;
    }
    if (savedInstanceState != null) {
      remoteFingerprint = savedInstanceState.getString(SAVED_REMOTE_FINGERPRINT);
      localFingerprint = savedInstanceState.getString(SAVED_LOCAL_FINGERPRINT);
    } else {
      remoteFingerprint = OTRManager.getInstance().getRemoteFingerprint(account, user);
      localFingerprint = OTRManager.getInstance().getLocalFingerprint(account);
    }
    verifiedView = (CheckBox) findViewById(R.id.verified);
    verifiedView.setOnCheckedChangeListener(this);
    scanView = findViewById(R.id.scan);
    scanView.setOnClickListener(this);
    showView = findViewById(R.id.show);
    showView.setOnClickListener(this);
    copyView = findViewById(R.id.copy);
    copyView.setOnClickListener(this);
    isUpdating = false;
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   getMenuInflater().inflate(R.menu.contact_list, menu);
   menu.findItem(R.id.action_search).setVisible(false);
   return true;
 }
 @Override
 protected void onResume() {
   super.onResume();
   Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
   Application.getInstance().addUIListener(OnContactChangedListener.class, this);
   update();
 }
 @Override
 protected void onNewIntent(Intent intent) {
   super.onNewIntent(intent);
   setIntent(intent);
   action = getIntent().getAction();
   getIntent().setAction(null);
 }
 @Override
 public void onBackPressed() {
   if (drawerLayout.isDrawerOpen(Gravity.START | Gravity.LEFT)) {
     drawerLayout.closeDrawers();
     return;
   }
   super.onBackPressed();
 }
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
   if (scanResult != null) {
     String code = scanResult.getContents();
     boolean equals = code != null && code.equals(remoteFingerprint);
     verifiedView.setChecked(equals);
     if (equals) showDialog(R.string.action_otr_smp_verified);
     else showDialog(R.string.action_otr_smp_unverified);
   }
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    if (Intent.ACTION_VIEW.equals(getIntent().getAction())
        || Intent.ACTION_SEND.equals(getIntent().getAction())
        || Intent.ACTION_SENDTO.equals(getIntent().getAction())
        || Intent.ACTION_CREATE_SHORTCUT.equals(getIntent().getAction())) {
      ActivityManager.getInstance().startNewTask(this);
    }
    super.onCreate(savedInstanceState);

    if (isFinishing()) {
      return;
    }

    setContentView(R.layout.contact_list);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setOnClickListener(this);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerToggle =
        new ActionBarDrawerToggle(
            this,
            drawerLayout,
            toolbar,
            R.string.application_title_short,
            R.string.application_title_short);
    drawerLayout.setDrawerListener(drawerToggle);

    toolbar.inflateMenu(R.menu.contact_list);
    optionsMenu = toolbar.getMenu();
    setUpSearchView(optionsMenu);
    toolbar.setOnMenuItemClickListener(this);

    barPainter = new BarPainter(this, toolbar);
    barPainter.setDefaultColor();

    toolbar.setTitle(R.string.application_title_full);

    if (savedInstanceState != null) {
      sendText = savedInstanceState.getString(SAVED_SEND_TEXT);
      action = savedInstanceState.getString(SAVED_ACTION);
    } else {
      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.container, new ContactListFragment(), CONTACT_LIST_TAG)
          .commit();

      sendText = null;
      action = getIntent().getAction();
    }
    getIntent().setAction(null);
  }
 @Override
 protected Dialog onCreateDialog(int id) {
   super.onCreateDialog(id);
   switch (id) {
     case DIALOG_CLOSE_APPLICATION_ID:
       ProgressDialog progressDialog = new ProgressDialog(this);
       progressDialog.setMessage(getString(R.string.application_state_closing));
       progressDialog.setOnCancelListener(
           new OnCancelListener() {
             @Override
             public void onCancel(DialogInterface dialog) {
               finish();
             }
           });
       progressDialog.setIndeterminate(true);
       return progressDialog;
     default:
       return null;
   }
 }
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putString(SAVED_REMOTE_FINGERPRINT, remoteFingerprint);
   outState.putString(SAVED_LOCAL_FINGERPRINT, localFingerprint);
 }
Example #10
0
 @Override
 protected void onRestoreInstanceState(Bundle savedInstanceState) {
   isUpdating = true;
   super.onRestoreInstanceState(savedInstanceState);
   isUpdating = false;
 }
Example #11
0
 @Override
 protected void onPause() {
   super.onPause();
   Application.getInstance().removeUIListener(OnAccountChangedListener.class, this);
   Application.getInstance().removeUIListener(OnContactChangedListener.class, this);
 }
 @Override
 public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
   super.onCreateContextMenu(menu, view, menuInfo);
 }
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
   drawerToggle.onConfigurationChanged(newConfig);
 }
 @Override
 protected void onPostCreate(Bundle savedInstanceState) {
   super.onPostCreate(savedInstanceState);
   drawerToggle.syncState();
 }
  @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");
        }
      }
    }
  }
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   outState.putString(SAVED_ACTION, action);
   outState.putString(SAVED_SEND_TEXT, sendText);
 }