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

Release/1.20.1 #1682

Merged
merged 23 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
af89d5f
Merge pull request #1662 from oxen-io/release/1.20.0
ThomasSession Sep 11, 2024
59eed88
Updating the app to using Compose 1.7.1 via the latest BOM
ThomasSession Sep 11, 2024
d897a83
Tweaking debug menu
ThomasSession Sep 11, 2024
607dae2
Removing hardcoded reference to material3
ThomasSession Sep 11, 2024
f0c8ec8
Using the latest compose compiler
ThomasSession Sep 11, 2024
fdf8f41
Merge pull request #1663 from oxen-io/feature/compose-1.7.1
ThomasSession Sep 11, 2024
73b0088
Fix ItemButton padding for downstate
Sep 18, 2024
6ca34b2
Merge pull request #1670 from oxen-io/release/1.20.0
ThomasSession Sep 19, 2024
89a854e
Merge pull request #1672 from bemusementpark/ItemButton
ThomasSession Sep 19, 2024
1ff8ea0
SES-1714 - SES-1715
ThomasSession Sep 19, 2024
3dfbd08
Cleaned up ItemButton to work in both its variations
ThomasSession Sep 20, 2024
75c5a75
Merge pull request #1675 from oxen-io/fix/message-request-after-delete
ThomasSession Sep 20, 2024
b74d35e
Merge pull request #1679 from oxen-io/release/1.20.0
ThomasSession Sep 24, 2024
c956b20
Making sure we don't pass in a null recipient name
ThomasSession Sep 30, 2024
29c6e6b
Adding back long press fix
ThomasSession Oct 1, 2024
3d42a04
Fixing property name
ThomasSession Oct 2, 2024
b237faa
Fixing ANRs
ThomasSession Oct 4, 2024
8fec296
Fixing Crashes
ThomasSession Oct 4, 2024
390757f
Updating QA tags for dialogs as per the QA Team's instructions
ThomasSession Oct 4, 2024
d257a1a
Moving recovery password dialogs to compose for QA
ThomasSession Oct 4, 2024
a3abf94
Latest translations
ThomasSession Oct 4, 2024
c095427
Build process update
ThomasSession Oct 7, 2024
b595475
Using appropriate name
ThomasSession Oct 7, 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
30 changes: 18 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ configurations.forEach {
it.exclude module: "commons-logging"
}

def canonicalVersionCode = 382
def canonicalVersionName = "1.20.0"
def canonicalVersionCode = 383
def canonicalVersionName = "1.20.1"

def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1,
Expand Down Expand Up @@ -68,7 +68,7 @@ android {
}

composeOptions {
kotlinCompilerExtensionVersion '1.5.14'
kotlinCompilerExtensionVersion '1.5.15'
}

defaultConfig {
Expand Down Expand Up @@ -353,15 +353,21 @@ dependencies {
testImplementation 'org.conscrypt:conscrypt-openjdk-uber:2.5.2' // For Robolectric
testImplementation 'app.cash.turbine:turbine:1.1.0'

implementation 'com.github.bumptech.glide:compose:1.0.0-alpha.5'
implementation "androidx.compose.ui:ui:$composeVersion"
implementation "androidx.compose.animation:animation:$composeVersion"
implementation "androidx.compose.ui:ui-tooling:$composeVersion"
implementation "androidx.compose.runtime:runtime-livedata:$composeVersion"
implementation "androidx.compose.foundation:foundation-layout:$composeVersion"
implementation "androidx.compose.material3:material3:1.2.1"
androidTestImplementation "androidx.compose.ui:ui-test-junit4-android:$composeVersion"
debugImplementation "androidx.compose.ui:ui-test-manifest:$composeVersion"
// compose
Dependency composeBom = platform('androidx.compose:compose-bom:2024.09.01')
implementation composeBom
testImplementation composeBom
androidTestImplementation composeBom

implementation "androidx.compose.ui:ui"
implementation "androidx.compose.animation:animation"
implementation "androidx.compose.ui:ui-tooling"
implementation "androidx.compose.runtime:runtime-livedata"
implementation "androidx.compose.foundation:foundation-layout"
implementation "androidx.compose.material3:material3"

androidTestImplementation "androidx.compose.ui:ui-test-junit4-android"
debugImplementation "androidx.compose.ui:ui-test-manifest"

implementation "com.google.accompanist:accompanist-themeadapter-appcompat:0.33.1-alpha"
implementation "com.google.accompanist:accompanist-permissions:0.36.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ class SessionDialogBuilder(val context: Context) {

// Main title entry point
fun title(text: String?) {
text(text, R.style.TextAppearance_Session_Dialog_Title) { setPadding(dp20, 0, dp20, 0) }
text(
text = text,
qaTag = context.getString(R.string.AccessibilityId_modalTitle),
style = R.style.TextAppearance_Session_Dialog_Title) { setPadding(dp20, 0, dp20, 0) }
}

// Convenience assessor for title that takes a string resource
Expand All @@ -74,18 +77,24 @@ class SessionDialogBuilder(val context: Context) {
fun text(@StringRes id: Int, style: Int? = null) = text(context.getString(id), style)

fun text(text: CharSequence?, @StyleRes style: Int? = null) {
text(text, style) {
text(text = text, style = style) {
layoutParams = LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
.apply { updateMargins(dp40, 0, dp40, 0) }
}
}

private fun text(text: CharSequence?, @StyleRes style: Int? = null, modify: TextView.() -> Unit) {
private fun text(
text: CharSequence?,
qaTag: String = context.getString(R.string.AccessibilityId_modalMessage),
@StyleRes style: Int? = null,
modify: TextView.() -> Unit
) {
text ?: return
TextView(context, null, 0, style ?: R.style.TextAppearance_Session_Dialog_Message)
.apply {
setText(text)
textAlignment = View.TEXT_ALIGNMENT_CENTER
contentDescription = qaTag
modify()
}.let(topView::addView)

Expand Down Expand Up @@ -166,7 +175,7 @@ class SessionDialogBuilder(val context: Context) {
textColor?.let{
setTextColor(it)
}
contentDescription = resources.getString(contentDescriptionRes)
contentDescription = resources.getString(text) // QA now wants the qa tag to mtch the button's text
layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, dp60, 1f)
setOnClickListener {
listener.invoke()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@ internal fun StartConversationScreen(
icon = R.drawable.ic_message,
modifier = Modifier.contentDescription(R.string.AccessibilityId_messageNew),
onClick = delegate::onNewMessageSelected)
Divider(startIndent = LocalDimensions.current.dividerIndent)
Divider(startIndent = LocalDimensions.current.minItemButtonHeight)
ItemButton(
textId = R.string.groupCreate,
icon = R.drawable.ic_group,
modifier = Modifier.contentDescription(R.string.AccessibilityId_groupCreate),
onClick = delegate::onCreateGroupSelected
)
Divider(startIndent = LocalDimensions.current.dividerIndent)
Divider(startIndent = LocalDimensions.current.minItemButtonHeight)
ItemButton(
textId = R.string.communityJoin,
icon = R.drawable.ic_globe,
modifier = Modifier.contentDescription(R.string.AccessibilityId_communityJoin),
onClick = delegate::onJoinCommunitySelected
)
Divider(startIndent = LocalDimensions.current.dividerIndent)
Divider(startIndent = LocalDimensions.current.minItemButtonHeight)
ItemButton(
textId = R.string.sessionInviteAFriend,
icon = R.drawable.ic_invite_friend,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.core.content.ContextCompat
import androidx.core.view.drawToBitmap
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.fragment.app.DialogFragment
Expand All @@ -59,6 +58,7 @@ import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -181,6 +181,7 @@ import org.thoughtcrime.securesms.util.DateUtils
import org.thoughtcrime.securesms.util.MediaUtil
import org.thoughtcrime.securesms.util.NetworkUtils
import org.thoughtcrime.securesms.util.SaveAttachmentTask
import org.thoughtcrime.securesms.util.drawToBitmap
import org.thoughtcrime.securesms.util.isScrolledToBottom
import org.thoughtcrime.securesms.util.isScrolledToWithin30dpOfBottom
import org.thoughtcrime.securesms.util.push
Expand Down Expand Up @@ -734,9 +735,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
private fun restoreDraftIfNeeded() {
val mediaURI = intent.data
val mediaType = AttachmentManager.MediaType.from(intent.type)
val mimeType = MediaUtil.getMimeType(this, mediaURI)
if (mediaURI != null && mediaType != null) {
if (AttachmentManager.MediaType.IMAGE == mediaType || AttachmentManager.MediaType.GIF == mediaType || AttachmentManager.MediaType.VIDEO == mediaType) {
val media = Media(mediaURI, MediaUtil.getMimeType(this, mediaURI)!!, 0, 0, 0, 0, Optional.absent(), Optional.absent())
if (mimeType != null && (AttachmentManager.MediaType.IMAGE == mediaType || AttachmentManager.MediaType.GIF == mediaType || AttachmentManager.MediaType.VIDEO == mediaType)) {
val media = Media(mediaURI, mimeType, 0, 0, 0, 0, Optional.absent(), Optional.absent())
startActivityForResult(MediaSendActivity.buildEditorIntent(this, listOf( media ), viewModel.recipient!!, ""), PICK_FROM_LIBRARY)
return
} else {
Expand Down Expand Up @@ -813,7 +815,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
if (shouldShowLegacy) {

val txt = Phrase.from(applicationContext, R.string.disappearingMessagesLegacy)
.put(NAME_KEY, legacyRecipient!!.name)
.put(NAME_KEY, legacyRecipient!!.toShortString())
.format()
binding?.outdatedBannerTextView?.text = txt
}
Expand Down Expand Up @@ -1191,14 +1193,14 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
title(R.string.block)
text(
Phrase.from(context, R.string.blockDescription)
.put(NAME_KEY, recipient.name)
.put(NAME_KEY, recipient.toShortString())
.format()
)
dangerButton(R.string.block, R.string.AccessibilityId_blockConfirm) {
viewModel.block()

// Block confirmation toast added as per SS-64
val txt = Phrase.from(context, R.string.blockBlockedUser).put(NAME_KEY, recipient.name).format().toString()
val txt = Phrase.from(context, R.string.blockBlockedUser).put(NAME_KEY, recipient.toShortString()).format().toString()
Toast.makeText(context, txt, Toast.LENGTH_LONG).show()

if (deleteThread) {
Expand Down Expand Up @@ -1249,7 +1251,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
title(R.string.blockUnblock)
text(
Phrase.from(context, R.string.blockUnblockName)
.put(NAME_KEY, recipient.name)
.put(NAME_KEY, recipient.toShortString())
.format()
)
dangerButton(R.string.blockUnblock, R.string.AccessibilityId_unblockConfirm) { viewModel.unblock() }
Expand Down Expand Up @@ -1737,10 +1739,19 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
binding.inputBar.text = ""
binding.inputBar.cancelQuoteDraft()
binding.inputBar.cancelLinkPreviewDraft()
// Put the message in the database
message.id = smsDb.insertMessageOutbox(viewModel.threadId, outgoingTextMessage, false, message.sentTimestamp!!, null, true)
// Send it
MessageSender.send(message, recipient.address)
lifecycleScope.launch(Dispatchers.Default) {
// Put the message in the database
message.id = smsDb.insertMessageOutbox(
viewModel.threadId,
outgoingTextMessage,
false,
message.sentTimestamp!!,
null,
true
)
// Send it
MessageSender.send(message, recipient.address)
}
// Send a typing stopped message
ApplicationContext.getInstance(this).typingStatusSender.onTypingStopped(viewModel.threadId)
return Pair(recipient.address, sentTimestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DownloadDialog(private val recipient: Recipient) : DialogFragment() {
title(getString(R.string.attachmentsAutoDownloadModalTitle))

val explanation = Phrase.from(context, R.string.attachmentsAutoDownloadModalDescription)
.put(CONVERSATION_NAME_KEY, recipient.name)
.put(CONVERSATION_NAME_KEY, recipient.toShortString())
.format()
val spannable = SpannableStringBuilder(explanation)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,7 @@ open class Storage(
if (recipient.isLocalNumber || !recipient.isContactRecipient) return
configFactory.contacts?.upsertContact(recipient.address.serialize()) {
this.approved = approved
this.priority = PRIORITY_VISIBLE
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,17 @@ public CharSequence getDisplayBody(@NonNull Context context) {
.format().toString();

} else if (MmsSmsColumns.Types.isMessageRequestResponse(type)) {
if (lastMessage.getRecipient().getAddress().serialize().equals(
TextSecurePreferences.getLocalNumber(context))) {
return UtilKt.getSubbedCharSequence(
context,
R.string.messageRequestYouHaveAccepted,
new Pair<>(NAME_KEY, getName())
);
try {
if (lastMessage.getRecipient().getAddress().serialize().equals(
TextSecurePreferences.getLocalNumber(context))) {
return UtilKt.getSubbedCharSequence(
context,
R.string.messageRequestYouHaveAccepted,
new Pair<>(NAME_KEY, getName())
);
}
}
catch (Exception e){} // the above can throw a null exception
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we address the NPE rather than catching it? Like getName() != null as part of the condition

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SessionHero01 Ideally yes but I couldn't be sure which part was returning null here.
Are we sure it is getName()?
The store seem to think it was here:

lastMessage.getRecipient().getAddress().serialize().equals(
                        TextSecurePreferences.getLocalNumber(context)))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right there's no clear indication which one is null


return context.getString(R.string.messageRequestsAccepted);
} else if (getCount() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ fun DebugMenu(
buttons = listOf(
DialogButtonModel(
text = GetString(R.string.cancel),
contentDescription = GetString(R.string.cancel),
onClick = { sendCommand(HideEnvironmentWarningDialog) }
),
DialogButtonModel(
text = GetString(R.string.ok),
contentDescription = GetString(R.string.ok),
onClick = { sendCommand(ChangeEnvironment) }
)
)
Expand Down Expand Up @@ -149,9 +147,11 @@ fun ColumnScope.DebugCell(
) {
Spacer(modifier = Modifier.height(LocalDimensions.current.smallSpacing))

Cell {
Cell(
modifier = modifier
) {
Column(
modifier = modifier.padding(LocalDimensions.current.spacing)
modifier = Modifier.padding(LocalDimensions.current.spacing)
) {
Text(
text = title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import org.thoughtcrime.securesms.home.search.GlobalSearchViewModel
import org.thoughtcrime.securesms.messagerequests.MessageRequestsActivity
import com.bumptech.glide.Glide
import com.bumptech.glide.RequestManager
import org.session.libsession.utilities.truncateIdForDisplay
import org.thoughtcrime.securesms.notifications.PushRegistry
import org.thoughtcrime.securesms.permissions.Permissions
import org.thoughtcrime.securesms.preferences.SettingsActivity
Expand Down Expand Up @@ -507,7 +508,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
showSessionDialog {
title(R.string.block)
text(Phrase.from(context, R.string.blockDescription)
.put(NAME_KEY, thread.recipient.name)
.put(NAME_KEY, thread.recipient.toShortString())
.format())
dangerButton(R.string.block, R.string.AccessibilityId_blockConfirm) {
lifecycleScope.launch(Dispatchers.IO) {
Expand All @@ -518,7 +519,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
}
}
// Block confirmation toast added as per SS-64
val txt = Phrase.from(context, R.string.blockBlockedUser).put(NAME_KEY, thread.recipient.name).format().toString()
val txt = Phrase.from(context, R.string.blockBlockedUser).put(NAME_KEY, thread.recipient.toShortString()).format().toString()
Toast.makeText(context, txt, Toast.LENGTH_LONG).show()
}
cancelButton()
Expand All @@ -528,7 +529,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
private fun unblockConversation(thread: ThreadRecord) {
showSessionDialog {
title(R.string.blockUnblock)
text(Phrase.from(context, R.string.blockUnblockName).put(NAME_KEY, thread.recipient.name).format())
text(Phrase.from(context, R.string.blockUnblockName).put(NAME_KEY, thread.recipient.toShortString()).format())
dangerButton(R.string.blockUnblock, R.string.AccessibilityId_unblockConfirm) {
lifecycleScope.launch(Dispatchers.IO) {
storage.setBlocked(listOf(thread.recipient), false)
Expand Down Expand Up @@ -616,7 +617,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
if (recipient.name != null) {
title = getString(R.string.conversationsDelete)
message = Phrase.from(this.applicationContext, R.string.conversationsDeleteDescription)
.put(NAME_KEY, recipient.name)
.put(NAME_KEY, recipient.toShortString())
.format()
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.home.search
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.channels.BufferOverflow
Expand All @@ -13,11 +14,13 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.buffer
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.launch
import kotlinx.coroutines.plus
import kotlinx.coroutines.withContext
import org.thoughtcrime.securesms.search.SearchRepository
import org.thoughtcrime.securesms.search.model.SearchResult
import javax.inject.Inject
Expand All @@ -38,9 +41,14 @@ class GlobalSearchViewModel @Inject constructor(
.buffer(onBufferOverflow = BufferOverflow.DROP_OLDEST)
.mapLatest { query ->
if (query.trim().isEmpty()) {
// searching for 05 as contactDb#getAllContacts was not returning contacts
// without a nickname/name who haven't approved us.
GlobalSearchResult(query.toString(), searchRepository.queryContacts("05").first.toList())
withContext(Dispatchers.Default) {
// searching for 05 as contactDb#getAllContacts was not returning contacts
// without a nickname/name who haven't approved us.
GlobalSearchResult(
query.toString(),
searchRepository.queryContacts("05").first.toList()
)
}
} else {
// User input delay in case we get a new query within a few hundred ms this
// coroutine will be cancelled and the expensive query will not be run.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ private fun SaveAttachmentWarningDialog(
title = context.getString(R.string.warning),
text = context.resources.getString(R.string.attachmentsWarning),
buttons = listOf(
DialogButtonModel(GetString(R.string.save), GetString(R.string.AccessibilityId_saveAttachment), color = LocalColors.current.danger, onClick = onAccepted),
DialogButtonModel(GetString(android.R.string.cancel), GetString(R.string.AccessibilityId_cancel), dismissOnClick = true)
DialogButtonModel(GetString(R.string.save), color = LocalColors.current.danger, onClick = onAccepted),
DialogButtonModel(GetString(android.R.string.cancel), dismissOnClick = true)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class MessageRequestsActivity : PassphraseRequiredActionBarActivity(), Conversat
showSessionDialog {
title(R.string.block)
text(Phrase.from(context, R.string.blockDescription)
.put(NAME_KEY, thread.recipient.name)
.put(NAME_KEY, thread.recipient.toShortString())
.format())
dangerButton(R.string.block, R.string.AccessibilityId_blockConfirm) {
doBlock()
Expand Down
Loading