Search in sources :

Example 1 with SharingController

use of com.waz.zclient.controllers.SharingController in project wire-android by wireapp.

the class MainActivity method onUserLoggedInAndVerified.

private void onUserLoggedInAndVerified(Self self) {
    getStoreFactory().getProfileStore().setUser(self);
    getControllerFactory().getAccentColorController().setColor(AccentColorChangeRequester.LOGIN, self.getAccent().getColor());
    getControllerFactory().getUsernameController().setUser(self);
    final Intent intent = getIntent();
    if (IntentUtils.isLaunchFromNotificationIntent(intent)) {
        final IConversation conversation = getStoreFactory().getConversationStore().getConversation(IntentUtils.getLaunchConversationId(intent));
        final boolean startCallNotificationIntent = IntentUtils.isStartCallNotificationIntent(intent);
        Timber.i("Start from notification with call=%b", startCallNotificationIntent);
        IntentUtils.clearLaunchIntentExtra(intent);
        if (conversation != null) {
            // Only want to swipe over when app has loaded
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    getStoreFactory().getConversationStore().setCurrentConversation(conversation, ConversationChangeRequester.NOTIFICATION);
                    if (startCallNotificationIntent) {
                        startCall(false);
                    }
                }
            }, LAUNCH_CONVERSATION_CHANGE_DELAY);
        }
    } else if (IntentUtils.isLaunchFromSharingIntent(intent)) {
        List<String> targetConversations = IntentUtils.getLaunchConversationIds(intent);
        String sharedText = IntentUtils.getLaunchConversationSharedText(intent);
        List<Uri> sharedFileUris = IntentUtils.getLaunchConversationSharedFiles(intent);
        EphemeralExpiration expiration = IntentUtils.getEphemeralExpiration(intent);
        SharingController sharingController = injectJava(SharingController.class);
        if (targetConversations != null) {
            if (targetConversations.size() == 1 && targetConversations.get(0) != null) {
                String conversationId = targetConversations.get(0);
                final IConversation conversation = getStoreFactory().getConversationStore().getConversation(conversationId);
                if (!TextUtils.isEmpty(sharedText)) {
                    getControllerFactory().getSharingController().setSharedContentType(SharedContentType.TEXT);
                } else {
                    getControllerFactory().getSharingController().setSharedContentType(SharedContentType.FILE);
                }
                getControllerFactory().getSharingController().setSharedText(sharedText);
                getControllerFactory().getSharingController().setSharedUris(sharedFileUris);
                getControllerFactory().getSharingController().setSharingConversationId(conversationId);
                if (conversation != null) {
                    conversation.setEphemeralExpiration(expiration);
                }
                // Only want to swipe over when app has loaded
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        getStoreFactory().getConversationStore().setCurrentConversation(conversation, ConversationChangeRequester.SHARING);
                    }
                }, LAUNCH_CONVERSATION_CHANGE_DELAY);
            } else {
                sharingController.sendContent(sharedText, sharedFileUris, targetConversations, expiration, this);
            }
        }
        IntentUtils.clearLaunchIntentExtra(intent);
    }
    setIntent(intent);
    openMainPage();
}
Also used : Handler(android.os.Handler) ExceptionHandler(net.hockeyapp.android.ExceptionHandler) EphemeralExpiration(com.waz.api.EphemeralExpiration) Intent(android.content.Intent) IConversation(com.waz.api.IConversation) List(java.util.List) ArrayList(java.util.ArrayList) ConversationsList(com.waz.api.ConversationsList) SharingController(com.waz.zclient.controllers.SharingController)

Aggregations

Intent (android.content.Intent)1 Handler (android.os.Handler)1 ConversationsList (com.waz.api.ConversationsList)1 EphemeralExpiration (com.waz.api.EphemeralExpiration)1 IConversation (com.waz.api.IConversation)1 SharingController (com.waz.zclient.controllers.SharingController)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExceptionHandler (net.hockeyapp.android.ExceptionHandler)1