Bring back setting to disable voice message recorder button

Change-Id: I81d647796b82e2034383278da7b169795a092f2e
This commit is contained in:
SpiritCroc 2021-08-12 09:22:35 +02:00
parent 033c3f7792
commit 8892248071
4 changed files with 19 additions and 4 deletions

View File

@ -989,7 +989,7 @@ class RoomDetailFragment @Inject constructor(
autoCompleter.exitSpecialMode() autoCompleter.exitSpecialMode()
views.composerLayout.collapse() views.composerLayout.collapse()
views.voiceMessageRecorderView.isVisible = text.isBlank() views.voiceMessageRecorderView.isVisible = text.isBlank() && vectorPreferences.useVoiceMessage()
updateComposerText(text) updateComposerText(text)
views.composerLayout.views.sendButton.contentDescription = getString(R.string.send) views.composerLayout.views.sendButton.contentDescription = getString(R.string.send)
@ -1330,7 +1330,7 @@ class RoomDetailFragment @Inject constructor(
} }
override fun onTextBlankStateChanged(isBlank: Boolean) { override fun onTextBlankStateChanged(isBlank: Boolean) {
if (!views.composerLayout.views.sendButton.isVisible) { if (!views.composerLayout.views.sendButton.isVisible && vectorPreferences.useVoiceMessage()) {
// Animate alpha to prevent overlapping with the animation of the send button // Animate alpha to prevent overlapping with the animation of the send button
views.voiceMessageRecorderView.alpha = 0f views.voiceMessageRecorderView.alpha = 0f
views.voiceMessageRecorderView.isVisible = true views.voiceMessageRecorderView.isVisible = true
@ -1403,10 +1403,10 @@ class RoomDetailFragment @Inject constructor(
if (state.canSendMessage) { if (state.canSendMessage) {
if (!views.voiceMessageRecorderView.isActive()) { if (!views.voiceMessageRecorderView.isActive()) {
views.composerLayout.isVisible = true views.composerLayout.isVisible = true
views.voiceMessageRecorderView.isVisible = views.composerLayout.text?.isBlank().orFalse() views.voiceMessageRecorderView.isVisible = vectorPreferences.useVoiceMessage() && views.composerLayout.text?.isBlank().orFalse()
views.composerLayout.setRoomEncrypted(summary.isEncrypted) views.composerLayout.setRoomEncrypted(summary.isEncrypted)
views.notificationAreaView.render(NotificationAreaView.State.Hidden) views.notificationAreaView.render(NotificationAreaView.State.Hidden)
views.composerLayout.alwaysShowSendButton = false views.composerLayout.alwaysShowSendButton = !vectorPreferences.useVoiceMessage()
} }
} else { } else {
views.composerLayout.isVisible = false views.composerLayout.isVisible = false

View File

@ -202,6 +202,7 @@ class VectorPreferences @Inject constructor(private val context: Context) {
private const val SETTINGS_USER_COLOR_MODE_DEFAULT = "SETTINGS_USER_COLOR_MODE_DEFAULT" private const val SETTINGS_USER_COLOR_MODE_DEFAULT = "SETTINGS_USER_COLOR_MODE_DEFAULT"
private const val SETTINGS_USER_COLOR_MODE_PUBLIC_ROOM = "SETTINGS_USER_COLOR_MODE_PUBLIC_ROOM" private const val SETTINGS_USER_COLOR_MODE_PUBLIC_ROOM = "SETTINGS_USER_COLOR_MODE_PUBLIC_ROOM"
private const val SETTINGS_OPEN_CHATS_AT_FIRST_UNREAD = "SETTINGS_OPEN_CHATS_AT_FIRST_UNREAD" private const val SETTINGS_OPEN_CHATS_AT_FIRST_UNREAD = "SETTINGS_OPEN_CHATS_AT_FIRST_UNREAD"
private const val SETTINGS_VOICE_MESSAGE = "SETTINGS_VOICE_MESSAGE"
private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH" private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH"
@ -1001,6 +1002,11 @@ class VectorPreferences @Inject constructor(private val context: Context) {
return defaultPrefs.getBoolean(SETTINGS_OPEN_CHATS_AT_FIRST_UNREAD, false) return defaultPrefs.getBoolean(SETTINGS_OPEN_CHATS_AT_FIRST_UNREAD, false)
} }
// Element removed this, SC added it back (but this time, default to true)
fun useVoiceMessage(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_VOICE_MESSAGE, true)
}
/** /**
* The user enable protecting app access with pin code. * The user enable protecting app access with pin code.
* Currently we use the pin code store to know if the pin is enabled, so this is not used * Currently we use the pin code store to know if the pin is enabled, so this is not used

View File

@ -87,6 +87,9 @@
<string name="settings_open_chats_at_first_unread">Open at first unread</string> <string name="settings_open_chats_at_first_unread">Open at first unread</string>
<string name="settings_open_chats_at_first_unread_summary">Open chats at the first unread message instead of at the bottom.</string> <string name="settings_open_chats_at_first_unread_summary">Open chats at the first unread message instead of at the bottom.</string>
<string name="settings_show_voice_message_recorder_ui">Voice messages</string>
<string name="settings_show_voice_message_recorder_ui_summary">Show a button to record voice messages</string>
<!-- Accent colors --> <!-- Accent colors -->
<string name="sc_accent_greenlight">Light green</string> <string name="sc_accent_greenlight">Light green</string>
<string name="sc_accent_greendark">Dark green</string> <string name="sc_accent_greendark">Dark green</string>

View File

@ -63,6 +63,12 @@
android:key="SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY" android:key="SETTINGS_LABS_ENABLE_SWIPE_TO_REPLY"
android:title="@string/labs_swipe_to_reply_in_timeline" /> android:title="@string/labs_swipe_to_reply_in_timeline" />
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="true"
android:key="SETTINGS_VOICE_MESSAGE"
android:title="@string/settings_show_voice_message_recorder_ui"
android:summary="@string/settings_show_voice_message_recorder_ui_summary" />
<im.vector.app.core.preference.VectorSwitchPreference <im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB" android:key="SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB"