Fix contact display + option to only display nicknames
This commit is contained in:
parent
7eb4e1be47
commit
2ef850574f
11 changed files with 63 additions and 15 deletions
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 4.3 KiB |
|
@ -39,7 +39,9 @@
|
|||
android:id="@+id/controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="20dp" />
|
||||
android:stretchColumns="*"
|
||||
android:paddingTop="20dp">
|
||||
</TableLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
|
|
|
@ -8,18 +8,18 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/numeroOrAddress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_weight="1"
|
||||
android:textColor="@android:color/black"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="left" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/dial"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="0.2"
|
||||
android:contentDescription="@string/content_description_dial_back"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="5dp"
|
||||
|
@ -29,9 +29,9 @@
|
|||
|
||||
<ImageView
|
||||
android:id="@+id/chat"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="0.2"
|
||||
android:contentDescription="@string/content_description_chat"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="5dp"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<bool name="hide_accounts">false</bool>
|
||||
<bool name="useFirstLoginActivity">true</bool>
|
||||
<bool name="disable_animations">false</bool>
|
||||
<bool name="only_display_username_if_unknown">true</bool>
|
||||
<bool name="show_full_remote_address_on_incoming_call">true</bool>
|
||||
<bool name="display_messages_time">true</bool> <!-- Used to show the time of each message arrival -->
|
||||
|
||||
|
|
|
@ -61,7 +61,14 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneO
|
|||
View view = inflater.inflate(R.layout.chat, container, false);
|
||||
|
||||
TextView contactName = (TextView) view.findViewById(R.id.contactName);
|
||||
contactName.setText(name == null ? sipUri : name);
|
||||
if (name == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
||||
contactName.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
||||
} else if (name == null) {
|
||||
contactName.setText(sipUri);
|
||||
}
|
||||
else {
|
||||
contactName.setText(name);
|
||||
}
|
||||
|
||||
ImageView contactPicture = (ImageView) view.findViewById(R.id.contactPicture);
|
||||
if (pictureUri != null) {
|
||||
|
|
|
@ -141,6 +141,13 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
|||
LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, view.getContext().getContentResolver());
|
||||
|
||||
TextView sipUri = (TextView) view.findViewById(R.id.sipUri);
|
||||
|
||||
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(address.getDisplayName())) {
|
||||
address.setDisplayName(LinphoneUtils.getUsernameFromAddress(address.getDisplayName()));
|
||||
} else if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(contact)) {
|
||||
contact = LinphoneUtils.getUsernameFromAddress(contact);
|
||||
}
|
||||
|
||||
sipUri.setText(address.getDisplayName() == null ? contact : address.getDisplayName());
|
||||
|
||||
ImageView delete, detail;
|
||||
|
|
|
@ -52,16 +52,20 @@ public class ContactFragment extends Fragment {
|
|||
|
||||
TableLayout controls = (TableLayout) view.findViewById(R.id.controls);
|
||||
|
||||
for (String numeroOrAddress : contact.getNumerosOrAddresses()) {
|
||||
for (String numberOrAddress : contact.getNumerosOrAddresses()) {
|
||||
View v = inflater.inflate(R.layout.contact_control_row, null);
|
||||
|
||||
((TextView) v.findViewById(R.id.numeroOrAddress)).setText(numeroOrAddress);
|
||||
((TextView) v.findViewById(R.id.numeroOrAddress)).setText(numberOrAddress);
|
||||
|
||||
v.findViewById(R.id.dial).setOnClickListener(dialListener);
|
||||
v.findViewById(R.id.dial).setTag(numeroOrAddress);
|
||||
v.findViewById(R.id.dial).setTag(numberOrAddress);
|
||||
|
||||
if (LinphoneUtils.isSipAddress(numberOrAddress)) {
|
||||
v.findViewById(R.id.chat).setOnClickListener(chatListener);
|
||||
v.findViewById(R.id.chat).setTag(numeroOrAddress);
|
||||
v.findViewById(R.id.chat).setTag(numberOrAddress);
|
||||
} else {
|
||||
v.findViewById(R.id.chat).setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
controls.addView(v);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,9 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
|||
addToContacts.setOnClickListener(this);
|
||||
|
||||
contactName = (TextView) view.findViewById(R.id.contactName);
|
||||
if (displayName == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
||||
displayName = LinphoneUtils.getUsernameFromAddress(sipUri);
|
||||
}
|
||||
contactName.setText(displayName == null ? sipUri : displayName);
|
||||
|
||||
dialBackUri = (TextView) view.findViewById(R.id.dialBackUri);
|
||||
|
|
|
@ -199,10 +199,18 @@ public class HistoryFragment extends Fragment implements OnClickListener, OnItem
|
|||
String sipUri = address.asStringUriOnly();
|
||||
|
||||
if (displayName == null) {
|
||||
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
||||
contact.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
||||
} else {
|
||||
contact.setText(sipUri);
|
||||
}
|
||||
} else {
|
||||
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(address.getDisplayName())) {
|
||||
contact.setText(LinphoneUtils.getUsernameFromAddress(address.getDisplayName()));
|
||||
} else {
|
||||
contact.setText(displayName);
|
||||
}
|
||||
}
|
||||
view.setTag(sipUri);
|
||||
|
||||
if (isEditMode) {
|
||||
|
|
|
@ -62,6 +62,20 @@ public final class LinphoneUtils {
|
|||
|
||||
private static boolean preventVolumeBarToDisplay = false;
|
||||
|
||||
public static boolean isSipAddress(String numberOrAddress) {
|
||||
return numberOrAddress != null && numberOrAddress.matches("^(sip:)?[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}$");
|
||||
}
|
||||
|
||||
public static String getUsernameFromAddress(String address) {
|
||||
if (address.contains("sip:"))
|
||||
address = address.replace("sip:", "");
|
||||
|
||||
if (address.contains("@"))
|
||||
address = address.split("@")[0];
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
public static boolean onKeyBackGoHome(Activity activity, int keyCode, KeyEvent event) {
|
||||
if (!(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)) {
|
||||
return false; // continue
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
|
||||
import org.linphone.mediastream.Version;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
|
@ -41,6 +42,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
/**
|
||||
* @author Sylvain Berfini
|
||||
*/
|
||||
@TargetApi(5)
|
||||
public class ApiFivePlus {
|
||||
public static void overridePendingTransition(Activity activity, int idAnimIn, int idAnimOut) {
|
||||
activity.overridePendingTransition(idAnimIn, idAnimOut);
|
||||
|
|
Loading…
Reference in a new issue