Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions domain/src/main/java/com/moez/QKSMS/util/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class Preferences @Inject constructor(
val swipeLeft = rxPrefs.getInteger("swipeLeft", SWIPE_ACTION_ARCHIVE)
val autoEmoji = rxPrefs.getBoolean("autoEmoji", true)
val delivery = rxPrefs.getBoolean("delivery", false)
val messageSound = rxPrefs.getBoolean("messageSound", false)
val signature = rxPrefs.getString("signature", "")
val unicode = rxPrefs.getBoolean("unicode", false)
val mobileOnly = rxPrefs.getBoolean("mobileOnly", false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
package com.moez.QKSMS.feature.compose

import android.content.Context
import android.media.AudioManager
import android.media.MediaPlayer
import android.net.Uri
import android.os.Vibrator
import android.provider.ContactsContract
import android.telephony.SmsMessage
import android.util.Log
import androidx.core.content.getSystemService
import com.moez.QKSMS.R
import com.moez.QKSMS.common.Navigator
Expand Down Expand Up @@ -112,6 +115,7 @@ class ComposeViewModel @Inject constructor(
private val searchSelection: Subject<Long> = BehaviorSubject.createDefault(-1)

private var shouldShowContacts = threadId == 0L && addresses.isEmpty()
var audioPlayer: MediaPlayer? = null

init {
val initialConversation = threadId.takeIf { it != 0L }
Expand Down Expand Up @@ -653,6 +657,13 @@ class ComposeViewModel @Inject constructor(
}
val sendAsGroup = !state.editingMode || state.sendAsGroup

//check if outgoing message sound is enabled then play sent sound every time user send messages
if (prefs.messageSound.get()) {
audioPlayer = MediaPlayer.create(context, R.raw.sentsound)
audioPlayer?.setAudioStreamType(AudioManager.STREAM_MUSIC)
audioPlayer?.isLooping = false
audioPlayer?.start()
}
when {
// Scheduling a message
state.scheduled != 0L -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class SettingsController : QkController<SettingsView, SettingsState, SettingsPre

delivery.checkbox.isChecked = state.deliveryEnabled

outgoing_message_sound.checkbox.isChecked = state.messageSoundEnabled

signature.summary = state.signature.takeIf { it.isNotBlank() }
?: context.getString(R.string.settings_signature_summary)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class SettingsPresenter @Inject constructor(
disposables += prefs.delivery.asObservable()
.subscribe { enabled -> newState { copy(deliveryEnabled = enabled) } }

disposables += prefs.messageSound.asObservable()
.subscribe { enabled -> newState { copy(messageSoundEnabled = enabled) } }

disposables += prefs.signature.asObservable()
.subscribe { signature -> newState { copy(signature = signature) } }

Expand Down Expand Up @@ -178,6 +181,8 @@ class SettingsPresenter @Inject constructor(

R.id.delivery -> prefs.delivery.set(!prefs.delivery.get())

R.id.outgoing_message_sound -> prefs.messageSound.set(!prefs.messageSound.get())

R.id.signature -> view.showSignatureDialog(prefs.signature.get())

R.id.textSize -> view.showTextSizePicker()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ data class SettingsState(
val sendDelaySummary: String = "",
val sendDelayId: Int = 0,
val deliveryEnabled: Boolean = false,
val messageSoundEnabled: Boolean = false,
val signature: String = "",
val textSizeSummary: String = "",
val textSizeId: Int = Preferences.TEXT_SIZE_NORMAL,
Expand Down
5 changes: 5 additions & 0 deletions presentation/src/main/res/drawable/ic_outgoing_sound.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,3v10.55c-0.59,-0.34 -1.27,-0.55 -2,-0.55 -2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4V7h4V3h-6z"/>
</vector>
8 changes: 8 additions & 0 deletions presentation/src/main/res/layout/settings_controller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@
app:summary="@string/settings_swipe_actions_summary"
app:title="@string/settings_swipe_actions" />

<com.moez.QKSMS.common.widget.PreferenceView
android:id="@+id/outgoing_message_sound"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:icon="@drawable/ic_outgoing_sound"
app:title="@string/outgoing_message_sound"
app:widget="@layout/settings_switch_widget" />

<com.moez.QKSMS.common.widget.PreferenceView
android:id="@+id/delivery"
android:layout_width="match_parent"
Expand Down
Binary file added presentation/src/main/res/raw/sentsound.mp3
Binary file not shown.
1 change: 1 addition & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
<item>Mark unread</item>
</string-array>
<string name="settings_delivery_title">Delivery confirmations</string>
<string name="outgoing_message_sound">Hear outgoing message sounds</string>
<string name="settings_delivery_summary">Confirm that messages were sent successfully</string>
<string name="settings_signature_title">Signature</string>
<string name="settings_signature_summary">Add a signature to the end of your messages</string>
Expand Down