[DisplayName] automatically add displayName in contactEditor if create new contact and DisplayName exists
This commit is contained in:
parent
21ed2955ef
commit
ab6e3737b1
7 changed files with 54 additions and 26 deletions
|
@ -18,16 +18,6 @@ package org.linphone;
|
|||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
|
@ -57,6 +47,16 @@ import android.widget.EditText;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.linphone.mediastream.Log;
|
||||
import org.linphone.mediastream.Version;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ContactEditorFragment extends Fragment {
|
||||
private View view;
|
||||
private ImageView cancel, deleteContact, ok;
|
||||
|
@ -73,7 +73,7 @@ public class ContactEditorFragment extends Fragment {
|
|||
private List<LinphoneNumberOrAddress> numbersAndAddresses;
|
||||
private int firstSipAddressIndex = -1;
|
||||
private LinearLayout sipAddresses, numbers;
|
||||
private String newSipOrNumberToAdd;
|
||||
private String newSipOrNumberToAdd, newDisplayName;
|
||||
private Uri pickedPhotoForContactUri;
|
||||
private byte[] photoToAdd;
|
||||
|
||||
|
@ -90,9 +90,14 @@ public class ContactEditorFragment extends Fragment {
|
|||
isNewContact = false;
|
||||
if (getArguments().getString("NewSipAdress") != null) {
|
||||
newSipOrNumberToAdd = getArguments().getString("NewSipAdress");
|
||||
}if (getArguments().getString("NewDisplayName") != null) {
|
||||
newDisplayName = getArguments().getString("NewDisplayName");
|
||||
}
|
||||
} else if (getArguments().getString("NewSipAdress") != null) {
|
||||
newSipOrNumberToAdd = getArguments().getString("NewSipAdress");
|
||||
if (getArguments().getString("NewDisplayName") != null) {
|
||||
newDisplayName = getArguments().getString("NewDisplayName");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,6 +444,12 @@ public class ContactEditorFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
if (newDisplayName != null) {
|
||||
EditText lastNameEditText = (EditText) view.findViewById(R.id.contactLastName);
|
||||
if (view != null)
|
||||
lastNameEditText.setText(newDisplayName);
|
||||
}
|
||||
|
||||
if (controls.getChildCount() == 0) {
|
||||
addEmptyRowToAllowNewNumberOrAddress(controls,false);
|
||||
}
|
||||
|
|
|
@ -19,12 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
package org.linphone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
|
@ -49,6 +43,12 @@ import android.widget.ProgressBar;
|
|||
import android.widget.SectionIndexer;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
|
@ -62,7 +62,7 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
|||
private LinearLayout editList, topbar;
|
||||
private int lastKnownPosition;
|
||||
private boolean editOnClick = false, editConsumed = false, onlyDisplayChatAddress = false;
|
||||
private String sipAddressToAdd;
|
||||
private String sipAddressToAdd, displayName = null;
|
||||
private ImageView clearSearchField;
|
||||
private EditText searchField;
|
||||
private ProgressBar contactsFetchInProgress;
|
||||
|
@ -75,7 +75,8 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
|||
if (getArguments() != null) {
|
||||
editOnClick = getArguments().getBoolean("EditOnClick");
|
||||
sipAddressToAdd = getArguments().getString("SipAddress");
|
||||
|
||||
if(getArguments().getString("DisplayName") != null)
|
||||
displayName = getArguments().getString("DisplayName");
|
||||
onlyDisplayChatAddress = getArguments().getBoolean("ChatAddressOnly");
|
||||
}
|
||||
|
||||
|
@ -253,6 +254,9 @@ public class ContactsListFragment extends Fragment implements OnClickListener, O
|
|||
|
||||
if (id == R.id.newContact) {
|
||||
editConsumed = true;
|
||||
if(displayName != null)
|
||||
LinphoneActivity.instance().addContact(displayName, sipAddressToAdd);
|
||||
else
|
||||
LinphoneActivity.instance().addContact(null, sipAddressToAdd);
|
||||
}
|
||||
else if (id == R.id.clearSearchField) {
|
||||
|
|
|
@ -164,12 +164,16 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
LinphoneActivity.instance().displayChat(sipUri, null, null);
|
||||
} else if (id == R.id.add_contact) {
|
||||
String uri = sipUri;
|
||||
LinphoneAddress addr = null;
|
||||
try {
|
||||
LinphoneAddress addr = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||
addr = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||
uri = addr.asStringUriOnly();
|
||||
} catch (LinphoneCoreException e) {
|
||||
Log.e(e);
|
||||
}
|
||||
if(addr != null && !addr.getDisplayName().equals("Dust Android"))
|
||||
LinphoneActivity.instance().displayContactsForEdition(addr.asStringUriOnly(), addr.getDisplayName());
|
||||
else
|
||||
LinphoneActivity.instance().displayContactsForEdition(uri);
|
||||
} else if (id == R.id.goto_contact) {
|
||||
LinphoneActivity.instance().displayContact(contact, false);
|
||||
|
|
|
@ -628,6 +628,14 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
changeCurrentFragment(FragmentsAvailable.ABOUT, null);
|
||||
}
|
||||
|
||||
public void displayContactsForEdition(String sipAddress, String displayName) {
|
||||
Bundle extras = new Bundle();
|
||||
extras.putBoolean("EditOnClick", true);
|
||||
extras.putString("SipAddress", sipAddress);
|
||||
extras.putString("DisplayName", displayName);
|
||||
changeCurrentFragment(FragmentsAvailable.CONTACTS_LIST, extras);
|
||||
}
|
||||
|
||||
public void displayAssistant() {
|
||||
startActivity(new Intent(LinphoneActivity.this, AssistantActivity.class));
|
||||
}
|
||||
|
@ -1091,6 +1099,7 @@ public class LinphoneActivity extends LinphoneGenericActivity implements OnClick
|
|||
{
|
||||
Bundle extras = new Bundle();
|
||||
extras.putSerializable("NewSipAdress", sipUri);
|
||||
extras.putSerializable("NewDisplayName", displayName);
|
||||
changeCurrentFragment(FragmentsAvailable.CONTACT_EDITOR, extras);
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ddd08052226c879df63b08ab11d4a4917cfc1da5
|
||||
Subproject commit f28d968a67eab65e07e60ef8a8b19621c6401e82
|
|
@ -1 +1 @@
|
|||
Subproject commit 6b78f95624660c4e1160c3caac74732250321ce1
|
||||
Subproject commit d765c5b947f2de52d97061e80784091ec043f5a0
|
|
@ -1 +1 @@
|
|||
Subproject commit ce3dedb58706f154c647bc99412aca8a42416d9d
|
||||
Subproject commit e9c2d48c917d78c529eefb9f824ae52238f950d4
|
Loading…
Reference in a new issue