Fix setup crash with sip:
This commit is contained in:
parent
594d442abb
commit
4c92aa2ed6
7 changed files with 49 additions and 30 deletions
|
@ -26,6 +26,7 @@
|
||||||
<string name="setup_linphone_account_hint">Enter your linphone.org username and password</string>
|
<string name="setup_linphone_account_hint">Enter your linphone.org username and password</string>
|
||||||
<string name="setup_general_account_hint">Enter your SIP account username, password and domain</string>
|
<string name="setup_general_account_hint">Enter your SIP account username, password and domain</string>
|
||||||
<string name="setup_username_hint">username</string>
|
<string name="setup_username_hint">username</string>
|
||||||
|
<string name="button_sip_contacts">SIP</string>
|
||||||
|
|
||||||
<string name="tunnel_host"></string>
|
<string name="tunnel_host"></string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -313,7 +313,6 @@
|
||||||
<string name="button_ok">Okay</string>
|
<string name="button_ok">Okay</string>
|
||||||
<string name="button_back">Back</string>
|
<string name="button_back">Back</string>
|
||||||
<string name="button_all_contacts">All</string>
|
<string name="button_all_contacts">All</string>
|
||||||
<string name="button_sip_contacts">SIP</string>
|
|
||||||
<string name="button_add_contact">New contact</string>
|
<string name="button_add_contact">New contact</string>
|
||||||
<string name="button_all_call">All</string>
|
<string name="button_all_call">All</string>
|
||||||
<string name="button_missed_call">Missed</string>
|
<string name="button_missed_call">Missed</string>
|
||||||
|
@ -346,7 +345,7 @@
|
||||||
<string name="image_not_saved">Error, image not saved</string>
|
<string name="image_not_saved">Error, image not saved</string>
|
||||||
<string name="pref_linphone_friend_title">Friends</string>
|
<string name="pref_linphone_friend_title">Friends</string>
|
||||||
<string name="pref_auto_accept_friends_title">New friends</string>
|
<string name="pref_auto_accept_friends_title">New friends</string>
|
||||||
<string name="pref_auto_accept_friends_desc">utomatically accept new friend requests</string>
|
<string name="pref_auto_accept_friends_desc">Automatically accept new friend requests</string>
|
||||||
<string name="linphone_friend_new_request_title">Friend request</string>
|
<string name="linphone_friend_new_request_title">Friend request</string>
|
||||||
<string name="linphone_friend_new_request_desc">wants to share it\'s presence status with you and be aware of yours.</string>
|
<string name="linphone_friend_new_request_desc">wants to share it\'s presence status with you and be aware of yours.</string>
|
||||||
<string name="setup_ec_calibration">Echo canceller calibration in progress</string>
|
<string name="setup_ec_calibration">Echo canceller calibration in progress</string>
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
contactsList.setVisibility(View.VISIBLE);
|
contactsList.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (onlyDisplayLinphoneContacts) {
|
if (onlyDisplayLinphoneContacts) {
|
||||||
if (sipContactsCursor.getCount() == 0) {
|
if (sipContactsCursor != null && sipContactsCursor.getCount() == 0) {
|
||||||
noSipContact.setVisibility(View.VISIBLE);
|
noSipContact.setVisibility(View.VISIBLE);
|
||||||
contactsList.setVisibility(View.GONE);
|
contactsList.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,7 +210,7 @@ public class ContactsFragment extends Fragment implements OnClickListener, OnIte
|
||||||
contactsList.setAdapter(new ContactsListAdapter(ContactsManager.getInstance().getSIPContacts(), sipContactsCursor));
|
contactsList.setAdapter(new ContactsListAdapter(ContactsManager.getInstance().getSIPContacts(), sipContactsCursor));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (allContactsCursor.getCount() == 0) {
|
if (allContactsCursor != null && allContactsCursor.getCount() == 0) {
|
||||||
noContact.setVisibility(View.VISIBLE);
|
noContact.setVisibility(View.VISIBLE);
|
||||||
contactsList.setVisibility(View.GONE);
|
contactsList.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -83,9 +83,13 @@ public class ContactsManager {
|
||||||
return isContactPresenceDisabled;
|
return isContactPresenceDisabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeSyncAccount(Context context, ContentResolver contentResolver) {
|
public void initializeContactManager(Context context, ContentResolver contentResolver){
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.contentResolver = contentResolver;
|
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));
|
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 accountManager = (AccountManager) context.getSystemService(context.ACCOUNT_SERVICE);
|
||||||
accountManager.addAccountExplicitly(newAccount, null, null);
|
accountManager.addAccountExplicitly(newAccount, null, null);
|
||||||
|
@ -342,7 +346,8 @@ public class ContactsManager {
|
||||||
if (sipUri.startsWith("sip:"))
|
if (sipUri.startsWith("sip:"))
|
||||||
sipUri = sipUri.substring(4);
|
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()) {
|
for (LinphoneFriend friend : LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList()) {
|
||||||
if (friend.getAddress().equals(address)) {
|
if (friend.getAddress().equals(address)) {
|
||||||
return getContact(friend.getRefKey(), contentResolver);
|
return getContact(friend.getRefKey(), contentResolver);
|
||||||
|
@ -522,7 +527,7 @@ public class ContactsManager {
|
||||||
Thread sipContactsHandler = new Thread(new Runnable() {
|
Thread sipContactsHandler = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(sipContactCursor.getCount() > 0) {
|
if(sipContactCursor != null && sipContactCursor.getCount() > 0) {
|
||||||
for (int i = 0; i < sipContactCursor.getCount(); i++) {
|
for (int i = 0; i < sipContactCursor.getCount(); i++) {
|
||||||
Contact contact = Compatibility.getContact(contentResolver, sipContactCursor, i);
|
Contact contact = Compatibility.getContact(contentResolver, sipContactCursor, i);
|
||||||
if (contact == null)
|
if (contact == null)
|
||||||
|
|
|
@ -152,6 +152,8 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
|
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
ContactsManager.getInstance().initializeSyncAccount(getApplicationContext(), getContentResolver());
|
ContactsManager.getInstance().initializeSyncAccount(getApplicationContext(), getContentResolver());
|
||||||
|
} else {
|
||||||
|
ContactsManager.getInstance().initializeContactManager(getApplicationContext(), getContentResolver());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!LinphonePreferences.instance().isContactsMigrationDone()){
|
if(!LinphonePreferences.instance().isContactsMigrationDone()){
|
||||||
|
|
|
@ -209,6 +209,7 @@ public class ApiFivePlus {
|
||||||
|
|
||||||
public static Contact getContact(ContentResolver cr, Cursor cursor, int position) {
|
public static Contact getContact(ContentResolver cr, Cursor cursor, int position) {
|
||||||
try {
|
try {
|
||||||
|
if(cursor != null) {
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
boolean success = cursor.move(position);
|
boolean success = cursor.move(position);
|
||||||
if (!success)
|
if (!success)
|
||||||
|
@ -223,16 +224,19 @@ public class ApiFivePlus {
|
||||||
Contact contact;
|
Contact contact;
|
||||||
if (input == null) {
|
if (input == null) {
|
||||||
contact = new Contact(id, name);
|
contact = new Contact(id, name);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Bitmap bm = null;
|
Bitmap bm = null;
|
||||||
try {
|
try {
|
||||||
bm = BitmapFactory.decodeStream(input);
|
bm = BitmapFactory.decodeStream(input);
|
||||||
} catch (OutOfMemoryError oome) {}
|
} catch (OutOfMemoryError oome) {
|
||||||
|
}
|
||||||
contact = new Contact(id, name, photo, thumbnail, bm);
|
contact = new Contact(id, name, photo, thumbnail, bm);
|
||||||
}
|
}
|
||||||
|
|
||||||
return contact;
|
return contact;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,6 +305,14 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
if (accountCreated)
|
if (accountCreated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(username.startsWith("sip:")) {
|
||||||
|
username = username.substring(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(domain.startsWith("sip:")) {
|
||||||
|
domain = domain.substring(4);
|
||||||
|
}
|
||||||
|
|
||||||
String identity = "sip:" + username + "@" + domain;
|
String identity = "sip:" + username + "@" + domain;
|
||||||
try {
|
try {
|
||||||
address = LinphoneCoreFactory.instance().createLinphoneAddress(identity);
|
address = LinphoneCoreFactory.instance().createLinphoneAddress(identity);
|
||||||
|
|
Loading…
Reference in a new issue