mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
parent
b05967f2c9
commit
4a088410ae
BIN
res/drawable-hdpi/ic_action_person.png
Normal file
BIN
res/drawable-hdpi/ic_action_person.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 573 B |
BIN
res/drawable-mdpi/ic_action_person.png
Normal file
BIN
res/drawable-mdpi/ic_action_person.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 468 B |
BIN
res/drawable-xhdpi/ic_action_person.png
Normal file
BIN
res/drawable-xhdpi/ic_action_person.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 781 B |
BIN
res/drawable-xxhdpi/ic_action_person.png
Normal file
BIN
res/drawable-xxhdpi/ic_action_person.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1004 B |
@ -5,10 +5,6 @@
|
||||
android:id="@+id/menu_add_attachment"
|
||||
android:icon="@drawable/ic_menu_attach" />
|
||||
|
||||
<item android:title="@string/conversation__menu_add_contact_info"
|
||||
android:id="@+id/menu_add_contact_info"
|
||||
android:icon="@drawable/ic_menu_friendslist" />
|
||||
|
||||
<item android:title="@string/conversation__menu_delete_thread"
|
||||
android:id="@+id/menu_delete_thread"
|
||||
android:icon="@android:drawable/ic_menu_delete" />
|
||||
|
10
res/menu/conversation_add_to_contacts.xml
Normal file
10
res/menu/conversation_add_to_contacts.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item android:id="@+id/menu_add_to_contacts"
|
||||
android:title="@string/conversation_add_to_contacts__menu_add_to_contacts"
|
||||
app:showAsAction="never" />
|
||||
|
||||
</menu>
|
@ -54,6 +54,7 @@
|
||||
<string name="AttachmentTypeSelectorAdapter_picture">Picture</string>
|
||||
<string name="AttachmentTypeSelectorAdapter_video">Video</string>
|
||||
<string name="AttachmentTypeSelectorAdapter_audio">Audio</string>
|
||||
<string name="AttachmentTypeSelectorAdapter_contact">Contact info</string>
|
||||
|
||||
<!-- ConversationItem -->
|
||||
<string name="ConversationItem_message_size_d_kb">Message size: %d KB</string>
|
||||
@ -755,9 +756,11 @@
|
||||
<string name="conversation__menu_add_attachment">Add attachment</string>
|
||||
<string name="conversation__menu_update_group">Update group</string>
|
||||
<string name="conversation__menu_leave_group">Leave group</string>
|
||||
<string name="conversation__menu_add_contact_info">Add contact info</string>
|
||||
<string name="conversation__menu_delete_thread">Delete thread</string>
|
||||
|
||||
<!-- conversation_callable -->
|
||||
<string name="conversation_add_to_contacts__menu_add_to_contacts">Add to contacts</string>
|
||||
|
||||
<!-- conversation_group_options -->
|
||||
<string name="convesation_group_options__recipients_list">Recipients list</string>
|
||||
<string name="conversation_group_options__delivery">Delivery</string>
|
||||
|
@ -245,7 +245,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
addAttachmentAudio(data.getData());
|
||||
break;
|
||||
case PICK_CONTACT_INFO:
|
||||
addContactInfo(data.getData());
|
||||
addAttachmentContactInfo(data.getData());
|
||||
break;
|
||||
case GROUP_EDIT:
|
||||
this.recipients = data.getParcelableExtra(GroupCreateActivity.GROUP_RECIPIENT_EXTRA);
|
||||
@ -286,6 +286,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
inflater.inflate(R.menu.conversation, menu);
|
||||
|
||||
if (isSingleConversation() && getRecipients().getPrimaryRecipient().getContactUri() == null) {
|
||||
inflater.inflate(R.menu.conversation_add_to_contacts, menu);
|
||||
}
|
||||
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
return true;
|
||||
}
|
||||
@ -296,8 +301,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_call: handleDial(getRecipients().getPrimaryRecipient()); return true;
|
||||
case R.id.menu_delete_thread: handleDeleteThread(); return true;
|
||||
case R.id.menu_add_contact_info: handleAddContactInfo(); return true;
|
||||
case R.id.menu_add_attachment: handleAddAttachment(); return true;
|
||||
case R.id.menu_add_to_contacts: handleAddToContacts(); return true;
|
||||
case R.id.menu_start_secure_session: handleStartSecureSession(); return true;
|
||||
case R.id.menu_abort_session: handleAbortSecureSession(); return true;
|
||||
case R.id.menu_verify_identity: handleVerifyIdentity(); return true;
|
||||
@ -561,9 +566,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void handleAddContactInfo() {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
|
||||
startActivityForResult(intent, PICK_CONTACT_INFO);
|
||||
private void handleAddToContacts() {
|
||||
final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
|
||||
intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipients.getPrimaryRecipient().getNumber());
|
||||
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void handleAddAttachment() {
|
||||
@ -840,6 +847,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
AttachmentManager.selectVideo(this, PICK_VIDEO); break;
|
||||
case AttachmentTypeSelectorAdapter.ADD_SOUND:
|
||||
AttachmentManager.selectAudio(this, PICK_AUDIO); break;
|
||||
case AttachmentTypeSelectorAdapter.ADD_CONTACT_INFO:
|
||||
AttachmentManager.selectContactInfo(this, PICK_CONTACT_INFO); break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -886,7 +895,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
}
|
||||
|
||||
private void addContactInfo(Uri contactUri) {
|
||||
private void addAttachmentContactInfo(Uri contactUri) {
|
||||
ContactAccessor contactDataList = ContactAccessor.getInstance();
|
||||
ContactData contactData = contactDataList.getContactData(this, contactUri);
|
||||
|
||||
@ -1176,6 +1185,16 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
}
|
||||
|
||||
private class AddContactButtonListener implements OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
|
||||
intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipients.getPrimaryRecipient().getNumber());
|
||||
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private class ComposeKeyPressedListener implements OnKeyListener, OnClickListener, TextWatcher, OnFocusChangeListener {
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
|
@ -29,6 +29,7 @@ import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.Contacts.Intents;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.ContactsContract.QuickContact;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@ -423,7 +424,9 @@ public class ConversationItem extends LinearLayout {
|
||||
if (recipient.getContactUri() != null) {
|
||||
QuickContact.showQuickContact(context, contactPhoto, recipient.getContactUri(), QuickContact.MODE_LARGE, null);
|
||||
} else {
|
||||
Intent intent = new Intent(Intents.SHOW_OR_CREATE_CONTACT, Uri.fromParts("tel", recipient.getNumber(), null));
|
||||
final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
|
||||
intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipient.getNumber());
|
||||
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.provider.ContactsContract;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
@ -104,6 +105,11 @@ public class AttachmentManager {
|
||||
selectMediaType(activity, "audio/*", requestCode);
|
||||
}
|
||||
|
||||
public static void selectContactInfo(Activity activity, int requestCode) {
|
||||
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
|
||||
activity.startActivityForResult(intent, requestCode);
|
||||
}
|
||||
|
||||
private static void selectMediaType(Activity activity, String type, int requestCode) {
|
||||
final Intent intent = new Intent();
|
||||
intent.setType(type);
|
||||
|
@ -32,86 +32,77 @@ import java.util.List;
|
||||
|
||||
public class AttachmentTypeSelectorAdapter extends ArrayAdapter<AttachmentTypeSelectorAdapter.IconListItem> {
|
||||
|
||||
public static final int ADD_IMAGE = 1;
|
||||
// public static final int TAKE_PICTURE = 2;
|
||||
public static final int ADD_VIDEO = 3;
|
||||
// public static final int RECORD_VIDEO = 4;
|
||||
public static final int ADD_SOUND = 5;
|
||||
// public static final int RECORD_SOUND = 6;
|
||||
public static final int ADD_IMAGE = 1;
|
||||
public static final int ADD_VIDEO = 2;
|
||||
public static final int ADD_SOUND = 3;
|
||||
public static final int ADD_CONTACT_INFO = 4;
|
||||
|
||||
private final Context context;
|
||||
private final Context context;
|
||||
|
||||
public AttachmentTypeSelectorAdapter(Context context) {
|
||||
super(context, R.layout.icon_list_item, getItemList(context));
|
||||
this.context = context;
|
||||
}
|
||||
public AttachmentTypeSelectorAdapter(Context context) {
|
||||
super(context, R.layout.icon_list_item, getItemList(context));
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public int buttonToCommand(int position) {
|
||||
return getItem(position).getCommand();
|
||||
}
|
||||
public int buttonToCommand(int position) {
|
||||
return getItem(position).getCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
TextView text;
|
||||
ImageView image;
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view;
|
||||
|
||||
View view;
|
||||
if (convertView == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(R.layout.icon_list_item, parent, false);
|
||||
} else {
|
||||
view = convertView;
|
||||
}
|
||||
if (convertView == null) {
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
view = inflater.inflate(R.layout.icon_list_item, parent, false);
|
||||
} else {
|
||||
view = convertView;
|
||||
}
|
||||
|
||||
text = (TextView) view.findViewById(R.id.text1);
|
||||
text.setText(getItem(position).getTitle());
|
||||
TextView text = (TextView) view.findViewById(R.id.text1);
|
||||
ImageView image = (ImageView) view.findViewById(R.id.icon);
|
||||
|
||||
image = (ImageView) view.findViewById(R.id.icon);
|
||||
image.setImageResource(getItem(position).getResource());
|
||||
text.setText(getItem(position).getTitle());
|
||||
image.setImageResource(getItem(position).getResource());
|
||||
|
||||
return view;
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
private static List<IconListItem> getItemList(Context context) {
|
||||
List<IconListItem> data = new ArrayList<IconListItem>(7);
|
||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_picture),
|
||||
R.drawable.ic_attach_picture_holo_light, ADD_IMAGE);
|
||||
// addItem(data, "Capture picture", R.drawable.ic_launcher_camera, TAKE_PICTURE);
|
||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_video),
|
||||
R.drawable.ic_attach_video_holo_light, ADD_VIDEO);
|
||||
// addItem(data, "Capture video", R.drawable.ic_launcher_camera_record, RECORD_VIDEO);
|
||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_audio),
|
||||
R.drawable.ic_attach_audio_holo_light, ADD_SOUND);
|
||||
// addItem(data, "Record audio", R.drawable.ic_launcher_record_audio, RECORD_SOUND);
|
||||
private static List<IconListItem> getItemList(Context context) {
|
||||
List<IconListItem> data = new ArrayList<>(4);
|
||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_picture), R.drawable.ic_attach_picture_holo_light, ADD_IMAGE);
|
||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_video), R.drawable.ic_attach_video_holo_light, ADD_VIDEO);
|
||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_audio), R.drawable.ic_attach_audio_holo_light, ADD_SOUND);
|
||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_contact), R.drawable.ic_action_person, ADD_CONTACT_INFO);
|
||||
|
||||
return data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private static void addItem(List<IconListItem> list, String text, int resource, int id) {
|
||||
list.add(new IconListItem(text, resource, id));
|
||||
}
|
||||
private static void addItem(List<IconListItem> list, String text, int resource, int id) {
|
||||
list.add(new IconListItem(text, resource, id));
|
||||
}
|
||||
|
||||
public static class IconListItem {
|
||||
private final String mTitle;
|
||||
private final int mResource;
|
||||
private final int id;
|
||||
public static class IconListItem {
|
||||
private final String title;
|
||||
private final int resource;
|
||||
private final int id;
|
||||
|
||||
public IconListItem(String title, int resource, int id) {
|
||||
mResource = resource;
|
||||
mTitle = title;
|
||||
this.id = id;
|
||||
}
|
||||
public IconListItem(String title, int resource, int id) {
|
||||
this.resource = resource;
|
||||
this.title = title;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getCommand() {
|
||||
return id;
|
||||
}
|
||||
public int getCommand() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public int getResource() {
|
||||
return mResource;
|
||||
}
|
||||
}
|
||||
public int getResource() {
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user