@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_with_toolbar_and_container); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); BarPainter barPainter = new BarPainter(this, toolbar); barPainter.setDefaultColor(); if (savedInstanceState == null) { getFragmentManager() .beginTransaction() .add(R.id.fragment_container, new PhraseEditorFragment()) .commit(); } }
@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 public void onAccountsChanged(Collection<String> accounts) { ((ContactListFragment) getSupportFragmentManager().findFragmentById(R.id.container)) .onAccountsChanged(); barPainter.setDefaultColor(); }
@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"); } } } }