Fix issue #574 - Copy account id into clipboard with long press

This commit is contained in:
stom79 2018-11-21 11:45:24 +01:00
parent 420914af73
commit ffc04cea3d
2 changed files with 17 additions and 0 deletions

View File

@ -14,6 +14,8 @@
* see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.activities;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
@ -807,6 +809,20 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
account_dn.setText(Helper.shortnameToUnicode(account.getDisplay_name(), true));
account_un.setText(String.format("@%s", account.getAcct()));
account_un.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
String account_id = account.getAcct();
if( account_id.split("@").length == 1)
account_id += "@" + Helper.getLiveInstance(getApplicationContext());
ClipData clip = ClipData.newPlainText("mastodon_account_id", "@"+account_id);
Toast.makeText(getApplicationContext(),R.string.account_id_clipbloard, Toast.LENGTH_SHORT).show();
assert clipboard != null;
clipboard.setPrimaryClip(clip);
return false;
}
});
SpannableString spannableString = Helper.clickableElementsDescription(ShowAccountActivity.this, account.getNote());
account.setNoteSpan(spannableString);
account.makeEmojisAccountProfile(ShowAccountActivity.this, ShowAccountActivity.this);

View File

@ -663,6 +663,7 @@
<string name="action_bug_report">Bug Report</string>
<string name="no_mail_client">There are no email clients installed.</string>
<string name="bug_report_mail">Send a bug report</string>
<string name="account_id_clipbloard">The account id has been copied in the clipboard!</string>
<string-array name="filter_expire">
<item>Never</item>