Search in sources :

Example 61 with IConversation

use of com.waz.api.IConversation in project wire-android by wireapp.

the class SendConnectRequestFragment method onConnectUserUpdated.

//////////////////////////////////////////////////////////////////////////////////////////
//
//  IConnectStoreObserver
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onConnectUserUpdated(final User user, final IConnectStore.UserRequester userRequester) {
    if (this.userRequester != userRequester) {
        return;
    }
    imageAssetImageViewProfile.connectImageAsset(user.getPicture());
    displayNameTextView.setText(user.getName());
    userDetailsView.setUser(user);
    connectButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (user == null || getStoreFactory() == null || getStoreFactory().isTornDown()) {
                return;
            }
            User me = getStoreFactory().getProfileStore().getSelfUser();
            String myName = me != null ? me.getName() : "";
            String otherName = user.getName();
            String message = getString(R.string.connect__message, otherName, myName);
            IConversation conversation = getStoreFactory().getConnectStore().connectToNewUser(user, message);
            trackSendConnectRequest(user);
            if (conversation != null) {
                KeyboardUtils.hideKeyboard(getActivity());
                getContainer().onConnectRequestWasSentToUser();
            }
        }
    });
    if (userRequester == IConnectStore.UserRequester.PARTICIPANTS) {
        footerMenu.setRightActionText(getString(R.string.glyph__minus));
    }
    footerMenu.setCallback(new FooterMenuCallback() {

        @Override
        public void onLeftActionClicked() {
            showConnectButtonInsteadOfFooterMenu();
        }

        @Override
        public void onRightActionClicked() {
            if (userRequester == IConnectStore.UserRequester.PARTICIPANTS) {
                getContainer().showRemoveConfirmation(user);
            }
        }
    });
    if (userRequester == IConnectStore.UserRequester.PARTICIPANTS) {
        footerMenu.setVisibility(View.VISIBLE);
        connectButton.setVisibility(View.GONE);
    } else {
        footerMenu.setVisibility(View.GONE);
        connectButton.setVisibility(View.VISIBLE);
    }
}
Also used : User(com.waz.api.User) IConversation(com.waz.api.IConversation) FooterMenuCallback(com.waz.zclient.views.menus.FooterMenuCallback) ImageAssetImageView(com.waz.zclient.views.images.ImageAssetImageView) View(android.view.View) UserDetailsView(com.waz.zclient.ui.views.UserDetailsView) TextView(android.widget.TextView)

Example 62 with IConversation

use of com.waz.api.IConversation in project wire-android by wireapp.

the class ConversationListAdapter method animateSortingOfConversation.

private void animateSortingOfConversation() {
    CoreList<IConversation> archivedConversations = conversationList.getArchivedConversations();
    boolean isArchiveVisible = archivedState == ArchivedState.VISIBLE;
    Map<Integer, View> currentViews = new HashMap<>();
    List<Animator> animators = new ArrayList<>();
    // Cache all displayed views and store the last and first to hack views that leave the screen
    View first = null;
    View last = null;
    for (int i = 0; i < listView.getChildCount(); i++) {
        View view = listView.getChildAt(i);
        if (view instanceof ConversationListRow || view instanceof ConversationListArchivedBorderRow) {
            if (first == null) {
                first = view;
            }
            last = view;
            currentViews.put(view.getId(), view);
        }
    }
    final View firstView = first;
    final View lastView = last;
    // run once through the list of all displayed items
    for (int i = 0; i < listView.getChildCount(); i++) {
        if (listView.getChildAt(i) instanceof ConversationListRow) {
            final ConversationListRow row = (ConversationListRow) listView.getChildAt(i);
            // needs to be called - this view cant be used as a convertView no more
            row.redraw();
            int currPos = row.getId();
            final IConversation conversation = row.getConversation();
            int newPos;
            // it is the inbox
            if (currPos == posOfInboxOld) {
                newPos = currPos;
            } else {
                newPos = conversationList.getConversationIndex(conversation.getId());
                // push one up for the inbox
                if (posOfInbox != CONNECT_REQUEST_INBOX_POSITION_NONE && newPos >= posOfInbox) {
                    newPos++;
                }
            }
            // the item is archived
            if (newPos == -1 && isArchiveVisible) {
                for (int j = 0; j < archivedConversations.size(); j++) {
                    if (ConversationUtils.isConversationEqual(archivedConversations.get(j), conversation)) {
                        newPos = getUnarchivedCount() + 1 + j;
                    }
                }
            }
            if (currPos != newPos) {
                if (currentViews.containsKey(newPos)) {
                    float t = currentViews.get(newPos).getY() - row.getY();
                    animators.add(ObjectAnimator.ofFloat(row, View.TRANSLATION_Y, t));
                } else {
                    // its archive target
                    if (newPos == -1) {
                        ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(row, View.ALPHA, 0);
                        alphaAnimator.setInterpolator(new Quart.EaseOut());
                        alphaAnimator.setDuration(sortingAnimationDuration);
                        alphaAnimator.start();
                        continue;
                    }
                    // this view goes far north - we need to hack a little around it
                    if (currPos > newPos) {
                        float targetY = row.getY();
                        targetY -= first.getY();
                        animators.add(ObjectAnimator.ofFloat(row, View.TRANSLATION_Y, -targetY));
                        animators.add(ObjectAnimator.ofFloat(row, View.ALPHA, 1, 0, 1));
                        new Handler().postDelayed(new Runnable() {

                            @Override
                            public void run() {
                                IConversation changeConversation = getItem(firstView.getId());
                                if (changeConversation != null) {
                                    row.setConversation(changeConversation);
                                }
                            }
                        }, sortingAnimationDuration / HACK_ANIMATION_FACTOR);
                    }
                    // this view goes far south - we need to hack a little around it
                    if (currPos < newPos) {
                        float targetY = row.getY() - last.getY();
                        boolean isOnlyArchive = conversationList.getArchivedConversations().size() == 1 && row.isArchiveTarget();
                        if (isOnlyArchive) {
                            targetY -= row.getMeasuredHeight();
                        }
                        animators.add(ObjectAnimator.ofFloat(row, View.TRANSLATION_Y, -targetY));
                        animators.add(ObjectAnimator.ofFloat(row, View.ALPHA, 1, 1, 1, 0, 1));
                        new Handler().postDelayed(new Runnable() {

                            @Override
                            public void run() {
                                if (conversation != null && lastView != null && row != null) {
                                    IConversation changeConversation = getItem(lastView.getId());
                                    if (changeConversation != null) {
                                        row.setConversation(changeConversation);
                                    }
                                }
                            }
                        }, sortingAnimationDuration / HACK_ANIMATION_FACTOR);
                    }
                }
            }
        } else if (listView.getChildAt(i) instanceof ConversationListArchivedBorderRow && isArchiveVisible) {
            View row = listView.getChildAt(i);
            int newPos = getUnarchivedCount();
            if (currentViews.containsKey(newPos)) {
                float t = currentViews.get(newPos).getY() - row.getY();
                animators.add(ObjectAnimator.ofFloat(row, View.TRANSLATION_Y, t));
            } else {
                animators.add(ObjectAnimator.ofFloat(row, View.TRANSLATION_Y, ViewUtils.getOrientationIndependentDisplayHeight(listView.getContext())));
            }
        }
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(sortingAnimationDuration);
    animatorSet.playTogether(animators);
    animatorSet.setInterpolator(new Expo.EaseOut());
    animatorSet.setStartDelay(translationDelay);
    animatorSet.start();
    cleanUpSorting();
}
Also used : HashMap(java.util.HashMap) ObjectAnimator(android.animation.ObjectAnimator) ArrayList(java.util.ArrayList) ConversationListRow(com.waz.zclient.pages.main.conversationlist.views.row.ConversationListRow) Handler(android.os.Handler) IConversation(com.waz.api.IConversation) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) SwipeListView(com.waz.zclient.pages.main.conversationlist.views.listview.SwipeListView) AbsListView(android.widget.AbsListView) RightIndicatorView(com.waz.zclient.pages.main.conversationlist.views.row.RightIndicatorView) ListView(android.widget.ListView) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) Quart(com.waz.zclient.ui.animation.interpolators.penner.Quart) Expo(com.waz.zclient.ui.animation.interpolators.penner.Expo) ConversationListArchivedBorderRow(com.waz.zclient.pages.main.conversationlist.views.row.ConversationListArchivedBorderRow)

Example 63 with IConversation

use of com.waz.api.IConversation in project wire-android by wireapp.

the class ConversationListAdapter method getView.

@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
    if (archivedState == ArchivedState.GONE && position == getCount() - 1) {
        return createFakeView(parent.getContext());
    }
    listView = (ListView) parent;
    if (getItemViewType(position) == ARCHIVE_BORDER_ROW) {
        return getArchiveBorderRow(parent.getContext(), position);
    }
    ConversationListRow conversationListRowItem;
    if (convertView == null || !(convertView instanceof ConversationListRow)) {
        conversationListRowItem = new ConversationListRow(parent.getContext());
        conversationListRowItem.setStreamMediaPlayerController(streamMediaPlayerController);
        conversationListRowItem.setConversationActionCallback(conversationActionCallback);
        conversationListRowItem.setNetworkStore(networkStore);
    } else {
        conversationListRowItem = (ConversationListRow) convertView;
        // needs redraw due to animation changes
        if (conversationListRowItem.needsRedraw()) {
            conversationListRowItem = new ConversationListRow(parent.getContext());
            conversationListRowItem.setStreamMediaPlayerController(streamMediaPlayerController);
            conversationListRowItem.setConversationActionCallback(conversationActionCallback);
            conversationListRowItem.setNetworkStore(networkStore);
        }
    }
    conversationListRowItem.setAlpha(1f);
    conversationListRowItem.setMaxAlpha(maxAlpha);
    conversationListRowItem.setId(position);
    conversationListRowItem.setSwipeable(mode == ConversationListFragment.Mode.NORMAL);
    conversationListRowItem.showIndicatorView(mode == ConversationListFragment.Mode.NORMAL);
    // integrate model
    final IConversation conversation = getItem(position);
    if (isArchived(position)) {
        conversationListRowItem.setBackgroundColor(parent.getResources().getColor(R.color.list_archive_box__background_color));
    } else {
        conversationListRowItem.setBackgroundColor(Color.TRANSPARENT);
    }
    conversationListRowItem.setAccentColor(accentColor);
    conversationListRowItem.setConversation(conversation);
    conversationListRowItem.setConversationCallback(conversationCallback);
    conversationListRowItem.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ((ListView) parent).performItemClick(parent, position, position);
        }
    });
    final ConversationListRow anchorView = conversationListRowItem;
    conversationListRowItem.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            if (conversationCallback == null) {
                return false;
            }
            conversationCallback.onConversationListRowLongClicked(conversation, anchorView);
            return true;
        }
    });
    setListRowPaddingTopAndBottom(conversationListRowItem, position);
    return conversationListRowItem;
}
Also used : ConversationListRow(com.waz.zclient.pages.main.conversationlist.views.row.ConversationListRow) IConversation(com.waz.api.IConversation) View(android.view.View) SwipeListView(com.waz.zclient.pages.main.conversationlist.views.listview.SwipeListView) AbsListView(android.widget.AbsListView) RightIndicatorView(com.waz.zclient.pages.main.conversationlist.views.row.RightIndicatorView) ListView(android.widget.ListView)

Example 64 with IConversation

use of com.waz.api.IConversation in project wire-android by wireapp.

the class ConversationFragment method onEphemeralButtonDoubleClicked.

@Override
public void onEphemeralButtonDoubleClicked(EphemeralExpiration currentEphemeralExpiration) {
    EphemeralExpiration lastExpiraton = EphemeralExpiration.getForMillis(getControllerFactory().getUserPreferencesController().getLastEphemeralValue());
    if (lastExpiraton.equals(EphemeralExpiration.NONE)) {
        return;
    }
    if (currentEphemeralExpiration.equals(EphemeralExpiration.NONE)) {
        onEphemeralExpirationSelected(lastExpiraton, true);
        IConversation conversation = getStoreFactory().getConversationStore().getCurrentConversation();
        ((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.ephemeral(conversation, true));
    } else {
        onEphemeralExpirationSelected(EphemeralExpiration.NONE, true);
    }
}
Also used : GlobalTrackingController(com.waz.zclient.tracking.GlobalTrackingController) EphemeralExpiration(com.waz.api.EphemeralExpiration) IConversation(com.waz.api.IConversation)

Example 65 with IConversation

use of com.waz.api.IConversation in project wire-android by wireapp.

the class ConversationManagerFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    getStoreFactory().getConversationStore().addConversationStoreObserver(this);
    getStoreFactory().getParticipantsStore().addParticipantsStoreObserver(this);
    getControllerFactory().getConversationScreenController().addConversationControllerObservers(this);
    getControllerFactory().getDrawingController().addDrawingObserver(this);
    getControllerFactory().getCameraController().addCameraActionObserver(this);
    getControllerFactory().getPickUserController().addPickUserScreenControllerObserver(this);
    IConversation currentConversation = getStoreFactory().getConversationStore().getCurrentConversation();
    if (currentConversation != null) {
        getStoreFactory().getParticipantsStore().setCurrentConversation(currentConversation);
    }
    getControllerFactory().getLocationController().addObserver(this);
    getCollectionController().addObserver(this);
}
Also used : IConversation(com.waz.api.IConversation)

Aggregations

IConversation (com.waz.api.IConversation)69 FragmentTest (com.waz.zclient.testutils.FragmentTest)25 Test (org.junit.Test)25 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)14 View (android.view.View)10 User (com.waz.api.User)9 ArrayList (java.util.ArrayList)6 SuppressLint (android.annotation.SuppressLint)5 Intent (android.content.Intent)4 Handler (android.os.Handler)4 AbsListView (android.widget.AbsListView)4 CreatedGroupConversationEvent (com.waz.zclient.controllers.tracking.events.group.CreatedGroupConversationEvent)4 FooterMenuCallback (com.waz.zclient.views.menus.FooterMenuCallback)4 Instrumentation (android.app.Instrumentation)3 TextView (android.widget.TextView)3 BaseScalaActivity (com.waz.zclient.BaseScalaActivity)3 AddedMemberToGroupEvent (com.waz.zclient.controllers.tracking.events.group.AddedMemberToGroupEvent)3 ExceptionHandler (net.hockeyapp.android.ExceptionHandler)3 Animator (android.animation.Animator)2 AnimatorSet (android.animation.AnimatorSet)2