mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 00:37:47 +00:00
More bold fixes and UI tweaks
This commit is contained in:
parent
78a9ab7159
commit
d35482daba
@ -2,8 +2,6 @@ package org.thoughtcrime.securesms.conversation.disappearingmessages
|
||||
|
||||
import android.content.Context
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import network.loki.messenger.R
|
||||
import network.loki.messenger.libsession_util.util.ExpiryMode
|
||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||
@ -15,13 +13,16 @@ import org.session.libsession.utilities.Address
|
||||
import org.session.libsession.utilities.ExpirationUtil
|
||||
import org.session.libsession.utilities.SSKEnvironment.MessageExpirationManagerProtocol
|
||||
import org.session.libsession.utilities.StringSubstitutionConstants.DISAPPEARING_MESSAGES_TYPE_KEY
|
||||
import org.session.libsession.utilities.StringSubstitutionConstants.TIME_LARGE_KEY
|
||||
import org.session.libsession.utilities.StringSubstitutionConstants.TIME_KEY
|
||||
import org.session.libsession.utilities.TextSecurePreferences
|
||||
import org.session.libsession.utilities.getExpirationTypeDisplayValue
|
||||
import org.thoughtcrime.securesms.database.model.MessageRecord
|
||||
import org.thoughtcrime.securesms.showSessionDialog
|
||||
import org.thoughtcrime.securesms.ui.getSubbedCharSequence
|
||||
import org.thoughtcrime.securesms.ui.getSubbedString
|
||||
import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
class DisappearingMessages @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
@ -48,10 +49,10 @@ class DisappearingMessages @Inject constructor(
|
||||
fun showFollowSettingDialog(context: Context, message: MessageRecord) = context.showSessionDialog {
|
||||
title(R.string.disappearingMessagesFollowSetting)
|
||||
text(if (message.expiresIn == 0L) {
|
||||
context.getString(R.string.disappearingMessagesFollowSettingOff)
|
||||
context.getText(R.string.disappearingMessagesFollowSettingOff)
|
||||
} else {
|
||||
context.getSubbedString(R.string.disappearingMessagesFollowSettingOn,
|
||||
TIME_LARGE_KEY to ExpirationUtil.getExpirationDisplayValue(context, message.expiresIn.milliseconds),
|
||||
context.getSubbedCharSequence(R.string.disappearingMessagesFollowSettingOn,
|
||||
TIME_KEY to ExpirationUtil.getExpirationDisplayValue(context, message.expiresIn.milliseconds),
|
||||
DISAPPEARING_MESSAGES_TYPE_KEY to context.getExpirationTypeDisplayValue(message.isNotDisappearAfterRead))
|
||||
})
|
||||
|
||||
|
@ -1106,8 +1106,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
val blindedRecipient = viewModel.blindedRecipient
|
||||
val openGroup = viewModel.openGroup
|
||||
|
||||
val isClosedGroup = recipient.isGroupRecipient
|
||||
|
||||
// Get the correct placeholder text for this type of empty conversation
|
||||
val isNoteToSelf = recipient.isLocalNumber
|
||||
val txtCS: CharSequence = when {
|
||||
@ -1143,11 +1141,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
val showPlaceholder = adapter.itemCount == 0
|
||||
binding.placeholderText.isVisible = showPlaceholder
|
||||
if (showPlaceholder) {
|
||||
if (!isNoteToSelf) {
|
||||
binding.placeholderText.text = org.session.libsession.utilities.Util.makeBoldBetweenTags(txtCS)
|
||||
} else {
|
||||
binding.placeholderText.text = txtCS
|
||||
}
|
||||
binding.placeholderText.text = txtCS
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
android:layout_height="12dp"
|
||||
android:layout_marginBottom="@dimen/small_spacing"
|
||||
android:visibility="gone"
|
||||
app:tint="?android:textColorPrimary"
|
||||
app:tint="?android:textColorTertiary"
|
||||
tools:src="@drawable/ic_timer"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
android:layout_height="12dp"
|
||||
android:layout_marginBottom="@dimen/small_spacing"
|
||||
android:visibility="gone"
|
||||
app:tint="?android:textColorPrimary"
|
||||
app:tint="?android:textColorTertiary"
|
||||
tools:src="@drawable/ic_timer"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
@ -45,9 +45,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textColor="?android:textColorTertiary"
|
||||
android:textSize="@dimen/very_small_font_size"
|
||||
android:textStyle="bold"
|
||||
tools:text="You disabled disappearing messages" />
|
||||
|
||||
<FrameLayout
|
||||
|
@ -43,7 +43,7 @@ object UpdateMessageBuilder {
|
||||
// --- Group created or joined ---
|
||||
is UpdateMessageData.Kind.GroupCreation -> {
|
||||
if (!isOutgoing) {
|
||||
Util.makeBoldBetweenTags(SpannableString(context.getString(R.string.groupInviteYou)))
|
||||
context.getText(R.string.groupInviteYou)
|
||||
} else {
|
||||
"" // We no longer add a string like `disappearingMessagesNewGroup` ("You created a new group") and leave the group with its default empty state
|
||||
}
|
||||
@ -51,18 +51,9 @@ object UpdateMessageBuilder {
|
||||
|
||||
// --- Group name changed ---
|
||||
is UpdateMessageData.Kind.GroupNameChange -> {
|
||||
if (isOutgoing) {
|
||||
val cs = Phrase.from(context, R.string.groupNameNew)
|
||||
.put(GROUP_NAME_KEY, updateData.name)
|
||||
.format()
|
||||
Util.makeBoldBetweenTags(cs)
|
||||
}
|
||||
else {
|
||||
val cs = Phrase.from(context, R.string.groupNameNew)
|
||||
.put(GROUP_NAME_KEY, updateData.name)
|
||||
.format()
|
||||
Util.makeBoldBetweenTags(cs)
|
||||
}
|
||||
Phrase.from(context, R.string.groupNameNew)
|
||||
.put(GROUP_NAME_KEY, updateData.name)
|
||||
.format()
|
||||
}
|
||||
|
||||
// --- Group member(s) were added ---
|
||||
@ -193,7 +184,7 @@ object UpdateMessageBuilder {
|
||||
isOutgoing: Boolean = false,
|
||||
timestamp: Long,
|
||||
expireStarted: Long
|
||||
): String {
|
||||
): CharSequence {
|
||||
if (!isOutgoing && senderId == null) {
|
||||
Log.w(TAG, "buildExpirationTimerMessage: Cannot build for outgoing message when senderId is null.")
|
||||
return ""
|
||||
@ -205,13 +196,13 @@ object UpdateMessageBuilder {
|
||||
if (duration <= 0) {
|
||||
// ..by you..
|
||||
return if (isOutgoing) {
|
||||
context.getString(R.string.disappearingMessagesTurnedOffYou)
|
||||
context.getText(R.string.disappearingMessagesTurnedOffYou)
|
||||
}
|
||||
else // ..or by someone else.
|
||||
{
|
||||
Phrase.from(context, R.string.disappearingMessagesTurnedOff)
|
||||
.put(NAME_KEY, senderName)
|
||||
.format().toString()
|
||||
.format()
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,13 +216,13 @@ object UpdateMessageBuilder {
|
||||
Phrase.from(context, R.string.disappearingMessagesSetYou)
|
||||
.put(TIME_KEY, time)
|
||||
.put(DISAPPEARING_MESSAGES_TYPE_KEY, action)
|
||||
.format().toString()
|
||||
.format()
|
||||
} else {
|
||||
// 1-on-1 conversation
|
||||
Phrase.from(context, R.string.disappearingMessagesSetYou)
|
||||
.put(TIME_KEY, time)
|
||||
.put(DISAPPEARING_MESSAGES_TYPE_KEY, action)
|
||||
.format().toString()
|
||||
.format()
|
||||
}
|
||||
}
|
||||
else // ..or by someone else.
|
||||
@ -240,7 +231,7 @@ object UpdateMessageBuilder {
|
||||
.put(NAME_KEY, senderName)
|
||||
.put(TIME_KEY, time)
|
||||
.put(DISAPPEARING_MESSAGES_TYPE_KEY, action)
|
||||
.format().toString()
|
||||
.format()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,25 +359,6 @@ object Util {
|
||||
val digitGroups = (Math.log10(sizeBytes.toDouble()) / Math.log10(1024.0)).toInt()
|
||||
return DecimalFormat("#,##0.#").format(sizeBytes / Math.pow(1024.0, digitGroups.toDouble())) + " " + units[digitGroups]
|
||||
}
|
||||
|
||||
// Method that takes a char sequence that contains one or more elements surrounded in bold tags
|
||||
// like "Hello <b>world</b>" and returns a SpannableString that will display the appropriate
|
||||
// elements in bold. If there are no such <b> or </b> elements then the original string is returned
|
||||
// as a SpannableString without any bold highlighting.
|
||||
@JvmStatic
|
||||
fun makeBoldBetweenTags(input: CharSequence): SpannableString {
|
||||
val spannable = SpannableString(input)
|
||||
var startIndex = 0
|
||||
while (true) {
|
||||
startIndex = input.indexOf("<b>", startIndex)
|
||||
if (startIndex == -1) break
|
||||
val endIndex = input.indexOf("</b>", startIndex + 3)
|
||||
if (endIndex == -1) break
|
||||
spannable.setSpan(StyleSpan(Typeface.BOLD),startIndex + 3, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
startIndex = endIndex + 4
|
||||
}
|
||||
return spannable
|
||||
}
|
||||
}
|
||||
|
||||
fun <T, R> T.runIf(condition: Boolean, block: T.() -> R): R where T: R = if (condition) block() else this
|
||||
|
Loading…
x
Reference in New Issue
Block a user