use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatAttachAlertPhotoLayout method updateAlbumsDropDown.
private void updateAlbumsDropDown() {
dropDownContainer.removeAllSubItems();
if (mediaEnabled) {
ArrayList<MediaController.AlbumEntry> albums;
if (parentAlert.baseFragment instanceof ChatActivity || parentAlert.avatarPicker == 2) {
albums = MediaController.allMediaAlbums;
} else {
albums = MediaController.allPhotoAlbums;
}
dropDownAlbums = new ArrayList<>(albums);
Collections.sort(dropDownAlbums, (o1, o2) -> {
if (o1.bucketId == 0 && o2.bucketId != 0) {
return -1;
} else if (o1.bucketId != 0 && o2.bucketId == 0) {
return 1;
}
int index1 = albums.indexOf(o1);
int index2 = albums.indexOf(o2);
if (index1 > index2) {
return 1;
} else if (index1 < index2) {
return -1;
} else {
return 0;
}
});
} else {
dropDownAlbums = new ArrayList<>();
}
if (dropDownAlbums.isEmpty()) {
dropDown.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
} else {
dropDown.setCompoundDrawablesWithIntrinsicBounds(null, null, dropDownDrawable, null);
for (int a = 0, N = dropDownAlbums.size(); a < N; a++) {
dropDownContainer.addSubItem(10 + a, dropDownAlbums.get(a).bucketName);
}
}
}
use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatAttachAlertPhotoLayout method openCamera.
private void openCamera(boolean animated) {
if (cameraView == null || cameraInitAnimation != null || !cameraView.isInitied() || parentAlert.isDismissed()) {
return;
}
if (parentAlert.avatarPicker == 2 || parentAlert.baseFragment instanceof ChatActivity) {
tooltipTextView.setVisibility(VISIBLE);
} else {
tooltipTextView.setVisibility(GONE);
}
if (cameraPhotos.isEmpty()) {
counterTextView.setVisibility(View.INVISIBLE);
cameraPhotoRecyclerView.setVisibility(View.GONE);
} else {
counterTextView.setVisibility(View.VISIBLE);
cameraPhotoRecyclerView.setVisibility(View.VISIBLE);
}
if (parentAlert.commentTextView.isKeyboardVisible() && isFocusable()) {
parentAlert.commentTextView.closeKeyboard();
}
zoomControlView.setVisibility(View.VISIBLE);
zoomControlView.setAlpha(0.0f);
cameraPanel.setVisibility(View.VISIBLE);
cameraPanel.setTag(null);
animateCameraValues[0] = 0;
animateCameraValues[1] = itemSize;
animateCameraValues[2] = itemSize;
additionCloseCameraY = 0;
cameraExpanded = true;
cameraView.setFpsLimit(-1);
if (animated) {
setCameraOpenProgress(0);
cameraAnimationInProgress = true;
animationIndex = NotificationCenter.getInstance(parentAlert.currentAccount).setAnimationInProgress(animationIndex, null);
ArrayList<Animator> animators = new ArrayList<>();
animators.add(ObjectAnimator.ofFloat(this, "cameraOpenProgress", 0.0f, 1.0f));
animators.add(ObjectAnimator.ofFloat(cameraPanel, View.ALPHA, 1.0f));
animators.add(ObjectAnimator.ofFloat(counterTextView, View.ALPHA, 1.0f));
animators.add(ObjectAnimator.ofFloat(cameraPhotoRecyclerView, View.ALPHA, 1.0f));
for (int a = 0; a < 2; a++) {
if (flashModeButton[a].getVisibility() == View.VISIBLE) {
animators.add(ObjectAnimator.ofFloat(flashModeButton[a], View.ALPHA, 1.0f));
break;
}
}
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(animators);
animatorSet.setDuration(350);
animatorSet.setInterpolator(CubicBezierInterpolator.DEFAULT);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
NotificationCenter.getInstance(parentAlert.currentAccount).onAnimationFinish(animationIndex);
cameraAnimationInProgress = false;
if (Build.VERSION.SDK_INT >= 21 && cameraView != null) {
cameraView.invalidateOutline();
} else if (cameraView != null) {
cameraView.invalidate();
}
if (cameraOpened) {
parentAlert.delegate.onCameraOpened();
}
if (Build.VERSION.SDK_INT >= 21 && cameraView != null) {
cameraView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN);
}
}
});
animatorSet.start();
} else {
setCameraOpenProgress(1.0f);
cameraPanel.setAlpha(1.0f);
counterTextView.setAlpha(1.0f);
cameraPhotoRecyclerView.setAlpha(1.0f);
for (int a = 0; a < 2; a++) {
if (flashModeButton[a].getVisibility() == View.VISIBLE) {
flashModeButton[a].setAlpha(1.0f);
break;
}
}
parentAlert.delegate.onCameraOpened();
if (Build.VERSION.SDK_INT >= 21) {
cameraView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN);
}
}
cameraOpened = true;
cameraView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
if (Build.VERSION.SDK_INT >= 19) {
gridView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
}
}
use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatAttachAlertPhotoLayout method onMenuItemClick.
@Override
void onMenuItemClick(int id) {
if (id == group || id == compress) {
if (parentAlert.maxSelectedPhotos > 0 && selectedPhotosOrder.size() > 1 && parentAlert.baseFragment instanceof ChatActivity) {
ChatActivity chatActivity = (ChatActivity) parentAlert.baseFragment;
TLRPC.Chat chat = chatActivity.getCurrentChat();
if (chat != null && !ChatObject.hasAdminRights(chat) && chat.slowmode_enabled) {
AlertsCreator.createSimpleAlert(getContext(), LocaleController.getString("Slowmode", R.string.Slowmode), LocaleController.getString("SlowmodeSendError", R.string.SlowmodeSendError), resourcesProvider).show();
return;
}
}
}
if (id == group) {
if (parentAlert.editingMessageObject == null && parentAlert.baseFragment instanceof ChatActivity && ((ChatActivity) parentAlert.baseFragment).isInScheduleMode()) {
AlertsCreator.createScheduleDatePickerDialog(getContext(), ((ChatActivity) parentAlert.baseFragment).getDialogId(), (notify, scheduleDate) -> {
parentAlert.applyCaption();
parentAlert.delegate.didPressedButton(7, false, notify, scheduleDate, false);
}, resourcesProvider);
} else {
parentAlert.applyCaption();
parentAlert.delegate.didPressedButton(7, false, true, 0, false);
}
} else if (id == compress) {
if (parentAlert.editingMessageObject == null && parentAlert.baseFragment instanceof ChatActivity && ((ChatActivity) parentAlert.baseFragment).isInScheduleMode()) {
AlertsCreator.createScheduleDatePickerDialog(getContext(), ((ChatActivity) parentAlert.baseFragment).getDialogId(), (notify, scheduleDate) -> {
parentAlert.applyCaption();
parentAlert.delegate.didPressedButton(4, true, notify, scheduleDate, false);
}, resourcesProvider);
} else {
parentAlert.applyCaption();
parentAlert.delegate.didPressedButton(4, true, true, 0, false);
}
} else if (id == open_in) {
try {
if (parentAlert.baseFragment instanceof ChatActivity || parentAlert.avatarPicker == 2) {
Intent videoPickerIntent = new Intent();
videoPickerIntent.setType("video/*");
videoPickerIntent.setAction(Intent.ACTION_GET_CONTENT);
videoPickerIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, FileLoader.MAX_FILE_SIZE);
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
Intent chooserIntent = Intent.createChooser(photoPickerIntent, null);
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { videoPickerIntent });
if (parentAlert.avatarPicker != 0) {
parentAlert.baseFragment.startActivityForResult(chooserIntent, 14);
} else {
parentAlert.baseFragment.startActivityForResult(chooserIntent, 1);
}
} else {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
if (parentAlert.avatarPicker != 0) {
parentAlert.baseFragment.startActivityForResult(photoPickerIntent, 14);
} else {
parentAlert.baseFragment.startActivityForResult(photoPickerIntent, 1);
}
}
parentAlert.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
} else if (id >= 10) {
selectedAlbumEntry = dropDownAlbums.get(id - 10);
if (selectedAlbumEntry == galleryAlbumEntry) {
dropDown.setText(LocaleController.getString("ChatGallery", R.string.ChatGallery));
} else {
dropDown.setText(selectedAlbumEntry.bucketName);
}
adapter.notifyDataSetChanged();
cameraAttachAdapter.notifyDataSetChanged();
layoutManager.scrollToPositionWithOffset(0, -gridView.getPaddingTop() + AndroidUtilities.dp(7));
}
}
use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatAttachAlertPhotoLayout method didReceivedNotification.
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.albumsDidLoad) {
if (adapter != null) {
if (parentAlert.baseFragment instanceof ChatActivity || parentAlert.avatarPicker == 2) {
galleryAlbumEntry = MediaController.allMediaAlbumEntry;
} else {
galleryAlbumEntry = MediaController.allPhotosAlbumEntry;
}
if (selectedAlbumEntry == null) {
selectedAlbumEntry = galleryAlbumEntry;
} else {
for (int a = 0; a < MediaController.allMediaAlbums.size(); a++) {
MediaController.AlbumEntry entry = MediaController.allMediaAlbums.get(a);
if (entry.bucketId == selectedAlbumEntry.bucketId && entry.videoOnly == selectedAlbumEntry.videoOnly) {
selectedAlbumEntry = entry;
break;
}
}
}
loading = false;
progressView.showTextView();
adapter.notifyDataSetChanged();
cameraAttachAdapter.notifyDataSetChanged();
if (!selectedPhotosOrder.isEmpty() && galleryAlbumEntry != null) {
for (int a = 0, N = selectedPhotosOrder.size(); a < N; a++) {
Integer imageId = (Integer) selectedPhotosOrder.get(a);
Object currentEntry = selectedPhotos.get(imageId);
MediaController.PhotoEntry entry = galleryAlbumEntry.photosByIds.get(imageId);
if (entry != null) {
if (currentEntry instanceof MediaController.PhotoEntry) {
MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) currentEntry;
entry.copyFrom(photoEntry);
}
selectedPhotos.put(imageId, entry);
}
}
}
updateAlbumsDropDown();
}
} else if (id == NotificationCenter.cameraInitied) {
checkCamera(false);
}
}
use of org.telegram.ui.ChatActivity in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatAttachAlert method sendPressed.
private void sendPressed(boolean notify, int scheduleDate) {
if (buttonPressed) {
return;
}
if (baseFragment instanceof ChatActivity) {
ChatActivity chatActivity = (ChatActivity) baseFragment;
TLRPC.Chat chat = chatActivity.getCurrentChat();
TLRPC.User user = chatActivity.getCurrentUser();
if (user != null || ChatObject.isChannel(chat) && chat.megagroup || !ChatObject.isChannel(chat)) {
MessagesController.getNotificationsSettings(currentAccount).edit().putBoolean("silent_" + chatActivity.getDialogId(), !notify).commit();
}
}
applyCaption();
buttonPressed = true;
delegate.didPressedButton(7, true, notify, scheduleDate, false);
}
Aggregations