From e7dd1c582d1ceb4bdf132ca068264badc70bccb4 Mon Sep 17 00:00:00 2001 From: alansley Date: Thu, 29 Aug 2024 08:16:09 +1000 Subject: [PATCH] Updated DisappearingMessages.kt and HelpSettingsActivity.kt --- .../DisappearingMessages.kt | 9 ++++---- .../preferences/HelpSettingsActivity.kt | 23 ++++++++----------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/DisappearingMessages.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/DisappearingMessages.kt index da2b532a5d..08cfcd2768 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/DisappearingMessages.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/disappearingmessages/DisappearingMessages.kt @@ -1,7 +1,6 @@ package org.thoughtcrime.securesms.conversation.disappearingmessages import android.content.Context -import com.squareup.phrase.Phrase import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject import kotlin.time.Duration.Companion.milliseconds @@ -21,6 +20,7 @@ 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.getSubbedString import org.thoughtcrime.securesms.util.ConfigurationMessageUtilities class DisappearingMessages @Inject constructor( @@ -50,10 +50,9 @@ class DisappearingMessages @Inject constructor( text(if (message.expiresIn == 0L) { context.getString(R.string.disappearingMessagesFollowSettingOff) } else { - Phrase.from(context, R.string.disappearingMessagesFollowSettingOn) - .put(TIME_LARGE_KEY, ExpirationUtil.getExpirationDisplayValue(context, message.expiresIn.milliseconds)) - .put(DISAPPEARING_MESSAGES_TYPE_KEY, context.getExpirationTypeDisplayValue(message.isNotDisappearAfterRead)) - .format().toString() + context.getSubbedString(R.string.disappearingMessagesFollowSettingOn, + TIME_LARGE_KEY to ExpirationUtil.getExpirationDisplayValue(context, message.expiresIn.milliseconds), + DISAPPEARING_MESSAGES_TYPE_KEY to context.getExpirationTypeDisplayValue(message.isNotDisappearAfterRead)) }) dangerButton( diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/HelpSettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/HelpSettingsActivity.kt index a63b8b391b..2959a46016 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/HelpSettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/HelpSettingsActivity.kt @@ -10,12 +10,13 @@ import android.widget.TextView import android.widget.Toast import androidx.core.view.isInvisible import androidx.preference.Preference -import com.squareup.phrase.Phrase import network.loki.messenger.R import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY import org.session.libsignal.utilities.Log import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.permissions.Permissions +import org.thoughtcrime.securesms.ui.getSubbedCharSequence +import org.thoughtcrime.securesms.ui.getSubbedString class HelpSettingsActivity: PassphraseRequiredActionBarActivity() { @@ -47,15 +48,11 @@ class HelpSettingsFragment: CorrectedPreferenceFragment() { // String sub the summary text of the `export_logs` element in preferences_help.xml val exportPref = preferenceScreen.findPreference(EXPORT_LOGS) - exportPref?.summary = Phrase.from(context, R.string.helpReportABugExportLogsDescription) - .put(APP_NAME_KEY, getString(R.string.app_name)) - .format() + exportPref?.summary = context?.getSubbedCharSequence(R.string.helpReportABugExportLogsDescription, APP_NAME_KEY to getString(R.string.app_name)) // String sub the summary text of the `translate_session` element in preferences_help.xml val translatePref = preferenceScreen.findPreference(TRANSLATE) - translatePref?.title = Phrase.from(context, R.string.helpHelpUsTranslateSession) - .put(APP_NAME_KEY, getString(R.string.app_name)) - .format() + translatePref?.title = context?.getSubbedCharSequence(R.string.helpHelpUsTranslateSession, APP_NAME_KEY to getString(R.string.app_name)) } override fun onPreferenceTreeClick(preference: Preference): Boolean { @@ -101,14 +98,11 @@ class HelpSettingsFragment: CorrectedPreferenceFragment() { Permissions.with(this) .request(Manifest.permission.WRITE_EXTERNAL_STORAGE) .maxSdkVersion(Build.VERSION_CODES.P) - .withPermanentDenialDialog(Phrase.from(context, R.string.permissionsStorageSaveDenied) - .put(APP_NAME_KEY, getString(R.string.app_name)) - .format().toString()) + .withPermanentDenialDialog(requireContext().getSubbedString(R.string.permissionsStorageSaveDenied, APP_NAME_KEY to getString(R.string.app_name))) .onAnyDenied { - val txt = Phrase.from(context, R.string.permissionsStorageSaveDenied) - .put(APP_NAME_KEY, getString(R.string.app_name)) - .format().toString() - Toast.makeText(requireActivity(), txt, Toast.LENGTH_LONG).show() + val c = requireContext() + val txt = c.getSubbedString(R.string.permissionsStorageSaveDenied, APP_NAME_KEY to getString(R.string.app_name)) + Toast.makeText(c, txt, Toast.LENGTH_LONG).show() } .onAllGranted { ShareLogsDialog(::updateExportButtonAndProgressBarUI).show(parentFragmentManager,"Share Logs Dialog") @@ -121,6 +115,7 @@ class HelpSettingsFragment: CorrectedPreferenceFragment() { val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) startActivity(intent) } catch (e: Exception) { + // TODO: Have asked Rebecca about a new string for this to replace the hard-coded text below Toast.makeText(requireActivity(), "Can't open URL", Toast.LENGTH_LONG).show() } }