mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Added local contact sharing
This commit is contained in:
parent
d507281f81
commit
d504e69ba4
1 changed files with 22 additions and 2 deletions
|
@ -21,10 +21,12 @@ package eu.faircode.email;
|
|||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.ContactsContract;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -212,14 +214,21 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|||
if (pos == RecyclerView.NO_POSITION)
|
||||
return false;
|
||||
|
||||
TupleContactEx contact = selected.get(pos);
|
||||
final TupleContactEx contact = selected.get(pos);
|
||||
|
||||
final Intent share = new Intent(Intent.ACTION_INSERT);
|
||||
share.setType(ContactsContract.Contacts.CONTENT_TYPE);
|
||||
share.putExtra(ContactsContract.Intents.Insert.NAME, contact.name);
|
||||
share.putExtra(ContactsContract.Intents.Insert.EMAIL, contact.email);
|
||||
|
||||
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, powner, view);
|
||||
|
||||
popupMenu.getMenu().add(Menu.NONE, 0, 0, contact.email).setEnabled(false);
|
||||
if (contact.state != EntityContact.STATE_IGNORE)
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_advanced_never_favorite, 1, R.string.title_advanced_never_favorite);
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete, 2, R.string.title_delete);
|
||||
if (share.resolveActivity(context.getPackageManager()) != null)
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_share, 2, R.string.title_share);
|
||||
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete, 3, R.string.title_delete);
|
||||
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
|
@ -228,6 +237,9 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|||
case R.string.title_advanced_never_favorite:
|
||||
onActionNeverFavorite();
|
||||
return true;
|
||||
case R.string.title_share:
|
||||
onActionShare();
|
||||
return true;
|
||||
case R.string.title_delete:
|
||||
onActionDelete();
|
||||
return true;
|
||||
|
@ -263,6 +275,14 @@ public class AdapterContact extends RecyclerView.Adapter<AdapterContact.ViewHold
|
|||
}.execute(context, owner, args, "contact:favorite");
|
||||
}
|
||||
|
||||
private void onActionShare() {
|
||||
try {
|
||||
context.startActivity(share);
|
||||
} catch (Throwable ex) {
|
||||
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void onActionDelete() {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", contact.id);
|
||||
|
|
Loading…
Reference in a new issue