From c4f08543355a5faf5dd4bf7353ba96000d9b3e53 Mon Sep 17 00:00:00 2001 From: ThomasSession Date: Fri, 30 Aug 2024 16:10:40 +1000 Subject: [PATCH] Fixing the crashing Share feature TODO: Rebuild this screen in compose because the search functionality is not working --- .../thoughtcrime/securesms/ShareActivity.java | 8 ++++---- .../securesms/components/SearchToolbar.java | 17 +++++------------ .../messaging/utilities/UpdateMessageBuilder.kt | 8 ++++---- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java b/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java index 815cb5c947..284a0e929a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/ShareActivity.java @@ -84,7 +84,7 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity setContentView(R.layout.share_activity); - initializeToolbar(); + // initializeToolbar(); initializeResources(); initializeSearch(); initializeMedia(); @@ -126,13 +126,13 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity else super.onBackPressed(); } - private void initializeToolbar() { - Toolbar toolbar = findViewById(R.id.search_toolbar); + /* private void initializeToolbar() { + SearchToolbar toolbar = findViewById(R.id.search_toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); - } + }*/ private void initializeResources() { progressWheel = findViewById(R.id.progress_wheel); diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/SearchToolbar.java b/app/src/main/java/org/thoughtcrime/securesms/components/SearchToolbar.java index 37d5cfad05..30e609a047 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/SearchToolbar.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/SearchToolbar.java @@ -2,13 +2,11 @@ package org.thoughtcrime.securesms.components; import android.animation.Animator; import android.content.Context; -import android.os.Build; import android.util.AttributeSet; import android.view.MenuItem; import android.view.View; import android.view.ViewAnimationUtils; import android.widget.EditText; -import android.widget.LinearLayout; import androidx.annotation.MainThread; import androidx.annotation.Nullable; @@ -19,7 +17,7 @@ import org.thoughtcrime.securesms.util.AnimationCompleteListener; import network.loki.messenger.R; -public class SearchToolbar extends LinearLayout { +public class SearchToolbar extends Toolbar { private float x, y; private MenuItem searchItem; @@ -41,15 +39,10 @@ public class SearchToolbar extends LinearLayout { } private void initialize() { - inflate(getContext(), R.layout.search_toolbar, this); - setOrientation(VERTICAL); + setNavigationIcon(getContext().getResources().getDrawable(R.drawable.ic_baseline_clear_24)); + inflateMenu(R.menu.conversation_list_search); - Toolbar toolbar = findViewById(R.id.search_toolbar); - - toolbar.setNavigationIcon(getContext().getResources().getDrawable(R.drawable.ic_baseline_clear_24)); - toolbar.inflateMenu(R.menu.conversation_list_search); - - this.searchItem = toolbar.getMenu().findItem(R.id.action_filter_search); + this.searchItem = getMenu().findItem(R.id.action_filter_search); SearchView searchView = (SearchView) searchItem.getActionView(); EditText searchText = searchView.findViewById(androidx.appcompat.R.id.search_src_text); @@ -82,7 +75,7 @@ public class SearchToolbar extends LinearLayout { } }); - toolbar.setNavigationOnClickListener(v -> hide()); + setNavigationOnClickListener(v -> hide()); } @MainThread diff --git a/libsession/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageBuilder.kt b/libsession/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageBuilder.kt index 1bb8ffbd29..c9f91cf11c 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageBuilder.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/utilities/UpdateMessageBuilder.kt @@ -70,19 +70,19 @@ object UpdateMessageBuilder { } 1 -> { Phrase.from(context, R.string.groupMemberNew) - .put(NAME_KEY, updateData.updatedMembers.elementAtOrNull(0)) + .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0))) .format() } 2 -> { Phrase.from(context, R.string.groupMemberTwoNew) - .put(NAME_KEY, updateData.updatedMembers.elementAtOrNull(0)) - .put(OTHER_NAME_KEY, updateData.updatedMembers.elementAtOrNull(1)) + .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0))) + .put(OTHER_NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(1))) .format() } else -> { val newMemberCountMinusOne = newMemberCount - 1 Phrase.from(context, R.string.groupMemberMoreNew) - .put(NAME_KEY, updateData.updatedMembers.elementAtOrNull(0)) + .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0))) .put(COUNT_KEY, newMemberCountMinusOne) .format() }