use of androidx.appcompat.widget.AppCompatImageView in project Signal-Android by WhisperSystems.
the class EnableCallNotificationSettingsDialog method bind.
private void bind(@NonNull View view) {
TextView allConfigured = view.findViewById(R.id.enable_call_notification_settings_dialog_system_all_configured);
AppCompatImageView systemSettingIndicator = view.findViewById(R.id.enable_call_notification_settings_dialog_system_setting_indicator);
TextView systemSettingText = view.findViewById(R.id.enable_call_notification_settings_dialog_system_setting_text);
AppCompatImageView channelSettingIndicator = view.findViewById(R.id.enable_call_notification_settings_dialog_channel_setting_indicator);
TextView channelSettingText = view.findViewById(R.id.enable_call_notification_settings_dialog_channel_setting_text);
AppCompatImageView backgroundRestrictedIndicator = view.findViewById(R.id.enable_call_notification_settings_dialog_background_restricted_indicator);
TextView backgroundRestrictedText = view.findViewById(R.id.enable_call_notification_settings_dialog_background_restricted_text);
if (areNotificationsDisabled(requireContext())) {
systemSettingIndicator.setVisibility(View.VISIBLE);
systemSettingText.setVisibility(View.VISIBLE);
systemSettingText.setOnClickListener(v -> showNotificationSettings());
} else {
systemSettingIndicator.setVisibility(View.GONE);
systemSettingText.setVisibility(View.GONE);
systemSettingText.setOnClickListener(null);
}
if (isCallChannelInvalid(requireContext())) {
channelSettingIndicator.setVisibility(View.VISIBLE);
channelSettingText.setVisibility(View.VISIBLE);
channelSettingText.setOnClickListener(v -> showNotificationChannelSettings());
} else {
channelSettingIndicator.setVisibility(View.GONE);
channelSettingText.setVisibility(View.GONE);
channelSettingText.setOnClickListener(null);
}
if (isBackgroundRestricted(requireContext())) {
backgroundRestrictedIndicator.setVisibility(View.VISIBLE);
backgroundRestrictedText.setVisibility(View.VISIBLE);
backgroundRestrictedText.setOnClickListener(v -> showAppSettings());
} else {
backgroundRestrictedIndicator.setVisibility(View.GONE);
backgroundRestrictedText.setVisibility(View.GONE);
backgroundRestrictedText.setOnClickListener(null);
}
allConfigured.setVisibility(shouldShow(requireContext()) ? View.GONE : View.VISIBLE);
}
use of androidx.appcompat.widget.AppCompatImageView in project J2ME-Loader by nikita36078.
the class ImageItem method getItemContentView.
@Override
public View getItemContentView() {
if (imageView == null) {
imageView = new AppCompatImageView(getOwnerForm().getParentActivity());
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setOnClickListener(v -> fireDefaultCommandAction());
updateImageView();
}
return imageView;
}
use of androidx.appcompat.widget.AppCompatImageView in project Signal-Android by signalapp.
the class EnableCallNotificationSettingsDialog method bind.
private void bind(@NonNull View view) {
TextView allConfigured = view.findViewById(R.id.enable_call_notification_settings_dialog_system_all_configured);
AppCompatImageView systemSettingIndicator = view.findViewById(R.id.enable_call_notification_settings_dialog_system_setting_indicator);
TextView systemSettingText = view.findViewById(R.id.enable_call_notification_settings_dialog_system_setting_text);
AppCompatImageView channelSettingIndicator = view.findViewById(R.id.enable_call_notification_settings_dialog_channel_setting_indicator);
TextView channelSettingText = view.findViewById(R.id.enable_call_notification_settings_dialog_channel_setting_text);
AppCompatImageView backgroundRestrictedIndicator = view.findViewById(R.id.enable_call_notification_settings_dialog_background_restricted_indicator);
TextView backgroundRestrictedText = view.findViewById(R.id.enable_call_notification_settings_dialog_background_restricted_text);
if (areNotificationsDisabled(requireContext())) {
systemSettingIndicator.setVisibility(View.VISIBLE);
systemSettingText.setVisibility(View.VISIBLE);
systemSettingText.setOnClickListener(v -> showNotificationSettings());
} else {
systemSettingIndicator.setVisibility(View.GONE);
systemSettingText.setVisibility(View.GONE);
systemSettingText.setOnClickListener(null);
}
if (isCallChannelInvalid(requireContext())) {
channelSettingIndicator.setVisibility(View.VISIBLE);
channelSettingText.setVisibility(View.VISIBLE);
channelSettingText.setOnClickListener(v -> showNotificationChannelSettings());
} else {
channelSettingIndicator.setVisibility(View.GONE);
channelSettingText.setVisibility(View.GONE);
channelSettingText.setOnClickListener(null);
}
if (isBackgroundRestricted(requireContext())) {
backgroundRestrictedIndicator.setVisibility(View.VISIBLE);
backgroundRestrictedText.setVisibility(View.VISIBLE);
backgroundRestrictedText.setOnClickListener(v -> showAppSettings());
} else {
backgroundRestrictedIndicator.setVisibility(View.GONE);
backgroundRestrictedText.setVisibility(View.GONE);
backgroundRestrictedText.setOnClickListener(null);
}
allConfigured.setVisibility(shouldShow(requireContext()) ? View.GONE : View.VISIBLE);
}
use of androidx.appcompat.widget.AppCompatImageView in project Signal-Android by signalapp.
the class ChatWallpaperFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
viewModel = ViewModelProviders.of(requireActivity()).get(ChatWallpaperViewModel.class);
AvatarImageView portrait = view.findViewById(R.id.chat_wallpaper_preview_top_bar_portrait);
Toolbar toolbar = view.findViewById(R.id.toolbar);
ImageView chatWallpaperPreview = view.findViewById(R.id.chat_wallpaper_preview_background);
View setWallpaper = view.findViewById(R.id.chat_wallpaper_set_wallpaper);
SwitchCompat dimInNightMode = view.findViewById(R.id.chat_wallpaper_dark_theme_dims_wallpaper);
View chatWallpaperDim = view.findViewById(R.id.chat_wallpaper_dim);
TextView setChatColor = view.findViewById(R.id.chat_wallpaper_set_chat_color);
TextView resetChatColors = view.findViewById(R.id.chat_wallpaper_reset_chat_colors);
ImageView sentBubble = view.findViewById(R.id.chat_wallpaper_preview_bubble_2);
ColorizerView colorizerView = view.findViewById(R.id.colorizer);
TextView resetAllWallpaper = view.findViewById(R.id.chat_wallpaper_reset_all_wallpapers);
AppCompatImageView recvBubble = view.findViewById(R.id.chat_wallpaper_preview_bubble_1);
toolbar.setTitle(R.string.preferences__chat_color_and_wallpaper);
toolbar.setNavigationOnClickListener(nav -> {
if (!Navigation.findNavController(nav).popBackStack()) {
requireActivity().finish();
}
});
forceAspectRatioToScreenByAdjustingHeight(chatWallpaperPreview);
viewModel.getWallpaperPreviewPortrait().observe(getViewLifecycleOwner(), wallpaperPreviewPortrait -> wallpaperPreviewPortrait.applyToAvatarImageView(portrait));
viewModel.getCurrentWallpaper().observe(getViewLifecycleOwner(), wallpaper -> {
if (wallpaper.isPresent()) {
wallpaper.get().loadInto(chatWallpaperPreview);
ImageViewCompat.setImageTintList(recvBubble, ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.conversation_item_wallpaper_bubble_color)));
} else {
chatWallpaperPreview.setImageDrawable(null);
ImageViewCompat.setImageTintList(recvBubble, ColorStateList.valueOf(ContextCompat.getColor(requireContext(), R.color.signal_background_secondary)));
}
});
viewModel.getDimInDarkTheme().observe(getViewLifecycleOwner(), shouldDimInNightMode -> {
if (shouldDimInNightMode != dimInNightMode.isChecked()) {
isSettingDimFromViewModel = true;
dimInNightMode.setChecked(shouldDimInNightMode);
isSettingDimFromViewModel = false;
}
chatWallpaperDim.setAlpha(ChatWallpaper.FIXED_DIM_LEVEL_FOR_DARK_THEME);
chatWallpaperDim.setVisibility(shouldDimInNightMode && ThemeUtil.isDarkTheme(requireContext()) ? View.VISIBLE : View.GONE);
});
viewModel.getEnableWallpaperControls().observe(getViewLifecycleOwner(), enableWallpaperControls -> {
dimInNightMode.setEnabled(enableWallpaperControls);
dimInNightMode.setAlpha(enableWallpaperControls ? 1 : 0.5f);
});
chatWallpaperPreview.setOnClickListener(unused -> setWallpaper.performClick());
setWallpaper.setOnClickListener(unused -> SafeNavigation.safeNavigate(Navigation.findNavController(view), R.id.action_chatWallpaperFragment_to_chatWallpaperSelectionFragment));
setChatColor.setOnClickListener(unused -> SafeNavigation.safeNavigate(Navigation.findNavController(view), ChatWallpaperFragmentDirections.actionChatWallpaperFragmentToChatColorSelectionFragment(viewModel.getRecipientId())));
if (viewModel.isGlobal()) {
resetAllWallpaper.setOnClickListener(unused -> {
new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.ChatWallpaperFragment__reset_wallpaper).setMessage(R.string.ChatWallpaperFragment__would_you_like_to_override_all_wallpapers).setPositiveButton(R.string.ChatWallpaperFragment__reset_default_wallpaper, (dialog, which) -> {
viewModel.setWallpaper(null);
viewModel.setDimInDarkTheme(true);
viewModel.saveWallpaperSelection();
dialog.dismiss();
}).setNegativeButton(R.string.ChatWallpaperFragment__reset_all_wallpapers, (dialog, which) -> {
viewModel.setWallpaper(null);
viewModel.setDimInDarkTheme(true);
viewModel.resetAllWallpaper();
dialog.dismiss();
}).setNeutralButton(android.R.string.cancel, (dialog, which) -> {
dialog.dismiss();
}).show();
});
resetChatColors.setOnClickListener(unused -> {
new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.ChatWallpaperFragment__reset_chat_colors).setMessage(R.string.ChatWallpaperFragment__would_you_like_to_override_all_chat_colors).setPositiveButton(R.string.ChatWallpaperFragment__reset_default_colors, (dialog, which) -> {
viewModel.clearChatColor();
dialog.dismiss();
}).setNegativeButton(R.string.ChatWallpaperFragment__reset_all_colors, (dialog, which) -> {
viewModel.resetAllChatColors();
dialog.dismiss();
}).setNeutralButton(android.R.string.cancel, (dialog, which) -> {
dialog.dismiss();
}).show();
});
} else {
resetAllWallpaper.setText(R.string.ChatWallpaperFragment__reset_wallpaper);
resetChatColors.setText(R.string.ChatWallpaperFragment__reset_chat_color);
resetAllWallpaper.setOnClickListener(unused -> {
new MaterialAlertDialogBuilder(requireContext()).setMessage(R.string.ChatWallpaperFragment__reset_wallpaper_question).setPositiveButton(R.string.ChatWallpaperFragment__reset, (dialog, which) -> {
viewModel.setWallpaper(null);
viewModel.setDimInDarkTheme(true);
viewModel.saveWallpaperSelection();
viewModel.refreshChatColors();
}).setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss()).show();
});
resetChatColors.setOnClickListener(unused -> {
new MaterialAlertDialogBuilder(requireContext()).setMessage(R.string.ChatWallpaperFragment__reset_chat_color_question).setPositiveButton(R.string.ChatWallpaperFragment__reset, (dialog, which) -> viewModel.clearChatColor()).setNegativeButton(android.R.string.cancel, (dialog, which) -> dialog.dismiss()).show();
});
}
dimInNightMode.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (!isSettingDimFromViewModel) {
viewModel.setDimInDarkTheme(isChecked);
}
});
viewModel.getCurrentChatColors().observe(getViewLifecycleOwner(), chatColors -> {
sentBubble.getDrawable().setColorFilter(chatColors.getChatBubbleColorFilter());
colorizerView.setBackground(chatColors.getChatBubbleMask());
Projection projection = Projection.relativeToViewWithCommonRoot(sentBubble, colorizerView, new Projection.Corners(ViewUtil.dpToPx(10)));
colorizerView.setProjections(Collections.singletonList(projection));
Drawable colorCircle = chatColors.asCircle();
colorCircle.setBounds(0, 0, ViewUtil.dpToPx(16), ViewUtil.dpToPx(16));
TextViewCompat.setCompoundDrawablesRelative(setChatColor, null, null, colorCircle, null);
});
sentBubble.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> viewModel.refreshChatColors());
}
use of androidx.appcompat.widget.AppCompatImageView in project Signal-Android by WhisperSystems.
the class AvatarUtil method loadBlurredIconIntoImageView.
public static void loadBlurredIconIntoImageView(@NonNull Recipient recipient, @NonNull AppCompatImageView target) {
Context context = target.getContext();
ContactPhoto photo;
if (recipient.isSelf()) {
photo = new ProfileContactPhoto(Recipient.self(), Recipient.self().getProfileAvatar());
} else if (recipient.getContactPhoto() == null) {
target.setImageDrawable(null);
target.setBackgroundColor(ContextCompat.getColor(target.getContext(), R.color.black));
return;
} else {
photo = recipient.getContactPhoto();
}
GlideApp.with(target).load(photo).transform(new BlurTransformation(context, 0.25f, BlurTransformation.MAX_RADIUS)).into(new CustomViewTarget<View, Drawable>(target) {
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
target.setImageDrawable(null);
target.setBackgroundColor(ContextCompat.getColor(target.getContext(), R.color.black));
}
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
target.setImageDrawable(resource);
}
@Override
protected void onResourceCleared(@Nullable Drawable placeholder) {
target.setImageDrawable(placeholder);
}
});
}
Aggregations