diff --git a/res/layout/contact.xml b/res/layout/contact.xml index 6a334719b..635ef6df7 100644 --- a/res/layout/contact.xml +++ b/res/layout/contact.xml @@ -12,48 +12,33 @@ android:background="@color/colorF"> + android:background="@drawable/toolbar_button" + android:contentDescription="@string/content_description_back" + android:layout_width="70dp" + android:layout_height="match_parent" + android:layout_alignParentLeft="true" + android:padding="20dp"/> + android:layout_width="70dp" + android:layout_height="match_parent"/> - - + android:layout_toLeftOf="@+id/editContact"/> @@ -61,40 +46,44 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingTop="20dp" - android:paddingLeft="10dp" - android:paddingRight="10dp" android:gravity="center" android:orientation="vertical"> - + android:id="@+id/contact_picture" + android:src="@drawable/avatar" + android:contentDescription="@string/content_description_contact_picture" + android:layout_width="100dp" + android:layout_height="100dp" + android:adjustViewBounds="true" + android:layout_alignParentLeft="true" + android:layout_marginLeft="5dp"/> + + + - - - - + android:layout_height="wrap_content"/> diff --git a/res/layout/contact_cell.xml b/res/layout/contact_cell.xml index 62751f508..f6983b691 100644 --- a/res/layout/contact_cell.xml +++ b/res/layout/contact_cell.xml @@ -2,39 +2,49 @@ - - - - + android:background="@color/colorH" + android:orientation="vertical"> + + + + + + + + + + + android:layout_height="match_parent" + android:gravity="center"> @@ -43,8 +53,8 @@ android:id="@+id/mask" android:src="@drawable/avatar_mask" android:contentDescription="@string/content_description_contact_picture" - android:layout_width="40dp" - android:layout_height="40dp" + android:layout_width="35dp" + android:layout_height="35dp" android:adjustViewBounds="true" android:layout_alignParentLeft="true" android:layout_marginLeft="5dp"/> @@ -81,6 +91,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" + android:layout_centerInParent="true" android:visibility="gone" android:paddingLeft="5dp" android:paddingRight="5dp" /> diff --git a/res/layout/contact_control_row.xml b/res/layout/contact_control_row.xml index 49b9629dc..9d91776f4 100644 --- a/res/layout/contact_control_row.xml +++ b/res/layout/contact_control_row.xml @@ -3,102 +3,69 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="2dp" - android:gravity="center_vertical" - android:padding="10dp"> + android:gravity="center_vertical"> - + - - - - - - - + android:textAllCaps="true" + android:textColor="@color/colorE" /> + + + + - - - - + android:contentDescription="@string/content_description_dial_back" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_margin="10dp" + android:adjustViewBounds="true" + android:layout_centerInParent="true"/> - - - - - - - + \ No newline at end of file diff --git a/res/layout/contact_edit_row.xml b/res/layout/contact_edit_row.xml index 650b56555..4a016383c 100644 --- a/res/layout/contact_edit_row.xml +++ b/res/layout/contact_edit_row.xml @@ -1,34 +1,30 @@ - - + android:orientation="horizontal" + android:paddingBottom="5dp"> + android:layout_weight="0.09"/> + android:layout_weight="0.91" + android:layout_gravity="center" + android:paddingLeft="5dp"/> - - - \ No newline at end of file diff --git a/res/layout/contacts_list.xml b/res/layout/contacts_list.xml index c0d676906..965abefbc 100644 --- a/res/layout/contacts_list.xml +++ b/res/layout/contacts_list.xml @@ -6,6 +6,7 @@ android:orientation="vertical" > @@ -49,9 +50,9 @@ android:contentDescription="@string/content_description_linphone_contacts" android:id="@+id/linphone_contacts" android:src="@drawable/contacts_sip" - android:padding="10dp" android:gravity="center" - android:layout_width="wrap_content" + android:padding="15dp" + android:layout_width="match_parent" android:layout_height="match_parent"/> - - - - - - - + android:padding="15dp" + android:adjustViewBounds="true"/> - + + + android:background="@color/colorF"> + + + - - + android:layout_toLeftOf="@+id/ok"/> @@ -66,16 +64,31 @@ android:orientation="vertical"> + android:id="@+id/contact_picture" + android:src="@drawable/avatar" + android:contentDescription="@string/content_description_contact_picture" + android:layout_width="100dp" + android:layout_height="100dp" + android:adjustViewBounds="true" + android:layout_alignParentLeft="true" + android:layout_marginLeft="5dp"/> + + + @@ -96,8 +109,7 @@ android:layout_height="wrap_content" android:gravity="left" android:paddingRight="5dp" - android:inputType="textPersonName|textCapWords" - android:layout_column="0"/> + android:inputType="textPersonName|textCapWords"/> + android:inputType="textPersonName|textCapWords"/> @@ -129,15 +140,15 @@ + android:layout_height="30dp" + android:layout_gravity="center"> + android:layout_height="match_parent"/> - + android:orientation="vertical"> - + @@ -168,15 +179,15 @@ + android:layout_height="30dp" + android:layout_gravity="center"> + android:layout_height="match_parent"/> - + android:orientation="vertical"> - + diff --git a/src/org/linphone/ContactFragment.java b/src/org/linphone/ContactFragment.java index b1059d001..4e005a88a 100644 --- a/src/org/linphone/ContactFragment.java +++ b/src/org/linphone/ContactFragment.java @@ -119,7 +119,7 @@ public class ContactFragment extends Fragment implements OnClickListener { @SuppressLint("InflateParams") private void displayContact(LayoutInflater inflater, View view) { - ImageView contactPicture = (ImageView) view.findViewById(R.id.contactPicture); + ImageView contactPicture = (ImageView) view.findViewById(R.id.contact_picture); if (contact.getPhotoUri() != null) { InputStream input = Compatibility.getContactPictureInputStream(LinphoneActivity.instance().getContentResolver(), contact.getID()); contactPicture.setImageBitmap(BitmapFactory.decodeStream(input)); @@ -127,9 +127,8 @@ public class ContactFragment extends Fragment implements OnClickListener { contactPicture.setImageResource(R.drawable.avatar); } - TextView contactName = (TextView) view.findViewById(R.id.contactName); + TextView contactName = (TextView) view.findViewById(R.id.contact_name); contactName.setText(contact.getName()); - TableLayout controls = (TableLayout) view.findViewById(R.id.controls); controls.removeAllViews(); @@ -140,19 +139,26 @@ public class ContactFragment extends Fragment implements OnClickListener { if (numberOrAddress.startsWith("sip:")) { displayednumberOrAddress = displayednumberOrAddress.replace("sip:", ""); } + + TextView label = (TextView) v.findViewById(R.id.address_label); + if(LinphoneUtils.isSipAddress(numberOrAddress)) { + label.setText(R.string.sip_address); + } else { + label.setText(R.string.phone_number); + } TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress); tv.setText(displayednumberOrAddress); tv.setSelected(true); if (!displayChatAddressOnly) { - v.findViewById(R.id.dial).setOnClickListener(dialListener); - v.findViewById(R.id.dial).setTag(displayednumberOrAddress); + v.findViewById(R.id.call).setOnClickListener(dialListener); + v.findViewById(R.id.call).setTag(displayednumberOrAddress); } else { - v.findViewById(R.id.dial).setVisibility(View.GONE); + v.findViewById(R.id.call).setVisibility(View.GONE); } - v.findViewById(R.id.start_chat).setOnClickListener(chatListener); + v.findViewById(R.id.chat).setOnClickListener(chatListener); LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig(); if (lpc != null) { displayednumberOrAddress = lpc.normalizePhoneNumber(displayednumberOrAddress); @@ -164,13 +170,13 @@ public class ContactFragment extends Fragment implements OnClickListener { if (!numberOrAddress.contains("@")) { tag = numberOrAddress + "@" + lpc.getDomain(); } - v.findViewById(R.id.start_chat).setTag(tag); + v.findViewById(R.id.chat).setTag(tag); } else { - v.findViewById(R.id.start_chat).setTag(numberOrAddress); + v.findViewById(R.id.chat).setTag(numberOrAddress); } final String finalNumberOrAddress = numberOrAddress; - ImageView friend = (ImageView) v.findViewById(R.id.addFriend); + /*ImageView friend = (ImageView) v.findViewById(R.id.addFriend); if (getResources().getBoolean(R.bool.enable_linphone_friends) && !displayChatAddressOnly) { friend.setVisibility(View.VISIBLE); @@ -196,10 +202,10 @@ public class ContactFragment extends Fragment implements OnClickListener { } }); } - } + }*/ if (getResources().getBoolean(R.bool.disable_chat)) { - v.findViewById(R.id.start_chat).setVisibility(View.GONE); + v.findViewById(R.id.chat).setVisibility(View.GONE); } controls.addView(v); @@ -209,7 +215,7 @@ public class ContactFragment extends Fragment implements OnClickListener { @Override public void onResume() { super.onResume(); - + if (LinphoneActivity.isInstanciated()) { LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT); @@ -217,13 +223,13 @@ public class ContactFragment extends Fragment implements OnClickListener { LinphoneActivity.instance().hideStatusBar(); } } - contact.refresh(getActivity().getContentResolver()); if (contact.getName() == null || contact.getName().equals("")) { //Contact has been deleted, return LinphoneActivity.instance().displayContacts(false); + } else { + displayContact(inflater, view); } - displayContact(inflater, view); } @Override diff --git a/src/org/linphone/ContactsFragment.java b/src/org/linphone/ContactsFragment.java index bc487c8de..67e54cc40 100644 --- a/src/org/linphone/ContactsFragment.java +++ b/src/org/linphone/ContactsFragment.java @@ -24,6 +24,7 @@ import org.linphone.compatibility.Compatibility; import org.linphone.core.LinphoneCallLog; import org.linphone.core.LinphoneFriend; import org.linphone.core.PresenceActivityType; +import org.linphone.mediastream.Log; import android.annotation.SuppressLint; import android.app.Dialog; @@ -62,9 +63,9 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte private LayoutInflater mInflater; private ListView contactsList; private TextView noSipContact, noContact; - private ImageView allContacts, linphoneContacts, newContact, edit, selectAll, deselectAll, delete; + private ImageView allContacts, linphoneContacts, newContact, edit, selectAll, deselectAll, delete, cancel; private boolean onlyDisplayLinphoneContacts, isEditMode; - private RelativeLayout allContactsSelected, linphoneContactsSelected; + private RelativeLayout allContactsSelected, linphoneContactsSelected, editList, topbar; private int lastKnownPosition; private AlphabetIndexer indexer; private boolean editOnClick = false, editConsumed = false, onlyDisplayChatAddress = false; @@ -129,7 +130,12 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte delete = (ImageView) view.findViewById(R.id.delete); delete.setOnClickListener(this); - delete.setVisibility(View.INVISIBLE); + + editList = (RelativeLayout) view.findViewById(R.id.edit_list); + topbar = (RelativeLayout) view.findViewById(R.id.top_bar); + + cancel = (ImageView) view.findViewById(R.id.cancel); + cancel.setOnClickListener(this); edit = (ImageView) view.findViewById(R.id.edit); edit.setOnClickListener(this); @@ -176,6 +182,11 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte return; } + if (id == R.id.cancel) { + quitEditMode(); + return; + } + if (id == R.id.delete) { final Dialog dialog = LinphoneActivity.instance().displayDialog(getString(R.string.delete_text)); Button delete = (Button) dialog.findViewById(R.id.delete); @@ -202,10 +213,8 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte } if (id == R.id.edit) { - edit.setVisibility(View.GONE); - selectAll.setVisibility(View.VISIBLE); - delete.setVisibility(View.VISIBLE); - newContact.setVisibility(View.GONE); + editList.setVisibility(View.VISIBLE); + topbar.setVisibility(View.GONE); isEditMode = true; } @@ -215,11 +224,6 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte allContacts.setEnabled(false); linphoneContacts.setEnabled(true); linphoneContactsSelected.setVisibility(View.INVISIBLE); - if (searchField.getText().toString().length() > 0) { - searchContacts(); - } else { - changeContactsAdapter(); - } } else if (id == R.id.linphone_contacts) { allContactsSelected.setVisibility(View.INVISIBLE); @@ -227,11 +231,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte linphoneContacts.setEnabled(false); allContacts.setEnabled(true); onlyDisplayLinphoneContacts = true; - if (searchField.getText().toString().length() > 0) { - searchContacts(); - } else { - changeContactsAdapter(); - } + } if(isEditMode){ @@ -239,7 +239,13 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte selectAll.setVisibility(View.VISIBLE); } - else if (id == R.id.newContact) { + if (searchField.getText().toString().length() > 0) { + searchContacts(); + } else { + changeContactsAdapter(); + } + + if (id == R.id.newContact) { editConsumed = true; LinphoneActivity.instance().addContact(null, sipAddressToAdd); } @@ -266,10 +272,8 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte public void quitEditMode(){ isEditMode = false; - selectAll.setVisibility(View.GONE); - deselectAll.setVisibility(View.GONE); - delete.setVisibility(View.GONE); - edit.setVisibility(View.VISIBLE); + editList.setVisibility(View.GONE); + topbar.setVisibility(View.VISIBLE); invalidate(); } @@ -319,6 +323,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte contactsList.setVisibility(View.GONE); } else { indexer = new AlphabetIndexer(sipContactsCursor, Compatibility.getCursorDisplayNameColumnIndex(sipContactsCursor), " ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); contactsList.setAdapter(new ContactsListAdapter(ContactsManager.getInstance().getSIPContacts(), sipContactsCursor)); } } else { @@ -327,6 +332,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte contactsList.setVisibility(View.GONE); } else { indexer = new AlphabetIndexer(allContactsCursor, Compatibility.getCursorDisplayNameColumnIndex(allContactsCursor), " ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + contactsList.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); contactsList.setAdapter(new ContactsListAdapter(ContactsManager.getInstance().getAllContacts(), allContactsCursor)); } } @@ -406,7 +412,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte cursor = c; margin = LinphoneUtils.pixelsToDpi(LinphoneActivity.instance().getResources(), 10); - bitmapUnknown = BitmapFactory.decodeResource(LinphoneActivity.instance().getResources(), R.drawable.unknown_small); + bitmapUnknown = BitmapFactory.decodeResource(LinphoneActivity.instance().getResources(), R.drawable.avatar); } public int getCount() { @@ -442,16 +448,14 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte TextView name = (TextView) view.findViewById(R.id.name); name.setText(contact.getName()); - - TextView separator = (TextView) view.findViewById(R.id.separator); - LinearLayout layout = (LinearLayout) view.findViewById(R.id.layout); + + LinearLayout separator = (LinearLayout) view.findViewById(R.id.separator); + TextView separatorText = (TextView) view.findViewById(R.id.separator_text); if (getPositionForSection(getSectionForPosition(position)) != position) { separator.setVisibility(View.GONE); - layout.setPadding(0, margin, 0, margin); } else { separator.setVisibility(View.VISIBLE); - separator.setText(String.valueOf(contact.getName().charAt(0))); - layout.setPadding(0, 0, 0, margin); + separatorText.setText(String.valueOf(contact.getName().charAt(0))); } ImageView icon = (ImageView) view.findViewById(R.id.contact_picture); diff --git a/src/org/linphone/EditContactFragment.java b/src/org/linphone/EditContactFragment.java index 8f5b95899..c7dd343e1 100644 --- a/src/org/linphone/EditContactFragment.java +++ b/src/org/linphone/EditContactFragment.java @@ -1,6 +1,5 @@ package org.linphone; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.InputStream; import java.util.ArrayList; @@ -15,14 +14,7 @@ import android.content.ContentProviderOperation; import android.content.Context; import android.content.Intent; import android.database.Cursor; -import android.graphics.Bitmap; import android.graphics.BitmapFactory; -import android.graphics.BitmapShader; -import android.graphics.Canvas; -import android.graphics.Matrix; -import android.graphics.Paint; -import android.graphics.Shader; -import android.media.ExifInterface; import android.net.Uri; import android.os.Bundle; import android.os.Environment; @@ -41,7 +33,7 @@ import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import android.widget.ImageView; -import android.widget.TableLayout; +import android.widget.LinearLayout; public class EditContactFragment extends Fragment { private View view; @@ -58,7 +50,7 @@ public class EditContactFragment extends Fragment { private List numbersAndAddresses; private ArrayList ops; private int firstSipAddressIndex = -1; - private TableLayout sipAddresses, numbers; + private LinearLayout sipAddresses, numbers; private String newSipOrNumberToAdd; private ContactsManager contactsManager; @@ -116,7 +108,7 @@ public class EditContactFragment extends Fragment { } else { contactsManager.updateExistingContact(ops, contact, firstName.getText().toString(), lastName.getText().toString()); } - + for (NewOrUpdatedNumberOrAddress numberOrAddress : numbersAndAddresses) { numberOrAddress.save(); } @@ -199,7 +191,7 @@ public class EditContactFragment extends Fragment { } } - contactPicture = (ImageView) view.findViewById(R.id.contactPicture); + contactPicture = (ImageView) view.findViewById(R.id.contact_picture); if (contact != null && contact.getPhotoUri() != null) { InputStream input = Compatibility.getContactPictureInputStream(getActivity().getContentResolver(), contact.getID()); contactPicture.setImageBitmap(BitmapFactory.decodeStream(input)); @@ -214,8 +206,17 @@ public class EditContactFragment extends Fragment { } }); - numbers = initNumbersFields(contact); + numbersAndAddresses = new ArrayList(); sipAddresses = initSipAddressFields(contact); + numbers = initNumbersFields(contact); + + addSipAddress = (ImageView) view.findViewById(R.id.add_address_field); + addSipAddress.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + addEmptyRowToAllowNewNumberOrAddress(sipAddresses,true); + } + }); addNumber = (ImageView) view.findViewById(R.id.add_number_field); addNumber.setOnClickListener(new OnClickListener() { @@ -224,13 +225,6 @@ public class EditContactFragment extends Fragment { addEmptyRowToAllowNewNumberOrAddress(numbers,false); } }); - addSipAddress = (ImageView) view.findViewById(R.id.add_address_field); - addSipAddress.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - addEmptyRowToAllowNewNumberOrAddress(sipAddresses,true); - } - }); ops = new ArrayList(); lastName.requestFocus(); @@ -319,10 +313,9 @@ public class EditContactFragment extends Fragment { } } - private TableLayout initNumbersFields(final Contact contact) { - TableLayout controls = (TableLayout) view.findViewById(R.id.controls_numbers); + private LinearLayout initNumbersFields(final Contact contact) { + LinearLayout controls = (LinearLayout) view.findViewById(R.id.controls_numbers); controls.removeAllViews(); - numbersAndAddresses = new ArrayList(); if (contact != null) { for (String numberOrAddress : contact.getNumbersOrAddresses()) { @@ -351,10 +344,9 @@ public class EditContactFragment extends Fragment { return controls; } - private TableLayout initSipAddressFields(final Contact contact) { - TableLayout controls = (TableLayout) view.findViewById(R.id.controls_sip_address); + private LinearLayout initSipAddressFields(final Contact contact) { + LinearLayout controls = (LinearLayout) view.findViewById(R.id.controls_sip_address); controls.removeAllViews(); - numbersAndAddresses = new ArrayList(); if (contact != null) { for (String numberOrAddress : contact.getNumbersOrAddresses()) { @@ -383,12 +375,12 @@ public class EditContactFragment extends Fragment { return controls; } - private View displayNumberOrAddress(final TableLayout controls, String numberOrAddress) { + private View displayNumberOrAddress(final LinearLayout controls, String numberOrAddress) { return displayNumberOrAddress(controls, numberOrAddress, false); } @SuppressLint("InflateParams") - private View displayNumberOrAddress(final TableLayout controls, String numberOrAddress, boolean forceAddNumber) { + private View displayNumberOrAddress(final LinearLayout controls, String numberOrAddress, boolean forceAddNumber) { boolean isSip = LinphoneUtils.isStrictSipAddress(numberOrAddress) || !LinphoneUtils.isNumberAddress(numberOrAddress); if (isSip) { @@ -418,7 +410,7 @@ public class EditContactFragment extends Fragment { numbersAndAddresses.add(nounoa); final View view = inflater.inflate(R.layout.contact_edit_row, null); - + final EditText noa = (EditText) view.findViewById(R.id.numoraddr); noa.setInputType(isSip ? InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS : InputType.TYPE_CLASS_PHONE); noa.setText(numberOrAddress); @@ -454,9 +446,8 @@ public class EditContactFragment extends Fragment { } @SuppressLint("InflateParams") - private void addEmptyRowToAllowNewNumberOrAddress(final TableLayout controls, final boolean isSip) { + private void addEmptyRowToAllowNewNumberOrAddress(final LinearLayout controls, final boolean isSip) { final View view = inflater.inflate(R.layout.contact_edit_row, null); - final NewOrUpdatedNumberOrAddress nounoa = new NewOrUpdatedNumberOrAddress(isSip); final EditText noa = (EditText) view.findViewById(R.id.numoraddr); @@ -489,22 +480,9 @@ public class EditContactFragment extends Fragment { } }); - /*if (!isSip) { - firstSipAddressIndex++; - addEmptyRowToAllowNewNumberOrAddress(controls, false); - } else { - addEmptyRowToAllowNewNumberOrAddress(controls, true); - } - }*/ - controls.addView(view, controls.getChildCount()); - //if (firstSipAddressIndex != -1) { - // controls.addView(view, firstSipAddressIndex); - //} else { - // controls.addView(view); - //} - //} + controls.addView(view); } private String findContactFirstName(String contactID) { @@ -609,7 +587,7 @@ public class EditContactFragment extends Fragment { newNumberOrAddress = newN; } - public void save() { + public void save() {; if (newNumberOrAddress == null || newNumberOrAddress.equals(oldNumberOrAddress)) return;