Skip to content

Commit

Permalink
fix: prevent users from responding to shortcode sms addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Oct 20, 2024
1 parent d0a0218 commit 59fef53
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ fun ElevatedTextInputField(
),
keyboardOptions = KeyboardOptions(imeAction = imeAction),
singleLine = singleLine,
enabled = enabled
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ fun SmsThreadScreen(
}
}
}

// can't respond to address short codes that don't include a number
val showSendButton = remember {
address.any { !it.isLetter() }
}

Row(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -172,13 +178,15 @@ fun SmsThreadScreen(
modifier = Modifier.weight(1f),
query = text,
onQueryChange = { text = it },
placeholder = stringResource(R.string.send)
placeholder = stringResource(if (showSendButton) R.string.send else R.string.cant_respond),
enabled = showSendButton
)

Spacer(modifier = Modifier.width(8.dp))

FilledIconButton(
modifier = Modifier.size(48.dp),
enabled = showSendButton,
onClick = {
if (text.isBlank()) return@FilledIconButton
if (!SmsUtil.isShortEnoughForSms(text)) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<!-- Sms -->
<string name="messages">Messages</string>
<string name="send">Send message</string>
<string name="cant_respond">Can\'t respond</string>
<string name="reply">Reply</string>
<string name="connection_error">Could not connect. Please ensure airplane mode is off.</string>
<string name="message_too_long">Message is too long!</string>
Expand Down

0 comments on commit 59fef53

Please sign in to comment.