Show 2 checks when sms is delivered

- differentiate between sent sms and delivered sms by updating the SmsStatusSentReceiver which updates the type to Telephony.Sms.MESSAGE_TYPE_SENT or Telephony.Sms.MESSAGE_TYPE_FAILED depending on the outcome.
- rename ThreadSuccess to ThreadSent and add a boolean field for the delivery status
- SmsStatusSentReceiver updates the status of the message to Telephony.Sms.STATUS_COMPLETE.
- accommodate for the need to keep track of the status by adding Int field status to the Message class,
- add appropriate database migrations (3 to 4) for the new status field.
- add status to the query for sms in extension function Context.getMessages and Context.getMMS
- add extension function Context.updateMessageStatus to update the status of a message in the database
This commit is contained in:
Paul Akhamiogu 2021-08-25 16:57:07 +01:00
parent 84c1705078
commit 46f71c994f
13 changed files with 58 additions and 27 deletions

View file

@ -17,7 +17,7 @@ import com.simplemobiletools.smsmessenger.models.Conversation
import com.simplemobiletools.smsmessenger.models.Message
import com.simplemobiletools.smsmessenger.models.MessageAttachment
@Database(entities = [Conversation::class, Attachment::class, MessageAttachment::class, Message::class], version = 3)
@Database(entities = [Conversation::class, Attachment::class, MessageAttachment::class, Message::class], version = 4)
@TypeConverters(Converters::class)
abstract class MessagesDatabase : RoomDatabase() {
@ -40,6 +40,7 @@ abstract class MessagesDatabase : RoomDatabase() {
.fallbackToDestructiveMigration()
.addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.addMigrations(MIGRATION_3_4)
.build()
}
}
@ -76,5 +77,13 @@ abstract class MessagesDatabase : RoomDatabase() {
}
}
}
private val MIGRATION_3_4 = object : Migration(3, 4) {
override fun migrate(database: SupportSQLiteDatabase) {
database.apply {
execSQL("ALTER TABLE messages ADD COLUMN status INTEGER NOT NULL DEFAULT -1")
}
}
}
}
}