mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
do not allow new contact creation on attaching contact
This commit is contained in:
@@ -86,7 +86,7 @@ public class BlockedAndShareContactsActivity extends PassphraseRequiredActionBar
|
||||
|
||||
@Override
|
||||
public Loader<DcContactsLoader.Ret> onCreateLoader(int id, Bundle args) {
|
||||
return new DcContactsLoader(getActivity(), -1, null, false, true);
|
||||
return new DcContactsLoader(getActivity(), -1, null, false, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -83,6 +83,7 @@ public class ContactSelectionListFragment extends Fragment
|
||||
public static final String MULTI_SELECT = "multi_select";
|
||||
public static final String SELECT_VERIFIED_EXTRA = "select_verified";
|
||||
public static final String FROM_SHARE_ACTIVITY_EXTRA = "from_share_activity";
|
||||
public static final String ALLOW_CREATION = "allow_creation";
|
||||
public static final String PRESELECTED_CONTACTS = "preselected_contacts";
|
||||
|
||||
private DcContext dcContext;
|
||||
@@ -287,7 +288,8 @@ public class ContactSelectionListFragment extends Fragment
|
||||
if(isSelectVerfied()) {
|
||||
listflags = DcContext.DC_GCL_VERIFIED_ONLY;
|
||||
}
|
||||
return new DcContactsLoader(getActivity(), listflags, cursorFilter, addCreateGroupLinks, false);
|
||||
boolean allowCreation = getActivity().getIntent().getBooleanExtra(ALLOW_CREATION, true);
|
||||
return new DcContactsLoader(getActivity(), listflags, cursorFilter, addCreateGroupLinks, false, allowCreation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -951,6 +951,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
private void startContactChooserActivity() {
|
||||
Intent intent = new Intent(ConversationActivity.this, AttachContactActivity.class);
|
||||
intent.putExtra(ContactSelectionListFragment.FROM_SHARE_ACTIVITY_EXTRA, true);
|
||||
intent.putExtra(ContactSelectionListFragment.ALLOW_CREATION, false);
|
||||
startActivityForResult(intent, PICK_CONTACT);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,13 +18,15 @@ public class DcContactsLoader extends AsyncLoader<DcContactsLoader.Ret> {
|
||||
private final String query;
|
||||
private final boolean addCreateGroupLinks;
|
||||
private final boolean blockedContacts;
|
||||
private final boolean allowCreation;
|
||||
|
||||
public DcContactsLoader(Context context, int listflags, String query, boolean addCreateGroupLinks, boolean blockedContacts) {
|
||||
public DcContactsLoader(Context context, int listflags, String query, boolean addCreateGroupLinks, boolean blockedContacts, boolean allowCreation) {
|
||||
super(context);
|
||||
this.listflags = listflags;
|
||||
this.query = (query==null||query.isEmpty())? null : query;
|
||||
this.addCreateGroupLinks = addCreateGroupLinks;
|
||||
this.blockedContacts = blockedContacts;
|
||||
this.allowCreation = allowCreation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +41,7 @@ public class DcContactsLoader extends AsyncLoader<DcContactsLoader.Ret> {
|
||||
int[] contact_ids = dcContext.getContacts(listflags, query);
|
||||
if(query!=null) {
|
||||
// show the "new contact" link also for partly typed e-mail addresses, so that the user knows he can continue
|
||||
if (dcContext.lookupContactIdByAddr(query)==0 && (listflags&DcContext.DC_GCL_VERIFIED_ONLY)==0) {
|
||||
if (allowCreation && dcContext.lookupContactIdByAddr(query)==0 && (listflags&DcContext.DC_GCL_VERIFIED_ONLY)==0) {
|
||||
contact_ids = Util.appendInt(contact_ids, DcContact.DC_CONTACT_ID_NEW_CONTACT);
|
||||
}
|
||||
return new DcContactsLoader.Ret(contact_ids, query);
|
||||
|
||||
Reference in New Issue
Block a user