use of org.thoughtcrime.securesms.conversation.colors.ColorizerView in project Signal-Android by signalapp.
the class WallpaperCropActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dynamicTheme.onCreate(this);
setContentView(R.layout.chat_wallpaper_crop_activity);
RecipientId recipientId = getIntent().getParcelableExtra(EXTRA_RECIPIENT_ID);
Uri inputImage = Objects.requireNonNull(getIntent().getParcelableExtra(EXTRA_IMAGE_URI));
Log.i(TAG, "Cropping wallpaper for " + (recipientId == null ? "default wallpaper" : recipientId));
WallpaperCropViewModel.Factory factory = new WallpaperCropViewModel.Factory(recipientId);
viewModel = ViewModelProviders.of(this, factory).get(WallpaperCropViewModel.class);
imageEditor = findViewById(R.id.image_editor);
View sentBubble = findViewById(R.id.preview_bubble_2);
TextView bubble2Text = findViewById(R.id.chat_wallpaper_bubble2_text);
View setWallPaper = findViewById(R.id.preview_set_wallpaper);
SwitchCompat blur = findViewById(R.id.preview_blur);
ColorizerView colorizerView = findViewById(R.id.colorizer);
setupImageEditor(inputImage);
setWallPaper.setOnClickListener(v -> setWallpaper());
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar supportActionBar = Objects.requireNonNull(getSupportActionBar());
supportActionBar.setHomeAsUpIndicator(ContextCompat.getDrawable(this, R.drawable.ic_arrow_left_24));
supportActionBar.setDisplayHomeAsUpEnabled(true);
blur.setOnCheckedChangeListener((v, checked) -> viewModel.setBlur(checked));
viewModel.getBlur().observe(this, blurred -> {
setBlurred(blurred);
if (blurred != blur.isChecked()) {
blur.setChecked(blurred);
}
});
viewModel.getRecipient().observe(this, r -> {
if (r.getId().isUnknown()) {
bubble2Text.setText(R.string.WallpaperCropActivity__set_wallpaper_for_all_chats);
} else {
bubble2Text.setText(getString(R.string.WallpaperCropActivity__set_wallpaper_for_s, r.getDisplayName(this)));
sentBubble.getBackground().setColorFilter(r.getChatColors().getChatBubbleColorFilter());
colorizerView.setBackground(r.getChatColors().getChatBubbleMask());
}
});
sentBubble.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
colorizerView.setProjections(Collections.singletonList(Projection.relativeToViewWithCommonRoot(sentBubble, colorizerView, new Projection.Corners(ViewUtil.dpToPx(18)))));
});
}
Aggregations