mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 09:49:21 +02:00
offer copy-to-clipboard on long-tap address
This commit is contained in:
parent
1f1859a823
commit
92570b8e1e
3 changed files with 38 additions and 0 deletions
|
@ -211,6 +211,9 @@ public class ProfileAdapter extends RecyclerView.Adapter
|
||||||
if (data.viewType == ITEM_LAST_SEEN || data.viewType == ITEM_ADDRESS) {
|
if (data.viewType == ITEM_LAST_SEEN || data.viewType == ITEM_ADDRESS) {
|
||||||
int padding = (int)((float)context.getResources().getDimensionPixelSize(R.dimen.contact_list_normal_padding) * 1.2);
|
int padding = (int)((float)context.getResources().getDimensionPixelSize(R.dimen.contact_list_normal_padding) * 1.2);
|
||||||
item.setPadding(item.getPaddingLeft(), item.getPaddingTop(), item.getPaddingRight(), padding);
|
item.setPadding(item.getPaddingLeft(), item.getPaddingTop(), item.getPaddingRight(), padding);
|
||||||
|
if (data.viewType == ITEM_ADDRESS) {
|
||||||
|
item.setOnLongClickListener(view -> {clickListener.onAddressLongClicked(); return true;});
|
||||||
|
}
|
||||||
} else if (data.viewType == ITEM_INTRODUCED_BY) {
|
} else if (data.viewType == ITEM_INTRODUCED_BY) {
|
||||||
int padding = context.getResources().getDimensionPixelSize(R.dimen.contact_list_normal_padding);
|
int padding = context.getResources().getDimensionPixelSize(R.dimen.contact_list_normal_padding);
|
||||||
item.setPadding(item.getPaddingLeft(), padding, item.getPaddingRight(), item.getPaddingBottom());
|
item.setPadding(item.getPaddingLeft(), padding, item.getPaddingRight(), item.getPaddingBottom());
|
||||||
|
@ -235,6 +238,7 @@ public class ProfileAdapter extends RecyclerView.Adapter
|
||||||
void onMemberClicked(int contactId);
|
void onMemberClicked(int contactId);
|
||||||
void onMemberLongClicked(int contactId);
|
void onMemberLongClicked(int contactId);
|
||||||
void onAvatarClicked();
|
void onAvatarClicked();
|
||||||
|
void onAddressLongClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleMemberSelection(int contactId) {
|
public void toggleMemberSelection(int contactId) {
|
||||||
|
|
|
@ -153,6 +153,23 @@ public class ProfileFragment extends Fragment
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAddressLongClicked() {
|
||||||
|
Context context = requireContext();
|
||||||
|
String address = dcContext.getContact(contactId).getAddr();
|
||||||
|
new AlertDialog.Builder(context)
|
||||||
|
.setTitle(address)
|
||||||
|
.setItems(new CharSequence[]{
|
||||||
|
context.getString(R.string.menu_copy_to_clipboard)
|
||||||
|
},
|
||||||
|
(dialogInterface, i) -> {
|
||||||
|
Util.writeTextToClipboard(context, address);
|
||||||
|
Toast.makeText(context, context.getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT).show();
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMemberLongClicked(int contactId) {
|
public void onMemberLongClicked(int contactId) {
|
||||||
if (contactId>DcContact.DC_CONTACT_ID_LAST_SPECIAL || contactId==DcContact.DC_CONTACT_ID_SELF) {
|
if (contactId>DcContact.DC_CONTACT_ID_LAST_SPECIAL || contactId==DcContact.DC_CONTACT_ID_SELF) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ public class ProfileTextItem extends LinearLayout {
|
||||||
|
|
||||||
private TextView labelView;
|
private TextView labelView;
|
||||||
private @Nullable TextView valueView;
|
private @Nullable TextView valueView;
|
||||||
|
private final ProfileTextItem.PassthroughClickListener passthroughClickListener = new ProfileTextItem.PassthroughClickListener();
|
||||||
|
|
||||||
public ProfileTextItem(Context context) {
|
public ProfileTextItem(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -31,6 +32,8 @@ public class ProfileTextItem extends LinearLayout {
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
labelView = findViewById(R.id.label);
|
labelView = findViewById(R.id.label);
|
||||||
|
labelView.setOnLongClickListener(passthroughClickListener);
|
||||||
|
labelView.setOnClickListener(passthroughClickListener);
|
||||||
valueView = findViewById(R.id.value);
|
valueView = findViewById(R.id.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,4 +57,18 @@ public class ProfileTextItem extends LinearLayout {
|
||||||
valueView.setVisibility(View.VISIBLE);
|
valueView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class PassthroughClickListener implements View.OnLongClickListener, View.OnClickListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onLongClick(View v) {
|
||||||
|
performLongClick();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
performClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue