feat: Added copy photo to PhotoViewer
Thanks to OwlGram
This commit is contained in:
parent
45d70e459e
commit
783415e3d0
@ -256,6 +256,7 @@ import tw.nekomimi.nekogram.transtale.TranslatorKt;
|
||||
import tw.nekomimi.nekogram.utils.AlertUtil;
|
||||
import tw.nekomimi.nekogram.utils.ProxyUtil;
|
||||
import xyz.nextalone.nagram.NaConfig;
|
||||
import xyz.nextalone.nagram.helper.MessageHelper;
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -1229,6 +1230,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
private final static int gallery_menu_share2 = 18;
|
||||
private final static int gallery_menu_speed = 19;
|
||||
|
||||
private final static int gallery_menu_copy = 100;
|
||||
|
||||
private static DecelerateInterpolator decelerateInterpolator;
|
||||
private static Paint progressPaint;
|
||||
|
||||
@ -4474,6 +4477,26 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
thumb = null;
|
||||
}
|
||||
placeProvider.openPhotoForEdit(f.getAbsolutePath(), thumb, isVideo);
|
||||
} else if (id == gallery_menu_copy) {
|
||||
File f = null;
|
||||
if (currentMessageObject != null) {
|
||||
if (currentMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && currentMessageObject.messageOwner.media.webpage != null && currentMessageObject.messageOwner.media.webpage.document == null) {
|
||||
TLObject fileLocation = getFileLocation(currentIndex, null);
|
||||
f = FileLoader.getPathToAttach(fileLocation, true);
|
||||
} else {
|
||||
f = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
|
||||
}
|
||||
} else if (currentFileLocationVideo != null) {
|
||||
f = FileLoader.getPathToAttach(getFileLocation(currentFileLocationVideo), getFileLocationExt(currentFileLocationVideo), avatarsDialogId != 0 || isEvent);
|
||||
} else if (pageBlocksAdapter != null) {
|
||||
f = pageBlocksAdapter.getFile(currentIndex);
|
||||
}
|
||||
|
||||
if (f != null && f.exists()) {
|
||||
MessageHelper.INSTANCE.addFileToClipboard(f, () -> BulletinFactory.of(containerView, null).createCopyBulletin(LocaleController.getString("PhotoCopied", R.string.PhotoCopied)).show());
|
||||
} else {
|
||||
showDownloadAlert();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4557,6 +4580,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
menuItem.addSubItem(gallery_menu_masks2, R.drawable.msg_sticker, LocaleController.getString("ShowStickers", R.string.ShowStickers)).setColors(0xfffafafa, 0xfffafafa);
|
||||
menuItem.addSubItem(gallery_menu_share, R.drawable.msg_shareout, LocaleController.getString("ShareFile", R.string.ShareFile)).setColors(0xfffafafa, 0xfffafafa);
|
||||
menuItem.addSubItem(gallery_menu_save, R.drawable.msg_gallery, LocaleController.getString("SaveToGallery", R.string.SaveToGallery)).setColors(0xfffafafa, 0xfffafafa);
|
||||
menuItem.addSubItem(gallery_menu_copy, R.drawable.msg_copy, LocaleController.getString("CopyPhoto", R.string.CopyPhoto)).setColors(0xfffafafa, 0xfffafafa);
|
||||
|
||||
menuItem.addSubItem(gallery_menu_scan, R.drawable.wallet_qr, LocaleController.getString("ScanQRCode", R.string.ScanQRCode)).setColors(0xfffafafa, 0xfffafafa);
|
||||
|
||||
@ -10571,6 +10595,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
if (currentAnimation != null) {
|
||||
menuItem.hideSubItem(gallery_menu_save);
|
||||
menuItem.hideSubItem(gallery_menu_copy);
|
||||
menuItem.hideSubItem(gallery_menu_share);
|
||||
menuItem.hideSubItem(gallery_menu_scan);
|
||||
if (!newMessageObject.canDeleteMessage(parentChatActivity != null && parentChatActivity.isInScheduleMode(), null)) {
|
||||
@ -10658,6 +10683,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (isEmbedVideo || newMessageObject.messageOwner.ttl != 0 && newMessageObject.messageOwner.ttl < 60 * 60 || noforwardsOverride) {
|
||||
allowShare = false;
|
||||
menuItem.hideSubItem(gallery_menu_save);
|
||||
menuItem.hideSubItem(gallery_menu_copy);
|
||||
bottomButtonsLayout.setVisibility(View.GONE);
|
||||
menuItem.hideSubItem(gallery_menu_scan);
|
||||
menuItem.hideSubItem(gallery_menu_share);
|
||||
@ -10675,6 +10701,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
} else {
|
||||
menuItem.showSubItem(gallery_menu_share);
|
||||
}
|
||||
if (newMessageObject.isPhoto()) {
|
||||
menuItem.showSubItem(gallery_menu_copy);
|
||||
} else {
|
||||
menuItem.hideSubItem(gallery_menu_copy);
|
||||
}
|
||||
}
|
||||
groupedPhotosListView.fillList();
|
||||
}
|
||||
@ -10682,6 +10713,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
allowShare = false;
|
||||
menuItem.showSubItem(gallery_menu_delete);
|
||||
menuItem.hideSubItem(gallery_menu_save);
|
||||
menuItem.hideSubItem(gallery_menu_copy);
|
||||
menuItem.hideSubItem(gallery_menu_scan);
|
||||
nameTextView.setText("");
|
||||
dateTextView.setText("");
|
||||
@ -10705,7 +10737,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
nameTextView.setText("");
|
||||
}
|
||||
}
|
||||
long date = (long) avatarsArr.get(switchingToIndex).date * 1000;
|
||||
TLRPC.Photo avatar = avatarsArr.get(switchingToIndex);
|
||||
long date = (long) avatar.date * 1000;
|
||||
if (date != 0) {
|
||||
String dateString = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date)));
|
||||
dateString = String.format(Locale.US, "%s @DC%d", dateString, avatarsArr.get(switchingToIndex).dc_id);
|
||||
@ -10747,6 +10780,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
} else {
|
||||
menuItem.showSubItem(gallery_menu_save);
|
||||
}
|
||||
if (!noforwardsOverrided && avatar.video_sizes.isEmpty()) {
|
||||
menuItem.showSubItem(gallery_menu_copy);
|
||||
} else {
|
||||
menuItem.hideSubItem(gallery_menu_copy);
|
||||
}
|
||||
menuItem.showSubItem(gallery_menu_scan);
|
||||
allowShare = !noforwardsOverrided;
|
||||
shareButton.setVisibility(allowShare && shareItem.getVisibility() != View.VISIBLE ? View.VISIBLE : View.GONE);
|
||||
@ -11013,6 +11051,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
groupedPhotosListView.fillList();
|
||||
pageBlocksAdapter.updateSlideshowCell(pageBlock);
|
||||
}
|
||||
if (!NaConfig.INSTANCE.getShowCopyPhoto().Bool()){
|
||||
menuItem.hideSubItem(gallery_menu_copy);
|
||||
}
|
||||
|
||||
setCurrentCaption(newMessageObject, caption, animateCaption);
|
||||
}
|
||||
@ -11127,6 +11168,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
menuItem.hideSubItem(gallery_menu_scan);
|
||||
setDoubleTapEnabled(false);
|
||||
}
|
||||
if (canZoom && allowShare && !isVideo && NaConfig.INSTANCE.getShowCopyPhoto().Bool()) {
|
||||
menuItem.showSubItem(gallery_menu_copy);
|
||||
} else {
|
||||
menuItem.hideSubItem(gallery_menu_copy);
|
||||
}
|
||||
}
|
||||
if (isVideo || isEmbedVideo) {
|
||||
speedItem.setVisibility(View.VISIBLE);
|
||||
|
Loading…
Reference in New Issue
Block a user