Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 19, 2025

Overview

This PR implements two new actions for sending SMS messages, addressing issue requirements for SMS functionality in Key Mapper.

New Actions

1. Send SMS

Instantly sends an SMS message to a specified phone number with a predefined message. Uses ACTION_SENDTO intent to send the message directly through the default messaging app.

2. Compose SMS

Opens the messaging app with a pre-filled SMS message, allowing the user to review and edit before sending. Uses ACTION_VIEW intent to provide a safer, user-controlled sending experience.

Implementation Details

Both actions prompt the user to configure:

  • Phone number: Input field with phone number keyboard
  • Message text: Multi-line text input for the SMS content

The actions are:

  • Categorized under Telephony alongside existing phone call actions
  • Protected by the SEND_SMS Android permission with proper request flow
  • Fully editable after creation
  • Persisted correctly to the database
  • Tagged with the telephony system feature requirement

Technical Changes

Core Components:

  • Added SendSms and ComposeSms data classes directly to ActionData (no parent sealed class)
  • Implemented sendSms() and composeSms() methods in PhoneAdapter/AndroidPhoneAdapter
  • Created SmsActionBottomSheet for SMS configuration UI following the pattern of other action bottom sheets
  • Integrated SMS action execution in PerformActionsUseCase

Database:

  • Added SEND_SMS and COMPOSE_SMS entity types to ActionEntity
  • Added EXTRA_SMS_MESSAGE constant for message persistence
  • Implemented full serialization/deserialization in ActionDataEntityMapper

Permissions:

  • Added SEND_SMS permission to the permission system
  • Implemented permission checking and request flow
  • Added permission to system module's AndroidManifest.xml

UI/UX:

  • Created SmsActionBottomSheet with Material Design components for a unified configuration experience
  • Bottom sheet includes phone number field (with phone keyboard) and message field (multi-line text input)
  • Input validation with error states before submission
  • Created Material Design message icon (ic_outline_message_24.xml)
  • Added localized strings for action titles, hints, and error messages
  • Integrated actions into the Choose Action screen

Error Handling:

  • Added NoAppToSendSms error type for cases where no SMS app is available
  • Proper error messaging throughout the permission and execution flow

Testing

While the implementation follows all established patterns in the codebase, testing should verify:

  1. Bottom sheet properly captures phone number and message with validation
  2. Send SMS action directly sends messages (with user permission)
  3. Compose SMS action opens messaging app with pre-filled content
  4. Permission requests work correctly
  5. Actions persist and reload from database correctly
  6. Error handling works when no SMS app is available

Files Changed

  • 19 files modified
  • 280+ lines added
  • No breaking changes

All changes follow existing code patterns and maintain backward compatibility.

Fixes #727

Original prompt

This section details on the original issue you should resolve

<issue_title>action to send an SMS</issue_title>
<issue_description>Developer TODO (don't remove)

  • create new branch. put issue number at start of name
  • option to send a predetermined message or show a prompt to choose the message.
  • two actions to instantly send the message or open the sms in the messaging app before sending. "Send SMS" and "Compose SMS"
  • update documentation
  • squash and merge
  • delete branch
    </issue_description>

Comments on the Issue (you are @copilot in this section)

@sds100 yeah

Fixes #727


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@sds100 sds100 marked this pull request as ready for review October 19, 2025 11:42
Copilot AI changed the title [WIP] Add action to send SMS functionality Add SMS actions: Send SMS and Compose SMS Oct 19, 2025
Copilot AI requested a review from sds100 October 19, 2025 11:43
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Instead of showing two dialogs can you use a jetpack compose bottom sheet instead? Look at how the other action bottom sheets are implemented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit d774d78. Created SmsActionBottomSheet following the pattern of HttpRequestBottomSheet with text fields for phone number and message. The bottom sheet validates inputs before allowing submission.

}

@Serializable
sealed class Sms : ActionData() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot do not create a parent Sms action.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit d774d78. Removed the parent Sms sealed class. Now SendSms and ComposeSms are separate data classes directly under ActionData.

Copilot AI requested a review from sds100 October 19, 2025 11:54
@sds100 sds100 merged commit 32e511e into develop Oct 19, 2025
1 of 3 checks passed
@sds100 sds100 deleted the copilot/action-send-sms branch October 19, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

action to send an SMS

2 participants