Search in sources :

Example 1 with Conversation

use of org.thoughtcrime.securesms.conversationlist.model.Conversation in project Signal-Android by WhisperSystems.

the class ConversationListDataSource method load.

@Override
@NonNull
public List<Conversation> load(int start, int length, @NonNull CancellationSignal cancellationSignal) {
    Stopwatch stopwatch = new Stopwatch("load(" + start + ", " + length + "), " + getClass().getSimpleName());
    List<Conversation> conversations = new ArrayList<>(length);
    List<Recipient> recipients = new LinkedList<>();
    try (ConversationReader reader = new ConversationReader(getCursor(start, length))) {
        ThreadRecord record;
        while ((record = reader.getNext()) != null && !cancellationSignal.isCanceled()) {
            conversations.add(new Conversation(record));
            recipients.add(record.getRecipient());
        }
    }
    stopwatch.split("cursor");
    ApplicationDependencies.getRecipientCache().addToCache(recipients);
    stopwatch.split("cache-recipients");
    stopwatch.stop(TAG);
    return conversations;
}
Also used : ConversationReader(org.thoughtcrime.securesms.conversationlist.model.ConversationReader) Stopwatch(org.thoughtcrime.securesms.util.Stopwatch) ArrayList(java.util.ArrayList) ThreadRecord(org.thoughtcrime.securesms.database.model.ThreadRecord) Conversation(org.thoughtcrime.securesms.conversationlist.model.Conversation) Recipient(org.thoughtcrime.securesms.recipients.Recipient) LinkedList(java.util.LinkedList) NonNull(androidx.annotation.NonNull)

Example 2 with Conversation

use of org.thoughtcrime.securesms.conversationlist.model.Conversation in project Signal-Android by WhisperSystems.

the class ConversationListFragment method updateMultiSelectState.

private void updateMultiSelectState() {
    int count = viewModel.currentSelectedConversations().size();
    boolean hasUnread = Stream.of(viewModel.currentSelectedConversations()).anyMatch(conversation -> !conversation.getThreadRecord().isRead());
    boolean hasUnpinned = Stream.of(viewModel.currentSelectedConversations()).anyMatch(conversation -> !conversation.getThreadRecord().isPinned());
    boolean hasUnmuted = Stream.of(viewModel.currentSelectedConversations()).anyMatch(conversation -> !conversation.getThreadRecord().getRecipient().live().get().isMuted());
    boolean canPin = viewModel.getPinnedCount() < MAXIMUM_PINNED_CONVERSATIONS;
    if (actionMode != null) {
        actionMode.setTitle(requireContext().getResources().getQuantityString(R.plurals.ConversationListFragment_s_selected, count, count));
    }
    List<ActionItem> items = new ArrayList<>();
    Set<Long> selectionIds = viewModel.currentSelectedConversations().stream().map(conversation -> conversation.getThreadRecord().getThreadId()).collect(Collectors.toSet());
    if (hasUnread) {
        items.add(new ActionItem(R.drawable.ic_read_24, getResources().getQuantityString(R.plurals.ConversationListFragment_read_plural, count), () -> handleMarkAsRead(selectionIds)));
    } else {
        items.add(new ActionItem(R.drawable.ic_unread_24, getResources().getQuantityString(R.plurals.ConversationListFragment_unread_plural, count), () -> handleMarkAsUnread(selectionIds)));
    }
    if (!isArchived() && hasUnpinned && canPin) {
        items.add(new ActionItem(R.drawable.ic_pin_24, getResources().getQuantityString(R.plurals.ConversationListFragment_pin_plural, count), () -> handlePin(viewModel.currentSelectedConversations())));
    } else if (!isArchived() && !hasUnpinned) {
        items.add(new ActionItem(R.drawable.ic_unpin_24, getResources().getQuantityString(R.plurals.ConversationListFragment_unpin_plural, count), () -> handleUnpin(selectionIds)));
    }
    if (isArchived()) {
        items.add(new ActionItem(R.drawable.ic_unarchive_24, getResources().getQuantityString(R.plurals.ConversationListFragment_unarchive_plural, count), () -> handleArchive(selectionIds, true)));
    } else {
        items.add(new ActionItem(R.drawable.ic_archive_24, getResources().getQuantityString(R.plurals.ConversationListFragment_archive_plural, count), () -> handleArchive(selectionIds, true)));
    }
    items.add(new ActionItem(R.drawable.ic_delete_24, getResources().getQuantityString(R.plurals.ConversationListFragment_delete_plural, count), () -> handleDelete(selectionIds)));
    if (hasUnmuted) {
        items.add(new ActionItem(R.drawable.ic_mute_24, getResources().getQuantityString(R.plurals.ConversationListFragment_mute_plural, count), () -> handleMute(viewModel.currentSelectedConversations())));
    } else {
        items.add(new ActionItem(R.drawable.ic_unmute_24, getResources().getQuantityString(R.plurals.ConversationListFragment_unmute_plural, count), () -> handleUnmute(viewModel.currentSelectedConversations())));
    }
    items.add(new ActionItem(R.drawable.ic_select_24, getString(R.string.ConversationListFragment_select_all), viewModel::onSelectAllClick));
    bottomActionBar.setItems(items);
}
Also used : NewConversationActivity(org.thoughtcrime.securesms.NewConversationActivity) Bundle(android.os.Bundle) PulsingFloatingActionButton(org.thoughtcrime.securesms.components.registration.PulsingFloatingActionButton) RecaptchaProofBottomSheetFragment(org.thoughtcrime.securesms.ratelimit.RecaptchaProofBottomSheetFragment) NonNull(androidx.annotation.NonNull) SimpleProgressDialog(org.thoughtcrime.securesms.util.views.SimpleProgressDialog) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) ColorInt(androidx.annotation.ColorInt) Manifest(android.Manifest) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) TooltipCompat(androidx.appcompat.widget.TooltipCompat) SnapToTopDataObserver(org.thoughtcrime.securesms.util.SnapToTopDataObserver) Fragment(androidx.fragment.app.Fragment) Badge(org.thoughtcrime.securesms.badges.models.Badge) Canvas(android.graphics.Canvas) SimpleColorFilter(com.airbnb.lottie.SimpleColorFilter) ThreadRecord(org.thoughtcrime.securesms.database.model.ThreadRecord) Megaphone(org.thoughtcrime.securesms.megaphone.Megaphone) ContextCompat(androidx.core.content.ContextCompat) ServiceUtil(org.thoughtcrime.securesms.util.ServiceUtil) ViewCompat(androidx.core.view.ViewCompat) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Set(java.util.Set) Megaphones(org.thoughtcrime.securesms.megaphone.Megaphones) ThreadDatabase(org.thoughtcrime.securesms.database.ThreadDatabase) DimensionUnit(org.signal.core.util.DimensionUnit) IdRes(androidx.annotation.IdRes) Nullable(androidx.annotation.Nullable) SignalContextMenu(org.thoughtcrime.securesms.components.menu.SignalContextMenu) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) InsightsLauncher(org.thoughtcrime.securesms.insights.InsightsLauncher) UnexpectedSubscriptionCancellation(org.thoughtcrime.securesms.components.settings.app.subscription.errors.UnexpectedSubscriptionCancellation) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) UnreadPayments(org.thoughtcrime.securesms.conversationlist.model.UnreadPayments) StickyHeaderDecoration(org.thoughtcrime.securesms.util.StickyHeaderDecoration) DialogFragment(androidx.fragment.app.DialogFragment) ServiceOutageReminder(org.thoughtcrime.securesms.components.reminder.ServiceOutageReminder) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) Stream(com.annimon.stream.Stream) Util(org.thoughtcrime.securesms.util.Util) AppCompatResources(androidx.appcompat.content.res.AppCompatResources) CantProcessSubscriptionPaymentBottomSheetDialogFragment(org.thoughtcrime.securesms.badges.self.expired.CantProcessSubscriptionPaymentBottomSheetDialogFragment) WorkerThread(androidx.annotation.WorkerThread) PaymentDetailsParcelable(org.thoughtcrime.securesms.payments.preferences.details.PaymentDetailsParcelable) MainFragment(org.thoughtcrime.securesms.MainFragment) ArrayList(java.util.ArrayList) ActionMenuView(androidx.appcompat.widget.ActionMenuView) ReminderView(org.thoughtcrime.securesms.components.reminder.ReminderView) KeyCachingService(org.thoughtcrime.securesms.service.KeyCachingService) WebSocketConnectionState(org.whispersystems.signalservice.api.websocket.WebSocketConnectionState) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) SignalProxyUtil(org.thoughtcrime.securesms.util.SignalProxyUtil) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) RatingManager(org.thoughtcrime.securesms.components.RatingManager) AppStartup(org.thoughtcrime.securesms.util.AppStartup) LinkedHashSet(java.util.LinkedHashSet) MainNavigator(org.thoughtcrime.securesms.MainNavigator) ViewModelProvider(androidx.lifecycle.ViewModelProvider) ProgressDialog(android.app.ProgressDialog) Permissions(org.thoughtcrime.securesms.permissions.Permissions) UnreadPaymentsView(org.thoughtcrime.securesms.components.UnreadPaymentsView) PushRegistrationReminder(org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder) Optional(org.whispersystems.libsignal.util.guava.Optional) Reminder(org.thoughtcrime.securesms.components.reminder.Reminder) BottomSheetUtil(org.thoughtcrime.securesms.util.BottomSheetUtil) Stopwatch(org.thoughtcrime.securesms.util.Stopwatch) SnackbarAsyncTask(org.thoughtcrime.securesms.util.task.SnackbarAsyncTask) SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) SignalBottomActionBar(org.thoughtcrime.securesms.components.menu.SignalBottomActionBar) ArgbEvaluatorCompat(com.google.android.material.animation.ArgbEvaluatorCompat) MessageSender(org.thoughtcrime.securesms.sms.MessageSender) NotificationProfileSelectionFragment(org.thoughtcrime.securesms.components.settings.app.notifications.manual.NotificationProfileSelectionFragment) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) PaymentDetailsFragmentArgs(org.thoughtcrime.securesms.payments.preferences.details.PaymentDetailsFragmentArgs) ConversationFragment(org.thoughtcrime.securesms.conversation.ConversationFragment) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) DrawableRes(androidx.annotation.DrawableRes) R(org.thoughtcrime.securesms.R) PlayStoreUtil(org.thoughtcrime.securesms.util.PlayStoreUtil) StorageSyncHelper(org.thoughtcrime.securesms.storage.StorageSyncHelper) Locale(java.util.Locale) PluralsRes(androidx.annotation.PluralsRes) NotificationProfiles(org.thoughtcrime.securesms.notifications.profiles.NotificationProfiles) View(android.view.View) MegaphoneViewBuilder(org.thoughtcrime.securesms.megaphone.MegaphoneViewBuilder) Recipient(org.thoughtcrime.securesms.recipients.Recipient) RecyclerView(androidx.recyclerview.widget.RecyclerView) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) SearchToolbar(org.thoughtcrime.securesms.components.SearchToolbar) Conversation(org.thoughtcrime.securesms.conversationlist.model.Conversation) AppSettingsActivity(org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity) ExpiredBuildReminder(org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder) SearchResult(org.thoughtcrime.securesms.search.SearchResult) AsyncTask(android.os.AsyncTask) VoiceNotePlayerView(org.thoughtcrime.securesms.components.voice.VoiceNotePlayerView) Collection(java.util.Collection) UUID(java.util.UUID) ThreadMode(org.greenrobot.eventbus.ThreadMode) AvatarUtil(org.thoughtcrime.securesms.util.AvatarUtil) ExpiredBadgeBottomSheetDialogFragment(org.thoughtcrime.securesms.badges.self.expired.ExpiredBadgeBottomSheetDialogFragment) NotificationProfile(org.thoughtcrime.securesms.notifications.profiles.NotificationProfile) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) CreateKbsPinActivity(org.thoughtcrime.securesms.lock.v2.CreateKbsPinActivity) VoiceNoteMediaControllerOwner(org.thoughtcrime.securesms.components.voice.VoiceNoteMediaControllerOwner) Objects(java.util.Objects) Log(org.signal.core.util.logging.Log) List(java.util.List) TextView(android.widget.TextView) MarkReadReceiver(org.thoughtcrime.securesms.notifications.MarkReadReceiver) MessageResult(org.thoughtcrime.securesms.search.MessageResult) Toolbar(androidx.appcompat.widget.Toolbar) Snackbar(com.google.android.material.snackbar.Snackbar) GlideApp(org.thoughtcrime.securesms.mms.GlideApp) DozeReminder(org.thoughtcrime.securesms.components.reminder.DozeReminder) MarkedMessageInfo(org.thoughtcrime.securesms.database.MessageDatabase.MarkedMessageInfo) Context(android.content.Context) TopToastPopup(org.thoughtcrime.securesms.util.TopToastPopup) RESULT_OK(android.app.Activity.RESULT_OK) SignalLocalMetrics(org.thoughtcrime.securesms.util.SignalLocalMetrics) Intent(android.content.Intent) AppForegroundObserver(org.thoughtcrime.securesms.util.AppForegroundObserver) TypedArray(android.content.res.TypedArray) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) HashSet(java.util.HashSet) TooltipPopup(org.thoughtcrime.securesms.components.TooltipPopup) SuppressLint(android.annotation.SuppressLint) ActionItem(org.thoughtcrime.securesms.components.menu.ActionItem) OutdatedBuildReminder(org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder) POSITION_BELOW(org.thoughtcrime.securesms.components.TooltipPopup.POSITION_BELOW) EventBus(org.greenrobot.eventbus.EventBus) Build(android.os.Build) WeakReference(java.lang.ref.WeakReference) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) MegaphoneActionController(org.thoughtcrime.securesms.megaphone.MegaphoneActionController) Stub(org.thoughtcrime.securesms.util.views.Stub) LayoutInflater(android.view.LayoutInflater) MediaSelectionActivity(org.thoughtcrime.securesms.mediasend.v2.MediaSelectionActivity) PaymentsActivity(org.thoughtcrime.securesms.payments.preferences.PaymentsActivity) ActionMode(androidx.appcompat.view.ActionMode) WindowUtil(org.thoughtcrime.securesms.util.WindowUtil) Color(android.graphics.Color) ServiceOutageDetectionJob(org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob) Subscribe(org.greenrobot.eventbus.Subscribe) BadgeImageView(org.thoughtcrime.securesms.badges.BadgeImageView) ReminderUpdateEvent(org.thoughtcrime.securesms.events.ReminderUpdateEvent) MuteDialog(org.thoughtcrime.securesms.MuteDialog) Activity(android.app.Activity) Collections(java.util.Collections) Resources(android.content.res.Resources) UnauthorizedReminder(org.thoughtcrime.securesms.components.reminder.UnauthorizedReminder) ActionItem(org.thoughtcrime.securesms.components.menu.ActionItem) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint)

Example 3 with Conversation

use of org.thoughtcrime.securesms.conversationlist.model.Conversation in project Signal-Android by WhisperSystems.

the class ConversationListFragment method handlePin.

private void handlePin(@NonNull Collection<Conversation> conversations) {
    final Set<Long> toPin = new LinkedHashSet<>(Stream.of(conversations).filterNot(conversation -> conversation.getThreadRecord().isPinned()).map(conversation -> conversation.getThreadRecord().getThreadId()).toList());
    if (toPin.size() + viewModel.getPinnedCount() > MAXIMUM_PINNED_CONVERSATIONS) {
        Snackbar.make(fab, getString(R.string.conversation_list__you_can_only_pin_up_to_d_chats, MAXIMUM_PINNED_CONVERSATIONS), Snackbar.LENGTH_LONG).setTextColor(Color.WHITE).show();
        endActionModeIfActive();
        return;
    }
    SimpleTask.run(SignalExecutors.BOUNDED, () -> {
        ThreadDatabase db = SignalDatabase.threads();
        db.pinConversations(toPin);
        return null;
    }, unused -> {
        endActionModeIfActive();
    });
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NewConversationActivity(org.thoughtcrime.securesms.NewConversationActivity) Bundle(android.os.Bundle) PulsingFloatingActionButton(org.thoughtcrime.securesms.components.registration.PulsingFloatingActionButton) RecaptchaProofBottomSheetFragment(org.thoughtcrime.securesms.ratelimit.RecaptchaProofBottomSheetFragment) NonNull(androidx.annotation.NonNull) SimpleProgressDialog(org.thoughtcrime.securesms.util.views.SimpleProgressDialog) Uri(android.net.Uri) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) ColorInt(androidx.annotation.ColorInt) Manifest(android.Manifest) RecipientId(org.thoughtcrime.securesms.recipients.RecipientId) TooltipCompat(androidx.appcompat.widget.TooltipCompat) SnapToTopDataObserver(org.thoughtcrime.securesms.util.SnapToTopDataObserver) Fragment(androidx.fragment.app.Fragment) Badge(org.thoughtcrime.securesms.badges.models.Badge) Canvas(android.graphics.Canvas) SimpleColorFilter(com.airbnb.lottie.SimpleColorFilter) ThreadRecord(org.thoughtcrime.securesms.database.model.ThreadRecord) Megaphone(org.thoughtcrime.securesms.megaphone.Megaphone) ContextCompat(androidx.core.content.ContextCompat) ServiceUtil(org.thoughtcrime.securesms.util.ServiceUtil) ViewCompat(androidx.core.view.ViewCompat) ApplicationDependencies(org.thoughtcrime.securesms.dependencies.ApplicationDependencies) Set(java.util.Set) Megaphones(org.thoughtcrime.securesms.megaphone.Megaphones) ThreadDatabase(org.thoughtcrime.securesms.database.ThreadDatabase) DimensionUnit(org.signal.core.util.DimensionUnit) IdRes(androidx.annotation.IdRes) Nullable(androidx.annotation.Nullable) SignalContextMenu(org.thoughtcrime.securesms.components.menu.SignalContextMenu) ConstraintLayout(androidx.constraintlayout.widget.ConstraintLayout) InsightsLauncher(org.thoughtcrime.securesms.insights.InsightsLauncher) UnexpectedSubscriptionCancellation(org.thoughtcrime.securesms.components.settings.app.subscription.errors.UnexpectedSubscriptionCancellation) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) UnreadPayments(org.thoughtcrime.securesms.conversationlist.model.UnreadPayments) StickyHeaderDecoration(org.thoughtcrime.securesms.util.StickyHeaderDecoration) DialogFragment(androidx.fragment.app.DialogFragment) ServiceOutageReminder(org.thoughtcrime.securesms.components.reminder.ServiceOutageReminder) SignalDatabase(org.thoughtcrime.securesms.database.SignalDatabase) Stream(com.annimon.stream.Stream) Util(org.thoughtcrime.securesms.util.Util) AppCompatResources(androidx.appcompat.content.res.AppCompatResources) CantProcessSubscriptionPaymentBottomSheetDialogFragment(org.thoughtcrime.securesms.badges.self.expired.CantProcessSubscriptionPaymentBottomSheetDialogFragment) WorkerThread(androidx.annotation.WorkerThread) PaymentDetailsParcelable(org.thoughtcrime.securesms.payments.preferences.details.PaymentDetailsParcelable) MainFragment(org.thoughtcrime.securesms.MainFragment) ArrayList(java.util.ArrayList) ActionMenuView(androidx.appcompat.widget.ActionMenuView) ReminderView(org.thoughtcrime.securesms.components.reminder.ReminderView) KeyCachingService(org.thoughtcrime.securesms.service.KeyCachingService) WebSocketConnectionState(org.whispersystems.signalservice.api.websocket.WebSocketConnectionState) ItemTouchHelper(androidx.recyclerview.widget.ItemTouchHelper) SignalProxyUtil(org.thoughtcrime.securesms.util.SignalProxyUtil) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) RatingManager(org.thoughtcrime.securesms.components.RatingManager) AppStartup(org.thoughtcrime.securesms.util.AppStartup) LinkedHashSet(java.util.LinkedHashSet) MainNavigator(org.thoughtcrime.securesms.MainNavigator) ViewModelProvider(androidx.lifecycle.ViewModelProvider) ProgressDialog(android.app.ProgressDialog) Permissions(org.thoughtcrime.securesms.permissions.Permissions) UnreadPaymentsView(org.thoughtcrime.securesms.components.UnreadPaymentsView) PushRegistrationReminder(org.thoughtcrime.securesms.components.reminder.PushRegistrationReminder) Optional(org.whispersystems.libsignal.util.guava.Optional) Reminder(org.thoughtcrime.securesms.components.reminder.Reminder) BottomSheetUtil(org.thoughtcrime.securesms.util.BottomSheetUtil) Stopwatch(org.thoughtcrime.securesms.util.Stopwatch) SnackbarAsyncTask(org.thoughtcrime.securesms.util.task.SnackbarAsyncTask) SignalStore(org.thoughtcrime.securesms.keyvalue.SignalStore) SignalBottomActionBar(org.thoughtcrime.securesms.components.menu.SignalBottomActionBar) ArgbEvaluatorCompat(com.google.android.material.animation.ArgbEvaluatorCompat) MessageSender(org.thoughtcrime.securesms.sms.MessageSender) NotificationProfileSelectionFragment(org.thoughtcrime.securesms.components.settings.app.notifications.manual.NotificationProfileSelectionFragment) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) PaymentDetailsFragmentArgs(org.thoughtcrime.securesms.payments.preferences.details.PaymentDetailsFragmentArgs) ConversationFragment(org.thoughtcrime.securesms.conversation.ConversationFragment) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) DrawableRes(androidx.annotation.DrawableRes) R(org.thoughtcrime.securesms.R) PlayStoreUtil(org.thoughtcrime.securesms.util.PlayStoreUtil) StorageSyncHelper(org.thoughtcrime.securesms.storage.StorageSyncHelper) Locale(java.util.Locale) PluralsRes(androidx.annotation.PluralsRes) NotificationProfiles(org.thoughtcrime.securesms.notifications.profiles.NotificationProfiles) View(android.view.View) MegaphoneViewBuilder(org.thoughtcrime.securesms.megaphone.MegaphoneViewBuilder) Recipient(org.thoughtcrime.securesms.recipients.Recipient) RecyclerView(androidx.recyclerview.widget.RecyclerView) SignalExecutors(org.signal.core.util.concurrent.SignalExecutors) SearchToolbar(org.thoughtcrime.securesms.components.SearchToolbar) Conversation(org.thoughtcrime.securesms.conversationlist.model.Conversation) AppSettingsActivity(org.thoughtcrime.securesms.components.settings.app.AppSettingsActivity) ExpiredBuildReminder(org.thoughtcrime.securesms.components.reminder.ExpiredBuildReminder) SearchResult(org.thoughtcrime.securesms.search.SearchResult) AsyncTask(android.os.AsyncTask) VoiceNotePlayerView(org.thoughtcrime.securesms.components.voice.VoiceNotePlayerView) Collection(java.util.Collection) UUID(java.util.UUID) ThreadMode(org.greenrobot.eventbus.ThreadMode) AvatarUtil(org.thoughtcrime.securesms.util.AvatarUtil) ExpiredBadgeBottomSheetDialogFragment(org.thoughtcrime.securesms.badges.self.expired.ExpiredBadgeBottomSheetDialogFragment) NotificationProfile(org.thoughtcrime.securesms.notifications.profiles.NotificationProfile) Collectors(java.util.stream.Collectors) ViewGroup(android.view.ViewGroup) CreateKbsPinActivity(org.thoughtcrime.securesms.lock.v2.CreateKbsPinActivity) VoiceNoteMediaControllerOwner(org.thoughtcrime.securesms.components.voice.VoiceNoteMediaControllerOwner) Objects(java.util.Objects) Log(org.signal.core.util.logging.Log) List(java.util.List) TextView(android.widget.TextView) MarkReadReceiver(org.thoughtcrime.securesms.notifications.MarkReadReceiver) MessageResult(org.thoughtcrime.securesms.search.MessageResult) Toolbar(androidx.appcompat.widget.Toolbar) Snackbar(com.google.android.material.snackbar.Snackbar) GlideApp(org.thoughtcrime.securesms.mms.GlideApp) DozeReminder(org.thoughtcrime.securesms.components.reminder.DozeReminder) MarkedMessageInfo(org.thoughtcrime.securesms.database.MessageDatabase.MarkedMessageInfo) Context(android.content.Context) TopToastPopup(org.thoughtcrime.securesms.util.TopToastPopup) RESULT_OK(android.app.Activity.RESULT_OK) SignalLocalMetrics(org.thoughtcrime.securesms.util.SignalLocalMetrics) Intent(android.content.Intent) AppForegroundObserver(org.thoughtcrime.securesms.util.AppForegroundObserver) TypedArray(android.content.res.TypedArray) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) TextSecurePreferences(org.thoughtcrime.securesms.util.TextSecurePreferences) HashSet(java.util.HashSet) TooltipPopup(org.thoughtcrime.securesms.components.TooltipPopup) SuppressLint(android.annotation.SuppressLint) ActionItem(org.thoughtcrime.securesms.components.menu.ActionItem) OutdatedBuildReminder(org.thoughtcrime.securesms.components.reminder.OutdatedBuildReminder) POSITION_BELOW(org.thoughtcrime.securesms.components.TooltipPopup.POSITION_BELOW) EventBus(org.greenrobot.eventbus.EventBus) Build(android.os.Build) WeakReference(java.lang.ref.WeakReference) SimpleTask(org.thoughtcrime.securesms.util.concurrent.SimpleTask) MegaphoneActionController(org.thoughtcrime.securesms.megaphone.MegaphoneActionController) Stub(org.thoughtcrime.securesms.util.views.Stub) LayoutInflater(android.view.LayoutInflater) MediaSelectionActivity(org.thoughtcrime.securesms.mediasend.v2.MediaSelectionActivity) PaymentsActivity(org.thoughtcrime.securesms.payments.preferences.PaymentsActivity) ActionMode(androidx.appcompat.view.ActionMode) WindowUtil(org.thoughtcrime.securesms.util.WindowUtil) Color(android.graphics.Color) ServiceOutageDetectionJob(org.thoughtcrime.securesms.jobs.ServiceOutageDetectionJob) Subscribe(org.greenrobot.eventbus.Subscribe) BadgeImageView(org.thoughtcrime.securesms.badges.BadgeImageView) ReminderUpdateEvent(org.thoughtcrime.securesms.events.ReminderUpdateEvent) MuteDialog(org.thoughtcrime.securesms.MuteDialog) Activity(android.app.Activity) Collections(java.util.Collections) Resources(android.content.res.Resources) UnauthorizedReminder(org.thoughtcrime.securesms.components.reminder.UnauthorizedReminder) ThreadDatabase(org.thoughtcrime.securesms.database.ThreadDatabase)

Example 4 with Conversation

use of org.thoughtcrime.securesms.conversationlist.model.Conversation in project Signal-Android by WhisperSystems.

the class ConversationListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == TYPE_ACTION || holder.getItemViewType() == TYPE_THREAD) {
        ConversationViewHolder casted = (ConversationViewHolder) holder;
        Conversation conversation = Objects.requireNonNull(getItem(position));
        casted.getConversationListItem().bind(conversation.getThreadRecord(), glideRequests, Locale.getDefault(), typingSet, selectedConversations);
    } else if (holder.getItemViewType() == TYPE_HEADER) {
        HeaderViewHolder casted = (HeaderViewHolder) holder;
        Conversation conversation = Objects.requireNonNull(getItem(position));
        switch(conversation.getType()) {
            case PINNED_HEADER:
                casted.headerText.setText(R.string.conversation_list__pinned);
                break;
            case UNPINNED_HEADER:
                casted.headerText.setText(R.string.conversation_list__chats);
                break;
            default:
                throw new IllegalArgumentException();
        }
    }
}
Also used : Conversation(org.thoughtcrime.securesms.conversationlist.model.Conversation)

Aggregations

Conversation (org.thoughtcrime.securesms.conversationlist.model.Conversation)4 NonNull (androidx.annotation.NonNull)3 Manifest (android.Manifest)2 SuppressLint (android.annotation.SuppressLint)2 Activity (android.app.Activity)2 RESULT_OK (android.app.Activity.RESULT_OK)2 ProgressDialog (android.app.ProgressDialog)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Resources (android.content.res.Resources)2 TypedArray (android.content.res.TypedArray)2 Canvas (android.graphics.Canvas)2 Color (android.graphics.Color)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Drawable (android.graphics.drawable.Drawable)2 Uri (android.net.Uri)2 AsyncTask (android.os.AsyncTask)2 Build (android.os.Build)2 Bundle (android.os.Bundle)2 LayoutInflater (android.view.LayoutInflater)2