mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Push before changing over all the Phrase.from to extension method calls
This commit is contained in:
parent
1f68791da9
commit
114066ad5f
@ -30,6 +30,7 @@ import org.session.libsession.utilities.modifyLayoutParams
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase
|
||||
import org.thoughtcrime.securesms.database.LokiAPIDatabase
|
||||
import org.thoughtcrime.securesms.ui.getSubbedString
|
||||
|
||||
@AndroidEntryPoint
|
||||
class ConversationActionBarView @JvmOverloads constructor(
|
||||
@ -107,10 +108,10 @@ class ConversationActionBarView @JvmOverloads constructor(
|
||||
val durationAbbreviated = ExpirationUtil.getExpirationAbbreviatedDisplayValue(config.expiryMode.expirySeconds)
|
||||
|
||||
// ..then substitute into the string..
|
||||
val subtitleTxt = Phrase.from(context, R.string.disappearingMessagesDisappear)
|
||||
.put(DISAPPEARING_MESSAGES_TYPE_KEY, dmTypeString)
|
||||
.put(TIME_KEY, durationAbbreviated)
|
||||
.format().toString()
|
||||
val subtitleTxt = context.getSubbedString(R.string.disappearingMessagesDisappear,
|
||||
DISAPPEARING_MESSAGES_TYPE_KEY to dmTypeString,
|
||||
TIME_KEY to durationAbbreviated
|
||||
).toString()
|
||||
|
||||
// .. and apply to the subtitle.
|
||||
settings += ConversationSetting(
|
||||
@ -127,9 +128,7 @@ class ConversationActionBarView @JvmOverloads constructor(
|
||||
?.let {
|
||||
val mutedDuration = (it - System.currentTimeMillis()).milliseconds
|
||||
val durationString = LocalisedTimeUtil.getDurationWithSingleLargestTimeUnit(context, mutedDuration)
|
||||
Phrase.from(context, R.string.notificationsMuteFor)
|
||||
.put(TIME_LARGE_KEY, durationString)
|
||||
.format().toString()
|
||||
context.getSubbedString(R.string.notificationsMuteFor, TIME_LARGE_KEY to durationString).toString()
|
||||
}
|
||||
?: context.getString(R.string.notificationsMuted),
|
||||
ConversationSettingType.NOTIFICATION,
|
||||
|
@ -19,6 +19,8 @@ import com.squareup.phrase.Phrase
|
||||
import network.loki.messenger.R
|
||||
import network.loki.messenger.databinding.FragmentModalUrlBottomSheetBinding
|
||||
import org.session.libsession.utilities.StringSubstitutionConstants.URL_KEY
|
||||
import org.session.libsignal.utilities.Log
|
||||
import org.thoughtcrime.securesms.ui.getSubbedString
|
||||
|
||||
class ModalUrlBottomSheet(private val url: String): BottomSheetDialogFragment(), View.OnClickListener {
|
||||
private lateinit var binding: FragmentModalUrlBottomSheetBinding
|
||||
@ -30,9 +32,8 @@ class ModalUrlBottomSheet(private val url: String): BottomSheetDialogFragment(),
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val explanation = Phrase.from(context, R.string.urlOpenDescription)
|
||||
.put(URL_KEY, url)
|
||||
.format()
|
||||
if (context == null) { return Log.w("MUBS", "Context is null") }
|
||||
val explanation = requireContext().getSubbedString(R.string.urlOpenDescription, URL_KEY to url)
|
||||
val spannable = SpannableStringBuilder(explanation)
|
||||
val startIndex = explanation.indexOf(url)
|
||||
spannable.setSpan(StyleSpan(Typeface.BOLD), startIndex, startIndex + url.count(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
|
@ -19,6 +19,14 @@ fun Context.createThemedComposeView(content: @Composable () -> Unit): ComposeVie
|
||||
setThemedContent(content)
|
||||
}
|
||||
|
||||
fun Context.getSubbedString(stringId: Int, vararg substitutionPairs: Pair<String, String>): CharSequence {
|
||||
val phrase = Phrase.from(this, stringId)
|
||||
for ((key, value) in substitutionPairs) {
|
||||
phrase.put(key, value)
|
||||
}
|
||||
return phrase.format()
|
||||
}
|
||||
|
||||
fun ComposeView.setThemedContent(content: @Composable () -> Unit) = setContent {
|
||||
SessionMaterialTheme {
|
||||
content()
|
||||
|
@ -20,6 +20,7 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.text.format.DateFormat
|
||||
import androidx.compose.ui.text.capitalize
|
||||
import org.session.libsignal.utilities.Log
|
||||
import java.text.DateFormat.SHORT
|
||||
import java.text.DateFormat.getTimeInstance
|
||||
@ -93,8 +94,7 @@ object DateUtils : android.text.format.DateUtils() {
|
||||
fun getDisplayFormattedTimeSpanString(c: Context, locale: Locale, timestamp: Long): String {
|
||||
// If the timestamp is invalid (ie. 0) then assume we're waiting on data and just use the 'Now' copy
|
||||
return if (timestamp == 0L || isWithin(timestamp, 1, TimeUnit.MINUTES)) {
|
||||
// TODO ACL: We need a string for "Now" because I can't seem to coax a localised version from DateUtils -
|
||||
// TODO: although anyone seeing is this is more than welcome to try! - 2024-08-26
|
||||
// TODO ACL: Adjust as per SES-360
|
||||
"Now"
|
||||
} else if (isToday(timestamp)) {
|
||||
getFormattedDateTime(timestamp, getHourFormat(c), locale)
|
||||
|
Loading…
Reference in New Issue
Block a user