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.