Skip to content

Commit

Permalink
feat: option to add unknown sms sender to contact (closes #339)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bnyro committed Dec 11, 2023
1 parent bec64b7 commit 8da77fa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ import com.bnyro.contacts.ui.screens.EditorScreen
import kotlinx.coroutines.launch

@Composable
fun AddToContactDialog(
newNumber: String
) {
fun AddToContactDialog(newNumber: String) {
val context = LocalContext.current
val contactsModel: ContactsModel = viewModel(factory = ContactsModel.Factory)

Expand Down
23 changes: 20 additions & 3 deletions app/src/main/java/com/bnyro/contacts/ui/screens/SmsThreadScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.PersonAddAlt1
import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledIconButton
Expand Down Expand Up @@ -43,6 +44,7 @@ import com.bnyro.contacts.ui.components.base.ClickableIcon
import com.bnyro.contacts.ui.components.base.ElevatedTextInputField
import com.bnyro.contacts.ui.components.base.FullScreenDialog
import com.bnyro.contacts.ui.components.conversation.Messages
import com.bnyro.contacts.ui.components.dialogs.AddToContactDialog
import com.bnyro.contacts.ui.components.dialogs.ConfirmationDialog
import com.bnyro.contacts.ui.models.SmsModel
import com.bnyro.contacts.util.SmsUtil
Expand All @@ -62,9 +64,6 @@ fun SmsThreadScreen(
val threadId = smsModel.smsList.firstOrNull { it.address == address }?.threadId
val smsList =
threadId?.let { smsModel.smsGroups[threadId]?.sortedBy { it.timestamp } } ?: listOf()
var showContactScreen by remember {
mutableStateOf(false)
}
val subscriptions = remember {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
SmsUtil.getSubscriptions(context)
Expand All @@ -73,6 +72,13 @@ fun SmsThreadScreen(
}
}

var showContactScreen by remember {
mutableStateOf(false)
}
var showAddToContactDialog by remember {
mutableStateOf(false)
}

FullScreenDialog(onClose = onClose) {
Scaffold(
topBar = {
Expand Down Expand Up @@ -101,6 +107,13 @@ fun SmsThreadScreen(
) {
onClose.invoke()
}
},
actions = {
if (contactData == null) {
ClickableIcon(icon = Icons.Default.PersonAddAlt1) {
showAddToContactDialog = true
}
}
}
)
}
Expand Down Expand Up @@ -199,4 +212,8 @@ fun SmsThreadScreen(
showContactScreen = false
}
}

if (showAddToContactDialog) {
AddToContactDialog(newNumber = address)
}
}

0 comments on commit 8da77fa

Please sign in to comment.