use of org.thoughtcrime.securesms.util.adapter.mapping.MappingModel in project Signal-Android by WhisperSystems.
the class ChatWallpaperPreviewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
dynamicTheme.onCreate(this);
setContentView(R.layout.chat_wallpaper_preview_activity);
adapter = new ChatWallpaperPreviewAdapter();
colorizerView = findViewById(R.id.colorizer);
bubble2 = findViewById(R.id.preview_bubble_2);
viewPager = findViewById(R.id.preview_pager);
View submit = findViewById(R.id.preview_set_wallpaper);
ChatWallpaperRepository repository = new ChatWallpaperRepository();
ChatWallpaper selected = getIntent().getParcelableExtra(EXTRA_CHAT_WALLPAPER);
boolean dim = getIntent().getBooleanExtra(EXTRA_DIM_IN_DARK_MODE, false);
Toolbar toolbar = findViewById(R.id.toolbar);
TextView bubble2Text = findViewById(R.id.preview_bubble_2_text);
toolbar.setNavigationOnClickListener(unused -> {
finish();
});
viewPager.setAdapter(adapter);
adapter.submitList(Collections.singletonList(new ChatWallpaperSelectionMappingModel(selected)));
repository.getAllWallpaper(wallpapers -> adapter.submitList(Stream.of(wallpapers).map(wallpaper -> ChatWallpaperFactory.updateWithDimming(wallpaper, dim ? ChatWallpaper.FIXED_DIM_LEVEL_FOR_DARK_THEME : 0f)).<MappingModel<?>>map(ChatWallpaperSelectionMappingModel::new).toList()));
submit.setOnClickListener(unused -> {
ChatWallpaperSelectionMappingModel model = (ChatWallpaperSelectionMappingModel) adapter.getCurrentList().get(viewPager.getCurrentItem());
setResult(RESULT_OK, new Intent().putExtra(EXTRA_CHAT_WALLPAPER, model.getWallpaper()));
finish();
});
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.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);
});
} else {
onPageChanged = new OnPageChanged();
viewPager.registerOnPageChangeCallback(onPageChanged);
bubble2.addOnLayoutChangeListener(new UpdateChatColorsOnNextLayoutChange(selected.getAutoChatColors()));
}
new FullscreenHelper(this).showSystemUI();
WindowUtil.setLightStatusBarFromTheme(this);
WindowUtil.setLightNavigationBarFromTheme(this);
}
use of org.thoughtcrime.securesms.util.adapter.mapping.MappingModel in project Signal-Android by signalapp.
the class ChatWallpaperPreviewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
dynamicTheme.onCreate(this);
setContentView(R.layout.chat_wallpaper_preview_activity);
adapter = new ChatWallpaperPreviewAdapter();
colorizerView = findViewById(R.id.colorizer);
bubble2 = findViewById(R.id.preview_bubble_2);
viewPager = findViewById(R.id.preview_pager);
View submit = findViewById(R.id.preview_set_wallpaper);
ChatWallpaperRepository repository = new ChatWallpaperRepository();
ChatWallpaper selected = getIntent().getParcelableExtra(EXTRA_CHAT_WALLPAPER);
boolean dim = getIntent().getBooleanExtra(EXTRA_DIM_IN_DARK_MODE, false);
Toolbar toolbar = findViewById(R.id.toolbar);
TextView bubble2Text = findViewById(R.id.preview_bubble_2_text);
toolbar.setNavigationOnClickListener(unused -> {
finish();
});
viewPager.setAdapter(adapter);
adapter.submitList(Collections.singletonList(new ChatWallpaperSelectionMappingModel(selected)));
repository.getAllWallpaper(wallpapers -> adapter.submitList(Stream.of(wallpapers).map(wallpaper -> ChatWallpaperFactory.updateWithDimming(wallpaper, dim ? ChatWallpaper.FIXED_DIM_LEVEL_FOR_DARK_THEME : 0f)).<MappingModel<?>>map(ChatWallpaperSelectionMappingModel::new).toList()));
submit.setOnClickListener(unused -> {
ChatWallpaperSelectionMappingModel model = (ChatWallpaperSelectionMappingModel) adapter.getCurrentList().get(viewPager.getCurrentItem());
setResult(RESULT_OK, new Intent().putExtra(EXTRA_CHAT_WALLPAPER, model.getWallpaper()));
finish();
});
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.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);
});
} else {
onPageChanged = new OnPageChanged();
viewPager.registerOnPageChangeCallback(onPageChanged);
bubble2.addOnLayoutChangeListener(new UpdateChatColorsOnNextLayoutChange(selected.getAutoChatColors()));
}
new FullscreenHelper(this).showSystemUI();
WindowUtil.setLightStatusBarFromTheme(this);
WindowUtil.setLightNavigationBarFromTheme(this);
}
use of org.thoughtcrime.securesms.util.adapter.mapping.MappingModel in project Signal-Android by WhisperSystems.
the class CallParticipantsListDialog method updateList.
private void updateList(@NonNull CallParticipantsState callParticipantsState) {
List<MappingModel<?>> items = new ArrayList<>();
boolean includeSelf = callParticipantsState.getGroupCallState() == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
OptionalLong headerCount = callParticipantsState.getParticipantCount();
headerCount.executeIfPresent(count -> {
items.add(new CallParticipantsListHeader((int) count));
if (includeSelf) {
items.add(new CallParticipantViewState(callParticipantsState.getLocalParticipant()));
}
for (CallParticipant callParticipant : callParticipantsState.getAllRemoteParticipants()) {
items.add(new CallParticipantViewState(callParticipant));
}
});
adapter.submitList(items);
}
use of org.thoughtcrime.securesms.util.adapter.mapping.MappingModel in project Signal-Android by signalapp.
the class CallParticipantsListDialog method updateList.
private void updateList(@NonNull CallParticipantsState callParticipantsState) {
List<MappingModel<?>> items = new ArrayList<>();
boolean includeSelf = callParticipantsState.getGroupCallState() == WebRtcViewModel.GroupCallState.CONNECTED_AND_JOINED;
OptionalLong headerCount = callParticipantsState.getParticipantCount();
headerCount.executeIfPresent(count -> {
items.add(new CallParticipantsListHeader((int) count));
if (includeSelf) {
items.add(new CallParticipantViewState(callParticipantsState.getLocalParticipant()));
}
for (CallParticipant callParticipant : callParticipantsState.getAllRemoteParticipants()) {
items.add(new CallParticipantViewState(callParticipant));
}
});
adapter.submitList(items);
}
Aggregations