mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
move contact-deletion to the contact-list, tackles
This commit is contained in:
@@ -518,14 +518,34 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
if (item instanceof TLRPC.User) {
|
||||
final TLRPC.User user = (TLRPC.User) item;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
CharSequence[] items = new CharSequence[]{context.getString(R.string.ViewProfile)};
|
||||
CharSequence[] items = new CharSequence[]{context.getString(R.string.ViewProfile),context.getString(R.string.DeleteContact)};
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", user.id);
|
||||
ProfileActivity fragment = new ProfileActivity(args);
|
||||
presentFragment(fragment);
|
||||
if( i == 0 ) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", user.id);
|
||||
ProfileActivity fragment = new ProfileActivity(args);
|
||||
presentFragment(fragment);
|
||||
}
|
||||
else if( i == 1 ) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(context.getString(R.string.AreYouSureDeleteContact));
|
||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if( MrMailbox.deleteContact(user.id)==0 ) {
|
||||
AndroidUtilities.showHint(getParentActivity(), context.getString(R.string.CannotDeleteContact));
|
||||
}
|
||||
else {
|
||||
AndroidUtilities.showDoneHint(getParentActivity());
|
||||
listViewAdapter.searchAgain();
|
||||
listViewAdapter.notifyDataSetChanged(); }
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
|
||||
@@ -113,9 +113,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
private int otherShadowRow = -1;
|
||||
private int otherHeaderRow = -1;
|
||||
private int addShortcutRow = -1;
|
||||
private int blockContactRow = -1;
|
||||
private int deleteContactRow = -1;
|
||||
|
||||
private int blockContactRow = -1; // only block, no deletion here: contacts shown here are typically in use; we cannot easily delete them and mrmailbox_delete_contact() will typically fail.
|
||||
// a delete function is available in the contact list, however, where the chance a contact can be deleted is larger
|
||||
private int rowCount = 0;
|
||||
|
||||
private class TopView extends View {
|
||||
@@ -422,25 +421,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
else if (position == deleteContactRow)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setMessage(context.getString(R.string.AreYouSureDeleteContact));
|
||||
builder.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if( MrMailbox.deleteContact(user_id)==0 ) {
|
||||
AndroidUtilities.showHint(getParentActivity(), context.getString(R.string.CannotDeleteContact));
|
||||
}
|
||||
else {
|
||||
AndroidUtilities.showDoneHint(getParentActivity());
|
||||
finishFragment();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.Cancel, null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
else if (position == addShortcutRow)
|
||||
{
|
||||
try {
|
||||
@@ -906,7 +886,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
otherHeaderRow = -1;
|
||||
addShortcutRow = -1;
|
||||
blockContactRow = -1;
|
||||
deleteContactRow = -1;
|
||||
|
||||
if( (user_id!=0 && user_id!=MrContact.MR_CONTACT_ID_SELF) || (chat_id!=0 && chat_id!=MrChat.MR_CHAT_ID_DEADDROP)) {
|
||||
changeNameRow = rowCount++;
|
||||
@@ -960,7 +939,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
|
||||
if( user_id != 0 && user_id != MrContact.MR_CONTACT_ID_SELF ) {
|
||||
blockContactRow = rowCount++;
|
||||
deleteContactRow = rowCount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1099,9 +1077,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
else if( i == blockContactRow ) {
|
||||
textCell.setText(userBlocked()? mContext.getString(R.string.UnblockContact) : mContext.getString(R.string.BlockContact), true);
|
||||
}
|
||||
else if( i == deleteContactRow ) {
|
||||
textCell.setText(mContext.getString(R.string.DeleteContact), true);
|
||||
}
|
||||
break;
|
||||
|
||||
case ROWTYPE_CONTACT:
|
||||
@@ -1185,7 +1160,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if ( i == changeNameRow || i==startChatRow || i == settingsRow || i == addMemberRow || i==emailRow
|
||||
|| i==addShortcutRow || i==blockContactRow || i==deleteContactRow ) {
|
||||
|| i==addShortcutRow || i==blockContactRow ) {
|
||||
return ROWTYPE_TEXT_SETTINGS;
|
||||
} else if (i >= memberlistFirstRow && i <= memberlistLastRow) {
|
||||
return ROWTYPE_CONTACT;
|
||||
|
||||
Reference in New Issue
Block a user