From bb7178bee65838fb3d809a7fe5f054d263433fe7 Mon Sep 17 00:00:00 2001 From: Paul Akhamiogu Date: Wed, 25 Aug 2021 17:17:21 +0100 Subject: [PATCH 1/2] Add setting for enabling/disabling delivery report --- .../activities/SettingsActivity.kt | 9 ++++++++ .../smsmessenger/activities/ThreadActivity.kt | 2 +- .../smsmessenger/helpers/Config.kt | 4 ++++ .../smsmessenger/helpers/Constants.kt | 1 + app/src/main/res/layout/activity_settings.xml | 23 +++++++++++++++++++ app/src/main/res/values-nl/strings.xml | 2 +- 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/SettingsActivity.kt index 809190d6..96f7f99e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/SettingsActivity.kt @@ -40,6 +40,7 @@ class SettingsActivity : SimpleActivity() { setupChangeDateTimeFormat() setupFontSize() setupShowCharacterCounter() + setupEnableDeliveryReports() setupLockScreenVisibility() updateTextColors(settings_scrollview) @@ -131,6 +132,14 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupEnableDeliveryReports() { + settings_enable_delivery_reports.isChecked = config.enableDeliveryReports + settings_enable_delivery_reports_holder.setOnClickListener { + settings_enable_delivery_reports.toggle() + config.enableDeliveryReports = settings_enable_delivery_reports.isChecked + } + } + private fun setupLockScreenVisibility() { settings_lock_screen_visibility.text = getLockScreenVisibilityText(config.lockScreenVisibilitySetting) settings_lock_screen_visibility_holder.setOnClickListener { diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt index 5e601968..674e66e1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt @@ -660,7 +660,7 @@ class ThreadActivity : SimpleActivity() { val settings = Settings() settings.useSystemSending = true - settings.deliveryReports = true + settings.deliveryReports = config.enableDeliveryReports val SIMId = availableSIMCards.getOrNull(currentSIMCardIndex)?.subscriptionId if (SIMId != null) { diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt index 7b767cd3..91cf88f6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt @@ -18,6 +18,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(SHOW_CHARACTER_COUNTER, false) set(showCharacterCounter) = prefs.edit().putBoolean(SHOW_CHARACTER_COUNTER, showCharacterCounter).apply() + var enableDeliveryReports: Boolean + get() = prefs.getBoolean(ENABLE_DELIVERY_REPORTS, true) + set(showCharacterCounter) = prefs.edit().putBoolean(ENABLE_DELIVERY_REPORTS, showCharacterCounter).apply() + var lockScreenVisibilitySetting: Int get() = prefs.getInt(LOCK_SCREEN_VISIBILITY, LOCK_SCREEN_SENDER_MESSAGE) set(lockScreenVisibilitySetting) = prefs.edit().putInt(LOCK_SCREEN_VISIBILITY, lockScreenVisibilitySetting).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt index f73c12e0..7ed017ca 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt @@ -14,6 +14,7 @@ const val USE_SIM_ID_PREFIX = "use_sim_id_" const val NOTIFICATION_CHANNEL = "simple_sms_messenger" const val SHOW_CHARACTER_COUNTER = "show_character_counter" const val LOCK_SCREEN_VISIBILITY = "lock_screen_visibility" +const val ENABLE_DELIVERY_REPORTS = "enable_delivery_reports" private const val PATH = "com.simplemobiletools.smsmessenger.action." const val MARK_AS_READ = PATH + "mark_as_read" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 7e778ed3..859fdf00 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -195,6 +195,29 @@ + + + + + + Meldingen op vergrendelscherm - Afzender en bericht/string> + Afzender en bericht Alleen afzender Bezorgingsrapporten inschakelen From 2ecca969f13c389de53207d99c3014c59c2aee87 Mon Sep 17 00:00:00 2001 From: Tibor Kaputa Date: Wed, 25 Aug 2021 18:44:45 +0200 Subject: [PATCH 2/2] Update Config.kt --- .../kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt index 91cf88f6..e284b832 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt @@ -20,7 +20,7 @@ class Config(context: Context) : BaseConfig(context) { var enableDeliveryReports: Boolean get() = prefs.getBoolean(ENABLE_DELIVERY_REPORTS, true) - set(showCharacterCounter) = prefs.edit().putBoolean(ENABLE_DELIVERY_REPORTS, showCharacterCounter).apply() + set(enableDeliveryReports) = prefs.edit().putBoolean(ENABLE_DELIVERY_REPORTS, enableDeliveryReports).apply() var lockScreenVisibilitySetting: Int get() = prefs.getInt(LOCK_SCREEN_VISIBILITY, LOCK_SCREEN_SENDER_MESSAGE)