Rewrite, move SMS related code into the app
This commit is contained in:
parent
7bce8ab31b
commit
1f36738be0
16 changed files with 647 additions and 162 deletions
|
|
@ -2,6 +2,10 @@ package com.simplemobiletools.smsmessenger.helpers
|
|||
|
||||
import com.simplemobiletools.smsmessenger.models.Events
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import kotlin.math.abs
|
||||
import kotlin.random.Random
|
||||
|
||||
const val THREAD_ID = "thread_id"
|
||||
const val THREAD_TITLE = "thread_title"
|
||||
|
|
@ -81,3 +85,10 @@ const val PICK_CONTACT_INTENT = 48
|
|||
fun refreshMessages() {
|
||||
EventBus.getDefault().post(Events.RefreshMessages())
|
||||
}
|
||||
|
||||
/** Not to be used with real messages persisted in the telephony db. This is for internal use only (e.g. scheduled messages, notification ids etc). */
|
||||
fun generateRandomId(length: Int = 9): Long {
|
||||
val millis = DateTime.now(DateTimeZone.UTC).millis
|
||||
val random = abs(Random(millis).nextLong())
|
||||
return random.toString().takeLast(length).toLong()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue