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 c8d6949e..b421f16d 100644
--- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/SettingsActivity.kt
@@ -13,6 +13,10 @@ import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.RadioItem
import com.simplemobiletools.smsmessenger.R
import com.simplemobiletools.smsmessenger.extensions.config
+import com.simplemobiletools.smsmessenger.extensions.getConfigurationText
+import com.simplemobiletools.smsmessenger.helpers.CONFIGURE_NAME
+import com.simplemobiletools.smsmessenger.helpers.CONFIGURE_NAME_AND_MESSAGE
+import com.simplemobiletools.smsmessenger.helpers.CONFIGURE_NO_DETAILS
import com.simplemobiletools.smsmessenger.helpers.refreshMessages
import kotlinx.android.synthetic.main.activity_settings.*
import java.util.*
@@ -35,6 +39,7 @@ class SettingsActivity : SimpleActivity() {
setupChangeDateTimeFormat()
setupFontSize()
setupShowCharacterCounter()
+ setupConfigureNotification()
updateTextColors(settings_scrollview)
if (blockedNumbersAtPause != -1 && blockedNumbersAtPause != getBlockedNumbers().hashCode()) {
@@ -116,4 +121,20 @@ class SettingsActivity : SimpleActivity() {
config.showCharacterCounter = settings_show_character_counter.isChecked
}
}
+
+ private fun setupConfigureNotification() {
+ settings_configure_notification_type.text = getConfigurationText(config.notificationSetting)
+ settings_configure_notification.setOnClickListener {
+ val items = arrayListOf(
+ RadioItem(CONFIGURE_NAME_AND_MESSAGE, getString(R.string.configure_name_and_message)),
+ RadioItem(CONFIGURE_NAME, getString(R.string.configure_name)),
+ RadioItem(CONFIGURE_NO_DETAILS, getString(R.string.configure_no_details)),
+ )
+
+ RadioGroupDialog(this@SettingsActivity, items, config.notificationSetting) {
+ config.notificationSetting = it as Int
+ settings_configure_notification_type.text = getConfigurationText(config.notificationSetting)
+ }
+ }
+ }
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt
index b30cf279..fa7d0b3b 100644
--- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/extensions/Context.kt
@@ -706,20 +706,30 @@ fun Context.showMessageNotification(address: String, body: String, threadId: Lon
}
val largeIcon = bitmap ?: SimpleContactsHelper(this).getContactLetterIcon(sender)
- val builder = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL)
- .setContentTitle(sender)
- .setContentText(body)
- .setColor(config.primaryColor)
- .setSmallIcon(R.drawable.ic_messenger)
- .setLargeIcon(largeIcon)
- .setStyle(NotificationCompat.BigTextStyle().setSummaryText(summaryText).bigText(body))
- .setContentIntent(pendingIntent)
- .setPriority(NotificationCompat.PRIORITY_MAX)
- .setDefaults(Notification.DEFAULT_LIGHTS)
- .setCategory(Notification.CATEGORY_MESSAGE)
- .setAutoCancel(true)
- .setSound(soundUri, AudioManager.STREAM_NOTIFICATION)
- if (replyAction != null) {
+ val builder = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL).apply {
+ when (config.notificationSetting) {
+ CONFIGURE_NAME_AND_MESSAGE -> {
+ this.setContentTitle(sender)
+ this.setLargeIcon(largeIcon)
+ this.setContentText(body)
+ }
+ CONFIGURE_NAME -> {
+ this.setContentTitle(sender)
+ this.setLargeIcon(largeIcon)
+ }
+ }
+ this.color = config.primaryColor
+ this.setSmallIcon(R.drawable.ic_messenger)
+ this.setStyle(NotificationCompat.BigTextStyle().setSummaryText(summaryText).bigText(body))
+ this.setContentIntent(pendingIntent)
+ this.priority = NotificationCompat.PRIORITY_MAX
+ this.setDefaults(Notification.DEFAULT_LIGHTS)
+ this.setCategory(Notification.CATEGORY_MESSAGE)
+ this.setAutoCancel(true)
+ this.setSound(soundUri, AudioManager.STREAM_NOTIFICATION)
+ }
+
+ if (replyAction != null && config.notificationSetting == CONFIGURE_NAME_AND_MESSAGE) {
builder.addAction(replyAction)
}
builder.addAction(R.drawable.ic_check_vector, getString(R.string.mark_as_read), markAsReadPendingIntent)
@@ -727,3 +737,9 @@ fun Context.showMessageNotification(address: String, body: String, threadId: Lon
notificationManager.notify(threadId.hashCode(), builder.build())
}
+
+fun Context.getConfigurationText(type: Int) = getString(when (type) {
+ CONFIGURE_NAME_AND_MESSAGE -> R.string.configure_name_and_message
+ CONFIGURE_NAME -> R.string.configure_name
+ else -> R.string.configure_no_details
+})
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 451fe60f..ed65e60c 100644
--- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Config.kt
@@ -17,4 +17,8 @@ class Config(context: Context) : BaseConfig(context) {
var showCharacterCounter: Boolean
get() = prefs.getBoolean(SHOW_CHARACTER_COUNTER, false)
set(showCharacterCounter) = prefs.edit().putBoolean(SHOW_CHARACTER_COUNTER, showCharacterCounter).apply()
+
+ var notificationSetting: Int
+ get() = prefs.getInt(CONFIGURATION_NOTIFICATION_SETTING, CONFIGURE_NAME_AND_MESSAGE)
+ set(size) = prefs.edit().putInt(CONFIGURATION_NOTIFICATION_SETTING, size).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 1705773f..11425c0a 100644
--- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/helpers/Constants.kt
@@ -12,6 +12,7 @@ const val THREAD_ATTACHMENT_URIS = "thread_attachment_uris"
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 CONFIGURATION_NOTIFICATION_SETTING = "configuration_notification_setting"
private const val PATH = "com.simplemobiletools.smsmessenger.action."
const val MARK_AS_READ = PATH + "mark_as_read"
@@ -25,6 +26,11 @@ const val THREAD_SENT_MESSAGE_ERROR = 4
const val THREAD_SENT_MESSAGE_SUCCESS = 5
const val THREAD_SENT_MESSAGE_SENDING = 6
+// configure notification setting constants
+const val CONFIGURE_NAME_AND_MESSAGE = 1
+const val CONFIGURE_NAME = 2
+const val CONFIGURE_NO_DETAILS = 3
+
fun refreshMessages() {
EventBus.getDefault().post(Events.RefreshMessages())
}
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index c71368f9..73b74258 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -172,5 +172,36 @@
app:switchPadding="@dimen/medium_margin" />
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c40c26d6..990ae0d5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -15,6 +15,12 @@
Sender doesn\'t support replies
Draft
Sending…
+ Configure Notification
+
+
+ Name and Message
+ Name
+ No Details
New conversation