From 66a6ac68af8deec0fa7246d0352bd41fb8750335 Mon Sep 17 00:00:00 2001 From: Riko Sakurauchi Date: Sun, 16 Feb 2020 13:47:23 +0800 Subject: [PATCH] Improve button copy --- .../telegram/ui/Cells/ChatMessageCell.java | 36 ++++++++++++++----- .../src/main/res/values/strings_neko.xml | 1 + 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index ddd099ce4..f4393ef59 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -1565,10 +1565,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate Gson gson = new Gson(); if (!TextUtils.isEmpty(button.button.url)) { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); - builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("CopyLink", R.string.CopyLink)}, (dialogInterface, i) -> { + builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("CopyLink", R.string.CopyLink), LocaleController.getString("CopyDetails", R.string.CopyDetails)}, (dialogInterface, i) -> { if (i == 0) { try { - AndroidUtilities.addToClipboard(gson.toJson(button.button)); + AndroidUtilities.addToClipboard(button.button.text); Toast.makeText(getContext(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show(); } catch (Exception e) { FileLog.e(e); @@ -1580,16 +1580,36 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } catch (Exception e) { FileLog.e(e); } + } else if (i == 2) { + try { + AndroidUtilities.addToClipboard(gson.toJson(button.button)); + Toast.makeText(getContext(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + FileLog.e(e); + } } }); builder.show(); } else { - try { - AndroidUtilities.addToClipboard(gson.toJson(button.button)); - Toast.makeText(getContext(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show(); - } catch (Exception e) { - FileLog.e(e); - } + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("CopyDetails", R.string.CopyDetails)}, (dialogInterface, i) -> { + if (i == 0) { + try { + AndroidUtilities.addToClipboard(button.button.text); + Toast.makeText(getContext(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + FileLog.e(e); + } + } else if (i == 1) { + try { + AndroidUtilities.addToClipboard(gson.toJson(button.button)); + Toast.makeText(getContext(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + FileLog.e(e); + } + } + }); + builder.show(); } pressedBotButton = -1; invalidate(); diff --git a/TMessagesProj/src/main/res/values/strings_neko.xml b/TMessagesProj/src/main/res/values/strings_neko.xml index f658d6aa7..78b629b42 100644 --- a/TMessagesProj/src/main/res/values/strings_neko.xml +++ b/TMessagesProj/src/main/res/values/strings_neko.xml @@ -81,4 +81,5 @@ The translation provider you selected don\'t support your language Lingocloud Undo translate + Copy Details \ No newline at end of file