diff --git a/res/values/custom.xml b/res/values/custom.xml
index ae5743ca8..516f0f4a6 100644
--- a/res/values/custom.xml
+++ b/res/values/custom.xml
@@ -26,6 +26,7 @@
Enter your linphone.org username and password
Enter your SIP account username, password and domain
username
+ SIP
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b55f1c215..5d3295be8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -313,7 +313,6 @@
Okay
Back
All
- SIP
New contact
All
Missed
@@ -346,7 +345,7 @@
Error, image not saved
Friends
New friends
- utomatically accept new friend requests
+ Automatically accept new friend requests
Friend request
wants to share it\'s presence status with you and be aware of yours.
Echo canceller calibration in progress
diff --git a/src/org/linphone/ContactsFragment.java b/src/org/linphone/ContactsFragment.java
index aa886801a..c8e0d4cf2 100644
--- a/src/org/linphone/ContactsFragment.java
+++ b/src/org/linphone/ContactsFragment.java
@@ -202,7 +202,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
contactsList.setVisibility(View.VISIBLE);
if (onlyDisplayLinphoneContacts) {
- if (sipContactsCursor.getCount() == 0) {
+ if (sipContactsCursor != null && sipContactsCursor.getCount() == 0) {
noSipContact.setVisibility(View.VISIBLE);
contactsList.setVisibility(View.GONE);
} else {
@@ -210,7 +210,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
contactsList.setAdapter(new ContactsListAdapter(ContactsManager.getInstance().getSIPContacts(), sipContactsCursor));
}
} else {
- if (allContactsCursor.getCount() == 0) {
+ if (allContactsCursor != null && allContactsCursor.getCount() == 0) {
noContact.setVisibility(View.VISIBLE);
contactsList.setVisibility(View.GONE);
} else {
diff --git a/src/org/linphone/ContactsManager.java b/src/org/linphone/ContactsManager.java
index 1e86f6958..6bd632f84 100644
--- a/src/org/linphone/ContactsManager.java
+++ b/src/org/linphone/ContactsManager.java
@@ -83,9 +83,13 @@ public class ContactsManager {
return isContactPresenceDisabled;
}
- public void initializeSyncAccount(Context context, ContentResolver contentResolver) {
+ public void initializeContactManager(Context context, ContentResolver contentResolver){
this.context = context;
this.contentResolver = contentResolver;
+ }
+
+ public void initializeSyncAccount(Context context, ContentResolver contentResolver) {
+ initializeContactManager(context,contentResolver);
Account newAccount = new Account(context.getString(R.string.sync_account_name), context.getString(R.string.sync_account_type));
AccountManager accountManager = (AccountManager) context.getSystemService(context.ACCOUNT_SERVICE);
accountManager.addAccountExplicitly(newAccount, null, null);
@@ -342,7 +346,8 @@ public class ContactsManager {
if (sipUri.startsWith("sip:"))
sipUri = sipUri.substring(4);
- if(LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList() != null && LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList().length > 0) {
+ LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
+ if(lc != null && lc.getFriendList() != null && LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList().length > 0) {
for (LinphoneFriend friend : LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList()) {
if (friend.getAddress().equals(address)) {
return getContact(friend.getRefKey(), contentResolver);
@@ -522,7 +527,7 @@ public class ContactsManager {
Thread sipContactsHandler = new Thread(new Runnable() {
@Override
public void run() {
- if(sipContactCursor.getCount() > 0) {
+ if(sipContactCursor != null && sipContactCursor.getCount() > 0) {
for (int i = 0; i < sipContactCursor.getCount(); i++) {
Contact contact = Compatibility.getContact(contentResolver, sipContactCursor, i);
if (contact == null)
diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java
index 0010f40e9..c505e7792 100644
--- a/src/org/linphone/LinphoneActivity.java
+++ b/src/org/linphone/LinphoneActivity.java
@@ -152,6 +152,8 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
ContactsManager.getInstance().initializeSyncAccount(getApplicationContext(), getContentResolver());
+ } else {
+ ContactsManager.getInstance().initializeContactManager(getApplicationContext(), getContentResolver());
}
if(!LinphonePreferences.instance().isContactsMigrationDone()){
diff --git a/src/org/linphone/compatibility/ApiFivePlus.java b/src/org/linphone/compatibility/ApiFivePlus.java
index 11ce8f0db..ee844df79 100644
--- a/src/org/linphone/compatibility/ApiFivePlus.java
+++ b/src/org/linphone/compatibility/ApiFivePlus.java
@@ -209,30 +209,34 @@ public class ApiFivePlus {
public static Contact getContact(ContentResolver cr, Cursor cursor, int position) {
try {
- cursor.moveToFirst();
- boolean success = cursor.move(position);
- if (!success)
- return null;
-
- String id = cursor.getString(cursor.getColumnIndex(Data.CONTACT_ID));
- String name = getContactDisplayName(cursor);
- Uri thumbnail = getContactPictureUri(id);
- Uri photo = getContactPhotoUri(id);
- InputStream input = getContactPictureInputStream(cr, id);
+ if(cursor != null) {
+ cursor.moveToFirst();
+ boolean success = cursor.move(position);
+ if (!success)
+ return null;
- Contact contact;
- if (input == null) {
- contact = new Contact(id, name);
- }
- else {
- Bitmap bm = null;
- try {
- bm = BitmapFactory.decodeStream(input);
- } catch (OutOfMemoryError oome) {}
- contact = new Contact(id, name, photo, thumbnail, bm);
- }
-
- return contact;
+ String id = cursor.getString(cursor.getColumnIndex(Data.CONTACT_ID));
+ String name = getContactDisplayName(cursor);
+ Uri thumbnail = getContactPictureUri(id);
+ Uri photo = getContactPhotoUri(id);
+ InputStream input = getContactPictureInputStream(cr, id);
+
+ Contact contact;
+ if (input == null) {
+ contact = new Contact(id, name);
+ } else {
+ Bitmap bm = null;
+ try {
+ bm = BitmapFactory.decodeStream(input);
+ } catch (OutOfMemoryError oome) {
+ }
+ contact = new Contact(id, name, photo, thumbnail, bm);
+ }
+
+ return contact;
+ } else {
+ return null;
+ }
} catch (Exception e) {
}
diff --git a/src/org/linphone/setup/SetupActivity.java b/src/org/linphone/setup/SetupActivity.java
index 6ae353d12..bba6e8292 100644
--- a/src/org/linphone/setup/SetupActivity.java
+++ b/src/org/linphone/setup/SetupActivity.java
@@ -305,6 +305,14 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
if (accountCreated)
return;
+ if(username.startsWith("sip:")) {
+ username = username.substring(4);
+ }
+
+ if(domain.startsWith("sip:")) {
+ domain = domain.substring(4);
+ }
+
String identity = "sip:" + username + "@" + domain;
try {
address = LinphoneCoreFactory.instance().createLinphoneAddress(identity);