use of com.waz.api.IConversation in project wire-android by wireapp.
the class ConversationListFragment method onConversationListUpdated.
//////////////////////////////////////////////////////////////////////////////////////////
//
// Notifications
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onConversationListUpdated(@NonNull final ConversationsList conversationsList) {
ConversationsList conversations = mode == Mode.SHARING ? conversationsList.getEstablishedConversations() : conversationsList;
conversationsListAdapter.setConversationList(conversations);
// We post this to notify that we are ready after the items are instantiated
swipeListView.post(new Runnable() {
@Override
public void run() {
if (getContainer() == null) {
return;
}
}
});
if (pendingCurrentConversation != null) {
final int pos = getStoreFactory().getConversationStore().getPositionInList(pendingCurrentConversation);
if (pos > 0) {
// set selection after updating the conversationlist
new Handler().post(new Runnable() {
@SuppressLint("NewApi")
@Override
public void run() {
int selectionPos = pos - LIST_VIEW_POSITION_OFFSET < 0 ? 0 : pos - LIST_VIEW_POSITION_OFFSET;
swipeListView.setSelectionFromTop(selectionPos, 0);
pendingCurrentConversation = null;
}
});
}
}
// sync state
onConversationSyncingStateHasChanged(getStoreFactory().getConversationStore().getConversationSyncingState());
CoreList<IConversation> archivedConversations = conversationsList.getArchivedConversations();
if (archivedConversations != null && archivedConversations.size() > 0) {
archiveBox.setAlpha(1f);
} else {
archiveBox.setAlpha(0f);
}
if (conversationsList.isReady()) {
maybeShowNoContactsLabel(conversationsList.size() == 0);
}
}
use of com.waz.api.IConversation in project wire-android by wireapp.
the class ConversationListFragment method onCurrentConversationHasChanged.
@Override
public void onCurrentConversationHasChanged(IConversation fromConversation, IConversation toConversation, ConversationChangeRequester conversationChangerSender) {
if (toConversation == null || conversationsListAdapter == null) {
return;
}
if (fromConversation != null && fromConversation.getId().equals(toConversation.getId())) {
return;
}
switch(conversationChangerSender) {
case CONVERSATION_LIST_SELECT_TO_SHARE:
case CONVERSATION_LIST:
break;
default:
if (toConversation.isArchived()) {
pendingCurrentConversation = toConversation;
} else {
// Don't autoscroll to selected conversation if list is just loaded
if (conversationChangerSender == ConversationChangeRequester.FIRST_LOAD) {
break;
} else if (conversationChangerSender == ConversationChangeRequester.UPDATER && !scrollToConversation) {
break;
}
// set selection after updating the conversationlist
final IConversation finalToConversation = toConversation;
new Handler().post(new Runnable() {
@Override
public void run() {
if (swipeListView == null || getStoreFactory().isTornDown()) {
return;
}
int pos = getStoreFactory().getConversationStore().getPositionInList(finalToConversation);
int selectionPos = pos - LIST_VIEW_POSITION_OFFSET < 0 ? 0 : pos - LIST_VIEW_POSITION_OFFSET;
swipeListView.setSelectionFromTop(selectionPos, 0);
}
});
}
break;
}
}
use of com.waz.api.IConversation in project wire-android by wireapp.
the class ConversationListManagerFragment method onSelectedUsers.
//////////////////////////////////////////////////////////////////////////////////////////
//
// PickUserFragment.Container
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onSelectedUsers(List<User> users, ConversationChangeRequester requester) {
// TODO https://wearezeta.atlassian.net/browse/AN-3730
getControllerFactory().getPickUserController().hidePickUser(getCurrentPickerDestination(), true);
if (users.size() == 1) {
User user = users.get(0);
IConversation conversation = user.getConversation();
if (conversation != null) {
getStoreFactory().getConversationStore().setCurrentConversation(conversation, requester);
}
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedConversationEvent(ConversationType.ONE_TO_ONE_CONVERSATION.name()));
} else {
getStoreFactory().getConversationStore().createGroupConversation(users, requester);
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new CreatedGroupConversationEvent(false, (users.size() + 1)));
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedConversationEvent(ConversationType.GROUP_CONVERSATION.name()));
}
}
use of com.waz.api.IConversation in project wire-android by wireapp.
the class ConversationFragment method onShowMediaBar.
//////////////////////////////////////////////////////////////////////////////////////////
//
// StreamMediaBar
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onShowMediaBar(String conversationId) {
IConversation currentConversation = getStoreFactory().getConversationStore().getCurrentConversation();
if (currentConversation == null || !conversationId.equals(currentConversation.getId())) {
return;
}
if (streamMediaBarFragment != null) {
streamMediaBarFragment.show();
return;
}
try {
FragmentManager fragmentManager = getChildFragmentManager();
streamMediaBarFragment = StreamMediaPlayerBarFragment.newInstance();
fragmentManager.beginTransaction().setCustomAnimations(R.anim.fade_in, R.anim.fade_out, R.anim.fade_in, R.anim.fade_out).add(R.id.fl__conversation__mediabar_container, streamMediaBarFragment, StreamMediaPlayerBarFragment.TAG).commit();
} catch (IllegalStateException e) {
Timber.e(e, "onShowMediaBar failed");
}
}
use of com.waz.api.IConversation in project wire-android by wireapp.
the class ConversationFragment method onCursorButtonClicked.
@SuppressLint("NewApi")
@Override
public void onCursorButtonClicked(CursorMenuItem cursorMenuItem) {
final IConversation conversation = getStoreFactory().getConversationStore().getCurrentConversation();
switch(cursorMenuItem) {
case AUDIO_MESSAGE:
if (PermissionUtils.hasSelfPermissions(getActivity(), AUDIO_PERMISSION)) {
openExtendedCursor(ExtendedCursorContainer.Type.VOICE_FILTER_RECORDING);
} else {
ActivityCompat.requestPermissions(getActivity(), AUDIO_PERMISSION, AUDIO_FILTER_PERMISSION_REQUEST_ID);
}
break;
case CAMERA:
if (LayoutSpec.isTablet(getContext())) {
KeyboardUtils.closeKeyboardIfShown(getActivity());
getControllerFactory().getCameraController().openCamera(CameraContext.MESSAGE);
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.PHOTO, conversation));
} else {
if (PermissionUtils.hasSelfPermissions(getContext(), EXTENDED_CURSOR_PERMISSIONS)) {
openExtendedCursor(ExtendedCursorContainer.Type.IMAGES);
} else {
ActivityCompat.requestPermissions(getActivity(), EXTENDED_CURSOR_PERMISSIONS, OPEN_EXTENDED_CURSOR_IMAGES);
}
}
break;
case PING:
getStoreFactory().getNetworkStore().doIfHasInternetOrNotifyUser(new DefaultNetworkAction() {
@Override
public void execute(NetworkMode networkMode) {
getStoreFactory().getConversationStore().knockCurrentConversation();
SoundController ctrl = inject(SoundController.class);
if (ctrl != null) {
ctrl.playPingFromMe();
}
}
});
TrackingUtils.onSentPingMessage(((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class), getStoreFactory().getConversationStore().getCurrentConversation());
break;
case SKETCH:
getControllerFactory().getDrawingController().showDrawing(null, IDrawingController.DrawingDestination.SKETCH_BUTTON);
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.SKETCH, conversation));
break;
case FILE:
assetIntentsManager.openFileSharing();
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.FILE, conversation));
break;
case VIDEO_MESSAGE:
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.VIDEO_MESSAGE, conversation));
isVideoMessageButtonClicked = true;
getCameraController().releaseCamera(new Callback<Void>() {
@Override
public void callback(Void v) {
if (!isVideoMessageButtonClicked || assetIntentsManager == null) {
return;
}
isVideoMessageButtonClicked = false;
assetIntentsManager.maybeCaptureVideo(getActivity(), AssetIntentsManager.IntentType.VIDEO_CURSOR_BUTTON);
}
});
break;
case LOCATION:
if (ConnectionResult.SUCCESS == GooglePlayServicesUtil.isGooglePlayServicesAvailable(getContext())) {
KeyboardUtils.hideKeyboard(getActivity());
getControllerFactory().getLocationController().showShareLocation();
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.LOCATION, conversation));
} else {
Toast.makeText(getContext(), R.string.location_sharing__missing_play_services, Toast.LENGTH_LONG).show();
}
break;
case MORE:
case LESS:
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedMoreActionsEvent(getConversationTypeString()));
break;
case GIF:
getControllerFactory().getGiphyController().handleInput(cursorLayout.getText());
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(OpenedMediaActionEvent.cursorAction(OpenedMediaAction.GIPHY, conversation));
break;
}
}
Aggregations