Update MuteDialog, LinkPreviewDialog, and PathActivity

This commit is contained in:
alansley 2024-08-29 08:25:24 +10:00
parent e7dd1c582d
commit 6dd93b33f2
3 changed files with 11 additions and 16 deletions

View File

@ -3,10 +3,10 @@ package org.thoughtcrime.securesms
import android.content.Context import android.content.Context
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import com.squareup.phrase.Phrase
import network.loki.messenger.R import network.loki.messenger.R
import org.session.libsession.LocalisedTimeUtil import org.session.libsession.LocalisedTimeUtil
import org.session.libsession.utilities.StringSubstitutionConstants.TIME_LARGE_KEY import org.session.libsession.utilities.StringSubstitutionConstants.TIME_LARGE_KEY
import org.thoughtcrime.securesms.ui.getSubbedString
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Duration.Companion.seconds import kotlin.time.Duration.Companion.seconds
@ -22,10 +22,8 @@ fun showMuteDialog(
if (entry.stringRes == R.string.notificationsMute) { if (entry.stringRes == R.string.notificationsMute) {
context.getString(R.string.notificationsMute) context.getString(R.string.notificationsMute)
} else { } else {
val largeTimeUnitText = LocalisedTimeUtil.getDurationWithSingleLargestTimeUnit(context, Option.entries[index].getTime().milliseconds) val largeTimeUnitString = LocalisedTimeUtil.getDurationWithSingleLargestTimeUnit(context, Option.entries[index].getTime().milliseconds)
Phrase.from(context, entry.stringRes) context.getSubbedString(entry.stringRes, TIME_LARGE_KEY to largeTimeUnitString)
.put(TIME_LARGE_KEY, largeTimeUnitText)
.format().toString()
} }
}.toTypedArray()) { }.toTypedArray()) {
// Note: We add the current timestamp to the mute duration to get the un-mute timestamp // Note: We add the current timestamp to the mute duration to get the un-mute timestamp

View File

@ -3,11 +3,12 @@ package org.thoughtcrime.securesms.conversation.v2.dialogs
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import com.squareup.phrase.Phrase
import network.loki.messenger.R import network.loki.messenger.R
import org.session.libsession.utilities.NonTranslatableStringConstants.APP_NAME
import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY
import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.TextSecurePreferences
import org.thoughtcrime.securesms.createSessionDialog import org.thoughtcrime.securesms.createSessionDialog
import org.thoughtcrime.securesms.ui.getSubbedCharSequence
/** Shown the first time the user inputs a URL that could generate a link preview, to /** Shown the first time the user inputs a URL that could generate a link preview, to
* let them know that Session offers the ability to send and receive link previews. */ * let them know that Session offers the ability to send and receive link previews. */
@ -15,9 +16,7 @@ class LinkPreviewDialog(private val onEnabled: () -> Unit) : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = createSessionDialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog = createSessionDialog {
title(R.string.linkPreviewsEnable) title(R.string.linkPreviewsEnable)
val txt = Phrase.from(context, R.string.linkPreviewsFirstDescription) val txt = context.getSubbedCharSequence(R.string.linkPreviewsFirstDescription, APP_NAME_KEY to APP_NAME)
.put(APP_NAME_KEY, context.getString(R.string.app_name))
.format()
text(txt) text(txt)
button(R.string.enable) { enable() } button(R.string.enable) { enable() }
cancelButton { dismiss() } cancelButton { dismiss() }

View File

@ -17,7 +17,6 @@ import android.widget.Toast
import androidx.annotation.ColorRes import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.squareup.phrase.Phrase
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
@ -28,10 +27,12 @@ import kotlinx.coroutines.withContext
import network.loki.messenger.R import network.loki.messenger.R
import network.loki.messenger.databinding.ActivityPathBinding import network.loki.messenger.databinding.ActivityPathBinding
import org.session.libsession.snode.OnionRequestAPI import org.session.libsession.snode.OnionRequestAPI
import org.session.libsession.utilities.NonTranslatableStringConstants.APP_NAME
import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY
import org.session.libsession.utilities.getColorFromAttr import org.session.libsession.utilities.getColorFromAttr
import org.session.libsignal.utilities.Snode import org.session.libsignal.utilities.Snode
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.ui.getSubbedString
import org.thoughtcrime.securesms.util.GlowViewUtilities import org.thoughtcrime.securesms.util.GlowViewUtilities
import org.thoughtcrime.securesms.util.IP2Country import org.thoughtcrime.securesms.util.IP2Country
import org.thoughtcrime.securesms.util.PathDotView import org.thoughtcrime.securesms.util.PathDotView
@ -54,8 +55,7 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
supportActionBar!!.title = resources.getString(R.string.onionRoutingPath) supportActionBar!!.title = resources.getString(R.string.onionRoutingPath)
// Substitute "Session" into the path description. Note: This is a non-translatable string. // Substitute "Session" into the path description. Note: This is a non-translatable string.
val appName = applicationContext.getString(R.string.app_name) val txt = applicationContext.getSubbedString(R.string.onionRoutingPathDescription,APP_NAME_KEY to APP_NAME)
val txt = Phrase.from(applicationContext, R.string.onionRoutingPathDescription).put(APP_NAME_KEY, appName).format().toString()
binding.pathDescription.text = txt binding.pathDescription.text = txt
binding.pathRowsContainer.disableClipping() binding.pathRowsContainer.disableClipping()
@ -259,13 +259,11 @@ class PathActivity : PassphraseRequiredActionBarActivity() {
override fun onAttachedToWindow() { override fun onAttachedToWindow() {
super.onAttachedToWindow() super.onAttachedToWindow()
startAnimation() startAnimation()
} }
override fun onDetachedFromWindow() { override fun onDetachedFromWindow() {
super.onDetachedFromWindow() super.onDetachedFromWindow()
stopAnimation() stopAnimation()
} }