Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/strings updates #1659

Merged
merged 37 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f241328
Fixing styling issue in unread scroll to bottom button
ThomasSession Sep 2, 2024
32acd6e
Fixing up styling of Prominent buttons and "view_user" to work better…
ThomasSession Sep 2, 2024
28d59f9
Fixing strings
ThomasSession Sep 2, 2024
ea24ff6
Strings fixes
ThomasSession Sep 3, 2024
97db1fe
Reworked preferences
ThomasSession Sep 3, 2024
2704bc7
Updated the fake message in appearance
ThomasSession Sep 3, 2024
4aa68c9
Adding the ability to copy in message details
ThomasSession Sep 3, 2024
4d47354
Showing 'copy account id' in menu in 1to1 too
ThomasSession Sep 3, 2024
ffbb7d8
Updating files tab in "All media"
ThomasSession Sep 3, 2024
2f4c605
Strings updates
ThomasSession Sep 4, 2024
81f56de
Latest strings and handling bold
ThomasSession Sep 4, 2024
86f89f8
Updated constants file
ThomasSession Sep 4, 2024
d7bd0bf
Can save media in message details page now
ThomasSession Sep 4, 2024
bc067b6
Adding padding so that context menu doesn't hit the bottom of the screen
ThomasSession Sep 4, 2024
3db8b46
Strings update
ThomasSession Sep 4, 2024
7f8e9fd
Reverted changes on DMs
ThomasSession Sep 4, 2024
14207c7
Better ripple for home FAB
ThomasSession Sep 5, 2024
2c3e73b
Added a control message when the current user accepts a message request
ThomasSession Sep 5, 2024
a7843af
Updated QR screen to show dialog when permission is permanently denied
ThomasSession Sep 5, 2024
fa90b74
Using the Compose version of our QR scanning
ThomasSession Sep 5, 2024
4fd3961
Comments for future changes in JoinCommunityFragment
ThomasSession Sep 5, 2024
139f4ba
New strings + new camera permission handling
ThomasSession Sep 5, 2024
5795998
Making sure we do not crash when making/receiving a call without the …
ThomasSession Sep 2, 2024
4860adc
Added a new control message type to handle missed calls due to permis…
ThomasSession Sep 2, 2024
f44d066
Changed the missed call control message logic
ThomasSession Sep 2, 2024
2174976
Do not change the text color on emioji picker
ThomasSession Sep 6, 2024
aef0adb
[SES-2695] Incorrect message request approval on home screen
Sep 6, 2024
c38efc2
WIP for new avatar selection
ThomasSession Sep 6, 2024
c633338
Merge branch 'feature/strings-updates' of https://github.com/oxen-io/…
ThomasSession Sep 8, 2024
c0bf015
SES-2651 - New avatar picker
ThomasSession Sep 8, 2024
422b8b2
Fixing the remaining tasks
ThomasSession Sep 9, 2024
ae64189
Differentiating between voice notes and regular audio
ThomasSession Sep 9, 2024
4e2cef6
Fixing 'Leave group dialog' from inside the group settings
ThomasSession Sep 9, 2024
1761024
SES-2692 only save valid media in message details
ThomasSession Sep 9, 2024
87e3f93
SES-2675 - Standardisingdenied mic permission
ThomasSession Sep 9, 2024
85161ff
PR comment
ThomasSession Sep 9, 2024
83b08cc
Fixing Camera permissions
ThomasSession Sep 9, 2024
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
457 changes: 233 additions & 224 deletions app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DisappearingMessagesViewModel(

init {
viewModelScope.launch {
val expiryMode = storage.getExpirationConfiguration(threadId)?.expiryMode?.maybeConvertToLegacy(isNewConfigEnabled) ?: ExpiryMode.NONE
val expiryMode = storage.getExpirationConfiguration(threadId)?.expiryMode ?: ExpiryMode.NONE
val recipient = threadDb.getRecipientForThreadId(threadId)
val groupRecord = recipient?.takeIf { it.isClosedGroupRecipient }
?.run { groupDb.getGroup(address.toGroupString()).orNull() }
Expand All @@ -80,7 +80,7 @@ class DisappearingMessagesViewModel(

override fun onSetClick() = viewModelScope.launch {
val state = _state.value
val mode = state.expiryMode?.coerceLegacyToAfterSend()
val mode = state.expiryMode
val address = state.address
if (address == null || mode == null) {
_event.send(Event.FAIL)
Expand All @@ -92,8 +92,6 @@ class DisappearingMessagesViewModel(
_event.send(Event.SUCCESS)
}

private fun ExpiryMode.coerceLegacyToAfterSend() = takeUnless { it is ExpiryMode.Legacy } ?: ExpiryMode.AfterSend(expirySeconds)

@dagger.assisted.AssistedFactory
interface AssistedFactory {
fun create(threadId: Long): Factory
Expand Down Expand Up @@ -125,5 +123,3 @@ class DisappearingMessagesViewModel(
) as T
}
}

private fun ExpiryMode.maybeConvertToLegacy(isNewConfigEnabled: Boolean): ExpiryMode = takeIf { isNewConfigEnabled } ?: ExpiryMode.Legacy(expirySeconds)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class State(
val isSelfAdmin: Boolean = true,
val address: Address? = null,
val isNoteToSelf: Boolean = false,
val expiryMode: ExpiryMode? = null,
val expiryMode: ExpiryMode = ExpiryMode.NONE,
val isNewConfigEnabled: Boolean = true,
val persistedMode: ExpiryMode? = null,
val showDebugOptions: Boolean = false
Expand All @@ -30,16 +30,10 @@ data class State(

val typeOptionsHidden get() = isNoteToSelf || (isGroup && isNewConfigEnabled)

val nextType get() = when {
expiryType == ExpiryType.AFTER_READ -> ExpiryType.AFTER_READ
isNewConfigEnabled -> ExpiryType.AFTER_SEND
else -> ExpiryType.LEGACY
}

val duration get() = expiryMode?.duration
val expiryType get() = expiryMode?.type
val duration get() = expiryMode.duration
val expiryType get() = expiryMode.type

val isTimeOptionsEnabled = isNoteToSelf || isSelfAdmin && (isNewConfigEnabled || expiryType == ExpiryType.LEGACY)
val isTimeOptionsEnabled = isNoteToSelf || isSelfAdmin && isNewConfigEnabled
}


Expand All @@ -54,11 +48,6 @@ enum class ExpiryType(
R.string.off,
contentDescription = R.string.AccessibilityId_disappearingMessagesOff,
),
LEGACY(
ExpiryMode::Legacy,
R.string.expiration_type_disappear_legacy,
contentDescription = R.string.AccessibilityId_disappearingMessagesLegacy
),
AFTER_READ(
ExpiryMode::AfterRead,
R.string.disappearingMessagesDisappearAfterRead,
Expand All @@ -83,7 +72,6 @@ enum class ExpiryType(
}

val ExpiryMode.type: ExpiryType get() = when(this) {
is ExpiryMode.Legacy -> ExpiryType.LEGACY
is ExpiryMode.AfterSend -> ExpiryType.AFTER_SEND
is ExpiryMode.AfterRead -> ExpiryType.AFTER_READ
else -> ExpiryType.NONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ fun State.toUiState() = UiState(
private fun State.typeOptions(): List<ExpiryRadioOption>? = if (typeOptionsHidden) null else {
buildList {
add(offTypeOption())
if (!isNewConfigEnabled) add(legacyTypeOption())
if (!isGroup) add(afterReadTypeOption())
add(afterSendTypeOption())
}
Expand All @@ -33,7 +32,7 @@ private fun State.timeOptions(): List<ExpiryRadioOption>? {
// Don't show times card if we have a types card, and type is off.
if (!typeOptionsHidden && expiryType == ExpiryType.NONE) return null

return nextType.let { type ->
return expiryType.let { type ->
when (type) {
ExpiryType.AFTER_READ -> afterReadTimes
else -> afterSendTimes
Expand All @@ -48,7 +47,6 @@ private fun State.timeOptions(): List<ExpiryRadioOption>? {
}

private fun State.offTypeOption() = typeOption(ExpiryType.NONE)
private fun State.legacyTypeOption() = typeOption(ExpiryType.LEGACY)
private fun State.afterReadTypeOption() = newTypeOption(ExpiryType.AFTER_READ)
private fun State.afterSendTypeOption() = newTypeOption(ExpiryType.AFTER_SEND)
private fun State.newTypeOption(type: ExpiryType) = typeOption(type, isNewConfigEnabled && isSelfAdmin)
Expand All @@ -71,7 +69,7 @@ private fun debugModes(isDebug: Boolean, type: ExpiryType) =
debugTimes(isDebug).map { type.mode(it.inWholeSeconds) }

private fun State.debugOptions(): List<ExpiryRadioOption> =
debugModes(showDebugOptions, nextType).map { timeOption(it, subtitle = GetString("for testing purposes")) }
debugModes(showDebugOptions, expiryType).map { timeOption(it, subtitle = GetString("for testing purposes")) }

// Standard list of available disappearing message times
private val afterSendTimes = listOf(12.hours, 1.days, 7.days, 14.days)
Expand All @@ -96,6 +94,6 @@ private fun State.timeOption(
title = title,
subtitle = subtitle,
contentDescription = title,
selected = mode.duration == expiryMode?.duration,
selected = mode.duration == expiryMode.duration,
enabled = isTimeOptionsEnabled
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.ui.Callbacks
import org.thoughtcrime.securesms.ui.NoOpCallbacks
import org.thoughtcrime.securesms.ui.OptionsCard
import org.thoughtcrime.securesms.ui.RadioOption
import org.thoughtcrime.securesms.ui.components.PrimaryOutlineButton
import org.thoughtcrime.securesms.ui.components.SlimOutlineButton
import org.thoughtcrime.securesms.ui.contentDescription
import org.thoughtcrime.securesms.ui.fadingEdges
Expand Down Expand Up @@ -71,13 +72,15 @@ fun DisappearingMessages(
}
}

if (state.showSetButton) SlimOutlineButton(
stringResource(R.string.set),
modifier = Modifier
.contentDescription(R.string.AccessibilityId_setButton)
.align(Alignment.CenterHorizontally)
.padding(bottom = LocalDimensions.current.spacing),
onClick = callbacks::onSetClick
)
if (state.showSetButton){
PrimaryOutlineButton(
stringResource(R.string.set),
modifier = Modifier
.contentDescription(R.string.AccessibilityId_setButton)
.align(Alignment.CenterHorizontally)
.padding(bottom = LocalDimensions.current.spacing),
onClick = callbacks::onSetClick
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,18 @@ fun PreviewStates(
}

class StatePreviewParameterProvider : PreviewParameterProvider<State> {
override val values = newConfigValues.filter { it.expiryType != ExpiryType.LEGACY } + newConfigValues.map { it.copy(isNewConfigEnabled = false) }
override val values = newConfigValues + newConfigValues.map { it.copy(isNewConfigEnabled = false) }

private val newConfigValues get() = sequenceOf(
// new 1-1
State(expiryMode = ExpiryMode.NONE),
State(expiryMode = ExpiryMode.Legacy(43200)),
State(expiryMode = ExpiryMode.AfterRead(300)),
State(expiryMode = ExpiryMode.AfterSend(43200)),
// new group non-admin
State(isGroup = true, isSelfAdmin = false),
State(isGroup = true, isSelfAdmin = false, expiryMode = ExpiryMode.Legacy(43200)),
State(isGroup = true, isSelfAdmin = false, expiryMode = ExpiryMode.AfterSend(43200)),
// new group admin
State(isGroup = true),
State(isGroup = true, expiryMode = ExpiryMode.Legacy(43200)),
State(isGroup = true, expiryMode = ExpiryMode.AfterSend(43200)),
// new note-to-self
State(isNoteToSelf = true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ class VisibleMessageView : FrameLayout {
MessageStatusInfo(
R.drawable.ic_delivery_status_sending,
context.getColorFromAttr(R.attr.message_status_color),
R.string.messageStatusUploading
R.string.uploading
)
}
message.isSyncing || message.isResyncing ->
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/share_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:layout_width="wrap_content"
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/share"
android:text="@string/shareToSession"
android:fontFamily="sans-serif-medium"
android:textSize="@dimen/very_large_font_size"
android:layout_alignParentStart="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,45 +99,6 @@ class DisappearingMessagesViewModelTest {
)
}

@Test
fun `note to self, off, old config`() = runTest {
mock1on1(ExpiryMode.NONE, LOCAL_ADDRESS)

val viewModel = createViewModel(isNewConfigEnabled = false)

advanceUntilIdle()

assertThat(
viewModel.state.value
).isEqualTo(
State(
isGroup = false,
isSelfAdmin = true,
address = LOCAL_ADDRESS,
isNoteToSelf = true,
expiryMode = ExpiryMode.Legacy(0),
isNewConfigEnabled = false,
persistedMode = ExpiryMode.Legacy(0),
showDebugOptions = false
)
)

assertThat(
viewModel.uiState.value
).isEqualTo(
UiState(
OptionsCardData(
R.string.disappearingMessagesTimer,
typeOption(ExpiryMode.NONE, selected = false),
timeOption(ExpiryType.LEGACY, 12.hours),
timeOption(ExpiryType.LEGACY, 1.days),
timeOption(ExpiryType.LEGACY, 7.days),
timeOption(ExpiryType.LEGACY, 14.days)
)
)
)
}

@Test
fun `group, off, admin, new config`() = runTest {
mockGroup(ExpiryMode.NONE, isAdmin = true)
Expand Down Expand Up @@ -303,53 +264,6 @@ class DisappearingMessagesViewModelTest {
)
}

@Test
fun `1-1 conversation, 12 hours legacy, old config`() = runTest {
val time = 12.hours
val someAddress = Address.fromSerialized("05---SOME---ADDRESS")
mock1on1(ExpiryType.LEGACY.mode(time), someAddress)

val viewModel = createViewModel(isNewConfigEnabled = false)

advanceUntilIdle()

assertThat(
viewModel.state.value
).isEqualTo(
State(
isGroup = false,
isSelfAdmin = true,
address = someAddress,
isNoteToSelf = false,
expiryMode = ExpiryType.LEGACY.mode(12.hours),
isNewConfigEnabled = false,
persistedMode = ExpiryType.LEGACY.mode(12.hours),
showDebugOptions = false
)
)

assertThat(
viewModel.uiState.value
).isEqualTo(
UiState(
OptionsCardData(
R.string.disappearingMessagesDeleteType,
typeOption(ExpiryMode.NONE),
typeOption(time, ExpiryType.LEGACY, selected = true),
typeOption(12.hours, ExpiryType.AFTER_READ, enabled = false),
typeOption(1.days, ExpiryType.AFTER_SEND, enabled = false)
),
OptionsCardData(
R.string.disappearingMessagesTimer,
timeOption(ExpiryType.LEGACY, 12.hours, selected = true),
timeOption(ExpiryType.LEGACY, 1.days),
timeOption(ExpiryType.LEGACY, 7.days),
timeOption(ExpiryType.LEGACY, 14.days)
)
)
)
}

@Test
fun `1-1 conversation, 1 day after send, new config`() = runTest {
val time = 1.days
Expand Down
4 changes: 0 additions & 4 deletions content-descriptions/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,4 @@
<string name="AccessibilityId_expand">Expand</string>
<string name="AccessibilityId_mediaMessage">Media message</string>

<!-- LEGACY DISAPPEARING MESSAGES WILL BE NO MORE & THIS CAN BE REMOVED AFTER ONBOARDING GOES OUT! -ACL -->
<!-- Also, this is associated with the string: expiration_type_disappear_legacy -->
<string name="AccessibilityId_disappearingMessagesLegacy">Original version of disappearing messages.</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import kotlin.time.Duration.Companion.seconds

sealed class ExpiryMode(val expirySeconds: Long) {
object NONE: ExpiryMode(0)
data class Legacy(private val seconds: Long = 0L): ExpiryMode(seconds)
data class AfterSend(private val seconds: Long = 0L): ExpiryMode(seconds)
data class AfterRead(private val seconds: Long = 0L): ExpiryMode(seconds)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ object UpdateMessageBuilder {
.format()
}
2 -> {
Phrase.from(context, R.string.groupMemberTwoNew)
Phrase.from(context, R.string.groupMemberNewTwo)
.put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0)))
.put(OTHER_NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(1)))
.format()
}
else -> {
val newMemberCountMinusOne = newMemberCount - 1
Phrase.from(context, R.string.groupMemberMoreNew)
Phrase.from(context, R.string.groupMemberNewMultiple)
.put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0)))
.put(COUNT_KEY, newMemberCountMinusOne)
.format()
Expand Down
Loading