updating commons and min SDK to 23
This commit is contained in:
parent
db37ac1b19
commit
db6ddceb73
9 changed files with 32 additions and 41 deletions
|
|
@ -679,26 +679,18 @@ fun Context.updateUnreadCountBadge(conversations: List<Conversation>) {
|
|||
|
||||
@SuppressLint("NewApi")
|
||||
fun Context.getThreadId(address: String): Long {
|
||||
return if (isMarshmallowPlus()) {
|
||||
try {
|
||||
Threads.getOrCreateThreadId(this, address)
|
||||
} catch (e: Exception) {
|
||||
0L
|
||||
}
|
||||
} else {
|
||||
return try {
|
||||
Threads.getOrCreateThreadId(this, address)
|
||||
} catch (e: Exception) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun Context.getThreadId(addresses: Set<String>): Long {
|
||||
return if (isMarshmallowPlus()) {
|
||||
try {
|
||||
Threads.getOrCreateThreadId(this, addresses)
|
||||
} catch (e: Exception) {
|
||||
0L
|
||||
}
|
||||
} else {
|
||||
return try {
|
||||
Threads.getOrCreateThreadId(this, addresses)
|
||||
} catch (e: Exception) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
|
@ -896,12 +888,7 @@ fun Context.clearAllMessagesIfNeeded() {
|
|||
}
|
||||
|
||||
fun Context.subscriptionManagerCompat(): SubscriptionManager {
|
||||
return if (isMarshmallowPlus()) {
|
||||
getSystemService(SubscriptionManager::class.java)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
SubscriptionManager.from(this)
|
||||
}
|
||||
return getSystemService(SubscriptionManager::class.java)
|
||||
}
|
||||
|
||||
fun Context.renameConversation(conversation: Conversation, newTitle: String): Conversation {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import com.klinker.android.send_message.Settings
|
|||
import com.klinker.android.send_message.Transaction
|
||||
import com.klinker.android.send_message.Utils
|
||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||
import com.simplemobiletools.commons.helpers.isMarshmallowPlus
|
||||
import com.simplemobiletools.smsmessenger.R
|
||||
import com.simplemobiletools.smsmessenger.extensions.config
|
||||
import com.simplemobiletools.smsmessenger.extensions.isPlainTextMimeType
|
||||
|
|
@ -81,11 +80,7 @@ fun Context.getScheduleSendPendingIntent(message: Message): PendingIntent {
|
|||
intent.putExtra(THREAD_ID, message.threadId)
|
||||
intent.putExtra(SCHEDULED_MESSAGE_ID, message.id)
|
||||
|
||||
var flags = PendingIntent.FLAG_UPDATE_CURRENT
|
||||
if (isMarshmallowPlus()) {
|
||||
flags = flags or PendingIntent.FLAG_IMMUTABLE
|
||||
}
|
||||
|
||||
val flags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
return PendingIntent.getBroadcast(this, message.id.toInt(), intent, flags)
|
||||
}
|
||||
|
||||
|
|
@ -99,11 +94,7 @@ fun Context.scheduleMessage(message: Message) {
|
|||
|
||||
fun Context.cancelScheduleSendPendingIntent(messageId: Long) {
|
||||
val intent = Intent(this, ScheduledMessageReceiver::class.java)
|
||||
var flags = PendingIntent.FLAG_UPDATE_CURRENT
|
||||
if (isMarshmallowPlus()) {
|
||||
flags = flags or PendingIntent.FLAG_IMMUTABLE
|
||||
}
|
||||
|
||||
val flags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
PendingIntent.getBroadcast(this, messageId.toInt(), intent, flags).cancel()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue