Fixing the crashing Share feature

TODO: Rebuild this screen in compose because the search functionality is not working
This commit is contained in:
ThomasSession 2024-08-30 16:10:40 +10:00 committed by fanchao
parent 786485d874
commit c4f0854335
3 changed files with 13 additions and 20 deletions

View File

@ -84,7 +84,7 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
setContentView(R.layout.share_activity); setContentView(R.layout.share_activity);
initializeToolbar(); // initializeToolbar();
initializeResources(); initializeResources();
initializeSearch(); initializeSearch();
initializeMedia(); initializeMedia();
@ -126,13 +126,13 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity
else super.onBackPressed(); else super.onBackPressed();
} }
private void initializeToolbar() { /* private void initializeToolbar() {
Toolbar toolbar = findViewById(R.id.search_toolbar); SearchToolbar toolbar = findViewById(R.id.search_toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true); actionBar.setHomeButtonEnabled(true);
} }*/
private void initializeResources() { private void initializeResources() {
progressWheel = findViewById(R.id.progress_wheel); progressWheel = findViewById(R.id.progress_wheel);

View File

@ -2,13 +2,11 @@ package org.thoughtcrime.securesms.components;
import android.animation.Animator; import android.animation.Animator;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewAnimationUtils; import android.view.ViewAnimationUtils;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout;
import androidx.annotation.MainThread; import androidx.annotation.MainThread;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -19,7 +17,7 @@ import org.thoughtcrime.securesms.util.AnimationCompleteListener;
import network.loki.messenger.R; import network.loki.messenger.R;
public class SearchToolbar extends LinearLayout { public class SearchToolbar extends Toolbar {
private float x, y; private float x, y;
private MenuItem searchItem; private MenuItem searchItem;
@ -41,15 +39,10 @@ public class SearchToolbar extends LinearLayout {
} }
private void initialize() { private void initialize() {
inflate(getContext(), R.layout.search_toolbar, this); setNavigationIcon(getContext().getResources().getDrawable(R.drawable.ic_baseline_clear_24));
setOrientation(VERTICAL); inflateMenu(R.menu.conversation_list_search);
Toolbar toolbar = findViewById(R.id.search_toolbar); this.searchItem = getMenu().findItem(R.id.action_filter_search);
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);
SearchView searchView = (SearchView) searchItem.getActionView(); SearchView searchView = (SearchView) searchItem.getActionView();
EditText searchText = searchView.findViewById(androidx.appcompat.R.id.search_src_text); 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 @MainThread

View File

@ -70,19 +70,19 @@ object UpdateMessageBuilder {
} }
1 -> { 1 -> {
Phrase.from(context, R.string.groupMemberNew) Phrase.from(context, R.string.groupMemberNew)
.put(NAME_KEY, updateData.updatedMembers.elementAtOrNull(0)) .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0)))
.format() .format()
} }
2 -> { 2 -> {
Phrase.from(context, R.string.groupMemberTwoNew) Phrase.from(context, R.string.groupMemberTwoNew)
.put(NAME_KEY, updateData.updatedMembers.elementAtOrNull(0)) .put(NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(0)))
.put(OTHER_NAME_KEY, updateData.updatedMembers.elementAtOrNull(1)) .put(OTHER_NAME_KEY, getSenderName(updateData.updatedMembers.elementAt(1)))
.format() .format()
} }
else -> { else -> {
val newMemberCountMinusOne = newMemberCount - 1 val newMemberCountMinusOne = newMemberCount - 1
Phrase.from(context, R.string.groupMemberMoreNew) 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) .put(COUNT_KEY, newMemberCountMinusOne)
.format() .format()
} }