mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 08:23:00 +01:00
Guard auto-lower hand behind labs.
This commit is contained in:
committed by
Cody Henthorne
parent
9594599d60
commit
e657a4adf3
@@ -11,4 +11,5 @@ sealed interface LabsSettingsEvents {
|
||||
data class ToggleIncognito(val enabled: Boolean) : LabsSettingsEvents
|
||||
data class ToggleGroupSuggestionsForMembers(val enabled: Boolean) : LabsSettingsEvents
|
||||
data class ToggleBetterSearch(val enabled: Boolean) : LabsSettingsEvents
|
||||
data class ToggleAutoLowerHand(val enabled: Boolean) : LabsSettingsEvents
|
||||
}
|
||||
|
||||
@@ -133,6 +133,15 @@ private fun LabsSettingsContent(
|
||||
onCheckChanged = { onEvent(LabsSettingsEvents.ToggleBetterSearch(it)) }
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
Rows.ToggleRow(
|
||||
checked = state.autoLowerHand,
|
||||
text = "Auto Lower Hand Suggestion",
|
||||
label = "Show a prompt to lower your raised hand when you are speaking in a group call.",
|
||||
onCheckChanged = { onEvent(LabsSettingsEvents.ToggleAutoLowerHand(it)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,5 +13,6 @@ data class LabsSettingsState(
|
||||
val storyArchive: Boolean = false,
|
||||
val incognito: Boolean = false,
|
||||
val groupSuggestionsForMembers: Boolean = false,
|
||||
val betterSearch: Boolean = false
|
||||
val betterSearch: Boolean = false,
|
||||
val autoLowerHand: Boolean = false
|
||||
)
|
||||
|
||||
@@ -37,6 +37,10 @@ class LabsSettingsViewModel : ViewModel() {
|
||||
SignalStore.labs.betterSearch = event.enabled
|
||||
_state.value = _state.value.copy(betterSearch = event.enabled)
|
||||
}
|
||||
is LabsSettingsEvents.ToggleAutoLowerHand -> {
|
||||
SignalStore.labs.autoLowerHand = event.enabled
|
||||
_state.value = _state.value.copy(autoLowerHand = event.enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +50,8 @@ class LabsSettingsViewModel : ViewModel() {
|
||||
storyArchive = SignalStore.labs.storyArchive,
|
||||
incognito = SignalStore.labs.incognito,
|
||||
groupSuggestionsForMembers = SignalStore.labs.groupSuggestionsForMembers,
|
||||
betterSearch = SignalStore.labs.betterSearch
|
||||
betterSearch = SignalStore.labs.betterSearch,
|
||||
autoLowerHand = SignalStore.labs.autoLowerHand
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,11 +217,11 @@ private fun getSnackbarText(state: RaiseHandState): String {
|
||||
|
||||
val shouldDisplayLowerYourHand = remember(state) {
|
||||
val now = System.currentTimeMillis().milliseconds
|
||||
val hasUnexpiredSelf = state.raisedHands.any { it.sender.isSelf && it.sender.isPrimary && it.getCollapseTimestamp() >= now }
|
||||
val hasSelfRaisedHand = state.raisedHands.any { it.sender.isSelf && it.sender.isPrimary }
|
||||
val expiration = state.speechEvent?.getCollapseTimestamp() ?: Duration.ZERO
|
||||
val isUnexpired = expiration >= now
|
||||
|
||||
state.speechEvent?.speechEvent == GroupCall.SpeechEvent.LOWER_HAND_SUGGESTION && isUnexpired && hasUnexpiredSelf
|
||||
state.speechEvent?.speechEvent == GroupCall.SpeechEvent.LOWER_HAND_SUGGESTION && isUnexpired && hasSelfRaisedHand
|
||||
}
|
||||
|
||||
if (shouldDisplayLowerYourHand && state.isExpanded) {
|
||||
|
||||
@@ -9,6 +9,7 @@ class LabsValues internal constructor(store: KeyValueStore) : SignalStoreValues(
|
||||
const val INCOGNITO: String = "labs.incognito"
|
||||
const val GROUP_SUGGESTIONS_FOR_MEMBERS: String = "labs.group_suggestions_for_members"
|
||||
const val BETTER_SEARCH: String = "labs.better_search"
|
||||
const val AUTO_LOWER_HAND: String = "labs.auto_lower_hand"
|
||||
}
|
||||
|
||||
public override fun onFirstEverAppLaunch() = Unit
|
||||
@@ -25,6 +26,8 @@ class LabsValues internal constructor(store: KeyValueStore) : SignalStoreValues(
|
||||
|
||||
var betterSearch by booleanValue(BETTER_SEARCH, true).falseForExternalUsers()
|
||||
|
||||
var autoLowerHand by booleanValue(AUTO_LOWER_HAND, true).falseForExternalUsers()
|
||||
|
||||
private fun SignalStoreValueDelegate<Boolean>.falseForExternalUsers(): SignalStoreValueDelegate<Boolean> {
|
||||
return this.map { actualValue -> RemoteConfig.internalUser && actualValue }
|
||||
}
|
||||
|
||||
@@ -383,6 +383,10 @@ public class GroupConnectedActionProcessor extends GroupActionProcessor {
|
||||
protected @NonNull WebRtcServiceState handleGroupCallSpeechEvent(@NonNull WebRtcServiceState currentState, @NonNull GroupCall.SpeechEvent speechEvent) {
|
||||
Log.i(tag, "handleGroupCallSpeechEvent :: " + speechEvent.name());
|
||||
|
||||
if (!SignalStore.labs().getAutoLowerHand()) {
|
||||
return currentState;
|
||||
}
|
||||
|
||||
return currentState.builder()
|
||||
.changeCallInfoState()
|
||||
.setGroupCallSpeechEvent(new GroupCallSpeechEvent(speechEvent))
|
||||
|
||||
Reference in New Issue
Block a user