From 5cc57fc2256357380371b674c877027ac6320cf2 Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:02:23 +1100 Subject: [PATCH] Fixed up legacy group banner --- .../conversation/v2/ConversationActivityV2.kt | 25 ++++++++-- .../res/layout/activity_conversation_v2.xml | 49 +++++++------------ .../libsession/utilities/StringSubKeys.kt | 1 + 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index e530e7526d..8e5549b964 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -92,8 +92,11 @@ import org.session.libsession.utilities.GroupUtil import org.session.libsession.utilities.MediaTypes import org.session.libsession.utilities.StringSubstitutionConstants.APP_NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.CONVERSATION_NAME_KEY +import org.session.libsession.utilities.StringSubstitutionConstants.DATE_KEY +import org.session.libsession.utilities.StringSubstitutionConstants.DATE_TIME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.GROUP_NAME_KEY import org.session.libsession.utilities.StringSubstitutionConstants.NAME_KEY +import org.session.libsession.utilities.StringSubstitutionConstants.URL_KEY import org.session.libsession.utilities.Stub import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.concurrent.SimpleTask @@ -176,6 +179,7 @@ import org.thoughtcrime.securesms.mms.MediaConstraints import org.thoughtcrime.securesms.mms.Slide import org.thoughtcrime.securesms.mms.SlideDeck import org.thoughtcrime.securesms.mms.VideoSlide +import org.thoughtcrime.securesms.openUrl import org.thoughtcrime.securesms.permissions.Permissions import org.thoughtcrime.securesms.reactions.ReactionsDialogFragment import org.thoughtcrime.securesms.reactions.any.ReactWithAnyEmojiDialogFragment @@ -822,25 +826,38 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe binding.outdatedDisappearingBanner.isVisible = shouldShowLegacy if (shouldShowLegacy) { - val txt = Phrase.from(applicationContext, R.string.disappearingMessagesLegacy) + val txt = Phrase.from(this, R.string.disappearingMessagesLegacy) .put(NAME_KEY, legacyRecipient!!.toShortString()) .format() - binding.outdatedBannerTextView.text = txt + binding.outdatedDisappearingBannerTextView.text = txt } } private fun setUpLegacyGroupBanner() { val shouldDisplayBanner = viewModel.recipient?.isLegacyGroupRecipient ?: return + //TODO groupsv2, URL + val url = "https://getsession.org" + with(binding) { outdatedGroupBanner.isVisible = shouldDisplayBanner + outdatedGroupBanner.text = Phrase.from(this@ConversationActivityV2, R.string.groupLegacyBanner) + //TODO groupsv2, date + .put(DATE_KEY, "") + .format() outdatedGroupBanner.setOnClickListener { showSessionDialog { title(R.string.urlOpenBrowser) - text(R.string.urlOpenDescription) + text(Phrase.from(this@ConversationActivityV2, R.string.urlOpenDescription) + .put(URL_KEY, url) + .format()) cancelButton() dangerButton(R.string.open) { - // open the URL (tbc) + try { + openUrl(url) + } catch (e: Exception) { + Log.e(TAG, "Error opening URL", e) + } } } } diff --git a/app/src/main/res/layout/activity_conversation_v2.xml b/app/src/main/res/layout/activity_conversation_v2.xml index dc71a9e71e..d362483eed 100644 --- a/app/src/main/res/layout/activity_conversation_v2.xml +++ b/app/src/main/res/layout/activity_conversation_v2.xml @@ -16,6 +16,7 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toTopOf="@+id/conversationRecyclerView" app:layout_constraintStart_toStartOf="parent" + app:layout_constraintVertical_bias="0" android:theme="@style/Widget.Session.ActionBar.Flat" android:background="?colorPrimary" app:contentInsetStart="0dp"> @@ -39,7 +40,7 @@ app:layout_constraintVertical_weight="1" app:layout_constraintStart_toStartOf="parent" app:layout_constraintBottom_toTopOf="@+id/typingIndicatorViewContainer" - app:layout_constraintTop_toBottomOf="@id/toolbar" /> + app:layout_constraintTop_toBottomOf="@id/outdatedGroupBanner" /> - - - - - - - - + android:textSize="@dimen/tiny_font_size" + tools:text="@string/groupLegacyBanner" + app:drawableEndCompat="@drawable/ic_link_out" /> @@ -383,10 +367,11 @@ - - + diff --git a/libsession/src/main/java/org/session/libsession/utilities/StringSubKeys.kt b/libsession/src/main/java/org/session/libsession/utilities/StringSubKeys.kt index 51b33b1ab4..dd737bde95 100644 --- a/libsession/src/main/java/org/session/libsession/utilities/StringSubKeys.kt +++ b/libsession/src/main/java/org/session/libsession/utilities/StringSubKeys.kt @@ -11,6 +11,7 @@ object StringSubstitutionConstants { const val CONVERSATION_NAME_KEY = "conversation_name" const val COUNT_KEY = "count" const val DATE_TIME_KEY = "date_time" + const val DATE_KEY = "date" const val DISAPPEARING_MESSAGES_TYPE_KEY = "disappearing_messages_type" const val DOWNLOAD_URL_KEY = "session_download_url" // Used to invite people to download Session const val EMOJI_KEY = "emoji"