mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
implement profile functions: new-chat, block-contact
This commit is contained in:
@@ -257,7 +257,8 @@ public class ProfileSettingsAdapter extends RecyclerView.Adapter
|
||||
}
|
||||
|
||||
if (dcContact!=null) {
|
||||
itemData.add(new ItemData(ItemData.TYPE_SECONDARY_SETTING, SETTING_BLOCK_CONTACT, context.getString(R.string.menu_block_contact)));
|
||||
itemData.add(new ItemData(ItemData.TYPE_SECONDARY_SETTING, SETTING_BLOCK_CONTACT,
|
||||
context.getString(dcContact.isBlocked()? R.string.menu_unblock_contact : R.string.menu_block_contact)));
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
@@ -115,6 +116,12 @@ public class ProfileSettingsFragment extends Fragment
|
||||
case ProfileSettingsAdapter.SETTING_ENCRYPTION:
|
||||
onEncrInfo();
|
||||
break;
|
||||
case ProfileSettingsAdapter.SETTING_NEW_CHAT:
|
||||
onNewChat();
|
||||
break;
|
||||
case ProfileSettingsAdapter.SETTING_BLOCK_CONTACT:
|
||||
onBlockContact();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,4 +162,43 @@ public class ProfileSettingsFragment extends Fragment
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void onNewChat() {
|
||||
DcContact dcContact = dcContext.getContact(contactId);
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(getActivity().getString(R.string.ask_start_chat_with, dcContact.getNameNAddr()))
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
int chatId = dcContext.createChatByContactId(dcContact.getId());
|
||||
if (chatId != 0) {
|
||||
Intent intent = new Intent(getActivity(), ConversationActivity.class);
|
||||
intent.putExtra(ConversationActivity.CHAT_ID_EXTRA, chatId);
|
||||
getActivity().startActivity(intent);
|
||||
getActivity().finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void onBlockContact() {
|
||||
DcContact dcContact = dcContext.getContact(contactId);
|
||||
if(dcContact.isBlocked()) {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.ask_unblock_contact)
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.menu_unblock_contact, (dialog, which) -> {
|
||||
dcContext.blockContact(contactId, 0);
|
||||
}).show();
|
||||
}
|
||||
else {
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.ask_block_contact)
|
||||
.setCancelable(true)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.menu_block_contact, (dialog, which) -> {
|
||||
dcContext.blockContact(contactId, 1);
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user