From b11039ed8ce49bc1316bea1aade5f6f0b2a4306d Mon Sep 17 00:00:00 2001 From: Michael W Date: Sun, 16 Jun 2024 13:44:19 +0200 Subject: [PATCH] Messaging: Allow deletion of messages without a sim inserted * Currently there is a check in place checking for the presence of a preferred sim card * For deletion of a conversation and message this is unnecessary and deleting a conversation from the main view does also not have that check already, so replace the check with just checking for being the default messaging app Fixes: https://gitlab.com/LineageOS/issues/android/-/issues/5974 Test: Try deleting a single message or conversation from within conversation before and after Change-Id: Icd47882eb29e16a17ad57a79ea5e0c0f7855ffc6 --- .../ui/conversation/ConversationFragment.java | 10 +++++++--- src/com/android/messaging/util/UiUtils.java | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/com/android/messaging/ui/conversation/ConversationFragment.java b/src/com/android/messaging/ui/conversation/ConversationFragment.java index 6eb7089..181e878 100644 --- a/src/com/android/messaging/ui/conversation/ConversationFragment.java +++ b/src/com/android/messaging/ui/conversation/ConversationFragment.java @@ -819,7 +819,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi return true; case R.id.action_delete: - if (isReadyForAction()) { + if (isReadyForDeleteAction()) { new AlertDialog.Builder(getActivity()) .setTitle(getResources().getQuantityString( R.plurals.delete_conversations_confirmation_dialog_title, 1)) @@ -1073,6 +1073,10 @@ public class ConversationFragment extends Fragment implements ConversationDataLi return UiUtils.isReadyForAction(); } + public boolean isReadyForDeleteAction() { + return UiUtils.isReadyForDeleteAction(); + } + /** * When there's some condition that prevents an operation, such as sending a message, * call warnOfMissingActionConditions to put up a snackbar and allow the user to repair @@ -1142,7 +1146,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi } void deleteMessage(final String messageId) { - if (isReadyForAction()) { + if (isReadyForDeleteAction()) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()) .setTitle(R.string.delete_message_confirmation_dialog_title) .setMessage(R.string.delete_message_confirmation_dialog_text) @@ -1178,7 +1182,7 @@ public class ConversationFragment extends Fragment implements ConversationDataLi } public void deleteConversation() { - if (isReadyForAction()) { + if (isReadyForDeleteAction()) { final Context context = getActivity(); mBinding.getData().deleteConversation(mBinding); closeConversation(mConversationId); diff --git a/src/com/android/messaging/util/UiUtils.java b/src/com/android/messaging/util/UiUtils.java index 17c877f..236de32 100644 --- a/src/com/android/messaging/util/UiUtils.java +++ b/src/com/android/messaging/util/UiUtils.java @@ -349,6 +349,18 @@ public class UiUtils { phoneUtils.isDefaultSmsApp(); } + /** + * Called to check if a message or conversation can be deleted - it needs to be the default + * sms app + * @return true if all conditions are nominal and we're ready to delete a message + */ + public static boolean isReadyForDeleteAction() { + final PhoneUtils phoneUtils = PhoneUtils.getDefault(); + + // Is the default sms app? + return phoneUtils.isDefaultSmsApp(); + } + /* * Removes all html markup from the text and replaces links with the the text and a text version * of the href.