0
0
mirror of https://github.com/thunderbird/thunderbird-android.git synced 2024-09-20 12:12:15 +02:00

Copy action added to Recipient select view

This commit is contained in:
r.zarchi 2023-12-10 15:21:09 +03:30
parent f2259c3fb0
commit 6fde3ad738
3 changed files with 25 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.widget.TooltipCompat;
import com.fsck.k9.activity.compose.RecipientAdapter;
import com.fsck.k9.ui.ContactBadge;
import com.fsck.k9.ui.R;
@ -164,6 +165,8 @@ public class AlternateRecipientAdapter extends BaseAdapter {
}
});
holder.copyEmailAddress.setOnClickListener(v -> listener.onRecipientAddressCopy(currentRecipient));
configureCryptoStatusView(holder, recipient);
}
@ -237,6 +240,7 @@ public class AlternateRecipientAdapter extends BaseAdapter {
public final TextView headerAddressLabel;
public final ContactBadge headerPhoto;
public final View headerRemove;
public final View copyEmailAddress;
public final TextView itemAddress;
public final TextView itemAddressLabel;
public final View itemCryptoStatus;
@ -253,6 +257,8 @@ public class AlternateRecipientAdapter extends BaseAdapter {
headerPhoto = view.findViewById(R.id.alternate_contact_photo);
headerRemove = view.findViewById(R.id.alternate_remove);
copyEmailAddress = view.findViewById(R.id.button_copy_email_address);
TooltipCompat.setTooltipText(copyEmailAddress, copyEmailAddress.getContext().getString(R.string.copy_action));
itemAddress = view.findViewById(R.id.alternate_address);
itemAddressLabel = view.findViewById(R.id.alternate_address_label);
itemCryptoStatus = view.findViewById(R.id.alternate_crypto_status);
@ -270,5 +276,6 @@ public class AlternateRecipientAdapter extends BaseAdapter {
public interface AlternateRecipientListener {
void onRecipientRemove(Recipient currentRecipient);
void onRecipientChange(Recipient currentRecipient, Recipient alternateRecipient);
void onRecipientAddressCopy(Recipient currentRecipient);
}
}

View File

@ -36,6 +36,7 @@ import android.widget.TextView;
import com.fsck.k9.DI;
import com.fsck.k9.K9;
import com.fsck.k9.ui.R;
import com.fsck.k9.helper.ClipboardManager;
import com.fsck.k9.activity.AlternateRecipientAdapter;
import com.fsck.k9.activity.AlternateRecipientAdapter.AlternateRecipientListener;
import com.fsck.k9.activity.compose.RecipientAdapter;
@ -486,6 +487,14 @@ public class RecipientSelectView extends TokenCompleteTextView<Recipient> implem
invalidateCursorPositionHack();
}
@Override
public void onRecipientAddressCopy(Recipient currentRecipient) {
ClipboardManager clipboardManager = DI.get(ClipboardManager.class);
String label = getContext().getResources().getString(R.string.clipboard_label_name_and_email_address);
String nameAndEmailAddress = currentRecipient.address.toString();
clipboardManager.setText(label, nameAndEmailAddress);
}
/**
* Changing the size of our RecipientTokenSpan doesn't seem to redraw the cursor in the new position. This will
* make sure the cursor position is recalculated.

View File

@ -143,6 +143,15 @@
tools:visibility="visible"
/>
<ImageView
android:id="@+id/button_copy_email_address"
android:layout_width="48dp"
android:layout_height="48dp"
android:scaleType="center"
android:background="?attr/controlBackground"
android:contentDescription="@string/copy_action"
app:srcCompat="@drawable/ic_content_copy" />
</LinearLayout>
</LinearLayout>