1
0
mirror of https://github.com/NekoX-Dev/NekoX.git synced 2024-12-03 13:10:32 +01:00

Improve button copy

This commit is contained in:
Riko Sakurauchi 2020-02-16 13:47:23 +08:00
parent c9582ed7ff
commit 66a6ac68af
No known key found for this signature in database
GPG Key ID: 25AC0345B92902AF
2 changed files with 29 additions and 8 deletions

View File

@ -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();

View File

@ -81,4 +81,5 @@
<string name="TranslateApiUnsupported">The translation provider you selected don\'t support your language</string>
<string name="ProviderLingocloud">Lingocloud</string>
<string name="UndoTranslate">Undo translate</string>
<string name="CopyDetails">Copy Details</string>
</resources>