kopia lustrzana https://github.com/ryukoposting/Signal-Android
Fix crash when entering conversation search through bottom sheet.
rodzic
5423ed1d91
commit
ef9f1e9884
|
@ -384,7 +384,7 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
|
|||
initializeMessageRequestViewModel();
|
||||
initializeListAdapter();
|
||||
|
||||
// TODO [alex] LargeScreenSupport -- conversationViewModel.getSearchQuery().observe(getViewLifecycleOwner(), this::onSearchQueryUpdated);
|
||||
conversationViewModel.getSearchQuery().observe(getViewLifecycleOwner(), this::onSearchQueryUpdated);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -1161,7 +1161,7 @@ public class ConversationFragment extends LoggingFragment implements Multiselect
|
|||
return getListAdapter().isTypingViewEnabled();
|
||||
}
|
||||
|
||||
public void onSearchQueryUpdated(@Nullable String query) {
|
||||
private void onSearchQueryUpdated(@Nullable String query) {
|
||||
if (getListAdapter() != null) {
|
||||
getListAdapter().onSearchQueryUpdated(query);
|
||||
}
|
||||
|
|
|
@ -1020,8 +1020,7 @@ public class ConversationParentFragment extends Fragment
|
|||
public boolean onQueryTextSubmit(String query) {
|
||||
searchViewModel.onQueryUpdated(query, threadId, true);
|
||||
searchNav.showLoading();
|
||||
// TODO [alex] LargeScreenSupport -- Set search query on viewModel
|
||||
fragment.onSearchQueryUpdated(query);
|
||||
viewModel.setSearchQuery(query);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1029,8 +1028,7 @@ public class ConversationParentFragment extends Fragment
|
|||
public boolean onQueryTextChange(String query) {
|
||||
searchViewModel.onQueryUpdated(query, threadId, false);
|
||||
searchNav.showLoading();
|
||||
// TODO [alex] LargeScreenSupport -- Set search query on viewModel
|
||||
fragment.onSearchQueryUpdated(query);
|
||||
viewModel.setSearchQuery(query);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -1059,8 +1057,7 @@ public class ConversationParentFragment extends Fragment
|
|||
searchViewModel.onSearchClosed();
|
||||
searchNav.setVisibility(View.GONE);
|
||||
inputPanel.setHideForSearch(false);
|
||||
// TODO [alex] LargeScreenSupport -- Set search query on viewModel
|
||||
fragment.onSearchQueryUpdated(null);
|
||||
viewModel.setSearchQuery(null);
|
||||
setBlockedUserState(recipient.get(), isSecureText, isDefaultSms);
|
||||
invalidateOptionsMenu();
|
||||
return true;
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Application;
|
|||
|
||||
import androidx.annotation.MainThread;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.LiveDataReactiveStreams;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
@ -90,6 +91,7 @@ public class ConversationViewModel extends ViewModel {
|
|||
private final Store<ThreadAnimationState> threadAnimationStateStore;
|
||||
private final Observer<ThreadAnimationState> threadAnimationStateStoreDriver;
|
||||
private final NotificationProfilesRepository notificationProfilesRepository;
|
||||
private final MutableLiveData<String> searchQuery;
|
||||
|
||||
private final Map<GroupId, Set<Recipient>> sessionMemberCache = new HashMap<>();
|
||||
|
||||
|
@ -115,6 +117,7 @@ public class ConversationViewModel extends ViewModel {
|
|||
this.conversationTopMargin = Transformations.distinctUntilChanged(LiveDataUtil.combineLatest(toolbarBottom, inlinePlayerHeight, Integer::sum));
|
||||
this.threadAnimationStateStore = new Store<>(new ThreadAnimationState(-1L, null, false));
|
||||
this.notificationProfilesRepository = new NotificationProfilesRepository();
|
||||
this.searchQuery = new MutableLiveData<>();
|
||||
|
||||
LiveData<Recipient> recipientLiveData = LiveDataUtil.mapAsync(recipientId, Recipient::resolved);
|
||||
LiveData<ThreadAndRecipient> threadAndRecipient = LiveDataUtil.combineLatest(threadId, recipientLiveData, ThreadAndRecipient::new);
|
||||
|
@ -149,10 +152,10 @@ public class ConversationViewModel extends ViewModel {
|
|||
ApplicationDependencies.getDatabaseObserver().registerMessageInsertObserver(data.getThreadId(), messageInsertObserver);
|
||||
|
||||
ConversationDataSource dataSource = new ConversationDataSource(context, data.getThreadId(), messageRequestData, data.showUniversalExpireTimerMessage());
|
||||
PagingConfig config = new PagingConfig.Builder().setPageSize(25)
|
||||
.setBufferPages(3)
|
||||
.setStartIndex(Math.max(startPosition, 0))
|
||||
.build();
|
||||
PagingConfig config = new PagingConfig.Builder().setPageSize(25)
|
||||
.setBufferPages(3)
|
||||
.setStartIndex(Math.max(startPosition, 0))
|
||||
.build();
|
||||
|
||||
Log.d(TAG, "Starting at position: " + startPosition + " || jumpToPosition: " + data.getJumpToPosition() + ", lastSeenPosition: " + data.getLastSeenPosition() + ", lastScrolledPosition: " + data.getLastScrolledPosition());
|
||||
return new Pair<>(data.getThreadId(), PagedData.create(dataSource, config));
|
||||
|
@ -167,13 +170,13 @@ public class ConversationViewModel extends ViewModel {
|
|||
canShowAsBubble = LiveDataUtil.mapAsync(threadId, conversationRepository::canShowAsBubble);
|
||||
wallpaper = LiveDataUtil.mapDistinct(Transformations.switchMap(recipientId,
|
||||
id -> Recipient.live(id).getLiveData()),
|
||||
Recipient::getWallpaper);
|
||||
Recipient::getWallpaper);
|
||||
|
||||
EventBus.getDefault().register(this);
|
||||
|
||||
chatColors = LiveDataUtil.mapDistinct(Transformations.switchMap(recipientId,
|
||||
id -> Recipient.live(id).getLiveData()),
|
||||
Recipient::getChatColors);
|
||||
Recipient::getChatColors);
|
||||
|
||||
threadAnimationStateStore.update(threadId, (id, state) -> {
|
||||
if (state.getThreadId() == id) {
|
||||
|
@ -243,6 +246,14 @@ public class ConversationViewModel extends ViewModel {
|
|||
this.threadId.postValue(-1L);
|
||||
}
|
||||
|
||||
void setSearchQuery(@Nullable String query) {
|
||||
searchQuery.setValue(query);
|
||||
}
|
||||
|
||||
@NonNull LiveData<String> getSearchQuery() {
|
||||
return searchQuery;
|
||||
}
|
||||
|
||||
@NonNull LiveData<Integer> getConversationTopMargin() {
|
||||
return conversationTopMargin;
|
||||
}
|
||||
|
@ -310,7 +321,7 @@ public class ConversationViewModel extends ViewModel {
|
|||
.sortBy(Recipient::requireStringId)
|
||||
.toList();
|
||||
|
||||
List<NameColor> names = ChatColorsPalette.Names.getAll();
|
||||
List<NameColor> names = ChatColorsPalette.Names.getAll();
|
||||
Map<RecipientId, NameColor> colors = new HashMap<>();
|
||||
for (int i = 0; i < sorted.size(); i++) {
|
||||
colors.put(sorted.get(i).getId(), names.get(i % names.size()));
|
||||
|
|
Ładowanie…
Reference in New Issue