diff --git a/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt b/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt index 805dda88..af81e68a 100644 --- a/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt +++ b/data/src/main/java/com/moez/QKSMS/repository/MessageRepositoryImpl.kt @@ -302,13 +302,20 @@ class MessageRepositoryImpl @Inject constructor( else -> prefs.signature.get() } + val smsManager = subId.takeIf { it != -1 } + ?.let(SmsManagerFactory::createSmsManager) + ?: SmsManager.getDefault() + // We only care about stripping SMS val strippedBody = when (prefs.unicode.get()) { true -> StripAccents.stripAccents(signedBody) false -> signedBody } - if (addresses.size == 1 && attachments.isEmpty()) { // SMS + val parts = smsManager.divideMessage(strippedBody).orEmpty() + val forceMms = prefs.longAsMms.get() && parts.size > 1 + + if (addresses.size == 1 && attachments.isEmpty() && !forceMms) { // SMS if (delay > 0) { // With delay val sendTime = System.currentTimeMillis() + delay val message = insertSentSms(subId, threadId, addresses.first(), strippedBody, sendTime) diff --git a/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt b/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt index dbb79612..d783e024 100644 --- a/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt +++ b/domain/src/main/java/com/moez/QKSMS/util/Preferences.kt @@ -109,6 +109,7 @@ class Preferences @Inject constructor( val signature = rxPrefs.getString("signature", "") val unicode = rxPrefs.getBoolean("unicode", false) val mobileOnly = rxPrefs.getBoolean("mobileOnly", false) + val longAsMms = rxPrefs.getBoolean("longAsMms", false) val mmsSize = rxPrefs.getInteger("mmsSize", 300) val logging = rxPrefs.getBoolean("logging", false) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt index 083abd8c..d035766e 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsController.kt @@ -168,6 +168,7 @@ class SettingsController : QkController newState { copy(mobileOnly = enabled) } } + disposables += prefs.longAsMms.asObservable() + .subscribe { enabled -> newState { copy(longAsMms = enabled) } } + val mmsSizeLabels = context.resources.getStringArray(R.array.mms_sizes) val mmsSizeIds = context.resources.getIntArray(R.array.mms_sizes_ids) disposables += prefs.mmsSize.asObservable() @@ -175,6 +178,8 @@ class SettingsPresenter @Inject constructor( R.id.mobileOnly -> prefs.mobileOnly.set(!prefs.mobileOnly.get()) + R.id.longAsMms -> prefs.longAsMms.set(!prefs.longAsMms.get()) + R.id.mmsSize -> view.showMmsSizePicker() R.id.sync -> syncMessages.execute(Unit) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsState.kt b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsState.kt index 1119b737..f18ccd80 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsState.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/settings/SettingsState.kt @@ -41,6 +41,7 @@ data class SettingsState( val splitSmsEnabled: Boolean = false, val stripUnicodeEnabled: Boolean = false, val mobileOnly: Boolean = false, + val longAsMms: Boolean = false, val maxMmsSizeSummary: String = "100KB", val maxMmsSizeId: Int = 100, val syncProgress: SyncRepository.SyncProgress = SyncRepository.SyncProgress.Idle diff --git a/presentation/src/main/res/drawable/ic_message_black_24dp.xml b/presentation/src/main/res/drawable/ic_message_black_24dp.xml new file mode 100644 index 00000000..d2876bfa --- /dev/null +++ b/presentation/src/main/res/drawable/ic_message_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/presentation/src/main/res/layout/settings_controller.xml b/presentation/src/main/res/layout/settings_controller.xml index 8e34c5e9..0ae7a8cf 100644 --- a/presentation/src/main/res/layout/settings_controller.xml +++ b/presentation/src/main/res/layout/settings_controller.xml @@ -177,6 +177,15 @@ app:title="@string/settings_mobile_title" app:widget="@layout/settings_switch_widget" /> + + Remove accents from characters in outgoing SMS messages Mobile numbers only When composing a message, only show mobile numbers + Send long messages as MMS + If your longer text messages are failing to send, or sending in the wrong order, you can send them as MMS messages instead. Additional charges may apply Auto-compress MMS attachments Sync messages Re-sync your messages with the native Android SMS database