Skip to content

Commit

Permalink
Inline remote delete feature flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Oct 7, 2020
1 parent 3fcaddf commit c80283d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -665,53 +665,7 @@ private void handleCopyMessage(final Set<ConversationMessage> conversationMessag

private void handleDeleteMessages(final Set<ConversationMessage> conversationMessages) {
Set<MessageRecord> messageRecords = Stream.of(conversationMessages).map(ConversationMessage::getMessageRecord).collect(Collectors.toSet());
if (FeatureFlags.remoteDelete()) {
buildRemoteDeleteConfirmationDialog(messageRecords).show();
} else {
buildLegacyDeleteConfirmationDialog(messageRecords).show();
}
}

private AlertDialog.Builder buildLegacyDeleteConfirmationDialog(Set<MessageRecord> messageRecords) {
int messagesCount = messageRecords.size();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

builder.setIconAttribute(R.attr.dialog_alert_icon);
builder.setTitle(getActivity().getResources().getQuantityString(R.plurals.ConversationFragment_delete_selected_messages, messagesCount, messagesCount));
builder.setMessage(getActivity().getResources().getQuantityString(R.plurals.ConversationFragment_this_will_permanently_delete_all_n_selected_messages, messagesCount, messagesCount));
builder.setCancelable(true);

builder.setPositiveButton(R.string.delete, (dialog, which) -> {
new ProgressDialogAsyncTask<Void, Void, Void>(getActivity(),
R.string.ConversationFragment_deleting,
R.string.ConversationFragment_deleting_messages)
{
@Override
protected Void doInBackground(Void... voids) {
for (MessageRecord messageRecord : messageRecords) {
boolean threadDeleted;

if (messageRecord.isMms()) {
threadDeleted = DatabaseFactory.getMmsDatabase(getActivity()).deleteMessage(messageRecord.getId());
} else {
threadDeleted = DatabaseFactory.getSmsDatabase(getActivity()).deleteMessage(messageRecord.getId());
}

if (threadDeleted) {
threadId = -1;
conversationViewModel.clearThreadId();
messageCountsViewModel.clearThreadId();
listener.setThreadId(threadId);
}
}

return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
});

builder.setNegativeButton(android.R.string.cancel, null);
return builder;
buildRemoteDeleteConfirmationDialog(messageRecords).show();
}

private AlertDialog.Builder buildRemoteDeleteConfirmationDialog(Set<MessageRecord> messageRecords) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public final class FeatureFlags {
private static final long FETCH_INTERVAL = TimeUnit.HOURS.toMillis(2);

private static final String USERNAMES = "android.usernames";
private static final String REMOTE_DELETE = "android.remoteDelete";
private static final String GROUPS_V2_CREATE_VERSION = "android.groupsv2.createVersion";
private static final String GROUPS_V2_JOIN_VERSION = "android.groupsv2.joinVersion";
private static final String GROUPS_V2_LINKS_VERSION = "android.groupsv2.manageGroupLinksVersion";
Expand All @@ -66,7 +65,6 @@ public final class FeatureFlags {
*/

private static final Set<String> REMOTE_CAPABLE = Sets.newHashSet(
REMOTE_DELETE,
GROUPS_V2_CREATE_VERSION,
GROUPS_V2_CAPACITY,
GROUPS_V2_JOIN_VERSION,
Expand Down Expand Up @@ -174,11 +172,6 @@ public static synchronized boolean usernames() {
return getBoolean(USERNAMES, false);
}

/** Send support for remotely deleting a message. */
public static boolean remoteDelete() {
return getBoolean(REMOTE_DELETE, false);
}

/** Attempt groups v2 creation. */
public static boolean groupsV2create() {
return getVersionFlag(GROUPS_V2_CREATE_VERSION) == VersionFlag.ON &&
Expand Down

0 comments on commit c80283d

Please sign in to comment.