feat: Copy Photo As Sticker
Co-authored-by: arsLan4k1390 <65973611+arsLan4k1390@users.noreply.github.com>
This commit is contained in:
parent
151885375b
commit
613d0d5079
@ -1028,6 +1028,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
private final static int OPTION_SPEED_PROMO = 103;
|
||||
private final static int OPTION_OPEN_PROFILE = 104;
|
||||
private final static int OPTION_COPY_PHOTO = 150;
|
||||
private final static int OPTION_COPY_PHOTO_AS_STICKER = 151;
|
||||
|
||||
private final static int[] allowedNotificationsDuringChatListAnimations = new int[]{
|
||||
NotificationCenter.messagesRead,
|
||||
@ -26140,7 +26141,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
items.add(LocaleController.getString("CopyPhoto", R.string.CopyPhoto));
|
||||
options.add(OPTION_COPY_PHOTO);
|
||||
icons.add(R.drawable.msg_copy);
|
||||
} }
|
||||
items.add(LocaleController.getString("CopyPhotoAsSticker", R.string.CopyPhotoAsSticker));
|
||||
options.add(OPTION_COPY_PHOTO_AS_STICKER);
|
||||
icons.add(R.drawable.msg_copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (type == 5) {
|
||||
@ -26508,7 +26513,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
items.add(LocaleController.getString("CopyPhoto", R.string.CopyPhoto));
|
||||
options.add(OPTION_COPY_PHOTO);
|
||||
icons.add(R.drawable.msg_copy);
|
||||
}}
|
||||
items.add(LocaleController.getString("CopyPhotoAsSticker", R.string.CopyPhotoAsSticker));
|
||||
options.add(OPTION_COPY_PHOTO_AS_STICKER);
|
||||
icons.add(R.drawable.msg_copy);
|
||||
}
|
||||
}
|
||||
} else if (type == 5) {
|
||||
items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile));
|
||||
options.add(OPTION_APPLY_LOCALIZATION_OR_THEME);
|
||||
@ -28968,6 +28977,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
});
|
||||
break;
|
||||
}
|
||||
case OPTION_COPY_PHOTO_AS_STICKER:{
|
||||
MessageHelper.INSTANCE.addMessageToClipboardAsSticker(selectedObject, () -> {
|
||||
if (BulletinFactory.canShowBulletin(ChatActivity.this)) {
|
||||
BulletinFactory.of(this).createCopyBulletin(LocaleController.getString("PhotoCopied", R.string.PhotoCopied)).show();
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
case OPTION_HIDE_SPONSORED_MESSAGE: {
|
||||
MessageObject message = selectedObject;
|
||||
showDialog(new PremiumFeatureBottomSheet(ChatActivity.this, PremiumPreviewFragment.PREMIUM_FEATURE_ADS, true));
|
||||
|
@ -3,13 +3,37 @@ package xyz.nextalone.nagram.helper
|
||||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Build
|
||||
import android.text.TextUtils
|
||||
import androidx.core.content.FileProvider
|
||||
import org.telegram.messenger.*
|
||||
import org.telegram.tgnet.TLRPC.*
|
||||
import org.telegram.messenger.AndroidUtilities
|
||||
import org.telegram.messenger.ApplicationLoader
|
||||
import org.telegram.messenger.BuildConfig
|
||||
import org.telegram.messenger.ChatObject
|
||||
import org.telegram.messenger.DialogObject
|
||||
import org.telegram.messenger.Emoji
|
||||
import org.telegram.messenger.FileLoader
|
||||
import org.telegram.messenger.FileLog
|
||||
import org.telegram.messenger.LocaleController
|
||||
import org.telegram.messenger.MediaDataController
|
||||
import org.telegram.messenger.MessageObject
|
||||
import org.telegram.messenger.UserConfig
|
||||
import org.telegram.tgnet.TLRPC.Chat
|
||||
import org.telegram.tgnet.TLRPC.TL_messageEntityBankCard
|
||||
import org.telegram.tgnet.TLRPC.TL_messageEntityBotCommand
|
||||
import org.telegram.tgnet.TLRPC.TL_messageEntityCashtag
|
||||
import org.telegram.tgnet.TLRPC.TL_messageEntityEmail
|
||||
import org.telegram.tgnet.TLRPC.TL_messageEntityHashtag
|
||||
import org.telegram.tgnet.TLRPC.TL_messageEntityMention
|
||||
import org.telegram.tgnet.TLRPC.TL_messageEntityPhone
|
||||
import org.telegram.tgnet.TLRPC.TL_messageEntityUrl
|
||||
import org.telegram.tgnet.TLRPC.TL_messageMediaPoll
|
||||
import org.telegram.ui.ChatActivity
|
||||
import xyz.nextalone.nagram.NaConfig
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
|
||||
|
||||
object MessageHelper {
|
||||
@ -54,6 +78,32 @@ object MessageHelper {
|
||||
}
|
||||
}
|
||||
|
||||
fun addMessageToClipboardAsSticker(selectedObject: MessageObject, callback: Runnable) {
|
||||
val file = getPathToMessage(selectedObject)
|
||||
try {
|
||||
if (file != null) {
|
||||
val path = file.path
|
||||
val image = BitmapFactory.decodeFile(path)
|
||||
if (image != null && !TextUtils.isEmpty(path)) {
|
||||
val file2 = File(
|
||||
if (path.endsWith(".jpg")) path.replace(
|
||||
".jpg",
|
||||
".webp"
|
||||
) else "$path.webp"
|
||||
)
|
||||
val stream = FileOutputStream(file2)
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
image.compress(Bitmap.CompressFormat.WEBP_LOSSLESS, 100, stream)
|
||||
} else {
|
||||
image.compress(Bitmap.CompressFormat.WEBP, 100, stream)
|
||||
}
|
||||
stream.close()
|
||||
addFileToClipboard(file2, callback)
|
||||
}
|
||||
}
|
||||
} catch (ignored: java.lang.Exception) {
|
||||
}
|
||||
}
|
||||
|
||||
fun addFileToClipboard(file: File?, callback: Runnable) {
|
||||
try {
|
||||
|
@ -94,4 +94,5 @@
|
||||
<string name="ShowSquareAvatar">显示方形头像</string>
|
||||
<string name="DisableCustomWallpaperUser">禁用私聊的自定义背景</string>
|
||||
<string name="DisableCustomWallpaperChannel">禁用频道的自定义背景</string>
|
||||
<string name="CopyPhotoAsSticker">复制图片但是贴纸</string>
|
||||
</resources>
|
||||
|
@ -97,4 +97,5 @@
|
||||
<string name="ShowSquareAvatar">Show square avatar</string>
|
||||
<string name="DisableCustomWallpaperUser">Disable user custom wallpaper</string>
|
||||
<string name="DisableCustomWallpaperChannel">Disable channel custom wallpaper</string>
|
||||
<string name="CopyPhotoAsSticker">Copy Photo As Sticker</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user