mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 10:47:46 +00:00
Copy public key to clipboard on settings header long press
This commit is contained in:
parent
a5a6631fb5
commit
6d13b49ed1
@ -1540,6 +1540,7 @@
|
||||
<!-- Conversation list activity -->
|
||||
<string name="activity_conversation_list_empty_state_message">Looks like you don\'t have any conversations yet. Get started by messaging a friend.</string>
|
||||
<!-- Settings activity -->
|
||||
<string name="activity_settings_public_key_copied_message">Copied to Clipboard</string>
|
||||
<string name="activity_settings_share_public_key_button_title">Share Public Key</string>
|
||||
<string name="activity_settings_show_seed_button_title">Show Seed</string>
|
||||
<string name="activity_settings_seed_dialog_title">Your Seed</string>
|
||||
|
@ -111,7 +111,7 @@ class KeyPairActivity : BaseActionBarActivity() {
|
||||
// region Interaction
|
||||
private fun copy() {
|
||||
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||
val clip = ClipData.newPlainText("mnemonic", mnemonic)
|
||||
val clip = ClipData.newPlainText("Mnemonic", mnemonic)
|
||||
clipboard.primaryClip = clip
|
||||
Toast.makeText(this, R.string.activity_key_pair_mnemonic_copied_message, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.thoughtcrime.securesms.preferences.widgets;
|
||||
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.graphics.Outline;
|
||||
import android.os.Build;
|
||||
@ -14,15 +16,18 @@ import android.view.ViewOutlineProvider;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.lelloman.identicon.drawable.ClassicIdenticonDrawable;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
import org.thoughtcrime.securesms.database.Address;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
import network.loki.messenger.R;
|
||||
|
||||
public class ProfilePreference extends Preference {
|
||||
|
||||
private View containerView;
|
||||
private ImageView avatarView;
|
||||
private TextView profileNameView;
|
||||
private TextView profileNumberView;
|
||||
@ -55,6 +60,8 @@ public class ProfilePreference extends Preference {
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder viewHolder) {
|
||||
super.onBindViewHolder(viewHolder);
|
||||
|
||||
containerView = viewHolder.itemView;
|
||||
avatarView = (ImageView)viewHolder.findViewById(R.id.avatar);
|
||||
profileNameView = (TextView)viewHolder.findViewById(R.id.profile_name);
|
||||
profileNumberView = (TextView)viewHolder.findViewById(R.id.number);
|
||||
@ -69,6 +76,15 @@ public class ProfilePreference extends Preference {
|
||||
final Address localAddress = Address.fromSerialized(userHexEncodedPublicKey);
|
||||
final String profileName = TextSecurePreferences.getProfileName(getContext());
|
||||
|
||||
Context context = getContext();
|
||||
containerView.setOnLongClickListener(v -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("Public Key", userHexEncodedPublicKey);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(context, R.string.activity_settings_public_key_copied_message, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
});
|
||||
|
||||
avatarView.setOutlineProvider(new ViewOutlineProvider() {
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user