mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-24 02:25:19 +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:id="@+id/menu_add_attachment"
|
||||||
android:icon="@drawable/ic_menu_attach" />
|
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"
|
<item android:title="@string/conversation__menu_delete_thread"
|
||||||
android:id="@+id/menu_delete_thread"
|
android:id="@+id/menu_delete_thread"
|
||||||
android:icon="@android:drawable/ic_menu_delete" />
|
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_picture">Picture</string>
|
||||||
<string name="AttachmentTypeSelectorAdapter_video">Video</string>
|
<string name="AttachmentTypeSelectorAdapter_video">Video</string>
|
||||||
<string name="AttachmentTypeSelectorAdapter_audio">Audio</string>
|
<string name="AttachmentTypeSelectorAdapter_audio">Audio</string>
|
||||||
|
<string name="AttachmentTypeSelectorAdapter_contact">Contact info</string>
|
||||||
|
|
||||||
<!-- ConversationItem -->
|
<!-- ConversationItem -->
|
||||||
<string name="ConversationItem_message_size_d_kb">Message size: %d KB</string>
|
<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_add_attachment">Add attachment</string>
|
||||||
<string name="conversation__menu_update_group">Update group</string>
|
<string name="conversation__menu_update_group">Update group</string>
|
||||||
<string name="conversation__menu_leave_group">Leave 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>
|
<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 -->
|
<!-- conversation_group_options -->
|
||||||
<string name="convesation_group_options__recipients_list">Recipients list</string>
|
<string name="convesation_group_options__recipients_list">Recipients list</string>
|
||||||
<string name="conversation_group_options__delivery">Delivery</string>
|
<string name="conversation_group_options__delivery">Delivery</string>
|
||||||
|
@ -245,7 +245,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
addAttachmentAudio(data.getData());
|
addAttachmentAudio(data.getData());
|
||||||
break;
|
break;
|
||||||
case PICK_CONTACT_INFO:
|
case PICK_CONTACT_INFO:
|
||||||
addContactInfo(data.getData());
|
addAttachmentContactInfo(data.getData());
|
||||||
break;
|
break;
|
||||||
case GROUP_EDIT:
|
case GROUP_EDIT:
|
||||||
this.recipients = data.getParcelableExtra(GroupCreateActivity.GROUP_RECIPIENT_EXTRA);
|
this.recipients = data.getParcelableExtra(GroupCreateActivity.GROUP_RECIPIENT_EXTRA);
|
||||||
@ -286,6 +286,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
inflater.inflate(R.menu.conversation, menu);
|
inflater.inflate(R.menu.conversation, menu);
|
||||||
|
|
||||||
|
if (isSingleConversation() && getRecipients().getPrimaryRecipient().getContactUri() == null) {
|
||||||
|
inflater.inflate(R.menu.conversation_add_to_contacts, menu);
|
||||||
|
}
|
||||||
|
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -296,8 +301,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.menu_call: handleDial(getRecipients().getPrimaryRecipient()); return true;
|
case R.id.menu_call: handleDial(getRecipients().getPrimaryRecipient()); return true;
|
||||||
case R.id.menu_delete_thread: handleDeleteThread(); 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_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_start_secure_session: handleStartSecureSession(); return true;
|
||||||
case R.id.menu_abort_session: handleAbortSecureSession(); return true;
|
case R.id.menu_abort_session: handleAbortSecureSession(); return true;
|
||||||
case R.id.menu_verify_identity: handleVerifyIdentity(); return true;
|
case R.id.menu_verify_identity: handleVerifyIdentity(); return true;
|
||||||
@ -561,9 +566,11 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleAddContactInfo() {
|
private void handleAddToContacts() {
|
||||||
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
|
final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
|
||||||
startActivityForResult(intent, PICK_CONTACT_INFO);
|
intent.putExtra(ContactsContract.Intents.Insert.PHONE, recipients.getPrimaryRecipient().getNumber());
|
||||||
|
intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleAddAttachment() {
|
private void handleAddAttachment() {
|
||||||
@ -840,6 +847,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
|||||||
AttachmentManager.selectVideo(this, PICK_VIDEO); break;
|
AttachmentManager.selectVideo(this, PICK_VIDEO); break;
|
||||||
case AttachmentTypeSelectorAdapter.ADD_SOUND:
|
case AttachmentTypeSelectorAdapter.ADD_SOUND:
|
||||||
AttachmentManager.selectAudio(this, PICK_AUDIO); break;
|
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();
|
ContactAccessor contactDataList = ContactAccessor.getInstance();
|
||||||
ContactData contactData = contactDataList.getContactData(this, contactUri);
|
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 {
|
private class ComposeKeyPressedListener implements OnKeyListener, OnClickListener, TextWatcher, OnFocusChangeListener {
|
||||||
@Override
|
@Override
|
||||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||||
|
@ -29,6 +29,7 @@ import android.net.Uri;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.provider.Contacts.Intents;
|
import android.provider.Contacts.Intents;
|
||||||
|
import android.provider.ContactsContract;
|
||||||
import android.provider.ContactsContract.QuickContact;
|
import android.provider.ContactsContract.QuickContact;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -423,7 +424,9 @@ public class ConversationItem extends LinearLayout {
|
|||||||
if (recipient.getContactUri() != null) {
|
if (recipient.getContactUri() != null) {
|
||||||
QuickContact.showQuickContact(context, contactPhoto, recipient.getContactUri(), QuickContact.MODE_LARGE, null);
|
QuickContact.showQuickContact(context, contactPhoto, recipient.getContactUri(), QuickContact.MODE_LARGE, null);
|
||||||
} else {
|
} 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);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ import android.content.Intent;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.provider.ContactsContract;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -104,6 +105,11 @@ public class AttachmentManager {
|
|||||||
selectMediaType(activity, "audio/*", requestCode);
|
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) {
|
private static void selectMediaType(Activity activity, String type, int requestCode) {
|
||||||
final Intent intent = new Intent();
|
final Intent intent = new Intent();
|
||||||
intent.setType(type);
|
intent.setType(type);
|
||||||
|
@ -32,86 +32,77 @@ import java.util.List;
|
|||||||
|
|
||||||
public class AttachmentTypeSelectorAdapter extends ArrayAdapter<AttachmentTypeSelectorAdapter.IconListItem> {
|
public class AttachmentTypeSelectorAdapter extends ArrayAdapter<AttachmentTypeSelectorAdapter.IconListItem> {
|
||||||
|
|
||||||
public static final int ADD_IMAGE = 1;
|
public static final int ADD_IMAGE = 1;
|
||||||
// public static final int TAKE_PICTURE = 2;
|
public static final int ADD_VIDEO = 2;
|
||||||
public static final int ADD_VIDEO = 3;
|
public static final int ADD_SOUND = 3;
|
||||||
// public static final int RECORD_VIDEO = 4;
|
public static final int ADD_CONTACT_INFO = 4;
|
||||||
public static final int ADD_SOUND = 5;
|
|
||||||
// public static final int RECORD_SOUND = 6;
|
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
public AttachmentTypeSelectorAdapter(Context context) {
|
public AttachmentTypeSelectorAdapter(Context context) {
|
||||||
super(context, R.layout.icon_list_item, getItemList(context));
|
super(context, R.layout.icon_list_item, getItemList(context));
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int buttonToCommand(int position) {
|
public int buttonToCommand(int position) {
|
||||||
return getItem(position).getCommand();
|
return getItem(position).getCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
TextView text;
|
View view;
|
||||||
ImageView image;
|
|
||||||
|
|
||||||
View view;
|
if (convertView == null) {
|
||||||
if (convertView == null) {
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
view = inflater.inflate(R.layout.icon_list_item, parent, false);
|
||||||
view = inflater.inflate(R.layout.icon_list_item, parent, false);
|
} else {
|
||||||
} else {
|
view = convertView;
|
||||||
view = convertView;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
text = (TextView) view.findViewById(R.id.text1);
|
TextView text = (TextView) view.findViewById(R.id.text1);
|
||||||
text.setText(getItem(position).getTitle());
|
ImageView image = (ImageView) view.findViewById(R.id.icon);
|
||||||
|
|
||||||
image = (ImageView) view.findViewById(R.id.icon);
|
text.setText(getItem(position).getTitle());
|
||||||
image.setImageResource(getItem(position).getResource());
|
image.setImageResource(getItem(position).getResource());
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<IconListItem> getItemList(Context context) {
|
private static List<IconListItem> getItemList(Context context) {
|
||||||
List<IconListItem> data = new ArrayList<IconListItem>(7);
|
List<IconListItem> data = new ArrayList<>(4);
|
||||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_picture),
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_picture), R.drawable.ic_attach_picture_holo_light, ADD_IMAGE);
|
||||||
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, "Capture picture", R.drawable.ic_launcher_camera, TAKE_PICTURE);
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_audio), R.drawable.ic_attach_audio_holo_light, ADD_SOUND);
|
||||||
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_video),
|
addItem(data, context.getString(R.string.AttachmentTypeSelectorAdapter_contact), R.drawable.ic_action_person, ADD_CONTACT_INFO);
|
||||||
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);
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addItem(List<IconListItem> list, String text, int resource, int id) {
|
private static void addItem(List<IconListItem> list, String text, int resource, int id) {
|
||||||
list.add(new IconListItem(text, resource, id));
|
list.add(new IconListItem(text, resource, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class IconListItem {
|
public static class IconListItem {
|
||||||
private final String mTitle;
|
private final String title;
|
||||||
private final int mResource;
|
private final int resource;
|
||||||
private final int id;
|
private final int id;
|
||||||
|
|
||||||
public IconListItem(String title, int resource, int id) {
|
public IconListItem(String title, int resource, int id) {
|
||||||
mResource = resource;
|
this.resource = resource;
|
||||||
mTitle = title;
|
this.title = title;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCommand() {
|
public int getCommand() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return mTitle;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getResource() {
|
public int getResource() {
|
||||||
return mResource;
|
return resource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user