mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 08:39:22 +01:00
Fix bubble color wallpaper preview not updating for individuals.
This commit is contained in:
@@ -8,6 +8,7 @@ import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.viewpager2.widget.ViewPager2;
|
||||
|
||||
@@ -29,7 +30,6 @@ import org.thoughtcrime.securesms.util.WindowUtil;
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingModel;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ChatWallpaperPreviewActivity extends PassphraseRequiredActivity {
|
||||
|
||||
@@ -94,25 +94,17 @@ public class ChatWallpaperPreviewActivity extends PassphraseRequiredActivity {
|
||||
|
||||
RecipientId recipientId = getIntent().getParcelableExtra(EXTRA_RECIPIENT_ID);
|
||||
|
||||
final ChatColors chatColors;
|
||||
if (recipientId != null && Recipient.live(recipientId).get().hasOwnChatColors()) {
|
||||
Recipient recipient = Recipient.live(recipientId).get();
|
||||
bubble2Text.setText(getString(R.string.ChatWallpaperPreviewActivity__set_wallpaper_for_s,
|
||||
recipient.isSelf() ? getString(R.string.note_to_self)
|
||||
: recipient.getDisplayName(this)));
|
||||
chatColors = recipient.getChatColors();
|
||||
bubble2.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
updateChatColors(chatColors);
|
||||
});
|
||||
} else if (SignalStore.chatColorsValues().hasChatColors()) {
|
||||
chatColors = Objects.requireNonNull(SignalStore.chatColorsValues().getChatColors());
|
||||
bubble2.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
updateChatColors(chatColors);
|
||||
});
|
||||
if (recipientId != null) {
|
||||
Recipient.live(recipientId)
|
||||
.getLiveDataResolved()
|
||||
.observe(this, recipient -> {
|
||||
bubble2Text.setText(getString(R.string.ChatWallpaperPreviewActivity__set_wallpaper_for_s,
|
||||
recipient.isSelf() ? getString(R.string.note_to_self)
|
||||
: recipient.getDisplayName(this)));
|
||||
addUpdateBubbleColorListeners(recipient.getChatColors(), selected.getAutoChatColors());
|
||||
});
|
||||
} else {
|
||||
onPageChanged = new OnPageChanged();
|
||||
viewPager.registerOnPageChangeCallback(onPageChanged);
|
||||
bubble2.addOnLayoutChangeListener(new UpdateChatColorsOnNextLayoutChange(selected.getAutoChatColors()));
|
||||
addUpdateBubbleColorListeners(SignalStore.chatColorsValues().getChatColors(), selected.getAutoChatColors());
|
||||
}
|
||||
|
||||
new FullscreenHelper(this).showSystemUI();
|
||||
@@ -120,7 +112,8 @@ public class ChatWallpaperPreviewActivity extends PassphraseRequiredActivity {
|
||||
WindowUtil.setLightNavigationBarFromTheme(this);
|
||||
}
|
||||
|
||||
@Override protected void onDestroy() {
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (onPageChanged != null) {
|
||||
viewPager.unregisterOnPageChangeCallback(onPageChanged);
|
||||
}
|
||||
@@ -128,6 +121,18 @@ public class ChatWallpaperPreviewActivity extends PassphraseRequiredActivity {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void addUpdateBubbleColorListeners(@Nullable ChatColors chatColors, @NonNull ChatColors selectedWallpaperAutoColors) {
|
||||
if (chatColors == null || chatColors.getId().equals(ChatColors.Id.Auto.INSTANCE)) {
|
||||
onPageChanged = new OnPageChanged();
|
||||
viewPager.registerOnPageChangeCallback(onPageChanged);
|
||||
bubble2.addOnLayoutChangeListener(new UpdateChatColorsOnNextLayoutChange(selectedWallpaperAutoColors));
|
||||
} else {
|
||||
bubble2.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
updateChatColors(chatColors);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private class OnPageChanged extends ViewPager2.OnPageChangeCallback {
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
|
||||
Reference in New Issue
Block a user