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