Merge branch 'master' into dev_lucas

This commit is contained in:
Sylvain Berfini 2018-09-03 11:36:25 +02:00
commit 8278c27b45
18 changed files with 155 additions and 210 deletions

View file

@ -8,9 +8,9 @@ Linphone is a free VoIP and video softphone based on the SIP protocol.
1. Download the Android sdk (API 28.0.0 at max) with platform-tools and tools updated to latest revision, then add both 'tools' and 'platform-tools' folders in your path and the android-sdk folder to ANDROID_HOME environment variable. 1. Download the Android sdk (API 28.0.0 at max) with platform-tools and tools updated to latest revision, then add both 'tools' and 'platform-tools' folders in your path and the android-sdk folder to ANDROID_HOME environment variable.
2. Download the Android ndk (version 16) from google and add it to your path (no symlink !!!) and ANDROID_NDK environment variable. 2. Download the Android NDK 17 from google and add it to your path (no symlink !!!) and ANDROID_NDK environment variable.
3. Install _yasm_, _nasm_ (For OpenH224 support only), _python_, _pkg_config_ and _cmake(>=3.10)_. 3. Install _yasm_, _nasm_ (For OpenH224 support only), _python_, _pkg_config_ and _cmake(>=3.12)_.
* On 64 bits linux systems you'll need the _ia32-libs_ package. * On 64 bits linux systems you'll need the _ia32-libs_ package.
* With the latest Debian (multiarch), you need this: * With the latest Debian (multiarch), you need this:
* `dpkg --add-architecture i386` * `dpkg --add-architecture i386`

View file

@ -3,5 +3,5 @@ RELEASE_STORE_FILE=""
RELEASE_STORE_PASSWORD= RELEASE_STORE_PASSWORD=
RELEASE_KEY_ALIAS= RELEASE_KEY_ALIAS=
RELEASE_KEY_PASSWORD= RELEASE_KEY_PASSWORD=
source:https://docs.gradle.org/current/userguide/build_environment.html#sec:configuring_jvm_memory #source:https://docs.gradle.org/current/userguide/build_environment.html#sec:configuring_jvm_memory
org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx2g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

View file

@ -80,6 +80,7 @@
<bool name="disable_chat_send_file">false</bool> <bool name="disable_chat_send_file">false</bool>
<string name="temp_photo_name">linphone-android-photo-temp</string> <string name="temp_photo_name">linphone-android-photo-temp</string>
<string name="temp_photo_name_with_date">linphone-android-photo-%s</string> <string name="temp_photo_name_with_date">linphone-android-photo-%s</string>
<bool name="lower_space_between_chat_bubbles_if_same_person">false</bool>
<!-- Contacts --> <!-- Contacts -->
<bool name="hide_contact_phone_numbers">false</bool> <bool name="hide_contact_phone_numbers">false</bool>

View file

@ -1012,9 +1012,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
private Vibrator mVibrator; private Vibrator mVibrator;
public void onNewSubscriptionRequested(Core lc, Friend lf, String url) {} public void onNewSubscriptionRequested(Core lc, Friend lf, String url) {}
public void onNotifyPresenceReceived(Core lc, Friend lf) { public void onNotifyPresenceReceived(Core lc, Friend lf) {}
ContactsManager.getInstance().refreshSipContact(lf);
}
@Override @Override
public void onEcCalibrationAudioInit(Core lc) { public void onEcCalibrationAudioInit(Core lc) {
@ -1659,12 +1657,12 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
@Override @Override
public void onFriendListCreated(Core lc, FriendList list) { public void onFriendListCreated(Core lc, FriendList list) {
// TODO Auto-generated method stub list.setListener(ContactsManager.getInstance());
} }
@Override @Override
public void onFriendListRemoved(Core lc, FriendList list) { public void onFriendListRemoved(Core lc, FriendList list) {
// TODO Auto-generated method stub list.setListener(null);
} }
@Override @Override

View file

@ -22,9 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.content.CursorLoader;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.Bitmap; import android.graphics.Bitmap;
@ -37,8 +35,8 @@ import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.provider.DocumentsContract;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.provider.OpenableColumns;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
@ -599,88 +597,42 @@ public final class LinphoneUtils {
} }
/************************************************************************************************
* Picasa/Photos management workaround *
************************************************************************************************/
public static String getFilePath(final Context context, final Uri uri) { public static String getFilePath(final Context context, final Uri uri) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && DocumentsContract.isDocumentUri(context, uri)) { if (uri == null) return null;
// ExternalStorageProvider
if ("com.android.externalstorage.documents".equals(uri.getAuthority())) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
if (split.length >= 1) return Environment.getExternalStorageDirectory() + "/" + split[1];
// TODO handle non-primary volumes String result = null;
}// Docs storage String name = getNameFromUri(uri, context);
else if ("com.google.android.apps.docs.storage".equals(uri.getAuthority())) {
//Google doc not supported right now
}
// DownloadsProvider
else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {
final String id = DocumentsContract.getDocumentId(uri);
try { try {
final Uri contentUri = ContentUris.withAppendedId( File localFile = createFile(context, name);
Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); InputStream remoteFile = context.getContentResolver().openInputStream(uri);
return getDataColumn(context, contentUri, null, null); if(copyToFile(remoteFile, localFile)) {
} catch (NumberFormatException nfe) {
if (id.startsWith("raw:")) {
return id.substring(4);
}
}
}
// MediaProvider
else if ("com.android.providers.media.documents".equals(uri.getAuthority())) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
}
final String selection = "_id=?";
final String[] selectionArgs = new String[] {
split[1]
};
return getDataColumn(context, contentUri, selection, selectionArgs);
}
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
String type = getTypeFromUri(uri, context);
String result = getDataColumn(context, uri, null, null); //
if (TextUtils.isEmpty(result))
if (uri.getAuthority().contains("com.google.android") || uri.getAuthority().contains("com.android")) {
try {
File localFile = createFile(context, null, type);
FileInputStream remoteFile = getSourceStream(context, uri);
if(copyToFile(remoteFile, localFile))
result = localFile.getAbsolutePath(); result = localFile.getAbsolutePath();
}
remoteFile.close(); remoteFile.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); Log.e("Enable to get sharing file", e);
}
} }
return result; return result;
} else if ("file".equalsIgnoreCase(uri.getScheme())) { // File
return uri.getPath();
}
return null;
} }
private static String getNameFromUri(Uri uri, Context context) {
private static String getTypeFromUri(Uri uri, Context context){ String name = null;
ContentResolver cR = context.getContentResolver(); if (uri.getScheme().equals("content")) {
MimeTypeMap mime = MimeTypeMap.getSingleton(); Cursor returnCursor = context.getContentResolver().query(uri, null, null, null, null);
String type = mime.getExtensionFromMimeType(cR.getType(uri)); if (returnCursor != null) {
return type; returnCursor.moveToFirst();
int nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
name = returnCursor.getString(nameIndex);
returnCursor.close();
}
} else if (uri.getScheme().equals("file")) {
name = uri.getLastPathSegment();
}
return name;
} }
/** /**
@ -714,74 +666,25 @@ public final class LinphoneUtils {
} }
} }
public static File createFile(Context context, String imageFileName, String type) throws IOException { public static File createFile(Context context, String fileName) throws IOException {
if (TextUtils.isEmpty(imageFileName)) if (TextUtils.isEmpty(fileName))
imageFileName = getStartDate()+"."+type; // make random filename if you want. fileName = getStartDate();
if (!fileName.contains(".")) {
fileName = fileName + ".unknown";
}
final File root; final File root;
imageFileName = imageFileName;
root = context.getExternalCacheDir(); root = context.getExternalCacheDir();
if (root != null && !root.exists()) if (root != null && !root.exists())
root.mkdirs(); root.mkdirs();
return new File(root, imageFileName); return new File(root, fileName);
}
public static FileInputStream getSourceStream(Context context, Uri u) throws FileNotFoundException {
FileInputStream out = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ParcelFileDescriptor parcelFileDescriptor =
context.getContentResolver().openFileDescriptor(u, "r");
FileDescriptor fileDescriptor = null;
if (parcelFileDescriptor != null) {
fileDescriptor = parcelFileDescriptor.getFileDescriptor();
out = new FileInputStream(fileDescriptor);
}
} else {
out = (FileInputStream) context.getContentResolver().openInputStream(u);
}
return out;
}
/**
* Get the value of the data column for this Uri. This is useful for
* MediaStore Uris, and other file-based ContentProviders.
*
* @param context The context.
* @param uri The Uri to query.
* @param selection (Optional) Filter used in the query.
* @param selectionArgs (Optional) Selection arguments used in the query.
* @return The value of the _data column, which is typically a file path.
*/
static String getDataColumn(Context context, Uri uri, String selection,
String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {
column
};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
null);
if (cursor != null && cursor.moveToFirst()) {
final int column_index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(column_index);
}
} finally {
if (cursor != null)
cursor.close();
}
return null;
} }
public static String getRealPathFromURI(Context context, Uri contentUri) { public static String getRealPathFromURI(Context context, Uri contentUri) {
String[] proj = {MediaStore.Images.Media.DATA}; String[] proj = {MediaStore.Images.Media.DATA};
CursorLoader loader = new CursorLoader(context, contentUri, proj, null, null, null); Cursor cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
Cursor cursor = loader.loadInBackground();
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
String result = cursor.getString(column_index); String result = cursor.getString(column_index);
@ -791,32 +694,6 @@ public final class LinphoneUtils {
return null; return null;
} }
public static String processContactUri(Context context, Uri contactUri){
ContentResolver cr = context.getContentResolver();
InputStream stream = null;
if(cr !=null) {
try {
stream = cr.openInputStream(contactUri);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
if(stream != null) {
StringBuffer fileContent = new StringBuffer("");
int ch;
try {
while ((ch = stream.read()) != -1)
fileContent.append((char) ch);
} catch (IOException e) {
e.printStackTrace();
}
String data = new String(fileContent);
return data;
}
return null;
}
return null;
}
public static String getContactNameFromVcard(String vcard){ public static String getContactNameFromVcard(String vcard){
if(vcard != null) { if(vcard != null) {
String contactName = vcard.substring(vcard.indexOf("FN:") + 3); String contactName = vcard.substring(vcard.indexOf("FN:") + 3);

View file

@ -132,26 +132,12 @@ public class LinphoneLauncherActivity extends Activity {
String type = intent.getType(); String type = intent.getType();
newIntent.setData(intent.getData()); newIntent.setData(intent.getData());
if (Intent.ACTION_SEND.equals(action) && type != null) { if (Intent.ACTION_SEND.equals(action) && type != null) {
if (type.contains("text/")){
if(("text/plain").equals(type) && (String)intent.getStringExtra(Intent.EXTRA_TEXT)!= null) { if(("text/plain").equals(type) && (String)intent.getStringExtra(Intent.EXTRA_TEXT)!= null) {
stringFileShared = intent.getStringExtra(Intent.EXTRA_TEXT); stringFileShared = intent.getStringExtra(Intent.EXTRA_TEXT);
newIntent.putExtra("msgShared", stringFileShared); newIntent.putExtra("msgShared", stringFileShared);
} else if(((Uri) intent.getExtras().get(Intent.EXTRA_STREAM)) != null){
stringFileShared = (LinphoneUtils.createCvsFromString(LinphoneUtils.processContactUri(getApplicationContext(), (Uri)intent.getExtras().get(Intent.EXTRA_STREAM)))).toString();
newIntent.putExtra("fileShared", stringFileShared);
}
}else {
if(((String) intent.getStringExtra(Intent.EXTRA_STREAM)) != null){
stringUriFileShared = intent.getStringExtra(Intent.EXTRA_STREAM);
} else { } else {
fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);
stringUriFileShared = LinphoneUtils.getRealPathFromURI(getBaseContext(), fileUri);
if(stringUriFileShared == null)
if(fileUri.getPath().contains("/0/1/mediakey:/local") || fileUri.getPath().contains("/ORIGINAL/NONE/")) {
stringUriFileShared = LinphoneUtils.getFilePath(getBaseContext(), fileUri); stringUriFileShared = LinphoneUtils.getFilePath(getBaseContext(), fileUri);
}else
stringUriFileShared = fileUri.getPath();
}
newIntent.putExtra("fileShared", stringUriFileShared); newIntent.putExtra("fileShared", stringUriFileShared);
} }
}else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { }else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) {

View file

@ -165,8 +165,21 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
if (event.getType() == EventLog.Type.ConferenceChatMessage) { if (event.getType() == EventLog.Type.ConferenceChatMessage) {
holder.bubbleLayout.setVisibility(View.VISIBLE); holder.bubbleLayout.setVisibility(View.VISIBLE);
final ChatMessage message = event.getChatMessage(); final ChatMessage message = event.getChatMessage();
if (position > 0 && mContext.getResources().getBoolean(R.bool.lower_space_between_chat_bubbles_if_same_person)) {
EventLog previousEvent = (EventLog)getItem(position-1);
if (previousEvent.getType() == EventLog.Type.ConferenceChatMessage) {
ChatMessage previousMessage = previousEvent.getChatMessage();
if (previousMessage.getFromAddress().weakEqual(message.getFromAddress())) {
holder.separatorLayout.setVisibility(View.GONE);
}
} else {
// No separator if previous event is not a message
holder.separatorLayout.setVisibility(View.GONE);
}
}
holder.messageId = message.getMessageId(); holder.messageId = message.getMessageId();
message.setUserData(holder); message.setUserData(holder);
@ -238,7 +251,6 @@ public class ChatEventsAdapter extends SelectableAdapter<ChatBubbleViewHolder> {
} }
} }
if (isEditionEnabled()) { if (isEditionEnabled()) {
layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId()); layoutParams.addRule(RelativeLayout.LEFT_OF, holder.delete.getId());
layoutParams.setMargins(SIDE_MARGIN, MARGIN_BETWEEN_MESSAGES/2, 0, MARGIN_BETWEEN_MESSAGES/2); layoutParams.setMargins(SIDE_MARGIN, MARGIN_BETWEEN_MESSAGES/2, 0, MARGIN_BETWEEN_MESSAGES/2);

View file

@ -59,6 +59,8 @@ public class ApiTwentyOnePlus {
.setVisibility(Notification.VISIBILITY_PRIVATE) .setVisibility(Notification.VISIBILITY_PRIVATE)
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setNumber(msgCount) .setNumber(msgCount)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.build(); .build();
return notif; return notif;
@ -80,6 +82,7 @@ public class ApiTwentyOnePlus {
.setLights(ContextCompat.getColor(context, R.color.notification_color_led), .setLights(ContextCompat.getColor(context, R.color.notification_color_led),
context.getResources().getInteger(R.integer.notification_ms_on), context.getResources().getInteger(R.integer.notification_ms_on),
context.getResources().getInteger(R.integer.notification_ms_off)) context.getResources().getInteger(R.integer.notification_ms_off))
.setShowWhen(true)
.build(); .build();
return notif; return notif;
@ -100,7 +103,9 @@ public class ApiTwentyOnePlus {
.setLights(ContextCompat.getColor(context, R.color.notification_color_led), .setLights(ContextCompat.getColor(context, R.color.notification_color_led),
context.getResources().getInteger(R.integer.notification_ms_on), context.getResources().getInteger(R.integer.notification_ms_on),
context.getResources().getInteger(R.integer.notification_ms_off)) context.getResources().getInteger(R.integer.notification_ms_off))
.setWhen(System.currentTimeMillis())
.setPriority(priority) .setPriority(priority)
.setShowWhen(true)
.build(); .build();
} else { } else {
notif = new Notification.Builder(context) notif = new Notification.Builder(context)
@ -114,6 +119,8 @@ public class ApiTwentyOnePlus {
context.getResources().getInteger(R.integer.notification_ms_on), context.getResources().getInteger(R.integer.notification_ms_on),
context.getResources().getInteger(R.integer.notification_ms_off)) context.getResources().getInteger(R.integer.notification_ms_off))
.setPriority(priority) .setPriority(priority)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.build(); .build();
} }
@ -139,6 +146,8 @@ public class ApiTwentyOnePlus {
context.getResources().getInteger(R.integer.notification_ms_on), context.getResources().getInteger(R.integer.notification_ms_on),
context.getResources().getInteger(R.integer.notification_ms_off)) context.getResources().getInteger(R.integer.notification_ms_off))
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.build(); .build();
return notif; return notif;
@ -158,7 +167,9 @@ public class ApiTwentyOnePlus {
.setLights(ContextCompat.getColor(context, R.color.notification_color_led), .setLights(ContextCompat.getColor(context, R.color.notification_color_led),
context.getResources().getInteger(R.integer.notification_ms_on), context.getResources().getInteger(R.integer.notification_ms_on),
context.getResources().getInteger(R.integer.notification_ms_off)) context.getResources().getInteger(R.integer.notification_ms_off))
.setWhen(System.currentTimeMillis())
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setShowWhen(true)
.build(); .build();
return notif; return notif;

View file

@ -87,6 +87,10 @@ public class ApiTwentySixPlus {
.setVisibility(Notification.VISIBILITY_PRIVATE) .setVisibility(Notification.VISIBILITY_PRIVATE)
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setNumber(msgCount) .setNumber(msgCount)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.setColorized(true)
.setColor(context.getColor(R.color.notification_color_led))
.build(); .build();
return notif; return notif;
@ -106,6 +110,10 @@ public class ApiTwentySixPlus {
.setCategory(Notification.CATEGORY_CALL) .setCategory(Notification.CATEGORY_CALL)
.setVisibility(Notification.VISIBILITY_PUBLIC) .setVisibility(Notification.VISIBILITY_PUBLIC)
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.setColorized(true)
.setColor(context.getColor(R.color.notification_color_led))
.build(); .build();
return notif; return notif;
@ -124,6 +132,10 @@ public class ApiTwentySixPlus {
.setCategory(Notification.CATEGORY_SERVICE) .setCategory(Notification.CATEGORY_SERVICE)
.setVisibility(Notification.VISIBILITY_SECRET) .setVisibility(Notification.VISIBILITY_SECRET)
.setPriority(priority) .setPriority(priority)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.setColorized(true)
.setColor(context.getColor(R.color.notification_color_led))
.build(); .build();
} else { } else {
notif = new Notification.Builder(context, context.getString(R.string.notification_service_channel_id)) notif = new Notification.Builder(context, context.getString(R.string.notification_service_channel_id))
@ -134,6 +146,10 @@ public class ApiTwentySixPlus {
.setCategory(Notification.CATEGORY_SERVICE) .setCategory(Notification.CATEGORY_SERVICE)
.setVisibility(Notification.VISIBILITY_SECRET) .setVisibility(Notification.VISIBILITY_SECRET)
.setPriority(priority) .setPriority(priority)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.setColorized(true)
.setColor(context.getColor(R.color.notification_color_led))
.build(); .build();
} }
@ -156,6 +172,10 @@ public class ApiTwentySixPlus {
.setCategory(Notification.CATEGORY_MESSAGE) .setCategory(Notification.CATEGORY_MESSAGE)
.setVisibility(Notification.VISIBILITY_PRIVATE) .setVisibility(Notification.VISIBILITY_PRIVATE)
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.setColorized(true)
.setColor(context.getColor(R.color.notification_color_led))
.build(); .build();
return notif; return notif;
@ -173,6 +193,10 @@ public class ApiTwentySixPlus {
.setCategory(Notification.CATEGORY_MESSAGE) .setCategory(Notification.CATEGORY_MESSAGE)
.setVisibility(Notification.VISIBILITY_PRIVATE) .setVisibility(Notification.VISIBILITY_PRIVATE)
.setPriority(Notification.PRIORITY_HIGH) .setPriority(Notification.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis())
.setShowWhen(true)
.setColorized(true)
.setColor(context.getColor(R.color.notification_color_led))
.build(); .build();
return notif; return notif;

View file

@ -167,7 +167,8 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
dividerItemDecoration.setDrawable(getActivity().getResources().getDrawable(R.drawable.divider)); dividerItemDecoration.setDrawable(getActivity().getResources().getDrawable(R.drawable.divider));
contactsList.addItemDecoration(dividerItemDecoration); contactsList.addItemDecoration(dividerItemDecoration);
ContactsManager.getInstance().fetchContactsAsync(); contactsFetchInProgress = (ProgressBar) view.findViewById(R.id.contactsFetchInProgress);
contactsFetchInProgress.setVisibility(View.VISIBLE);
return view; return view;
} }
@ -312,8 +313,8 @@ public class ContactsListFragment extends Fragment implements OnItemClickListene
@Override @Override
public void onResume() { public void onResume() {
ContactsManager.addContactsListener(this);
super.onResume(); super.onResume();
ContactsManager.addContactsListener(this);
if (editConsumed) { if (editConsumed) {
editOnClick = false; editOnClick = false;

View file

@ -45,6 +45,7 @@ import org.linphone.core.Core;
import org.linphone.core.Factory; import org.linphone.core.Factory;
import org.linphone.core.Friend; import org.linphone.core.Friend;
import org.linphone.core.FriendList; import org.linphone.core.FriendList;
import org.linphone.core.FriendListListener;
import org.linphone.core.MagicSearch; import org.linphone.core.MagicSearch;
import org.linphone.core.ProxyConfig; import org.linphone.core.ProxyConfig;
import org.linphone.mediastream.Log; import org.linphone.mediastream.Log;
@ -59,7 +60,7 @@ import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class ContactsManager extends ContentObserver { public class ContactsManager extends ContentObserver implements FriendListListener {
private static ContactsManager instance; private static ContactsManager instance;
private List<LinphoneContact> contacts, sipContacts; private List<LinphoneContact> contacts, sipContacts;
@ -93,6 +94,12 @@ public class ContactsManager extends ContentObserver {
} }
public void destroy() { public void destroy() {
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) {
for (FriendList list : lc.getFriendsLists()) {
list.setListener(null);
}
}
defaultAvatar.recycle(); defaultAvatar.recycle();
instance = null; instance = null;
} }
@ -293,10 +300,6 @@ public class ContactsManager extends ContentObserver {
LinphoneContact contact = (LinphoneContact)lf.getUserData(); LinphoneContact contact = (LinphoneContact)lf.getUserData();
if (contact != null && !sipContacts.contains(contact)) { if (contact != null && !sipContacts.contains(contact)) {
sipContacts.add(contact); sipContacts.add(contact);
Collections.sort(sipContacts);
for (ContactsUpdatedListener listener : contactsUpdatedListeners) {
listener.onContactsUpdated();
}
} }
} }
@ -590,4 +593,36 @@ public class ContactsManager extends ContentObserver {
Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI, projection, select, new String[]{ ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE }, null); Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI, projection, select, new String[]{ ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE }, null);
return c; return c;
} }
@Override
public void onContactCreated(FriendList list, Friend lf) {
}
@Override
public void onContactDeleted(FriendList list, Friend lf) {
}
@Override
public void onContactUpdated(FriendList list, Friend newFriend, Friend oldFriend) {
}
@Override
public void onSyncStatusChanged(FriendList list, FriendList.SyncStatus status, String msg) {
}
@Override
public void onPresenceReceived(FriendList list, Friend[] friends) {
for (Friend lf : friends) {
ContactsManager.getInstance().refreshSipContact(lf);
}
Collections.sort(sipContacts);
for (ContactsUpdatedListener listener : contactsUpdatedListeners) {
listener.onContactsUpdated();
}
}
} }

@ -1 +1 @@
Subproject commit ca4a89930dd8db94a60ae4a1dbf44a3710497429 Subproject commit e8a69bdc3f8828cfd83b0938955132918364b175

@ -1 +1 @@
Subproject commit ed53ae3c9da4fb15c13454153383014b3257939a Subproject commit 88ed003beb9a33d9d80bbac8c53287039e1e30b0

@ -1 +1 @@
Subproject commit 11f4c9c61feece2d46909ae62e91ac1bace64c2c Subproject commit 41666379abcdd4f14fcf08732e21b2d7b81cf729

@ -1 +1 @@
Subproject commit f58510c8ce6cd89dadff2b29574d03b05c6efcc9 Subproject commit 81f2fa301e392a33e63fb6ac6ded9b9d48832605

@ -1 +1 @@
Subproject commit d0232344c705a482feb5ca272abcb044303ef284 Subproject commit 494baf59e48e38f92e959ee1aac763d2caca39ce

@ -1 +1 @@
Subproject commit 52d3169349b55b27090ecb81f88d10ebb65fa469 Subproject commit 94892b662ef2009f27eaa4c164a0595b32d7f5c8

@ -1 +1 @@
Subproject commit a88be02b93e2274ae3fcf80e1e0032adc43c0448 Subproject commit c9dde282bf48af9a8844f0686a09a1d0347e6856