diff --git a/src/org/linphone/HistorySimpleFragment.java b/src/org/linphone/HistorySimpleFragment.java index 9236a584d..3a1614196 100644 --- a/src/org/linphone/HistorySimpleFragment.java +++ b/src/org/linphone/HistorySimpleFragment.java @@ -132,7 +132,7 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener, mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs()); if (!hideHistoryListAndDisplayMessageIfEmpty()) { - historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext())); + historyList.setAdapter(new CallHistoryAdapter(getActivity())); } } @@ -149,7 +149,7 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener, LinphoneManager.getLc().removeCallLog(log); mLogs = Arrays.asList(LinphoneManager.getLc().getCallLogs()); if (!hideHistoryListAndDisplayMessageIfEmpty()) { - historyList.setAdapter(new CallHistoryAdapter(getActivity().getApplicationContext())); + historyList.setAdapter(new CallHistoryAdapter(getActivity())); } return true; } @@ -314,7 +314,6 @@ public class HistorySimpleFragment extends Fragment implements OnClickListener, ImageView delete = (ImageView) view.findViewById(R.id.delete); ImageView callDirection = (ImageView) view.findViewById(R.id.icon); - if (log.getDirection() == CallDirection.Incoming) { address = log.getFrom(); if (log.getStatus() == CallStatus.Missed) { diff --git a/src/org/linphone/LinphoneUtils.java b/src/org/linphone/LinphoneUtils.java index 8304fd699..e64e5e905 100644 --- a/src/org/linphone/LinphoneUtils.java +++ b/src/org/linphone/LinphoneUtils.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.regex.Pattern; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCall; @@ -63,13 +64,17 @@ public final class LinphoneUtils { private LinphoneUtils(){} private static boolean preventVolumeBarToDisplay = false; + private static final String sipAddressRegExp = "^(sip:)?(\\+)?[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}(:[0-9]{2,5})?$"; + private static final String strictSipAddressRegExp = "^sip:(\\+)?[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}$"; 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,}$"); + Pattern p = Pattern.compile(sipAddressRegExp); + return p.matcher(numberOrAddress).matches(); } public static boolean isStrictSipAddress(String numberOrAddress) { - return numberOrAddress != null && numberOrAddress.matches("^sip:(\\+)?[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\\.-][a-z0-9]+)*)+\\.[a-z]{2,}$"); + Pattern p = Pattern.compile(strictSipAddressRegExp); + return p.matcher(numberOrAddress).matches(); } public static String getUsernameFromAddress(String address) {