use of org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference in project Signal-Android by signalapp.
the class VoiceNoteMediaItemFactory method buildMediaItem.
private static MediaItem buildMediaItem(@NonNull Context context, @NonNull Recipient threadRecipient, @NonNull Recipient avatarRecipient, @NonNull Recipient sender, int startingPosition, long threadId, long messageId, long dateReceived, @NonNull Uri audioUri) {
Bundle extras = new Bundle();
extras.putString(EXTRA_THREAD_RECIPIENT_ID, threadRecipient.getId().serialize());
extras.putString(EXTRA_AVATAR_RECIPIENT_ID, avatarRecipient.getId().serialize());
extras.putString(EXTRA_INDIVIDUAL_RECIPIENT_ID, sender.getId().serialize());
extras.putLong(EXTRA_MESSAGE_POSITION, startingPosition);
extras.putLong(EXTRA_THREAD_ID, threadId);
extras.putLong(EXTRA_COLOR, threadRecipient.getChatColors().asSingleColor());
extras.putLong(EXTRA_MESSAGE_ID, messageId);
extras.putLong(EXTRA_MESSAGE_TIMESTAMP, dateReceived);
NotificationPrivacyPreference preference = SignalStore.settings().getMessageNotificationsPrivacy();
String title = getTitle(context, sender, threadRecipient, preference);
String subtitle = null;
if (preference.isDisplayContact()) {
subtitle = context.getString(R.string.VoiceNoteMediaItemFactory__voice_message, DateUtils.formatDateWithoutDayOfWeek(Locale.getDefault(), dateReceived));
}
return new MediaItem.Builder().setUri(audioUri).setMediaMetadata(new MediaMetadata.Builder().setTitle(title).setSubtitle(subtitle).setExtras(extras).build()).setTag(new MediaDescriptionCompat.Builder().setMediaUri(audioUri).setTitle(title).setSubtitle(subtitle).setExtras(extras).build()).build();
}
use of org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference in project Signal-Android by WhisperSystems.
the class BubbleUtil method canBubble.
/**
* Checks whether we are allowed to create a bubble for the given recipient.
*
* In order to Bubble, a recipient must have a thread, be unblocked, and the user must not have
* notification privacy settings enabled. Furthermore, we check the Notifications system to verify
* that bubbles are allowed in the first place.
*/
@RequiresApi(CONVERSATION_SUPPORT_VERSION)
@WorkerThread
public static boolean canBubble(@NonNull Context context, @NonNull RecipientId recipientId, @Nullable Long threadId) {
if (threadId == null) {
Log.i(TAG, "Cannot bubble recipient without thread");
return false;
}
NotificationPrivacyPreference privacyPreference = SignalStore.settings().getMessageNotificationsPrivacy();
if (!privacyPreference.isDisplayContact()) {
Log.i(TAG, "Bubbles are not available when notification privacy settings are enabled.");
return false;
}
Recipient recipient = Recipient.resolved(recipientId);
if (recipient.isBlocked()) {
Log.i(TAG, "Cannot bubble blocked recipient");
return false;
}
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
NotificationChannel conversationChannel = notificationManager.getNotificationChannel(ConversationUtil.getChannelId(context, recipient), ConversationUtil.getShortcutId(recipientId));
return notificationManager.areBubblesAllowed() || (conversationChannel != null && conversationChannel.canBubble());
}
use of org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference in project Signal-Android by WhisperSystems.
the class VoiceNoteMediaItemFactory method buildMediaItem.
private static MediaItem buildMediaItem(@NonNull Context context, @NonNull Recipient threadRecipient, @NonNull Recipient avatarRecipient, @NonNull Recipient sender, int startingPosition, long threadId, long messageId, long dateReceived, @NonNull Uri audioUri) {
Bundle extras = new Bundle();
extras.putString(EXTRA_THREAD_RECIPIENT_ID, threadRecipient.getId().serialize());
extras.putString(EXTRA_AVATAR_RECIPIENT_ID, avatarRecipient.getId().serialize());
extras.putString(EXTRA_INDIVIDUAL_RECIPIENT_ID, sender.getId().serialize());
extras.putLong(EXTRA_MESSAGE_POSITION, startingPosition);
extras.putLong(EXTRA_THREAD_ID, threadId);
extras.putLong(EXTRA_COLOR, threadRecipient.getChatColors().asSingleColor());
extras.putLong(EXTRA_MESSAGE_ID, messageId);
extras.putLong(EXTRA_MESSAGE_TIMESTAMP, dateReceived);
NotificationPrivacyPreference preference = SignalStore.settings().getMessageNotificationsPrivacy();
String title = getTitle(context, sender, threadRecipient, preference);
String subtitle = null;
if (preference.isDisplayContact()) {
subtitle = context.getString(R.string.VoiceNoteMediaItemFactory__voice_message, DateUtils.formatDateWithoutDayOfWeek(Locale.getDefault(), dateReceived));
}
return new MediaItem.Builder().setUri(audioUri).setMediaMetadata(new MediaMetadata.Builder().setTitle(title).setSubtitle(subtitle).setExtras(extras).build()).setTag(new MediaDescriptionCompat.Builder().setMediaUri(audioUri).setTitle(title).setSubtitle(subtitle).setExtras(extras).build()).build();
}
use of org.thoughtcrime.securesms.preferences.widgets.NotificationPrivacyPreference in project Signal-Android by signalapp.
the class BubbleUtil method canBubble.
/**
* Checks whether we are allowed to create a bubble for the given recipient.
*
* In order to Bubble, a recipient must have a thread, be unblocked, and the user must not have
* notification privacy settings enabled. Furthermore, we check the Notifications system to verify
* that bubbles are allowed in the first place.
*/
@RequiresApi(CONVERSATION_SUPPORT_VERSION)
@WorkerThread
public static boolean canBubble(@NonNull Context context, @NonNull RecipientId recipientId, @Nullable Long threadId) {
if (threadId == null) {
Log.i(TAG, "Cannot bubble recipient without thread");
return false;
}
NotificationPrivacyPreference privacyPreference = SignalStore.settings().getMessageNotificationsPrivacy();
if (!privacyPreference.isDisplayContact()) {
Log.i(TAG, "Bubbles are not available when notification privacy settings are enabled.");
return false;
}
Recipient recipient = Recipient.resolved(recipientId);
if (recipient.isBlocked()) {
Log.i(TAG, "Cannot bubble blocked recipient");
return false;
}
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
NotificationChannel conversationChannel = notificationManager.getNotificationChannel(ConversationUtil.getChannelId(context, recipient), ConversationUtil.getShortcutId(recipientId));
return notificationManager.areBubblesAllowed() || (conversationChannel != null && conversationChannel.canBubble());
}
Aggregations