Search in sources :

Example 86 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class ConversationsActivity method onBackendConnected.

@Override
void onBackendConnected() {
    if (performRedirectIfNecessary(true)) {
        return;
    }
    xmppConnectionService.getNotificationService().setIsInForeground(true);
    Intent intent = pendingViewIntent.pop();
    if (intent != null) {
        if (processViewIntent(intent)) {
            if (binding.secondaryFragment != null) {
                notifyFragmentOfBackendConnected(R.id.main_fragment);
            }
            invalidateActionBarTitle();
            return;
        }
    }
    for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
        notifyFragmentOfBackendConnected(id);
    }
    ActivityResult activityResult = postponedActivityResult.pop();
    if (activityResult != null) {
        handleActivityResult(activityResult);
    }
    invalidateActionBarTitle();
    if (binding.secondaryFragment != null && ConversationFragment.getConversation(this) == null) {
        Conversation conversation = ConversationsOverviewFragment.getSuggestion(this);
        if (conversation != null) {
            openConversation(conversation, null);
        }
    }
    showDialogsIfMainIsOverview();
}
Also used : IdRes(androidx.annotation.IdRes) Intent(android.content.Intent) Conversation(eu.siacs.conversations.entities.Conversation) ActivityResult(eu.siacs.conversations.ui.util.ActivityResult) SuppressLint(android.annotation.SuppressLint)

Example 87 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class ConversationsActivity method invalidateActionBarTitle.

private void invalidateActionBarTitle() {
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar == null) {
        return;
    }
    final FragmentManager fragmentManager = getFragmentManager();
    final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment);
    if (mainFragment instanceof ConversationFragment) {
        final Conversation conversation = ((ConversationFragment) mainFragment).getConversation();
        if (conversation != null) {
            actionBar.setTitle(EmojiWrapper.transform(conversation.getName()));
            actionBar.setDisplayHomeAsUpEnabled(true);
            ActionBarUtil.setActionBarOnClickListener(binding.toolbar, (v) -> openConversationDetails(conversation));
            return;
        }
    }
    actionBar.setTitle(R.string.app_name);
    actionBar.setDisplayHomeAsUpEnabled(false);
    ActionBarUtil.resetActionBarOnClickListeners(binding.toolbar);
}
Also used : FragmentManager(android.app.FragmentManager) Conversation(eu.siacs.conversations.entities.Conversation) Fragment(android.app.Fragment) ActionBar(androidx.appcompat.app.ActionBar)

Example 88 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class ConversationsActivity method processViewIntent.

private boolean processViewIntent(Intent intent) {
    final String uuid = intent.getStringExtra(EXTRA_CONVERSATION);
    final Conversation conversation = uuid != null ? xmppConnectionService.findConversationByUuid(uuid) : null;
    if (conversation == null) {
        Log.d(Config.LOGTAG, "unable to view conversation with uuid:" + uuid);
        return false;
    }
    openConversation(conversation, intent.getExtras());
    return true;
}
Also used : Conversation(eu.siacs.conversations.entities.Conversation)

Example 89 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class ConversationsActivity method onConversationArchived.

@Override
public void onConversationArchived(Conversation conversation) {
    if (performRedirectIfNecessary(conversation, false)) {
        return;
    }
    final FragmentManager fragmentManager = getFragmentManager();
    final Fragment mainFragment = fragmentManager.findFragmentById(R.id.main_fragment);
    if (mainFragment instanceof ConversationFragment) {
        try {
            fragmentManager.popBackStack();
        } catch (final IllegalStateException e) {
            Log.w(Config.LOGTAG, "state loss while popping back state after archiving conversation", e);
        // this usually means activity is no longer active; meaning on the next open we will run through this again
        }
        return;
    }
    final Fragment secondaryFragment = fragmentManager.findFragmentById(R.id.secondary_fragment);
    if (secondaryFragment instanceof ConversationFragment) {
        if (((ConversationFragment) secondaryFragment).getConversation() == conversation) {
            Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation);
            if (suggestion != null) {
                openConversation(suggestion, null);
            }
        }
    }
}
Also used : FragmentManager(android.app.FragmentManager) Conversation(eu.siacs.conversations.entities.Conversation) Fragment(android.app.Fragment)

Example 90 with Conversation

use of eu.siacs.conversations.entities.Conversation in project Conversations by siacs.

the class ConversationFragment method onContactPictureClicked.

@Override
public void onContactPictureClicked(Message message) {
    String fingerprint;
    if (message.getEncryption() == Message.ENCRYPTION_PGP || message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
        fingerprint = "pgp";
    } else {
        fingerprint = message.getFingerprint();
    }
    final boolean received = message.getStatus() <= Message.STATUS_RECEIVED;
    if (received) {
        if (message.getConversation() instanceof Conversation && message.getConversation().getMode() == Conversation.MODE_MULTI) {
            Jid tcp = message.getTrueCounterpart();
            Jid user = message.getCounterpart();
            if (user != null && !user.isBareJid()) {
                final MucOptions mucOptions = ((Conversation) message.getConversation()).getMucOptions();
                if (mucOptions.participating() || ((Conversation) message.getConversation()).getNextCounterpart() != null) {
                    if (!mucOptions.isUserInRoom(user) && mucOptions.findUserByRealJid(tcp == null ? null : tcp.asBareJid()) == null) {
                        Toast.makeText(getActivity(), activity.getString(R.string.user_has_left_conference, user.getResource()), Toast.LENGTH_SHORT).show();
                    }
                    highlightInConference(user.getResource());
                } else {
                    Toast.makeText(getActivity(), R.string.you_are_not_participating, Toast.LENGTH_SHORT).show();
                }
            }
            return;
        } else {
            if (!message.getContact().isSelf()) {
                activity.switchToContactDetails(message.getContact(), fingerprint);
                return;
            }
        }
    }
    activity.switchToAccount(message.getConversation().getAccount(), fingerprint);
}
Also used : MucOptions(eu.siacs.conversations.entities.MucOptions) Jid(eu.siacs.conversations.xmpp.Jid) Conversation(eu.siacs.conversations.entities.Conversation)

Aggregations

Conversation (eu.siacs.conversations.entities.Conversation)110 Account (eu.siacs.conversations.entities.Account)27 Message (eu.siacs.conversations.entities.Message)24 Jid (eu.siacs.conversations.xmpp.Jid)22 Contact (eu.siacs.conversations.entities.Contact)17 MucOptions (eu.siacs.conversations.entities.MucOptions)10 Intent (android.content.Intent)9 Element (eu.siacs.conversations.xml.Element)9 PendingIntent (android.app.PendingIntent)8 XmppAxolotlMessage (eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)8 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)8 Uri (android.net.Uri)7 Conversational (eu.siacs.conversations.entities.Conversational)7 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)7 SuppressLint (android.annotation.SuppressLint)6 SpannableString (android.text.SpannableString)6 XmppConnection (eu.siacs.conversations.xmpp.XmppConnection)6 Jid (eu.siacs.conversations.xmpp.jid.Jid)6 ArrayList (java.util.ArrayList)6 Fragment (android.app.Fragment)4